-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,369 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
<script lang="ts"> | ||
import { Card, Empty, Layout } from '@appwrite.io/pink-svelte'; | ||
import { Button } from '$lib/elements/forms'; | ||
import { EmptySearch } from '.'; | ||
import { queries } from './filters'; | ||
export let resource: string; | ||
</script> | ||
|
||
<EmptySearch hidePages> | ||
<div class="common-section"> | ||
<div class="u-text-center common-section"> | ||
<b class="body-text-2 u-bold">Sorry, we couldn't find any {resource}.</b> | ||
<p>There are no {resource} that match your filters.</p> | ||
</div> | ||
<div class="u-flex common-section u-main-center"> | ||
<Button | ||
secondary | ||
on:click={() => { | ||
queries.clearAll(); | ||
queries.apply(); | ||
}}> | ||
Clear filters | ||
</Button> | ||
</div> | ||
</div> | ||
</EmptySearch> | ||
<Card.Base padding="none"> | ||
<Empty | ||
title={`Sorry, we couldn't find any ${resource}`} | ||
description={`There are no ${resource} that match your filters.`} | ||
type="secondary"> | ||
<svelte:fragment slot="actions"> | ||
<Layout.Stack direction="row" justifyContent="center"> | ||
<Button | ||
secondary | ||
on:click={() => { | ||
queries.clearAll(); | ||
queries.apply(); | ||
}}> | ||
Clear filters | ||
</Button> | ||
<slot /> | ||
</Layout.Stack> | ||
</svelte:fragment> | ||
</Empty> | ||
</Card.Base> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 153 additions & 0 deletions
153
src/routes/(console)/project-[project]/sites/site-[site]/deployments/+layout.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
<script lang="ts"> | ||
import { onMount } from 'svelte'; | ||
import { page } from '$app/stores'; | ||
import { sdk } from '$lib/stores/sdk'; | ||
import { Dependencies } from '$lib/constants'; | ||
import { invalidate, goto } from '$app/navigation'; | ||
import { registerCommands } from '$lib/commandCenter'; | ||
import { project } from '../../../store'; | ||
import type { Models } from '@appwrite.io/console'; | ||
import { base } from '$app/paths'; | ||
import { canWriteSites } from '$lib/stores/roles'; | ||
onMount(() => { | ||
let previousStatus = null; | ||
return sdk.forConsole.client.subscribe<Models.Deployment>('console', (message) => { | ||
if (previousStatus === message.payload.status) { | ||
return; | ||
} | ||
previousStatus = message.payload.status; | ||
if (message.events.includes('sites.*.deployments.*.create')) { | ||
invalidate(Dependencies.DEPLOYMENTS); | ||
return; | ||
} | ||
if (message.events.includes('sites.*.deployments.*.update')) { | ||
invalidate(Dependencies.DEPLOYMENTS); | ||
invalidate(Dependencies.FUNCTION); | ||
return; | ||
} | ||
if (message.events.includes('sites.*.deployments.*.delete')) { | ||
invalidate(Dependencies.DEPLOYMENTS); | ||
return; | ||
} | ||
}); | ||
}); | ||
$: $registerCommands([ | ||
{ | ||
label: 'Create deployment', | ||
async callback() { | ||
if (!$page.url.pathname.endsWith($page.params.site)) { | ||
await goto(`${base}/project-${$project.$id}/sites/site-${$page.params.site}`); | ||
} | ||
}, | ||
keys: $page.url.pathname.endsWith($page.params.site) ? ['c'] : ['c', 'd'], | ||
group: 'functions', | ||
icon: 'plus', | ||
disabled: !$canWriteSites | ||
}, | ||
{ | ||
label: 'Permissions', | ||
async callback() { | ||
await goto( | ||
`${base}/project-${$project.$id}/sites/site-${$page.params.site}/settings#permissions` | ||
); | ||
scrollBy({ top: -100 }); | ||
}, | ||
icon: 'search', | ||
group: 'functions', | ||
disabled: !$canWriteSites | ||
}, | ||
{ | ||
label: 'Events', | ||
async callback() { | ||
await goto( | ||
`${base}/project-${$project.$id}/sites/site-${$page.params.site}/settings#events` | ||
); | ||
scrollBy({ top: -100 }); | ||
}, | ||
icon: 'calendar', | ||
group: 'functions', | ||
disabled: !$canWriteSites | ||
}, | ||
{ | ||
label: 'Variables', | ||
async callback() { | ||
await goto( | ||
`${base}/project-${$project.$id}/sites/site-${$page.params.site}/settings#variables` | ||
); | ||
}, | ||
icon: 'list', | ||
group: 'functions', | ||
disabled: !$canWriteSites | ||
}, | ||
{ | ||
label: 'Timeout', | ||
callback() { | ||
goto( | ||
`${base}/project-${$project.$id}/sites/site-${$page.params.site}/settings#timeout` | ||
); | ||
}, | ||
icon: 'x-circle', | ||
group: 'functions', | ||
disabled: !$canWriteSites | ||
}, | ||
{ | ||
label: 'Schedule', | ||
async callback() { | ||
await goto( | ||
`${base}/project-${$project.$id}/sites/site-${$page.params.site}/settings#schedule` | ||
); | ||
scrollBy({ top: -100 }); | ||
}, | ||
icon: 'clock', | ||
group: 'functions', | ||
disabled: !$canWriteSites | ||
}, | ||
{ | ||
label: 'Go to deployments', | ||
callback() { | ||
goto(`${base}/project-${$project.$id}/sites/site-${$page.params.site}`); | ||
}, | ||
keys: ['g', 'd'], | ||
group: 'navigation', | ||
rank: 10, | ||
disabled: $page.url.pathname.endsWith($page.params.site) | ||
}, | ||
{ | ||
label: 'Go to usage', | ||
callback() { | ||
goto(`${base}/project-${$project.$id}/sites/site-${$page.params.site}/usage`); | ||
}, | ||
keys: ['g', 'u'], | ||
group: 'navigation', | ||
rank: 10, | ||
disabled: $page.url.pathname.endsWith('usage') | ||
}, | ||
{ | ||
label: 'Go to executions', | ||
callback() { | ||
goto(`${base}/project-${$project.$id}/sites/site-${$page.params.site}/executions`); | ||
}, | ||
keys: ['g', 'e'], | ||
group: 'navigation', | ||
rank: 10, | ||
disabled: $page.url.pathname.endsWith('executions') | ||
}, | ||
{ | ||
label: 'Go to settings', | ||
callback() { | ||
goto(`${base}/project-${$project.$id}/sites/site-${$page.params.site}/settings`); | ||
}, | ||
keys: ['g', 's'], | ||
group: 'navigation', | ||
rank: 10, | ||
disabled: $page.url.pathname.endsWith('settings') || !$canWriteSites | ||
} | ||
]); | ||
</script> | ||
|
||
<slot /> |
28 changes: 28 additions & 0 deletions
28
src/routes/(console)/project-[project]/sites/site-[site]/deployments/+layout.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { sdk } from '$lib/stores/sdk'; | ||
import { Dependencies } from '$lib/constants'; | ||
import type { LayoutLoad } from './$types'; | ||
import { error } from '@sveltejs/kit'; | ||
import { Query } from '@appwrite.io/console'; | ||
|
||
export const load: LayoutLoad = async ({ params, depends }) => { | ||
depends(Dependencies.SITE); | ||
depends(Dependencies.DEPLOYMENTS); | ||
|
||
try { | ||
const [site, proxyRuleList] = await Promise.all([ | ||
sdk.forProject.sites.get(params.site), | ||
sdk.forProject.proxy.listRules([ | ||
Query.equal('resourceType', 'sites'), | ||
Query.equal('resourceId', params.site), | ||
Query.limit(1) | ||
]) | ||
]); | ||
|
||
return { | ||
site, | ||
proxyRuleList | ||
}; | ||
} catch (e) { | ||
error(e.code, e.message); | ||
} | ||
}; |
Oops, something went wrong.