From 4f74f80873440ea9bbf6201a933447872b340bf3 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 12 Jul 2023 12:37:51 +0200 Subject: [PATCH] fix: organize overview --- .../project-[project]/settings/+page.svelte | 443 ++---------------- .../project-[project]/settings/+page.ts | 13 +- .../settings/deleteProject.svelte | 28 +- .../settings/updateInstallations.svelte | 201 ++++++++ .../settings/updateName.svelte | 79 ++++ .../settings/updateServices.svelte | 61 +++ 6 files changed, 421 insertions(+), 404 deletions(-) create mode 100644 src/routes/console/project-[project]/settings/updateInstallations.svelte create mode 100644 src/routes/console/project-[project]/settings/updateName.svelte create mode 100644 src/routes/console/project-[project]/settings/updateServices.svelte diff --git a/src/routes/console/project-[project]/settings/+page.svelte b/src/routes/console/project-[project]/settings/+page.svelte index c46a9f1ca..d93b6d63c 100644 --- a/src/routes/console/project-[project]/settings/+page.svelte +++ b/src/routes/console/project-[project]/settings/+page.svelte @@ -1,437 +1,84 @@ {#if $project} -
- - API Credentials -

Access Appwrite services using your API Endpoint and Project ID.

- - - - - - - - - -
- - Name - - - - - - - - - - - -
- - - Services -

- Choose services you wish to enable or disable for the client API. When disabled, the - services are not accessible to client SDKs but remain accessible to server SDKs. -

- - -
-
    - {#each $services.list as service} - { - serviceUpdate(service); - }} /> - {/each} -
-
-
-
-
- - - Git configuration -

- Add a Git installation to your project. You can connect a repository in your - function settings. -

- - {#if data.installations.total > 0} -
-
-
    -
  • - -
  • -
-
- - - - Installations - - - {#each data.installations.installations as installation, i} - - -
-
-
- -
-
-
-
{installation.organization}
- -
-

- Last configure: {toLocaleDateTime( - installation.$updatedAt - )} -

-
-
- -
- - - - { - showInstallationDropdown[ - i - ] = false; - configureGitHub(); - }}> - Configure {installation.provider} - - { - showInstallationDropdown[ - i - ] = false; - showGitDisconnect = true; - selectedInstallation = - installation; - }}> - Disconnect - - - -
-
-
-
- {/each} -
-
-
-
-

Total installations: {installationsSum}

- -
- {:else} -
-
-
- - - -
-
- -
-
- {/if} -
-
- + + + - - -
- Delete Project -
-

- The project will be permanently deleted, including all the metadata, resources and - stats within it. This action is irreversible. -

- - - -
{$project.name}
-
-

Last update: {toLocaleDateTime($project.$updatedAt)}

-
-
- - - - -
+ {/if}
- - - -{#if showGitIstall} - -{/if} - -{#if showGitDisconnect} - -{/if} - - diff --git a/src/routes/console/project-[project]/settings/+page.ts b/src/routes/console/project-[project]/settings/+page.ts index a0168ccf9..687a3c271 100644 --- a/src/routes/console/project-[project]/settings/+page.ts +++ b/src/routes/console/project-[project]/settings/+page.ts @@ -1,14 +1,21 @@ import { Dependencies } from '$lib/constants'; import { sdk } from '$lib/stores/sdk'; -import type { PageLoad } from './$types'; import { Query } from '@appwrite.io/console'; +import type { PageLoad } from './$types'; -export const load: PageLoad = async ({ depends }) => { +export const load: PageLoad = async ({ depends, url }) => { depends(Dependencies.PROJECT_VARIABLES); depends(Dependencies.PROJECT_INSTALLATIONS); + const limit = 1; + const offset = Number(url.searchParams.get('offset') ?? 0); return { + limit, + offset, variables: await sdk.forProject.projectApi.listVariables(), - installations: await sdk.forProject.vcs.listInstallations([Query.limit(10)]) + installations: await sdk.forProject.vcs.listInstallations([ + Query.limit(limit), + Query.offset(offset) + ]) }; }; diff --git a/src/routes/console/project-[project]/settings/deleteProject.svelte b/src/routes/console/project-[project]/settings/deleteProject.svelte index b33d4941e..6e1af2ee1 100644 --- a/src/routes/console/project-[project]/settings/deleteProject.svelte +++ b/src/routes/console/project-[project]/settings/deleteProject.svelte @@ -2,14 +2,14 @@ import { goto } from '$app/navigation'; import { base } from '$app/paths'; import { Submit, trackEvent, trackError } from '$lib/actions/analytics'; - import { Modal } from '$lib/components'; + import { Box, CardGrid, Heading, Modal } from '$lib/components'; import { Button, FormList, InputPassword, InputText } from '$lib/elements/forms'; + import { toLocaleDateTime } from '$lib/helpers/date'; import { addNotification } from '$lib/stores/notifications'; import { sdk } from '$lib/stores/sdk'; import { project } from '../store'; - export let showDelete = false; - + let showDelete = false; let password: string = null; let name: string = null; @@ -33,6 +33,28 @@ }; + +
+ Delete Project +
+

+ The project will be permanently deleted, including all the metadata, resources and stats + within it. This action is irreversible. +

+ + + +
{$project.name}
+
+

Last update: {toLocaleDateTime($project.$updatedAt)}

+
+
+ + + + +
+ + import { goto } from '$app/navigation'; + import { page } from '$app/stores'; + import { + AvatarGroup, + CardGrid, + DropList, + DropListItem, + Heading, + PaginationInline + } from '$lib/components'; + import { Button } from '$lib/elements/forms'; + import { + Table, + TableBody, + TableCell, + TableCellHead, + TableHeader, + TableRow + } from '$lib/elements/table'; + import { toLocaleDateTime } from '$lib/helpers/date'; + import { sdk } from '$lib/stores/sdk'; + import type { Models } from '@appwrite.io/console'; + import GitInstallationModal from './GitInstallationModal.svelte'; + import GitDisconnectModal from './GitDisconnectModal.svelte'; + + export let total: number; + export let limit: number; + export let offset: number; + export let installations: Models.Installation[]; + + let showGitIstall = false; + let showGitDisconnect = false; + let showInstallationDropdown: boolean[] = []; + let selectedInstallation: Models.Installation; + + function getInstallationLink(installation: Models.Installation) { + switch (installation.provider) { + case 'github': + return `https://github.com/${installation.organization}`; + default: + return ''; + } + } + + function getProviderIcon(provider: string): string { + switch (provider) { + case 'github': + return 'icon-github'; + default: + return ''; + } + } + + function configureGitHub() { + const redirect = new URL($page.url); + redirect.searchParams.set('alert', 'installation-updated'); + sdk.forProject.vcs.createGitHubInstallation(redirect.toString()); + } + + async function navigateInstallations() { + const next = new URL($page.url); + next.searchParams.set('offset', offset.toString()); + await goto(next, { + noScroll: true + }); + } + + + + Git configuration +

+ Add a Git installation to your project. You can connect a repository in your function + settings. +

+ + {#if total > 0} +
+
+
    +
  • + +
  • +
+
+ + + + Installations + + + {#each installations as installation, i} + + +
+
+
+ +
+
+
+
{installation.organization}
+ +
+

+ Last configure: {toLocaleDateTime( + installation.$updatedAt + )} +

+
+
+ +
+ + + + { + showInstallationDropdown[i] = false; + configureGitHub(); + }}> + Configure {installation.provider} + + { + showInstallationDropdown[i] = false; + showGitDisconnect = true; + selectedInstallation = installation; + }}> + Disconnect + + + +
+
+
+
+ {/each} +
+
+
+
+

Total installations: {total}

+ +
+ {:else} +
+
+
+ + + +
+
+ +
+
+ {/if} +
+
+ +{#if showGitIstall} + +{/if} + +{#if showGitDisconnect} + +{/if} diff --git a/src/routes/console/project-[project]/settings/updateName.svelte b/src/routes/console/project-[project]/settings/updateName.svelte new file mode 100644 index 000000000..305d94a66 --- /dev/null +++ b/src/routes/console/project-[project]/settings/updateName.svelte @@ -0,0 +1,79 @@ + + +
+ + API Credentials +

Access Appwrite services using your API Endpoint and Project ID.

+ + + + + + + + + +
+ + Name + + + + + + + + + + + +
diff --git a/src/routes/console/project-[project]/settings/updateServices.svelte b/src/routes/console/project-[project]/settings/updateServices.svelte new file mode 100644 index 000000000..9a1e0acbb --- /dev/null +++ b/src/routes/console/project-[project]/settings/updateServices.svelte @@ -0,0 +1,61 @@ + + + + Services +

+ Choose services you wish to enable or disable for the client API. When disabled, the + services are not accessible to client SDKs but remain accessible to server SDKs. +

+ + +
+
    + {#each $services.list as service} + serviceUpdate(service)} /> + {/each} +
+
+
+
+