mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
sync against main
This commit is contained in:
commit
6fc1a602f3
284 files changed
+2422
-10598
No files matched your search
@@ -15,11 +15,11 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v2
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
- name: Audit dependencies
|
||||
run: npm audit --audit-level low
|
||||
node-version: 18
|
||||
# - name: Audit dependencies
|
||||
# run: npm audit --audit-level low
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Build Console
|
||||
@@ -30,7 +30,3 @@ jobs:
|
||||
run: npm run lint
|
||||
- name: Unit Tests
|
||||
run: npm test
|
||||
# - name: E2E Tests
|
||||
# run: |
|
||||
# npx playwright install
|
||||
# npm run e2e
|
||||
+15
-1
@@ -33,7 +33,21 @@ If you are worried about or don’t know where to start, check out the next sect
|
||||
|
||||
## Development
|
||||
|
||||
Once you've created a project and installed dependencies with `npm install`, create a `.env` file using `.env.example` as a template.
|
||||
### 1. Clone the repository with git
|
||||
|
||||
```bash
|
||||
git clone https://github.com/appwrite/console.git appwrite-console
|
||||
```
|
||||
|
||||
### 2. Install dependencies with npm
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
### 3. Setup environment variables
|
||||
|
||||
Add a `.env` file by copying the `.env.example` file as a template in the project's root directory.
|
||||
|
||||
Finally, start a development server:
|
||||
|
||||
|
||||
Generated
-8923
File diff suppressed because it is too large.
Load diff
+5
-4
@@ -21,12 +21,13 @@
|
||||
"dependencies": {
|
||||
"@analytics/google-analytics": "^1.0.5",
|
||||
"@appwrite.io/pink": "^0.0.4",
|
||||
"@aw-labs/appwrite-console": "npm:appwrite-shimon@^7.1.1",
|
||||
"@aw-labs/appwrite-console": "npm:appwrite-shimon@^7.2.4",
|
||||
"@popperjs/core": "^2.11.6",
|
||||
"@sentry/svelte": "^7.36.0",
|
||||
"@sentry/tracing": "^7.36.0",
|
||||
"analytics": "^0.8.1",
|
||||
"echarts": "^5.4.1",
|
||||
"logrocket": "^3.0.1",
|
||||
"pretty-bytes": "^6.1.0",
|
||||
"prismjs": "^1.29.0",
|
||||
"tippy.js": "^6.3.7",
|
||||
@@ -35,7 +36,7 @@
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.30.0",
|
||||
"@sveltejs/adapter-static": "1.0.6",
|
||||
"@sveltejs/kit": "1.3.10",
|
||||
"@sveltejs/kit": "^1.3.10",
|
||||
"@sveltejs/vite-plugin-svelte": "^2.0.2",
|
||||
"@testing-library/dom": "^8.20.0",
|
||||
"@testing-library/jest-dom": "^5.16.5",
|
||||
@@ -44,7 +45,7 @@
|
||||
"@types/prismjs": "^1.26.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.50.0",
|
||||
"@typescript-eslint/parser": "^5.50.0",
|
||||
"@vitest/ui": "^0.28.4",
|
||||
"@vitest/ui": "^0.28.5",
|
||||
"eslint": "^8.33.0",
|
||||
"eslint-config-prettier": "^8.6.0",
|
||||
"eslint-plugin-svelte3": "^4.0.0",
|
||||
@@ -60,7 +61,7 @@
|
||||
"tslib": "^2.5.0",
|
||||
"typescript": "^4.9.5",
|
||||
"vite": "^4.1.1",
|
||||
"vitest": "^0.28.4"
|
||||
"vitest": "^0.28.5"
|
||||
},
|
||||
"type": "module",
|
||||
"pre-commit": [
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import Analytics from 'analytics';
|
||||
import googleAnalytics from '@analytics/google-analytics';
|
||||
import { get } from 'svelte/store';
|
||||
import { page } from '$app/stores';
|
||||
import { user } from '$lib/stores/user';
|
||||
import { growthEndpoint, Mode } from '$lib/constants';
|
||||
import { ENV, MODE, VARS } from '$lib/system';
|
||||
import googleAnalytics from '@analytics/google-analytics';
|
||||
import { AppwriteException } from '@aw-labs/appwrite-console';
|
||||
import Analytics from 'analytics';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
const isDevelopment =
|
||||
import.meta.env.DEV || import.meta.env?.VITE_VERCEL_ENV?.toString() === 'preview';
|
||||
const analytics = Analytics({
|
||||
app: 'appwrite',
|
||||
plugins: [
|
||||
googleAnalytics({
|
||||
measurementIds: [import.meta.env.VITE_GA_PROJECT?.toString() || 'G-R4YJ9JN8L4']
|
||||
measurementIds: [VARS.GOOGLE_ANALYTICS || 'G-R4YJ9JN8L4']
|
||||
})
|
||||
]
|
||||
});
|
||||
@@ -32,7 +30,7 @@ export function trackEvent(name: string, data: object = null): void {
|
||||
};
|
||||
}
|
||||
|
||||
if (isDevelopment) {
|
||||
if (ENV.DEV || ENV.PREVIEW) {
|
||||
console.debug(`[Analytics] Event ${name} ${path}`, data);
|
||||
} else {
|
||||
analytics.track(name, { ...data, path });
|
||||
@@ -54,7 +52,7 @@ export function trackPageView(path: string) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDevelopment) {
|
||||
if (ENV.DEV || ENV.PREVIEW) {
|
||||
console.debug(`[Analytics] Pageview ${path}`);
|
||||
} else {
|
||||
analytics.page({
|
||||
@@ -64,14 +62,14 @@ export function trackPageView(path: string) {
|
||||
}
|
||||
|
||||
function sendEventToGrowth(event: string, path: string, data: object = null): void {
|
||||
if (!growthEndpoint) return;
|
||||
if (!VARS.GROWTH_ENDPOINT) return;
|
||||
const userStore = get(user);
|
||||
let email: string, name: string;
|
||||
if (userStore) {
|
||||
email = userStore.email;
|
||||
name = userStore.name;
|
||||
}
|
||||
fetch(`${growthEndpoint}/analytics`, {
|
||||
fetch(`${VARS.GROWTH_ENDPOINT}/analytics`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -80,7 +78,7 @@ function sendEventToGrowth(event: string, path: string, data: object = null): vo
|
||||
action: event,
|
||||
label: event,
|
||||
url: window.location.origin + path,
|
||||
account: import.meta.env.VITE_CONSOLE_MODE?.toString() || Mode.SELF_HOSTED,
|
||||
account: MODE,
|
||||
data: {
|
||||
email,
|
||||
name,
|
||||
@@ -90,8 +88,8 @@ function sendEventToGrowth(event: string, path: string, data: object = null): vo
|
||||
});
|
||||
}
|
||||
|
||||
function isTrackingAllowed() {
|
||||
if (import.meta.env?.VITEST) {
|
||||
export function isTrackingAllowed() {
|
||||
if (ENV.TEST) {
|
||||
return;
|
||||
}
|
||||
if (window.navigator?.doNotTrack) {
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
class:icon-exclamation={type === 'warning'}
|
||||
class:icon-exclamation-circle={type === 'error'}
|
||||
aria-hidden="true" />
|
||||
<div class="alert-content">
|
||||
<div class="alert-content" data-private>
|
||||
{#if $$slots.title}
|
||||
<h6 class="alert-title">
|
||||
<slot name="title" />
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<script lang="ts">
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import Avatar from './avatar.svelte';
|
||||
|
||||
export let name: string;
|
||||
export let size: number;
|
||||
|
||||
$: src = sdkForConsole.avatars.getInitials(name, size * 2, size * 2).toString();
|
||||
$: src = sdk.forConsole.avatars.getInitials(name, size * 2, size * 2).toString();
|
||||
</script>
|
||||
|
||||
<Avatar {name} {size} {src} />
|
||||
@@ -1,16 +1,31 @@
|
||||
<script lang="ts">
|
||||
import { clickOnEnter } from '$lib/helpers/a11y';
|
||||
|
||||
type BaseProps = {
|
||||
isTile?: boolean;
|
||||
isDashed?: boolean;
|
||||
danger?: boolean;
|
||||
};
|
||||
|
||||
type ButtonProps = {
|
||||
isButton: true;
|
||||
href?: never;
|
||||
};
|
||||
|
||||
type AnchorProps = {
|
||||
href: string;
|
||||
isButton?: never;
|
||||
};
|
||||
|
||||
type $$Props = BaseProps & (ButtonProps | AnchorProps | BaseProps);
|
||||
|
||||
export let isTile = false;
|
||||
export let isDashed = false;
|
||||
export let isButton = false;
|
||||
export let danger = false;
|
||||
export let href: string = null;
|
||||
|
||||
//allows to add the href attribute without throwing an error
|
||||
let attributes = { href } as Record<string, string>;
|
||||
|
||||
function getElement(): string {
|
||||
function getElement() {
|
||||
switch (true) {
|
||||
case !!href:
|
||||
return 'a';
|
||||
@@ -30,6 +45,6 @@
|
||||
class:is-danger={danger}
|
||||
on:click
|
||||
on:keyup={clickOnEnter}
|
||||
{...attributes}>
|
||||
{href}>
|
||||
<slot />
|
||||
</svelte:element>
|
||||
@@ -10,7 +10,8 @@
|
||||
|
||||
<ul
|
||||
class="grid-box common-section u-margin-block-start-32"
|
||||
style={`--grid-gap:1.5rem; --grid-item-size:${total > 3 ? '22rem' : '25rem'};`}>
|
||||
style={`--grid-gap:1.5rem; --grid-item-size:${total > 3 ? '22rem' : '25rem'};`}
|
||||
data-private>
|
||||
<slot />
|
||||
|
||||
{#if total > 3 ? total < limit + offset : total % 2 !== 0}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<div class="options-list">
|
||||
<button
|
||||
type="button"
|
||||
class="input-button"
|
||||
class="options-list-button"
|
||||
aria-label="Click to copy."
|
||||
on:click={handleCopy}
|
||||
on:mouseenter={() => setTimeout(() => (content = 'Click to copy'))}
|
||||
|
||||
@@ -245,7 +245,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show on:submit={create} size="big">
|
||||
<Modal bind:show onSubmit={create} size="big">
|
||||
<svelte:fragment slot="header">Create Event</svelte:fragment>
|
||||
<slot />
|
||||
<div>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
Your feedback is important to us. Please be honest and tell us what you think.
|
||||
</div>
|
||||
|
||||
<Form on:submit={handleSubmit}>
|
||||
<Form onSubmit={handleSubmit}>
|
||||
<FormList>
|
||||
<InputText
|
||||
label="name"
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
await feedback.submitFeedback('feedback-nps', message, name, email, value);
|
||||
console.log(value, message);
|
||||
feedback.switchType('general');
|
||||
} catch (error) {
|
||||
feedback.switchType('general');
|
||||
@@ -50,7 +49,7 @@
|
||||
think.
|
||||
</div>
|
||||
|
||||
<Form on:submit={handleSubmit}>
|
||||
<Form onSubmit={handleSubmit}>
|
||||
<Evaluation bind:value>
|
||||
How likely are you to recommend Appwrite to a friend or colleague?
|
||||
</Evaluation>
|
||||
|
||||
@@ -2,12 +2,16 @@
|
||||
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
|
||||
import { Alert } from '$lib/components';
|
||||
import { trackEvent } from '$lib/actions/analytics';
|
||||
import { Form } from '$lib/elements/forms';
|
||||
|
||||
export let show = false;
|
||||
export let size: 'small' | 'big' = null;
|
||||
export let warning = false;
|
||||
export let error: string = null;
|
||||
export let closable = true;
|
||||
export let onSubmit: () => Promise<void> | void = function () {
|
||||
return;
|
||||
};
|
||||
|
||||
let dialog: HTMLDialogElement;
|
||||
let alert: HTMLElement;
|
||||
@@ -77,11 +81,10 @@
|
||||
class:is-big={size === 'big'}
|
||||
bind:this={dialog}>
|
||||
{#if show}
|
||||
<!-- svelte-ignore a11y-no-redundant-roles -->
|
||||
<form class="modal-form" role="form" on:submit|preventDefault>
|
||||
<Form isModal {onSubmit}>
|
||||
<header class="modal-header">
|
||||
{#if warning}
|
||||
<div class="avatar is-color-orange is-medium">
|
||||
<div class="avatar is-warning is-medium">
|
||||
<span class="icon-exclamation" aria-hidden="true" />
|
||||
</div>
|
||||
{/if}
|
||||
@@ -127,6 +130,6 @@
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</form>
|
||||
</Form>
|
||||
{/if}
|
||||
</dialog>
|
||||
@@ -25,7 +25,7 @@
|
||||
$: disabled = !value || $groups.has(value);
|
||||
</script>
|
||||
|
||||
<Modal bind:show on:close={reset} on:submit={create}>
|
||||
<Modal bind:show on:close={reset} onSubmit={create}>
|
||||
<svelte:fragment slot="header">Custom permission</svelte:fragment>
|
||||
<p class="text">
|
||||
Custom permissions allow you to grant access to specific users or teams using their ID and
|
||||
@@ -44,6 +44,6 @@
|
||||
</FormList>
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<Button submit {disabled}>Create</Button>
|
||||
<Button submit {disabled}>Add</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
import { tick } from 'svelte';
|
||||
import { AvatarInitials } from '../';
|
||||
@@ -18,11 +18,11 @@
|
||||
const role = permission.split(':')[0];
|
||||
const id = permission.split(':')[1].split('/')[0];
|
||||
if (role === 'user') {
|
||||
const user = await sdkForProject.users.get(id);
|
||||
const user = await sdk.forProject.users.get(id);
|
||||
return user;
|
||||
}
|
||||
if (role === 'team') {
|
||||
const team = await sdkForProject.teams.get(id);
|
||||
const team = await sdk.forProject.teams.get(id);
|
||||
return team;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { Button, InputSearch } from '$lib/elements/forms';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Query, type Models } from '@aw-labs/appwrite-console';
|
||||
import { AvatarInitials, EmptySearch, Modal, PaginationInline } from '..';
|
||||
import type { Writable } from 'svelte/store';
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
async function request() {
|
||||
if (!show) return;
|
||||
results = await sdkForProject.teams.list([Query.limit(5), Query.offset(offset)], search);
|
||||
results = await sdk.forProject.teams.list([Query.limit(5), Query.offset(offset)], search);
|
||||
}
|
||||
|
||||
function onSelection(event: Event, role: string) {
|
||||
@@ -58,7 +58,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show on:submit={create} on:close={reset} size="big">
|
||||
<Modal bind:show onSubmit={create} on:close={reset} size="big">
|
||||
<svelte:fragment slot="header">Select teams</svelte:fragment>
|
||||
<p class="text">
|
||||
Grant access to any member of a specific team. To grant access to team members with specific
|
||||
@@ -144,6 +144,6 @@
|
||||
{/if}
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<Button submit disabled={!hasSelection}>Create</Button>
|
||||
<Button submit disabled={!hasSelection}>Add</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -2,7 +2,7 @@
|
||||
import { Button, InputSearch } from '$lib/elements/forms';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { AvatarInitials, EmptySearch, Modal, PaginationInline } from '..';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Query, type Models } from '@aw-labs/appwrite-console';
|
||||
import type { Writable } from 'svelte/store';
|
||||
import type { Permission } from './permissions.svelte';
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
async function request() {
|
||||
if (!show) return;
|
||||
results = await sdkForProject.users.list([Query.limit(5), Query.offset(offset)], search);
|
||||
results = await sdk.forProject.users.list([Query.limit(5), Query.offset(offset)], search);
|
||||
}
|
||||
|
||||
function onSelection(event: Event, role: string) {
|
||||
@@ -58,7 +58,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show on:submit={create} on:close={reset} size="big">
|
||||
<Modal bind:show onSubmit={create} on:close={reset} size="big">
|
||||
<svelte:fragment slot="header">Select users</svelte:fragment>
|
||||
<p class="text">Grant access to any authenticated or anonymous user.</p>
|
||||
<InputSearch
|
||||
@@ -163,6 +163,6 @@
|
||||
{/if}
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<Button submit disabled={!hasSelection}>Create</Button>
|
||||
<Button submit disabled={!hasSelection}>Add</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -8,7 +8,7 @@
|
||||
export let copyEvent: string = null;
|
||||
</script>
|
||||
|
||||
<div class="interactive-text-output" class:is-textarea={show}>
|
||||
<div class="interactive-text-output" class:is-textarea={show} data-private>
|
||||
{#if show}
|
||||
<span class="text u-line-height-1-5 u-break-all">{value}</span>
|
||||
{:else}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<ul class="grid-box common-section" style="--grid-item-size:25rem;">
|
||||
<ul class="grid-box common-section" style="--grid-item-size:25rem;" data-private>
|
||||
<slot />
|
||||
</ul>
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { uploader } from '$lib/stores/uploader';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Avatar } from '$lib/components';
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
@@ -9,7 +9,7 @@
|
||||
let hovering = false;
|
||||
|
||||
const getPreview = (fileId: string, bucketId: string) =>
|
||||
sdkForProject.storage.getFilePreview(bucketId, fileId, 32, 32).toString() + '&mode=admin';
|
||||
sdk.forProject.storage.getFilePreview(bucketId, fileId, 32, 32).toString() + '&mode=admin';
|
||||
</script>
|
||||
|
||||
{#if $uploader?.isOpen}
|
||||
|
||||
@@ -2,13 +2,6 @@ export const PAGE_LIMIT = 12; // default page limit
|
||||
export const CARD_LIMIT = 6; // default card limit
|
||||
export const INTERVAL = 5 * 60000; // default interval to check for feedback
|
||||
|
||||
export enum Mode {
|
||||
CLOUD = 'cloud',
|
||||
SELF_HOSTED = 'self-hosted'
|
||||
}
|
||||
|
||||
export const growthEndpoint = import.meta.env.VITE_APPWRITE_GROWTH_ENDPOINT;
|
||||
|
||||
export enum Dependencies {
|
||||
ORGANIZATION = 'dependency:organization',
|
||||
PROJECT = 'dependency:project',
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { trackEvent } from '$lib/actions/analytics';
|
||||
import { getContext, hasContext } from 'svelte';
|
||||
import { readable } from 'svelte/store';
|
||||
import type { FormContext } from './form.svelte';
|
||||
|
||||
export let submit = false;
|
||||
export let secondary = false;
|
||||
@@ -14,8 +17,14 @@
|
||||
export let noMargin = false;
|
||||
export let event: string = null;
|
||||
|
||||
const isSubmitting = hasContext('form')
|
||||
? getContext<FormContext>('form').isSubmitting
|
||||
: readable(false);
|
||||
|
||||
$: internalDisabled = (submit && $isSubmitting) || disabled;
|
||||
|
||||
//allows to add the disabled attribute to <a> tag without throwing an error
|
||||
let attributes = { disabled } as Record<string, boolean>;
|
||||
$: attributes = { internalDisabled } as Record<string, boolean>;
|
||||
|
||||
function track() {
|
||||
if (!event) {
|
||||
@@ -49,7 +58,7 @@
|
||||
<button
|
||||
on:click
|
||||
on:click={track}
|
||||
{disabled}
|
||||
disabled={internalDisabled}
|
||||
class="button"
|
||||
class:is-only-icon={round}
|
||||
class:is-secondary={secondary}
|
||||
|
||||
@@ -1,9 +1,35 @@
|
||||
<script lang="ts">
|
||||
export let noMargin = false;
|
||||
export let noStyle = false;
|
||||
<script context="module" lang="ts">
|
||||
import type { Writable } from 'svelte/store';
|
||||
|
||||
export type FormContext = {
|
||||
isSubmitting: Writable<boolean>;
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y-no-redundant-roles -->
|
||||
<form role="form" class:form={!noStyle} class:common-section={!noMargin} on:submit|preventDefault>
|
||||
<script lang="ts">
|
||||
import { setContext } from 'svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export let noMargin = false;
|
||||
export let noStyle = false;
|
||||
export let isModal = false;
|
||||
export let onSubmit: () => Promise<void> | void;
|
||||
|
||||
const { isSubmitting } = setContext<FormContext>('form', {
|
||||
isSubmitting: writable(false)
|
||||
});
|
||||
|
||||
async function submit() {
|
||||
isSubmitting.set(true);
|
||||
await onSubmit();
|
||||
isSubmitting.set(false);
|
||||
}
|
||||
</script>
|
||||
|
||||
<form
|
||||
class:form={!noStyle}
|
||||
class:common-section={!noMargin}
|
||||
class:modal-form={isModal}
|
||||
on:submit|preventDefault={submit}>
|
||||
<slot />
|
||||
</form>
|
||||
@@ -23,3 +23,4 @@ export { default as InputURL } from './inputURL.svelte';
|
||||
export { default as InputId } from './inputId.svelte';
|
||||
export { default as InputSecret } from './inputSecret.svelte';
|
||||
export { default as Helper } from './helper.svelte';
|
||||
export { default as Label } from './label.svelte';
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { FormItem, Helper } from '.';
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
|
||||
export let label: string;
|
||||
export let optionalText: string | undefined = undefined;
|
||||
@@ -27,12 +27,9 @@
|
||||
</script>
|
||||
|
||||
<FormItem>
|
||||
<label class:u-hide={!showLabel} class="label" for={id}>
|
||||
<Label {required} {optionalText} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
{#if optionalText}
|
||||
<span class="optional">{optionalText}</span>
|
||||
{/if}
|
||||
</label>
|
||||
</Label>
|
||||
|
||||
<div class="input-text-wrapper">
|
||||
<input
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { FormItem, Helper } from '.';
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
|
||||
export let label: string;
|
||||
export let showLabel = true;
|
||||
@@ -48,7 +48,10 @@
|
||||
</script>
|
||||
|
||||
<FormItem>
|
||||
<label class:u-hide={!showLabel} class="label" for={id}>{label}</label>
|
||||
<Label {required} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
</Label>
|
||||
|
||||
<div class="input-text-wrapper">
|
||||
<input
|
||||
{id}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { FormItem, Helper } from '.';
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
|
||||
export let label: string;
|
||||
export let showLabel = true;
|
||||
@@ -39,12 +39,9 @@
|
||||
</script>
|
||||
|
||||
<FormItem>
|
||||
<label class:u-hide={!showLabel} class="label" for={id}>
|
||||
<Label {required} {optionalText} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
<span class:u-hide={!showLabel || !optionalText} class="optional">
|
||||
{optionalText}
|
||||
</span>
|
||||
</label>
|
||||
</Label>
|
||||
|
||||
<div class="input-text-wrapper" style="--amount-of-buttons:1; --button-size: 1rem">
|
||||
<input
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { FormItem, Helper } from '.';
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
|
||||
export let label: string;
|
||||
export let showLabel = true;
|
||||
@@ -47,7 +47,10 @@
|
||||
</script>
|
||||
|
||||
<FormItem>
|
||||
<label class:u-hide={!showLabel} class="label" for={id}>{label}</label>
|
||||
<Label {required} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
</Label>
|
||||
|
||||
<div class="input-text-wrapper">
|
||||
<input
|
||||
{id}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { FormItem, Helper } from '.';
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
|
||||
export let label: string;
|
||||
export let showLabel = true;
|
||||
@@ -41,7 +41,10 @@
|
||||
</script>
|
||||
|
||||
<FormItem>
|
||||
<label class:u-hide={!showLabel} class="label" for={id}>{label}</label>
|
||||
<Label {required} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
</Label>
|
||||
|
||||
<div class="input-text-wrapper">
|
||||
<input
|
||||
{id}
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
</div>
|
||||
<div class="u-min-width-0 u-text-center">
|
||||
<h5 class="upload-file-box-title heading-level-7 u-inline">
|
||||
<span class="is-only-desktop">Drag and drop files here to upload</span>
|
||||
<span class="is-only-desktop">Drag and drop a file here to upload</span>
|
||||
<span class="is-not-desktop">Upload a File</span>
|
||||
</h5>
|
||||
{#if allowedFileExtensions?.length}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { FormItem, Helper } from '.';
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
|
||||
export let label: string;
|
||||
export let optionalText: string | undefined = undefined;
|
||||
@@ -52,12 +52,9 @@
|
||||
</script>
|
||||
|
||||
<FormItem>
|
||||
<label class:u-hide={!showLabel} class="label" for={id}>
|
||||
<Label {required} {optionalText} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
{#if optionalText}
|
||||
<span class="optional">{optionalText}</span>
|
||||
{/if}
|
||||
</label>
|
||||
</Label>
|
||||
|
||||
<div class="input-text-wrapper">
|
||||
<input
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { FormItem, Helper } from '.';
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
|
||||
export let id: string;
|
||||
export let label: string;
|
||||
@@ -47,7 +47,10 @@
|
||||
</script>
|
||||
|
||||
<FormItem>
|
||||
<label class:u-hide={!showLabel} class="label" for={id}>{label}</label>
|
||||
<Label {required} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
</Label>
|
||||
|
||||
<div class="input-text-wrapper">
|
||||
{#if showInPlainText}
|
||||
<input
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { FormItem, Helper } from '.';
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
|
||||
export let label: string;
|
||||
export let showLabel = true;
|
||||
@@ -46,7 +46,9 @@
|
||||
</script>
|
||||
|
||||
<FormItem>
|
||||
<label class:u-hide={!showLabel} class="label" for={id}>{label}</label>
|
||||
<Label {required} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
</Label>
|
||||
<div class="input-text-wrapper">
|
||||
<input
|
||||
{id}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { FormItem, Helper } from '.';
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
|
||||
export let label: string;
|
||||
export let showLabel = true;
|
||||
@@ -40,7 +40,9 @@
|
||||
bind:group
|
||||
bind:this={element}
|
||||
on:invalid={handleInvalid} />
|
||||
<label class:u-hide={!showLabel} class="label" for={id}>{label}</label>
|
||||
<Label {required} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
</Label>
|
||||
</div>
|
||||
{#if error}
|
||||
<Helper type="warning">{error}</Helper>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { FormItem } from '.';
|
||||
import { FormItem, Label } from '.';
|
||||
|
||||
export let id: string;
|
||||
export let label: string;
|
||||
@@ -11,7 +11,10 @@
|
||||
</script>
|
||||
|
||||
<FormItem>
|
||||
<label class:u-hide={!showLabel} class="label" for={id}>{label}</label>
|
||||
<Label hide={!showLabel} for={id}>
|
||||
{label}
|
||||
</Label>
|
||||
|
||||
<div class="input-text-wrapper" style=" --amount-of-buttons: 1;">
|
||||
{#if showInPlainText}
|
||||
<div
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { FormItem, Helper } from '.';
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
|
||||
export let id: string;
|
||||
export let label: string;
|
||||
@@ -41,12 +41,9 @@
|
||||
</script>
|
||||
|
||||
<FormItem>
|
||||
<label class:u-hide={!showLabel} class="label" for={id}>
|
||||
<Label {required} {optionalText} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
{#if optionalText}
|
||||
<span class="optional">{optionalText}</span>
|
||||
{/if}
|
||||
</label>
|
||||
</Label>
|
||||
|
||||
<div class="select">
|
||||
<select
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { last } from '$lib/helpers/array';
|
||||
import { onMount } from 'svelte';
|
||||
import { FormItem, Helper } from '.';
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
|
||||
export let id: string;
|
||||
export let label: string;
|
||||
@@ -77,7 +77,10 @@
|
||||
value={tags.join(',')}
|
||||
{required}
|
||||
on:invalid={handleInvalid} />
|
||||
<label class:u-hide={!showLabel} class="label" for={id}>{label}</label>
|
||||
<Label {required} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
</Label>
|
||||
|
||||
<div class="input-text-wrapper">
|
||||
<div class="tags-input">
|
||||
<div class="tags">
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { tooltip as tooltipAction } from '$lib/actions/tooltip';
|
||||
import { onMount } from 'svelte';
|
||||
import { FormItem, Helper } from '.';
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
|
||||
export let label: string;
|
||||
export let optionalText: string | undefined = undefined;
|
||||
@@ -43,20 +42,9 @@
|
||||
</script>
|
||||
|
||||
<FormItem>
|
||||
<label class:u-hide={!showLabel} class="label" for={id}>
|
||||
<Label {required} {tooltip} {optionalText} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
{#if tooltip}
|
||||
<span
|
||||
class="icon-info"
|
||||
aria-hidden="true"
|
||||
use:tooltipAction={{
|
||||
content: tooltip
|
||||
}} />
|
||||
{/if}
|
||||
{#if optionalText}
|
||||
<span class="optional">{optionalText}</span>
|
||||
{/if}
|
||||
</label>
|
||||
</Label>
|
||||
|
||||
<div class="input-text-wrapper">
|
||||
<input
|
||||
@@ -72,6 +60,13 @@
|
||||
bind:value
|
||||
bind:this={element}
|
||||
on:invalid={handleInvalid} />
|
||||
{#if maxlength}
|
||||
<span class="text-counter">
|
||||
<span class="text-counter-count">{value?.length ?? 0}</span>
|
||||
<span class="text-counter-separator" />
|
||||
<span class="text-counter-max">{maxlength}</span>
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
{#if error}
|
||||
<Helper type="warning">{error}</Helper>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { FormItem, Helper } from '.';
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
|
||||
export let label: string;
|
||||
export let showLabel = true;
|
||||
@@ -37,7 +37,10 @@
|
||||
</script>
|
||||
|
||||
<FormItem>
|
||||
<label class:u-hide={!showLabel} class="label" for={id}>{label}</label>
|
||||
<Label {required} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
</Label>
|
||||
|
||||
<div class="input-text-wrapper">
|
||||
<textarea
|
||||
{id}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { FormItem, Helper } from '.';
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
|
||||
export let label: string;
|
||||
export let showLabel = true;
|
||||
@@ -50,7 +50,10 @@
|
||||
</script>
|
||||
|
||||
<FormItem>
|
||||
<label class:u-hide={!showLabel} class="label" for={id}>{label}</label>
|
||||
<Label {required} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
</Label>
|
||||
|
||||
<div class="input-text-wrapper">
|
||||
<input
|
||||
{id}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<script lang="ts">
|
||||
interface $$Props extends Partial<HTMLLabelElement> {
|
||||
required?: boolean;
|
||||
optionalText?: string | undefined;
|
||||
hide?: boolean;
|
||||
tooltip?: string;
|
||||
for?: string;
|
||||
}
|
||||
|
||||
export let required: $$Props['required'] = false;
|
||||
export let optionalText: $$Props['optionalText'] = undefined;
|
||||
export let hide: $$Props['hide'] = false;
|
||||
export let tooltip: $$Props['tooltip'] = null;
|
||||
</script>
|
||||
|
||||
<label class:is-required={required} class:u-hide={hide} class="label" {...$$restProps}>
|
||||
<slot />
|
||||
</label>
|
||||
|
||||
{#if optionalText}
|
||||
<span class="optional">{optionalText}</span>
|
||||
{/if}
|
||||
|
||||
{#if tooltip}
|
||||
<button class="tooltip" aria-label="variables info">
|
||||
<span class="icon-info" aria-hidden="true" />
|
||||
<span class="tooltip-popup" role="tooltip">
|
||||
<p class="text">
|
||||
{tooltip}
|
||||
</p>
|
||||
</span>
|
||||
</button>
|
||||
{/if}
|
||||
@@ -3,6 +3,6 @@
|
||||
export let title: string;
|
||||
</script>
|
||||
|
||||
<div class="table-col" data-title={title} role="cell">
|
||||
<div class="table-col" data-title={title} role="cell" data-private>
|
||||
<a role="button" tabindex="0" class="link" {href}><slot /></a>
|
||||
</div>
|
||||
@@ -10,6 +10,7 @@
|
||||
class:is-only-desktop={onlyDesktop}
|
||||
class:u-overflow-visible={showOverflow}
|
||||
data-title={title}
|
||||
role="cell">
|
||||
role="cell"
|
||||
data-private>
|
||||
<Trim><slot /></Trim>
|
||||
</div>
|
||||
@@ -7,6 +7,7 @@
|
||||
class="table is-selected-columns-mobile"
|
||||
class:u-margin-block-start-32={!noMargin}
|
||||
class:is-remove-outer-styles={noStyles}
|
||||
role="table">
|
||||
role="table"
|
||||
data-private>
|
||||
<slot />
|
||||
</div>
|
||||
@@ -1,5 +1,5 @@
|
||||
<!-- TODO: is 100% height needed? -->
|
||||
<div class="table-with-scroll">
|
||||
<div class="table-with-scroll" data-private>
|
||||
<div class="table-wrapper">
|
||||
<div class="table is-remove-outer-styles">
|
||||
<ul class="table-thead">
|
||||
|
||||
@@ -1,10 +1,30 @@
|
||||
<script lang="ts">
|
||||
import type { Action } from 'svelte/action';
|
||||
|
||||
export let isSticky = false;
|
||||
|
||||
const hasOverflow: Action<HTMLDivElement, (value: boolean) => void> = (node, callback) => {
|
||||
const observer = new ResizeObserver((entries) => {
|
||||
for (const entry of entries) {
|
||||
callback(entry.contentRect.width < entry.target.scrollWidth);
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(node);
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
observer.disconnect();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
let isOverflowing = false;
|
||||
</script>
|
||||
|
||||
<div class="table-with-scroll u-margin-block-start-32">
|
||||
<div class="table-wrapper">
|
||||
<table class="table" class:is-sticky-scroll={isSticky}>
|
||||
<div class="table-with-scroll u-margin-block-start-32" data-private>
|
||||
<div class="table-wrapper" use:hasOverflow={(v) => (isOverflowing = v)}>
|
||||
<table class="table" class:is-sticky-scroll={isSticky && isOverflowing}>
|
||||
<slot />
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export function getProjectId() {
|
||||
const pathname = window.location.pathname;
|
||||
const projectMatch = pathname.match(/\/project-(.*?)\//);
|
||||
return projectMatch?.[1] || null;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export async function sleep(ms: number): Promise<void> {
|
||||
return new Promise((r) => setTimeout(r, ms));
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] as const;
|
||||
export type Size = (typeof sizes)[number];
|
||||
|
||||
export function calculateSize(bytes: number, decimals = 1) {
|
||||
if (bytes === 0) return '0 Bytes';
|
||||
@@ -13,18 +14,19 @@ export function calculateSize(bytes: number, decimals = 1) {
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
||||
}
|
||||
|
||||
export function sizeToBytes(value: number, unit: string) {
|
||||
export function sizeToBytes(value: number, unit: Size) {
|
||||
const index = sizes.indexOf(unit);
|
||||
return value * Math.pow(1024, index);
|
||||
}
|
||||
export function bytesToSize(value: number, unit: string) {
|
||||
|
||||
export function bytesToSize(value: number, unit: Size) {
|
||||
const index = sizes.indexOf(unit);
|
||||
return value / Math.pow(1024, index);
|
||||
}
|
||||
|
||||
export function humanFileSize(bytes: number): {
|
||||
value: string;
|
||||
unit: string;
|
||||
unit: Size;
|
||||
} {
|
||||
const value = prettyBytes(bytes, {
|
||||
locale: 'en'
|
||||
@@ -32,6 +34,6 @@ export function humanFileSize(bytes: number): {
|
||||
|
||||
return {
|
||||
value: value[0],
|
||||
unit: value[1]
|
||||
unit: value[1] as Size
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import { derived, writable } from 'svelte/store';
|
||||
import { last } from './array';
|
||||
import { withPrevious } from './withPrevious';
|
||||
|
||||
export type Unit<T = string> = {
|
||||
name: T;
|
||||
value: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a value-unit pair. When the unit is changed, the value is updated
|
||||
* to reflect the new unit.
|
||||
*
|
||||
* @export
|
||||
* @template T = string
|
||||
* @param {number} [initialValue=0]
|
||||
* @param {Unit<T>[]} units
|
||||
*/
|
||||
export function createValueUnitPair<T = string>(initialValue = 0, units: Unit<T>[]) {
|
||||
if (!units.some((u) => u.value === 1)) {
|
||||
throw new Error('Units must have a value of 1');
|
||||
}
|
||||
|
||||
if (units.some((u) => u.value < 1)) {
|
||||
throw new Error('Units must have a value greater than 1');
|
||||
}
|
||||
|
||||
// Highest to lowest
|
||||
const sortedUnits = units.sort((a, b) => b.value - a.value);
|
||||
|
||||
const unit = withPrevious(last(sortedUnits).name);
|
||||
const value = writable(initialValue);
|
||||
const baseValue = derived([value, unit], ([$value, $unit]) => {
|
||||
return $value * units.find((u) => u.name === $unit).value;
|
||||
});
|
||||
|
||||
for (const u of sortedUnits) {
|
||||
if (initialValue >= u.value && initialValue % u.value === 0) {
|
||||
unit.set(u.name, { updateAll: true });
|
||||
value.set(initialValue / u.value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
unit.subscribe((newValue, prev) => {
|
||||
value.update((v) => {
|
||||
const unitInBase = v * units.find((u) => u.name === prev).value;
|
||||
return unitInBase / units.find((u) => u.name === newValue).value;
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
value,
|
||||
unit,
|
||||
baseValue
|
||||
};
|
||||
}
|
||||
|
||||
export function createTimeUnitPair(initialValue = 0) {
|
||||
const units: Unit[] = [
|
||||
{ name: 'Days', value: 86400 },
|
||||
{ name: 'Hours', value: 3600 },
|
||||
{ name: 'Minutes', value: 60 },
|
||||
{ name: 'Seconds', value: 1 }
|
||||
];
|
||||
return { ...createValueUnitPair(initialValue, units), units };
|
||||
}
|
||||
|
||||
export function createByteUnitPair(initialValue = 0) {
|
||||
const units: Unit[] = [
|
||||
{ name: 'Bytes', value: 1 },
|
||||
{ name: 'Kilobytes', value: 1024 },
|
||||
{ name: 'Megabytes', value: 1024 ** 2 },
|
||||
{ name: 'Gigabytes', value: 1024 ** 3 }
|
||||
];
|
||||
return { ...createValueUnitPair(initialValue, units), units };
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
type SetterOptions = {
|
||||
updateAll?: boolean;
|
||||
};
|
||||
|
||||
type Listener<T> = (value: T, previous: T | null) => void;
|
||||
|
||||
export function withPrevious<T>(value: T) {
|
||||
let current = value;
|
||||
let previous: T | null = null;
|
||||
|
||||
let subscribers: Array<Listener<T>> = [];
|
||||
|
||||
const subscribe = (listener: Listener<T>) => {
|
||||
subscribers.push(listener);
|
||||
listener(current, previous);
|
||||
|
||||
return () => {
|
||||
subscribers = subscribers.filter((s) => s !== listener);
|
||||
};
|
||||
};
|
||||
|
||||
const set = (value: T, options?: SetterOptions) => {
|
||||
previous = options?.updateAll ? value : current;
|
||||
current = value;
|
||||
|
||||
subscribers.forEach((s) => s(current, previous));
|
||||
};
|
||||
|
||||
const getPrevious = () => previous;
|
||||
|
||||
const currentStore = {
|
||||
subscribe,
|
||||
set,
|
||||
getPrevious
|
||||
};
|
||||
|
||||
return currentStore;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { EmptySearch, Pagination, Trim } from '$lib/components';
|
||||
import { AvatarInitials, EmptySearch, Pagination, Trim } from '$lib/components';
|
||||
import {
|
||||
TableBody,
|
||||
TableHeader,
|
||||
@@ -11,24 +11,19 @@
|
||||
} from '$lib/elements/table';
|
||||
import { Container } from '$lib/layout';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { PAGE_LIMIT } from '$lib/constants';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
|
||||
export let logs: Models.LogList;
|
||||
export let path: string;
|
||||
export let offset = 0;
|
||||
|
||||
const getBrowser = (clientCode: string) => {
|
||||
return sdkForConsole.avatars.getBrowser(clientCode, 40, 40);
|
||||
};
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
{#if logs.total}
|
||||
<TableScroll>
|
||||
<TableHeader>
|
||||
<TableCellHead width={150}>Client</TableCellHead>
|
||||
<TableCellHead width={100}>User</TableCellHead>
|
||||
<TableCellHead width={100}>Event</TableCellHead>
|
||||
<TableCellHead width={80}>Location</TableCellHead>
|
||||
<TableCellHead width={90}>IP</TableCellHead>
|
||||
@@ -38,28 +33,22 @@
|
||||
{#each logs.logs as log}
|
||||
<TableRow>
|
||||
<TableCell title="Client">
|
||||
{#if log.clientName}
|
||||
<div class="u-flex u-cross-center u-gap-12">
|
||||
<div class="avatar is-small">
|
||||
<img
|
||||
height="20"
|
||||
width="20"
|
||||
src={getBrowser(log.clientCode).toString()}
|
||||
alt={log.clientName} />
|
||||
<div class="u-flex u-cross-center u-gap-12">
|
||||
{#if log.userEmail}
|
||||
{#if log.userName}
|
||||
<AvatarInitials size={32} name={log.userName} />
|
||||
<Trim>{log.userName}</Trim>
|
||||
{:else}
|
||||
<AvatarInitials size={32} name={log.userEmail} />
|
||||
<Trim>{log.userEmail}</Trim>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="avatar is-size-small ">
|
||||
<span class="icon-anonymous" aria-hidden="true" />
|
||||
</div>
|
||||
<Trim>
|
||||
{log.clientName}
|
||||
{log.clientVersion}
|
||||
on {log.osName}
|
||||
{log.osVersion}
|
||||
</Trim>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="u-flex u-cross-center u-gap-12">
|
||||
<span class="avatar is-color-empty" />
|
||||
<p class="text u-trim">Unknown</p>
|
||||
</div>
|
||||
{/if}
|
||||
<span class="text u-trim">{log.userName ?? 'Anonymous'}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCellText title="Event">{log.event}</TableCellText>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<nav class="breadcrumbs is-only-desktop" aria-label="breadcrumb">
|
||||
<ol class="breadcrumbs-list">
|
||||
{#each breadcrumbs as breadcrumb}
|
||||
<li class="breadcrumbs-item">
|
||||
<li class="breadcrumbs-item" data-private>
|
||||
{#if breadcrumb.href}
|
||||
<a href={breadcrumb.href} title={breadcrumb.title} on:click={track}>
|
||||
{breadcrumb.title}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<span class="icon-cheveron-left" aria-hidden="true" />
|
||||
</a>
|
||||
{/if}
|
||||
<span class="text u-trim-1">
|
||||
<span class="text u-trim-1" data-private>
|
||||
<slot />
|
||||
</span>
|
||||
</Heading>
|
||||
@@ -1,47 +1,68 @@
|
||||
<footer class="main-footer">
|
||||
<div class="container">
|
||||
<ul class="inline-links is-center">
|
||||
<script>
|
||||
import { Mode, MODE } from '$lib/system';
|
||||
|
||||
import { version } from '$routes/console/store';
|
||||
|
||||
const currentYear = new Date().getFullYear();
|
||||
</script>
|
||||
|
||||
<footer class="main-footer u-cross-center">
|
||||
<div class="main-footer-start">
|
||||
<ul class="inline-links is-no-padding-first-and-last u-x-small">
|
||||
<li class="inline-links-item">
|
||||
<a
|
||||
class="link"
|
||||
href="https://github.com/appwrite/appwrite"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer">
|
||||
<span class="icon-github-circled" aria-hidden="true" />
|
||||
<span class="text">GitHub</span>
|
||||
<div class="u-flex u-cross-center u-gap-8">
|
||||
{#if MODE === Mode.CLOUD}
|
||||
<span class="icon-cloud" />
|
||||
{/if}
|
||||
{#if $version}
|
||||
<a
|
||||
class="text"
|
||||
href="https://github.com/appwrite/appwrite/blob/master/CHANGES.md"
|
||||
target="_blank"
|
||||
rel="noreferrer">
|
||||
Version {$version}
|
||||
</a>
|
||||
{/if}
|
||||
</div>
|
||||
</li>
|
||||
<li class="inline-links-item">
|
||||
<a href="https://appwrite.io/policy/terms" target="_blank" rel="noreferrer">
|
||||
<span class="text">Terms</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="inline-links-item">
|
||||
<a
|
||||
class="link"
|
||||
href="https://appwrite.io/discord"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer">
|
||||
<span class="icon-discord" aria-hidden="true" />
|
||||
<span class="text">Discord</span>
|
||||
<a href="https://appwrite.io/policy/privacy" target="_blank" rel="noreferrer">
|
||||
<span class="text">Privacy</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="main-footer-end">
|
||||
<ul class="inline-links is-no-padding-first-and-last u-x-small">
|
||||
<li class="inline-links-item">
|
||||
<a
|
||||
class="link"
|
||||
href="https://github.com/appwrite/appwrite/issues/new"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer">
|
||||
<span class="text">Open an Issue</span>
|
||||
</a>
|
||||
<span class="text">ⓒ {currentYear} Appwrite. All rights reserved.</span>
|
||||
</li>
|
||||
<li class="inline-links-item">
|
||||
<a
|
||||
class="link"
|
||||
href="https://appwrite.io/docs"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer">
|
||||
<span class="text">Docs</span>
|
||||
<li class="inline-links-item u-flex u-gap-8">
|
||||
<a href="https://github.com/appwrite/appwrite" target="_blank" rel="noreferrer">
|
||||
<span class="icon-github" aria-hidden="true" aria-label="Appwrite on Github" />
|
||||
</a>
|
||||
<a href="https://appwrite.io/discord" target="_blank" rel="noreferrer">
|
||||
<span
|
||||
class="icon-discord"
|
||||
aria-hidden="true"
|
||||
aria-label="Appwrite on Discord" />
|
||||
</a>
|
||||
</li>
|
||||
<li class="inline-links-item">
|
||||
<span class="text">API:0.13.2</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<style lang="scss">
|
||||
.main-footer {
|
||||
margin-block-start: auto;
|
||||
}
|
||||
|
||||
[class^='icon-']:not(:hover) {
|
||||
color: hsl(var(--color-neutral-50));
|
||||
}
|
||||
</style>
|
||||
@@ -20,7 +20,7 @@
|
||||
import { slide } from 'svelte/transition';
|
||||
import { page } from '$app/stores';
|
||||
import { Submit, trackEvent } from '$lib/actions/analytics';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
let showDropdown = false;
|
||||
@@ -35,7 +35,7 @@
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
await sdkForConsole.account.deleteSession('current');
|
||||
await sdk.forConsole.account.deleteSession('current');
|
||||
trackEvent(Submit.AccountLogout);
|
||||
await goto(`${base}/login`);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { base } from '$app/paths';
|
||||
import { app } from '$lib/stores/app';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { page } from '$app/stores';
|
||||
import { calculateTime } from '$lib/helpers/timeConversion';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
@@ -17,7 +17,7 @@
|
||||
function isDeployment(data: Models.Deployment | Models.Execution): data is Models.Deployment {
|
||||
if ('buildId' in data) {
|
||||
selectedTab = 'logs';
|
||||
rawData = `${sdkForConsole.client.config.endpoint}/functions/${$log.func.$id}/deployment/${$log.data.$id}?mode=admin&project=${$page.params.project}`;
|
||||
rawData = `${sdk.forConsole.client.config.endpoint}/functions/${$log.func.$id}/deployment/${$log.data.$id}?mode=admin&project=${$page.params.project}`;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@
|
||||
function isExecution(data: Models.Deployment | Models.Execution): data is Models.Execution {
|
||||
if ('trigger' in data) {
|
||||
selectedTab = 'response';
|
||||
rawData = `${sdkForConsole.client.config.endpoint}/functions/${$log.func.$id}/execution/${$log.data.$id}?mode=admin&project=${$page.params.project}`;
|
||||
rawData = `${sdk.forConsole.client.config.endpoint}/functions/${$log.func.$id}/execution/${$log.data.$id}?mode=admin&project=${$page.params.project}`;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@
|
||||
<svelte:window on:keydown={handleKeydown} />
|
||||
|
||||
{#if $log.data}
|
||||
<section class="cover-frame">
|
||||
<section class="cover-frame" data-private>
|
||||
<header class="cover-frame-header u-flex u-gap-16 u-main-space-between u-cross-center">
|
||||
<h1 class="body-text-1">Function ID: {$log.func.$id}</h1>
|
||||
<button
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
|
||||
<main
|
||||
class:grid-with-side={showSideNavigation}
|
||||
class:grid={!showSideNavigation}
|
||||
class:is-open={isOpen}
|
||||
class:u-hide={$wizard.show || $log.show}>
|
||||
<header class="main-header u-padding-inline-end-0">
|
||||
@@ -54,9 +53,11 @@
|
||||
</button>
|
||||
<slot name="header" />
|
||||
</header>
|
||||
<nav class="main-side">
|
||||
<slot name="side" />
|
||||
</nav>
|
||||
{#if showSideNavigation}
|
||||
<nav class="main-side">
|
||||
<slot name="side" />
|
||||
</nav>
|
||||
{/if}
|
||||
<section class="main-content">
|
||||
{#if $page.data?.header}
|
||||
<svelte:component this={$page.data.header} />
|
||||
@@ -64,19 +65,30 @@
|
||||
|
||||
<slot />
|
||||
</section>
|
||||
<slot name="footer" />
|
||||
</main>
|
||||
|
||||
<style>
|
||||
.grid-with-side {
|
||||
<style lang="scss">
|
||||
main {
|
||||
min-height: 100vh;
|
||||
|
||||
&:not(.grid-with-side) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
.main-side {
|
||||
z-index: 25;
|
||||
}
|
||||
|
||||
@media (max-width: 550.99px), (min-width: 551px) and (max-width: 1198.99px) {
|
||||
.main-side {
|
||||
top: 4.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.main-content {
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
@@ -122,7 +122,7 @@
|
||||
{/if}
|
||||
</div>
|
||||
<div class="wizard-main">
|
||||
<Form noStyle on:submit={submit}>
|
||||
<Form noStyle onSubmit={submit}>
|
||||
{#each sortedSteps as [step, { component }]}
|
||||
{#if currentStep === step}
|
||||
<svelte:component this={component} />
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show on:submit={handleSubmit} warning>
|
||||
<Modal bind:show onSubmit={handleSubmit} warning>
|
||||
<svelte:fragment slot="header">Exit Process</svelte:fragment>
|
||||
<p>
|
||||
Are you sure you want to exit from <slot />? All data will be deleted. This action is
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<script lang="ts">
|
||||
import Form from '../elements/forms/form.svelte';
|
||||
import Button from '../elements/forms/button.svelte';
|
||||
|
||||
export let onSubmit: () => Promise<void> | void;
|
||||
</script>
|
||||
|
||||
<Form {onSubmit}>
|
||||
<Button submit>Submit</Button>
|
||||
<Button>Button</Button>
|
||||
</Form>
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { Models, Payload } from '@aw-labs/appwrite-console';
|
||||
import { Service } from './service';
|
||||
|
||||
export class Project extends Service {
|
||||
/**
|
||||
* Get usage stats for a project
|
||||
*
|
||||
*
|
||||
* @param {string} range
|
||||
* @throws {AppwriteException}
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async getUsage(range?: string): Promise<Models.UsageProject> {
|
||||
const path = '/project/usage';
|
||||
const payload: Payload = {};
|
||||
|
||||
if (typeof range !== 'undefined') {
|
||||
payload['range'] = range;
|
||||
}
|
||||
|
||||
const uri = new URL(this.client.config.endpoint + path);
|
||||
return await this.client.call(
|
||||
'get',
|
||||
uri,
|
||||
{
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
payload
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import type { Client, Payload } from '@aw-labs/appwrite-console';
|
||||
|
||||
export class Service {
|
||||
static CHUNK_SIZE = 5 * 1024 * 1024; // 5MB
|
||||
|
||||
client: Client;
|
||||
|
||||
constructor(client: Client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
static flatten(data: Payload, prefix = ''): Payload {
|
||||
let output: Payload = {};
|
||||
|
||||
for (const key in data) {
|
||||
const value = data[key];
|
||||
const finalKey = prefix ? `${prefix}[${key}]` : key;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
output = Object.assign(output, this.flatten(value, finalKey));
|
||||
} else {
|
||||
output[finalKey] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { browser } from '$app/environment';
|
||||
import { growthEndpoint } from '$lib/constants';
|
||||
import { VARS } from '$lib/system';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export type AppStore = {
|
||||
@@ -64,8 +64,8 @@ function createFeedbackStore() {
|
||||
email?: string,
|
||||
value?: number
|
||||
) => {
|
||||
if (!growthEndpoint) return;
|
||||
const response = await fetch(`${growthEndpoint}/feedback`, {
|
||||
if (!VARS.GROWTH_ENDPOINT) return;
|
||||
const response = await fetch(`${VARS.GROWTH_ENDPOINT}/feedback`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
||||
+25
-20
@@ -1,3 +1,6 @@
|
||||
import { getProjectId } from '$lib/helpers/project';
|
||||
import { Project } from '$lib/sdk/project';
|
||||
import { VARS } from '$lib/system';
|
||||
import {
|
||||
Account,
|
||||
Avatars,
|
||||
@@ -12,30 +15,13 @@ import {
|
||||
Users
|
||||
} from '@aw-labs/appwrite-console';
|
||||
|
||||
import { Project } from './project';
|
||||
const endpoint = VARS.APPWRITE_ENDPOINT ?? `${globalThis?.location?.origin}/v1`;
|
||||
|
||||
const endpoint =
|
||||
import.meta.env.VITE_APPWRITE_ENDPOINT?.toString() ?? `${globalThis?.location?.origin}/v1`;
|
||||
const clientConsole = new Client();
|
||||
clientConsole.setEndpoint(endpoint).setProject('console');
|
||||
|
||||
const clientProject = new Client();
|
||||
clientProject.setEndpoint(endpoint).setMode('admin');
|
||||
|
||||
const setProject = (projectId: string): Client => clientProject.setProject(projectId);
|
||||
|
||||
const sdkForConsole = {
|
||||
client: clientConsole,
|
||||
account: new Account(clientConsole),
|
||||
avatars: new Avatars(clientConsole),
|
||||
functions: new Functions(clientConsole),
|
||||
health: new Health(clientConsole),
|
||||
locale: new Locale(clientConsole),
|
||||
projects: new Projects(clientConsole),
|
||||
teams: new Teams(clientConsole),
|
||||
users: new Users(clientConsole)
|
||||
};
|
||||
|
||||
const sdkForProject = {
|
||||
client: clientProject,
|
||||
account: new Account(clientProject),
|
||||
@@ -45,10 +31,29 @@ const sdkForProject = {
|
||||
health: new Health(clientProject),
|
||||
locale: new Locale(clientProject),
|
||||
project: new Project(clientProject),
|
||||
projects: new Projects(clientProject),
|
||||
storage: new Storage(clientProject),
|
||||
teams: new Teams(clientProject),
|
||||
users: new Users(clientProject)
|
||||
};
|
||||
|
||||
export { sdkForConsole, sdkForProject, setProject, endpoint };
|
||||
export const sdk = {
|
||||
forConsole: {
|
||||
client: clientConsole,
|
||||
account: new Account(clientConsole),
|
||||
avatars: new Avatars(clientConsole),
|
||||
functions: new Functions(clientConsole),
|
||||
health: new Health(clientConsole),
|
||||
locale: new Locale(clientConsole),
|
||||
projects: new Projects(clientConsole),
|
||||
teams: new Teams(clientConsole),
|
||||
users: new Users(clientConsole)
|
||||
},
|
||||
get forProject() {
|
||||
const projectId = getProjectId();
|
||||
if (projectId && projectId !== clientProject.config.project) {
|
||||
clientProject.setProject(projectId);
|
||||
}
|
||||
|
||||
return sdkForProject;
|
||||
}
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
import { writable } from 'svelte/store';
|
||||
import { sdkForProject } from './sdk';
|
||||
import { sdk } from './sdk';
|
||||
|
||||
type UploaderFile = {
|
||||
$id: string;
|
||||
@@ -71,7 +71,7 @@ const createUploader = () => {
|
||||
n.files.unshift(newFile);
|
||||
return n;
|
||||
});
|
||||
const uploadedFile = await sdkForProject.storage.createFile(
|
||||
const uploadedFile = await sdk.forProject.storage.createFile(
|
||||
bucketId,
|
||||
id ?? 'unique()',
|
||||
file,
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
export enum Mode {
|
||||
CLOUD = 'cloud',
|
||||
SELF_HOSTED = 'self-hosted'
|
||||
}
|
||||
|
||||
export const VARS = {
|
||||
APPWRITE_ENDPOINT: import.meta.env?.VITE_APPWRITE_ENDPOINT?.toString() as string | undefined,
|
||||
GROWTH_ENDPOINT: import.meta.env?.VITE_APPWRITE_GROWTH_ENDPOINT?.toString() as
|
||||
| string
|
||||
| undefined,
|
||||
CONSOLE_MODE: import.meta.env?.VITE_CONSOLE_MODE?.toString() as string | undefined,
|
||||
VERCEL_ENV: import.meta.env?.VITE_VERCEL_ENV?.toString() as string | undefined,
|
||||
GOOGLE_ANALYTICS: import.meta.env?.VITE_GA_PROJECT?.toString() as string | undefined
|
||||
};
|
||||
|
||||
export const ENV = {
|
||||
DEV: import.meta.env.DEV,
|
||||
PROD: import.meta.env.PROD,
|
||||
PREVIEW: VARS.VERCEL_ENV === 'preview',
|
||||
TEST: !!import.meta.env?.VITEST
|
||||
};
|
||||
|
||||
export const MODE = VARS.CONSOLE_MODE === Mode.CLOUD ? Mode.CLOUD : Mode.SELF_HOSTED;
|
||||
export const isCloud = MODE === Mode.CLOUD;
|
||||
export const isSelfHosted = MODE === Mode.SELF_HOSTED;
|
||||
@@ -0,0 +1,12 @@
|
||||
<script>
|
||||
import { page } from '$app/stores';
|
||||
import { Heading } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Unauthenticated } from '$lib/layout';
|
||||
</script>
|
||||
|
||||
<Unauthenticated>
|
||||
<Heading size="1" tag="h3">{$page.status}</Heading>
|
||||
<Heading size="3" tag="h4">{$page.error.message}</Heading>
|
||||
<Button href="/">Back to the console</Button>
|
||||
</Unauthenticated>
|
||||
+29
-19
@@ -1,19 +1,21 @@
|
||||
<script lang="ts">
|
||||
import { browser } from '$app/environment';
|
||||
import { afterNavigate, goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { user } from '$lib/stores/user';
|
||||
import { onCLS, onFID, onLCP, onFCP, onINP, onTTFB } from 'web-vitals';
|
||||
import { reportWebVitals } from '$lib/helpers/vitals';
|
||||
import { onMount } from 'svelte';
|
||||
import { base } from '$app/paths';
|
||||
import { browser, dev } from '$app/environment';
|
||||
import { page } from '$app/stores';
|
||||
import { isTrackingAllowed, trackPageView } from '$lib/actions/analytics';
|
||||
import { reportWebVitals } from '$lib/helpers/vitals';
|
||||
import { Notifications, Progress } from '$lib/layout';
|
||||
import { app } from '$lib/stores/app';
|
||||
import { Progress, Notifications } from '$lib/layout';
|
||||
import { loading } from './store';
|
||||
import Loading from './loading.svelte';
|
||||
import { trackPageView } from '$lib/actions/analytics';
|
||||
import { user } from '$lib/stores/user';
|
||||
import { ENV, isCloud } from '$lib/system';
|
||||
import * as Sentry from '@sentry/svelte';
|
||||
import LogRocket from 'logrocket';
|
||||
import { BrowserTracing } from '@sentry/tracing';
|
||||
import { onMount } from 'svelte';
|
||||
import { onCLS, onFCP, onFID, onINP, onLCP, onTTFB } from 'web-vitals';
|
||||
import Loading from './loading.svelte';
|
||||
import { loading } from './store';
|
||||
|
||||
if (browser) {
|
||||
window.VERCEL_ANALYTICS_ID = import.meta.env.VERCEL_ANALYTICS_ID?.toString() ?? false;
|
||||
@@ -23,7 +25,7 @@
|
||||
/**
|
||||
* Reporting Web Vitals.
|
||||
*/
|
||||
if (!dev && window.VERCEL_ANALYTICS_ID) {
|
||||
if (ENV.PROD && window.VERCEL_ANALYTICS_ID) {
|
||||
onCLS(reportWebVitals);
|
||||
onFID(reportWebVitals);
|
||||
onLCP(reportWebVitals);
|
||||
@@ -32,15 +34,26 @@
|
||||
onTTFB(reportWebVitals);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sentry Error Logging
|
||||
*/
|
||||
if (!dev) {
|
||||
if (ENV.PROD) {
|
||||
/**
|
||||
* Sentry Error Logging
|
||||
*/
|
||||
Sentry.init({
|
||||
dsn: 'https://c7ce178bdedd486480317b72f282fd39@o1063647.ingest.sentry.io/4504158071422976',
|
||||
integrations: [new BrowserTracing()],
|
||||
tracesSampleRate: 1.0
|
||||
});
|
||||
|
||||
/**
|
||||
* LogRocket
|
||||
*/
|
||||
if (isCloud && isTrackingAllowed()) {
|
||||
LogRocket.init('rgthvf/appwrite', {
|
||||
dom: {
|
||||
inputSanitizer: true
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,10 +72,7 @@
|
||||
}
|
||||
loading.set(false);
|
||||
} else {
|
||||
if (
|
||||
acceptedRoutes.includes($page.url.pathname) ||
|
||||
$page.url.pathname.startsWith('/register/invite')
|
||||
) {
|
||||
if (acceptedRoutes.some((n) => $page.url.pathname.startsWith(n))) {
|
||||
await goto(`${base}${$page.url.pathname}${$page.url.search}`);
|
||||
} else {
|
||||
await goto(`${base}/login`, {
|
||||
|
||||
+10
-7
@@ -1,7 +1,8 @@
|
||||
import '@appwrite.io/pink';
|
||||
import '@appwrite.io/pink-icons';
|
||||
import 'tippy.js/dist/tippy.css';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import LogRocket from 'logrocket';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import type { LayoutLoad } from './$types';
|
||||
@@ -11,11 +12,16 @@ export const ssr = false;
|
||||
export const load: LayoutLoad = async ({ depends, url }) => {
|
||||
depends(Dependencies.ACCOUNT);
|
||||
try {
|
||||
const account = await sdkForConsole.account.get();
|
||||
const account = await sdk.forConsole.account.get();
|
||||
|
||||
LogRocket.identify(account.$id, {
|
||||
name: account.name,
|
||||
email: account.email
|
||||
});
|
||||
|
||||
return {
|
||||
account,
|
||||
organizations: sdkForConsole.teams.list()
|
||||
organizations: sdk.forConsole.teams.list()
|
||||
};
|
||||
} catch (error) {
|
||||
const acceptedRoutes = [
|
||||
@@ -28,10 +34,7 @@ export const load: LayoutLoad = async ({ depends, url }) => {
|
||||
'/auth/oauth2/failure'
|
||||
];
|
||||
|
||||
if (
|
||||
!acceptedRoutes.includes(url.pathname) &&
|
||||
!url.pathname.startsWith('/register/invite')
|
||||
) {
|
||||
if (!acceptedRoutes.some((n) => url.pathname.startsWith(n))) {
|
||||
throw redirect(303, '/login');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
<script lang="ts">
|
||||
import Shell from '$lib/layout/shell.svelte';
|
||||
import SideNavigation from '$lib/layout/navigation.svelte';
|
||||
import Header from '$lib/layout/header.svelte';
|
||||
import { newOrgModal } from '$lib/stores/organization';
|
||||
import Create from './createOrganization.svelte';
|
||||
import { page } from '$app/stores';
|
||||
import { beforeNavigate } from '$app/navigation';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { page } from '$app/stores';
|
||||
import { INTERVAL } from '$lib/constants';
|
||||
import { Logs } from '$lib/layout';
|
||||
import Footer from '$lib/layout/footer.svelte';
|
||||
import Header from '$lib/layout/header.svelte';
|
||||
import SideNavigation from '$lib/layout/navigation.svelte';
|
||||
import Shell from '$lib/layout/shell.svelte';
|
||||
import { feedback } from '$lib/stores/app';
|
||||
import { log } from '$lib/stores/logs';
|
||||
import { newOrgModal } from '$lib/stores/organization';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { onMount } from 'svelte';
|
||||
import { loading } from '../store';
|
||||
import { feedback } from '$lib/stores/app';
|
||||
import { INTERVAL } from '$lib/constants';
|
||||
import Create from './createOrganization.svelte';
|
||||
|
||||
onMount(() => {
|
||||
loading.set(false);
|
||||
@@ -50,14 +51,10 @@
|
||||
!$page?.params.organization &&
|
||||
!$page.url.pathname.includes('/console/account') &&
|
||||
!$page.url.pathname.includes('/console/onboarding')}>
|
||||
<svelte:fragment slot="header">
|
||||
<Header />
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="side">
|
||||
<SideNavigation />
|
||||
</svelte:fragment>
|
||||
<Header slot="header" />
|
||||
<SideNavigation slot="side" />
|
||||
<slot />
|
||||
<footer class="main-footer" />
|
||||
<Footer slot="footer" />
|
||||
</Shell>
|
||||
|
||||
{#if $wizard.show && $wizard.component}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { LayoutLoad } from './$types';
|
||||
|
||||
export const load: LayoutLoad = async () => {
|
||||
const response = await fetch(`${sdk.forConsole.client.config.endpoint}/health/version`);
|
||||
const data = await response.json();
|
||||
|
||||
return {
|
||||
version: data?.version ?? null
|
||||
};
|
||||
};
|
||||
@@ -4,7 +4,7 @@
|
||||
import { Container } from '$lib/layout';
|
||||
import { onMount } from 'svelte';
|
||||
import { user } from '$lib/stores/user';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { base } from '$app/paths';
|
||||
import Delete from './delete.svelte';
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
async function updateName() {
|
||||
try {
|
||||
await sdkForConsole.account.updateName(name);
|
||||
await sdk.forConsole.account.updateName(name);
|
||||
invalidate(Dependencies.ACCOUNT);
|
||||
addNotification({
|
||||
message: 'Name has been updated',
|
||||
@@ -43,7 +43,7 @@
|
||||
}
|
||||
async function updateEmail() {
|
||||
try {
|
||||
await sdkForConsole.account.updateEmail(email, emailPassword);
|
||||
await sdk.forConsole.account.updateEmail(email, emailPassword);
|
||||
invalidate(Dependencies.ACCOUNT);
|
||||
addNotification({
|
||||
message: 'Email has been updated',
|
||||
@@ -61,7 +61,7 @@
|
||||
|
||||
async function updatePassword() {
|
||||
try {
|
||||
await sdkForConsole.account.updatePassword(newPassword, oldPassword);
|
||||
await sdk.forConsole.account.updatePassword(newPassword, oldPassword);
|
||||
newPassword = oldPassword = null;
|
||||
addNotification({
|
||||
message: 'Password has been updated',
|
||||
@@ -79,19 +79,13 @@
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<Form on:submit={updateName}>
|
||||
<Form onSubmit={updateName}>
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Update Name</Heading>
|
||||
<Heading tag="h6" size="7">Name</Heading>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
<ul>
|
||||
<InputText
|
||||
id="name"
|
||||
label="Name"
|
||||
placeholder="Enter name"
|
||||
autocomplete={false}
|
||||
autofocus={true}
|
||||
bind:value={name} />
|
||||
<InputText id="name" label="Name" placeholder="Enter name" bind:value={name} />
|
||||
</ul>
|
||||
</svelte:fragment>
|
||||
|
||||
@@ -100,9 +94,9 @@
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
<Form on:submit={updateEmail}>
|
||||
<Form onSubmit={updateEmail}>
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Update Email</Heading>
|
||||
<Heading tag="h6" size="7">Email</Heading>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
@@ -110,14 +104,12 @@
|
||||
id="email"
|
||||
label="Email"
|
||||
placeholder="Enter email"
|
||||
autocomplete={false}
|
||||
bind:value={email} />
|
||||
{#if email !== $user.email && email}
|
||||
<InputPassword
|
||||
id="emailPassword"
|
||||
label="Password"
|
||||
placeholder="Enter password"
|
||||
autocomplete={false}
|
||||
showPasswordButton={true}
|
||||
bind:value={emailPassword} />
|
||||
{/if}
|
||||
@@ -130,9 +122,9 @@
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
<Form on:submit={updatePassword}>
|
||||
<Form onSubmit={updatePassword}>
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Update Password</Heading>
|
||||
<Heading tag="h6" size="7">Password</Heading>
|
||||
<p class="text">
|
||||
Forgot your password? <a class="link" href={`${base}/recover`}
|
||||
>Recover your password</a>
|
||||
@@ -144,14 +136,12 @@
|
||||
id="oldPassword"
|
||||
label="Old password"
|
||||
placeholder="Enter password"
|
||||
autocomplete={false}
|
||||
showPasswordButton={true}
|
||||
bind:value={oldPassword} />
|
||||
<InputPassword
|
||||
id="newPassword"
|
||||
label="New password"
|
||||
placeholder="Enter password"
|
||||
autocomplete={false}
|
||||
showPasswordButton={true}
|
||||
bind:value={newPassword} />
|
||||
</FormList>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Query } from '@aw-labs/appwrite-console';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { pageToOffset } from '$lib/helpers/load';
|
||||
import { PAGE_LIMIT } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
@@ -10,6 +10,6 @@ export const load: PageLoad = async ({ params }) => {
|
||||
|
||||
return {
|
||||
offset,
|
||||
logs: await sdkForConsole.account.listLogs([Query.offset(offset), Query.limit(PAGE_LIMIT)])
|
||||
logs: await sdk.forConsole.account.listLogs([Query.offset(offset), Query.limit(PAGE_LIMIT)])
|
||||
};
|
||||
};
|
||||
@@ -5,13 +5,13 @@
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
|
||||
export let showDelete = false;
|
||||
|
||||
const deleteAccount = async () => {
|
||||
try {
|
||||
await sdkForConsole.account.updateStatus();
|
||||
await sdk.forConsole.account.updateStatus();
|
||||
showDelete = false;
|
||||
invalidate(Dependencies.ACCOUNT);
|
||||
addNotification({
|
||||
@@ -29,7 +29,7 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} on:submit={deleteAccount} warning>
|
||||
<Modal bind:show={showDelete} onSubmit={deleteAccount} warning>
|
||||
<svelte:fragment slot="header">Delete Account</svelte:fragment>
|
||||
<p>Are you sure you want to delete your account?</p>
|
||||
<svelte:fragment slot="footer">
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { isTabSelected } from '$lib/helpers/load';
|
||||
import { Cover, CoverTitle } from '$lib/layout';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { user } from '$lib/stores/user';
|
||||
|
||||
const path = `/console/account`;
|
||||
@@ -38,7 +38,7 @@
|
||||
];
|
||||
|
||||
async function logout() {
|
||||
await sdkForConsole.account.deleteSession('current');
|
||||
await sdk.forConsole.account.deleteSession('current');
|
||||
trackEvent(Submit.AccountLogout);
|
||||
await goto(`${base}/login`);
|
||||
}
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Container } from '$lib/layout';
|
||||
import CreateOrganization from '../../../createOrganization.svelte';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { CARD_LIMIT } from '$lib/constants';
|
||||
import type { PageData } from './$types';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
const getMemberships = async (teamId: string) => {
|
||||
const memberships = await sdkForConsole.teams.listMemberships(teamId);
|
||||
const memberships = await sdk.forConsole.teams.listMemberships(teamId);
|
||||
return memberships.memberships.map((team) => team.userName);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Query } from '@aw-labs/appwrite-console';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { pageToOffset } from '$lib/helpers/load';
|
||||
import { CARD_LIMIT } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
@@ -10,7 +10,7 @@ export const load: PageLoad = async ({ params }) => {
|
||||
|
||||
return {
|
||||
offset,
|
||||
organizations: await sdkForConsole.teams.list([
|
||||
organizations: await sdk.forConsole.teams.list([
|
||||
Query.offset(offset),
|
||||
Query.limit(CARD_LIMIT),
|
||||
Query.orderDesc('$createdAt')
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
TableScroll
|
||||
} from '$lib/elements/table';
|
||||
import { Container } from '$lib/layout';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { goto, invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
@@ -23,11 +23,11 @@
|
||||
export let data: PageData;
|
||||
|
||||
const getBrowser = (clientCode: string) => {
|
||||
return sdkForConsole.avatars.getBrowser(clientCode, 40, 40);
|
||||
return sdk.forConsole.avatars.getBrowser(clientCode, 40, 40);
|
||||
};
|
||||
|
||||
const logout = async (session: Models.Session) => {
|
||||
await sdkForConsole.account.deleteSession(session.$id);
|
||||
await sdk.forConsole.account.deleteSession(session.$id);
|
||||
trackEvent(Submit.AccountDeleteSession);
|
||||
if (session.current) {
|
||||
await goto(`${base}/login`);
|
||||
@@ -35,7 +35,7 @@
|
||||
invalidate(Dependencies.ACCOUNT_SESSIONS);
|
||||
};
|
||||
const logoutAll = async () => {
|
||||
await sdkForConsole.account.deleteSessions();
|
||||
await sdk.forConsole.account.deleteSessions();
|
||||
trackEvent(Submit.AccountDeleteAllSessions);
|
||||
await goto(`${base}/login`);
|
||||
invalidate(Dependencies.ACCOUNT_SESSIONS);
|
||||
@@ -115,7 +115,7 @@
|
||||
<Button
|
||||
external
|
||||
secondary
|
||||
href="https://appwrite.io/docs/server/auth?sdk=nodejs-default#usersGetsessions">
|
||||
href="https://appwrite.io/docs/client/account#accountCreateEmailSession">
|
||||
Documentation
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ depends }) => {
|
||||
depends(Dependencies.ACCOUNT_SESSIONS);
|
||||
|
||||
return {
|
||||
sessions: await sdkForConsole.account.listSessions()
|
||||
sessions: await sdk.forConsole.account.listSessions()
|
||||
};
|
||||
};
|
||||
@@ -3,7 +3,7 @@
|
||||
import { Pill } from '$lib/elements';
|
||||
import { InputText, Button, FormList } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { goto, invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
const create = async () => {
|
||||
try {
|
||||
const org = await sdkForConsole.teams.create(id ?? ID.unique(), name);
|
||||
const org = await sdk.forConsole.teams.create(id ?? ID.unique(), name);
|
||||
await invalidate(Dependencies.ACCOUNT);
|
||||
dispatch('created');
|
||||
await goto(`/console/organization-${org.$id}`);
|
||||
@@ -42,7 +42,7 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal {error} on:submit={create} size="big" bind:show>
|
||||
<Modal {error} onSubmit={create} size="big" bind:show>
|
||||
<svelte:fragment slot="header">Create New Organization</svelte:fragment>
|
||||
<FormList>
|
||||
<InputText
|
||||
|
||||
@@ -9,19 +9,17 @@
|
||||
import FormList from '$lib/elements/forms/formList.svelte';
|
||||
import { Container } from '$lib/layout';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { ID } from '@aw-labs/appwrite-console';
|
||||
|
||||
let name: string;
|
||||
let id: string;
|
||||
let showCustomId = false;
|
||||
let loading = false;
|
||||
|
||||
async function createProject() {
|
||||
try {
|
||||
loading = true;
|
||||
const org = await createOrganization();
|
||||
const project = await sdkForConsole.projects.create(
|
||||
const project = await sdk.forConsole.projects.create(
|
||||
id ?? ID.unique(),
|
||||
name,
|
||||
org.$id,
|
||||
@@ -34,7 +32,6 @@
|
||||
teamId: org.$id
|
||||
});
|
||||
} catch (error) {
|
||||
loading = false;
|
||||
addNotification({
|
||||
message: error.message,
|
||||
type: 'error'
|
||||
@@ -44,20 +41,19 @@
|
||||
}
|
||||
|
||||
async function createOrganization() {
|
||||
return await sdkForConsole.teams.create(ID.unique(), 'Personal Projects');
|
||||
return await sdk.forConsole.teams.create(ID.unique(), 'Personal Projects');
|
||||
}
|
||||
</script>
|
||||
|
||||
<Container overlapCover size="large">
|
||||
<Card>
|
||||
<Form on:submit={createProject}>
|
||||
<Form onSubmit={createProject}>
|
||||
<FormList>
|
||||
<InputText
|
||||
id="name"
|
||||
label="Project name"
|
||||
placeholder="First Appwrite Project"
|
||||
required
|
||||
disabled={loading}
|
||||
bind:value={name} />
|
||||
{#if !showCustomId}
|
||||
<div>
|
||||
@@ -70,7 +66,7 @@
|
||||
{:else}
|
||||
<CustomId bind:show={showCustomId} name="Project" bind:id />
|
||||
{/if}
|
||||
<Button fullWidth submit disabled={loading || name === ''} event="create_project">
|
||||
<Button fullWidth submit disabled={name === ''} event="create_project">
|
||||
Create project
|
||||
</Button>
|
||||
</FormList>
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
import Header from './header.svelte';
|
||||
import Breadcrumbs from './breadcrumbs.svelte';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { LayoutLoad } from './$types';
|
||||
import { error } from '@sveltejs/kit';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
|
||||
export const load: LayoutLoad = async ({ params, parent, depends }) => {
|
||||
await parent();
|
||||
export const load: LayoutLoad = async ({ params, depends }) => {
|
||||
depends(Dependencies.ORGANIZATION);
|
||||
|
||||
try {
|
||||
return {
|
||||
header: Header,
|
||||
breadcrumbs: Breadcrumbs,
|
||||
organization: await sdkForConsole.teams.get(params.organization),
|
||||
members: await sdkForConsole.teams.listMemberships(params.organization)
|
||||
organization: await sdk.forConsole.teams.get(params.organization),
|
||||
members: await sdk.forConsole.teams.listMemberships(params.organization)
|
||||
};
|
||||
} catch (e) {
|
||||
localStorage.removeItem('organization');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Query } from '@aw-labs/appwrite-console';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { pageToOffset } from '$lib/helpers/load';
|
||||
import { CARD_LIMIT } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
@@ -10,7 +10,7 @@ export const load: PageLoad = async ({ params }) => {
|
||||
|
||||
return {
|
||||
offset,
|
||||
projects: await sdkForConsole.projects.list([
|
||||
projects: await sdk.forConsole.projects.list([
|
||||
Query.offset(offset),
|
||||
Query.limit(CARD_LIMIT),
|
||||
Query.equal('teamId', params.organization),
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { Modal } from '$lib/components';
|
||||
import { InputText, InputEmail, Button, FormList } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { invalidate } from '$app/navigation';
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
const create = async () => {
|
||||
try {
|
||||
const team = await sdkForConsole.teams.createMembership(
|
||||
const team = await sdk.forConsole.teams.createMembership(
|
||||
$organization.$id,
|
||||
email,
|
||||
['owner'],
|
||||
@@ -47,7 +47,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal {error} size="big" bind:show={showCreate} on:submit={create}>
|
||||
<Modal {error} size="big" bind:show={showCreate} onSubmit={create}>
|
||||
<svelte:fragment slot="header">Invite Member</svelte:fragment>
|
||||
<FormList>
|
||||
<InputEmail
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { Pill } from '$lib/elements';
|
||||
import { InputText, Button, FormList } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { ID } from '@aw-labs/appwrite-console';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
@@ -18,12 +18,10 @@
|
||||
let name: string;
|
||||
let showCustomId = false;
|
||||
let error: string;
|
||||
let isCreating = false;
|
||||
|
||||
async function create() {
|
||||
try {
|
||||
isCreating = true;
|
||||
const project = await sdkForConsole.projects.create(
|
||||
const project = await sdk.forConsole.projects.create(
|
||||
id ?? ID.unique(),
|
||||
name,
|
||||
teamId,
|
||||
@@ -40,23 +38,16 @@
|
||||
});
|
||||
await goto(`/console/project-${project.$id}`);
|
||||
} catch (e) {
|
||||
isCreating = false;
|
||||
error = e.message;
|
||||
trackError(e, Submit.ProjectCreate);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal {error} on:submit={create} size="big" bind:show>
|
||||
<Modal {error} onSubmit={create} size="big" bind:show>
|
||||
<svelte:fragment slot="header">Create Project</svelte:fragment>
|
||||
<FormList>
|
||||
<InputText
|
||||
id="name"
|
||||
label="Name"
|
||||
bind:value={name}
|
||||
required
|
||||
autofocus={true}
|
||||
disabled={isCreating} />
|
||||
<InputText id="name" label="Name" bind:value={name} required autofocus={true} />
|
||||
{#if !showCustomId}
|
||||
<div>
|
||||
<Pill button on:click={() => (showCustomId = !showCustomId)}>
|
||||
@@ -71,6 +62,6 @@
|
||||
</FormList>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button secondary on:click={() => (show = false)}>Cancel</Button>
|
||||
<Button submit disabled={isCreating}>Create</Button>
|
||||
<Button submit>Create</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -4,7 +4,7 @@
|
||||
import { Modal } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { user } from '$lib/stores/user';
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
const deleteMembership = async () => {
|
||||
try {
|
||||
await sdkForConsole.teams.deleteMembership(selectedMember.teamId, selectedMember.$id);
|
||||
await sdk.forConsole.teams.deleteMembership(selectedMember.teamId, selectedMember.$id);
|
||||
|
||||
if (isUser) {
|
||||
await sdkForConsole.account.deleteSession('current');
|
||||
await sdk.forConsole.account.deleteSession('current');
|
||||
await goto(`${base}/login`);
|
||||
} else {
|
||||
dispatch('deleted');
|
||||
@@ -43,11 +43,11 @@
|
||||
$: isUser = selectedMember?.userId === $user?.$id;
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} on:submit={deleteMembership} warning>
|
||||
<Modal bind:show={showDelete} onSubmit={deleteMembership} warning>
|
||||
<svelte:fragment slot="header">
|
||||
{isUser ? 'Leave Organization' : 'Delete Member'}
|
||||
</svelte:fragment>
|
||||
<p>
|
||||
<p data-private>
|
||||
{isUser
|
||||
? `Are you sure you want to leave '${selectedMember?.teamName}'?`
|
||||
: `Are you sure you want to delete ${selectedMember?.userName} from '${selectedMember?.teamName}'?`}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { Modal } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { organization, organizationList } from '$lib/stores/organization';
|
||||
import { goto, invalidate } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
const deleteOrg = async () => {
|
||||
try {
|
||||
await sdkForConsole.teams.delete($organization.$id);
|
||||
await sdk.forConsole.teams.delete($organization.$id);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${$organization.name} has been deleted`
|
||||
@@ -37,7 +37,7 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal on:submit={deleteOrg} bind:show={showDelete} warning>
|
||||
<Modal onSubmit={deleteOrg} bind:show={showDelete} warning>
|
||||
<svelte:fragment slot="header">Delete Organization</svelte:fragment>
|
||||
<p>
|
||||
Are you sure you want to delete <b>{$organization.name}</b>? All projects ({$organization.total})
|
||||
|
||||
@@ -72,7 +72,9 @@
|
||||
</DropList>
|
||||
<div class="u-margin-inline-start-auto">
|
||||
<div class="u-flex u-gap-16">
|
||||
<AvatarGroup size={40} {avatars} total={$members?.total ?? 0} />
|
||||
<a href={`${path}/members`}>
|
||||
<AvatarGroup size={40} {avatars} total={$members?.total ?? 0} />
|
||||
</a>
|
||||
<Button secondary on:click={() => newMemberModal.set(true)}>
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Invite</span>
|
||||
|
||||
@@ -1,38 +1,37 @@
|
||||
<script lang="ts">
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import { AvatarInitials, Heading, Pagination } from '$lib/components';
|
||||
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
TableHeader,
|
||||
TableBody,
|
||||
TableCellHead,
|
||||
TableCell,
|
||||
TableCellHead,
|
||||
TableCellText,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
TableScroll
|
||||
} from '$lib/elements/table';
|
||||
import { AvatarInitials, Heading, Pagination } from '$lib/components';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Container } from '$lib/layout';
|
||||
import { organization, members, newMemberModal } from '$lib/stores/organization';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { page } from '$app/stores';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
|
||||
import Delete from '../../deleteMember.svelte';
|
||||
import { members, newMemberModal, organization } from '$lib/stores/organization';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
import type { PageData } from './$types';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import Delete from '../../deleteMember.svelte';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
let selectedMember: Models.Membership;
|
||||
let showDelete = false;
|
||||
|
||||
const url = `${$page.url.origin}/console/`;
|
||||
const deleted = () => invalidate(Dependencies.ACCOUNT);
|
||||
const resend = async (member: Models.Membership) => {
|
||||
try {
|
||||
await sdkForConsole.teams.createMembership(
|
||||
await sdk.forConsole.teams.createMembership(
|
||||
$organization.$id,
|
||||
member.userEmail,
|
||||
member.roles,
|
||||
@@ -69,7 +68,7 @@
|
||||
<TableHeader>
|
||||
<TableCellHead width={140}>Name</TableCellHead>
|
||||
<TableCellHead width={120}>Email</TableCellHead>
|
||||
<TableCellHead width={90}>Role</TableCellHead>
|
||||
<TableCellHead width={90} />
|
||||
<TableCellHead width={30} />
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
@@ -87,17 +86,14 @@
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCellText title="Email">{member.userEmail}</TableCellText>
|
||||
<TableCell title="Roles">
|
||||
<TableCell>
|
||||
{#if member.invited && !member.joined}
|
||||
<Button
|
||||
secondary
|
||||
event="invite_resend"
|
||||
on:click={() => resend(member)}>Resend</Button>
|
||||
{:else}
|
||||
{member.roles}
|
||||
{/if}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<button
|
||||
class="button is-only-icon is-text"
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import { PAGE_LIMIT } from '$lib/constants';
|
||||
import { pageToOffset } from '$lib/helpers/load';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Query } from '@aw-labs/appwrite-console';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ params, parent }) => {
|
||||
await parent();
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
const page = Number(params.page);
|
||||
const offset = pageToOffset(page, PAGE_LIMIT);
|
||||
|
||||
return {
|
||||
offset,
|
||||
organizationMembers: await sdkForConsole.teams.listMemberships(params.organization, [
|
||||
organizationMembers: await sdk.forConsole.teams.listMemberships(params.organization, [
|
||||
Query.limit(PAGE_LIMIT),
|
||||
Query.offset(offset)
|
||||
])
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { InputText, Form, Button } from '$lib/elements/forms';
|
||||
import { Container } from '$lib/layout';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { members, organization } from '$lib/stores/organization';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
async function updateName() {
|
||||
try {
|
||||
await sdkForConsole.teams.update($organization.$id, name);
|
||||
await sdk.forConsole.teams.update($organization.$id, name);
|
||||
await invalidate(Dependencies.ORGANIZATION);
|
||||
addNotification({
|
||||
message: 'Name has been updated',
|
||||
@@ -41,9 +41,9 @@
|
||||
|
||||
<Container>
|
||||
{#if $organization}
|
||||
<Form on:submit={updateName}>
|
||||
<Form onSubmit={updateName}>
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Update Name</Heading>
|
||||
<Heading tag="h6" size="7">Name</Heading>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
<ul>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<script lang="ts">
|
||||
import { UploadBox } from '$lib/components';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
import { stats } from './store';
|
||||
|
||||
let unsubscribe: { (): void };
|
||||
|
||||
onMount(() => {
|
||||
unsubscribe = sdkForConsole.client.subscribe(['project', 'console'], (response) => {
|
||||
unsubscribe = sdk.forConsole.client.subscribe(['project', 'console'], (response) => {
|
||||
if (response.events.includes('stats.connections')) {
|
||||
for (const [projectId, value] of Object.entries(response.payload)) {
|
||||
stats.add(projectId, [new Date(response.timestamp).toISOString(), value]);
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { sdkForConsole, sdkForProject, setProject } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { LayoutLoad } from './$types';
|
||||
|
||||
export const load: LayoutLoad = async ({ params, depends }) => {
|
||||
depends(Dependencies.PROJECT);
|
||||
|
||||
if (sdkForProject.client.config.project !== params.project) {
|
||||
setProject(params.project);
|
||||
}
|
||||
|
||||
try {
|
||||
const project = await sdkForConsole.projects.get(params.project);
|
||||
const project = await sdk.forConsole.projects.get(params.project);
|
||||
localStorage.setItem('project', project.$id);
|
||||
localStorage.setItem('organization', project.teamId);
|
||||
|
||||
return {
|
||||
project,
|
||||
organization: await sdkForConsole.teams.get(project.teamId)
|
||||
organization: await sdk.forConsole.teams.get(project.teamId)
|
||||
};
|
||||
} catch (e) {
|
||||
throw error(e.code, e.message);
|
||||
|
||||
@@ -2,9 +2,7 @@ import Breadcrumbs from './breadcrumbs.svelte';
|
||||
import Header from './header.svelte';
|
||||
import type { LayoutLoad } from './$types';
|
||||
|
||||
export const load: LayoutLoad = async ({ parent }) => {
|
||||
await parent();
|
||||
|
||||
export const load: LayoutLoad = async () => {
|
||||
return {
|
||||
header: Header,
|
||||
breadcrumbs: Breadcrumbs
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { Query } from '@aw-labs/appwrite-console';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { pageToOffset } from '$lib/helpers/load';
|
||||
import { PAGE_LIMIT } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ params, parent, url }) => {
|
||||
await parent();
|
||||
export const load: PageLoad = async ({ params, url }) => {
|
||||
const page = Number(params.page);
|
||||
const offset = pageToOffset(page, PAGE_LIMIT);
|
||||
const search = url.search.slice(1) ?? undefined;
|
||||
@@ -14,7 +13,7 @@ export const load: PageLoad = async ({ params, parent, url }) => {
|
||||
offset,
|
||||
search,
|
||||
page,
|
||||
users: await sdkForProject.users.list(
|
||||
users: await sdk.forProject.users.list(
|
||||
[Query.limit(PAGE_LIMIT), Query.offset(offset), Query.orderDesc('$createdAt')],
|
||||
search
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { Modal, CopyInput, Alert } from '$lib/components';
|
||||
import { Button, InputText, InputTextarea, InputSwitch, FormList } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { Provider } from '$lib/stores/oauth-providers';
|
||||
import { onMount } from 'svelte';
|
||||
import { invalidate } from '$app/navigation';
|
||||
@@ -29,7 +29,7 @@
|
||||
const projectId = $page.params.project;
|
||||
const update = async () => {
|
||||
try {
|
||||
await sdkForConsole.projects.updateOAuth2(
|
||||
await sdk.forConsole.projects.updateOAuth2(
|
||||
projectId,
|
||||
provider.name.toLowerCase(),
|
||||
appId,
|
||||
@@ -57,7 +57,7 @@
|
||||
$: secret = keyID && teamID && p8 ? JSON.stringify({ keyID, teamID, p8 }) : provider.secret;
|
||||
</script>
|
||||
|
||||
<Modal {error} on:submit={update} size="big" show on:close>
|
||||
<Modal {error} onSubmit={update} size="big" show on:close>
|
||||
<svelte:fragment slot="header">{provider.name} OAuth2 Settings</svelte:fragment>
|
||||
<FormList>
|
||||
<p>
|
||||
@@ -84,7 +84,7 @@
|
||||
<p>URI</p>
|
||||
<CopyInput
|
||||
value={`${
|
||||
sdkForConsole.client.config.endpoint
|
||||
sdk.forConsole.client.config.endpoint
|
||||
}/account/sessions/oauth2/callback/${provider.name.toLocaleLowerCase()}/${projectId}`} />
|
||||
</div>
|
||||
</FormList>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { page } from '$app/stores';
|
||||
import { Modal, CopyInput, Alert } from '$lib/components';
|
||||
import { Button, InputPassword, InputText, InputSwitch, FormList } from '$lib/elements/forms';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { Provider } from '$lib/stores/oauth-providers';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { onMount } from 'svelte';
|
||||
@@ -27,7 +27,7 @@
|
||||
const projectId = $page.params.project;
|
||||
const update = async () => {
|
||||
try {
|
||||
await sdkForConsole.projects.updateOAuth2(
|
||||
await sdk.forConsole.projects.updateOAuth2(
|
||||
projectId,
|
||||
provider.name.toLowerCase(),
|
||||
appId,
|
||||
@@ -58,7 +58,7 @@
|
||||
: provider.secret;
|
||||
</script>
|
||||
|
||||
<Modal {error} size="big" show on:submit={update} on:close>
|
||||
<Modal {error} size="big" show onSubmit={update} on:close>
|
||||
<svelte:fragment slot="header">{provider.name} OAuth2 Settings</svelte:fragment>
|
||||
<FormList>
|
||||
<p>
|
||||
@@ -93,7 +93,7 @@
|
||||
<p>URI</p>
|
||||
<CopyInput
|
||||
value={`${
|
||||
sdkForConsole.client.config.endpoint
|
||||
sdk.forConsole.client.config.endpoint
|
||||
}/account/sessions/oauth2/callback/${provider.name.toLocaleLowerCase()}/${projectId}`} />
|
||||
</div>
|
||||
</FormList>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { page } from '$app/stores';
|
||||
import { Modal, CopyInput, Alert } from '$lib/components';
|
||||
import { Button, InputPassword, InputText, InputSwitch, FormList } from '$lib/elements/forms';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { Provider } from '$lib/stores/oauth-providers';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { onMount } from 'svelte';
|
||||
@@ -27,7 +27,7 @@
|
||||
const projectId = $page.params.project;
|
||||
const update = async () => {
|
||||
try {
|
||||
await sdkForConsole.projects.updateOAuth2(
|
||||
await sdk.forConsole.projects.updateOAuth2(
|
||||
projectId,
|
||||
provider.name.toLowerCase(),
|
||||
appId,
|
||||
@@ -58,7 +58,7 @@
|
||||
: provider.secret;
|
||||
</script>
|
||||
|
||||
<Modal {error} size="big" show on:submit={update} on:close>
|
||||
<Modal {error} size="big" show onSubmit={update} on:close>
|
||||
<svelte:fragment slot="header">{provider.name} OAuth2 Settings</svelte:fragment>
|
||||
<FormList>
|
||||
<p>
|
||||
@@ -93,7 +93,7 @@
|
||||
<p>URI</p>
|
||||
<CopyInput
|
||||
value={`${
|
||||
sdkForConsole.client.config.endpoint
|
||||
sdk.forConsole.client.config.endpoint
|
||||
}/account/sessions/oauth2/callback/${provider.name.toLocaleLowerCase()}/${projectId}`} />
|
||||
</div>
|
||||
</FormList>
|
||||
|
||||
Loaded 100 of 284 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user