feat: alyout lifecycle

This commit is contained in:
Torsten Dittmann committed 2022-07-01 17:03:58 +02:00
1 parent 9c22c68d35
commit d2b186ec5c
17 files changed
+372 -302

No files matched your search

-1
View File
@@ -112,7 +112,6 @@
}
};
const handleResize = () => {
console.log('test');
if (timeoutId == undefined) {
timeoutId = setTimeout(() => {
if (myChart && !myChart.isDisposed()) {
@@ -1,14 +1,21 @@
<script>
import { afterNavigate } from '$app/navigation';
import { tabs, title, backButton, copyData } from '$lib/stores/layout';
import { onMount } from 'svelte';
title.set('Databases');
backButton.set('');
tabs.set([]);
onMount(handle);
afterNavigate(handle);
copyData.set({
text: '',
value: ''
});
function handle() {
title.set('Databases');
backButton.set('');
tabs.set([]);
copyData.set({
text: '',
value: ''
});
}
</script>
<svelte:head>
@@ -1,41 +1,45 @@
<script>
import { browser } from '$app/env';
import { afterNavigate } from '$app/navigation';
import { page } from '$app/stores';
import { tabs, title, backButton, copyData } from '$lib/stores/layout';
import { setDatabase } from '$lib/stores/sdk';
import { sdkForProject, setDatabase } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import { database } from './store';
const databaseId = $page.params.database;
const path = `databases/database/${databaseId}`;
backButton.set('');
onMount(handle);
afterNavigate(handle);
copyData.set({
text: '',
value: ''
});
tabs.set([
{
href: path,
title: 'Collections'
},
{
href: `${path}/usage`,
title: 'Usage'
}
]);
$: {
if (browser) {
async function handle() {
if ($database?.$id !== databaseId) {
setDatabase($page.params.database);
database.load();
await database.load();
title.set(`Database - ${$database.name}`);
} else if ($database) {
title.set(`Database - ${$database.name}`);
}
}
$: if ($database) {
title.set(`Database - ${$database.name}`);
backButton.set('');
copyData.set({
text: '',
value: ''
});
tabs.set([
{
href: path,
title: 'Collections'
},
{
href: `${path}/usage`,
title: 'Usage'
}
]);
}
</script>
@@ -43,4 +47,6 @@
<title>Appwrite - Database</title>
</svelte:head>
<slot />
{#if $database}
<slot />
{/if}
@@ -1,8 +1,9 @@
<script lang="ts">
import { browser } from '$app/env';
import { afterNavigate } from '$app/navigation';
import { base } from '$app/paths';
import { page } from '$app/stores';
import { tabs, title, backButton, copyData } from '$lib/stores/layout';
import { onMount } from 'svelte';
import { collection } from './store';
const databaseId = $page.params.database;
@@ -10,43 +11,43 @@
const path = `databases/database/${databaseId}/collection/${collectionId}`;
$: {
if (browser) {
collection.load(collectionId);
}
}
onMount(handle);
afterNavigate(handle);
$: {
if ($collection) {
async function handle() {
if ($collection?.$id !== collectionId) {
await collection.load(collectionId);
title.set($collection.name);
} else if ($collection) {
title.set($collection.name);
}
backButton.set(`${base}/console/${$page.params.project}/database`);
copyData.set({
text: '',
value: ''
});
tabs.set([
{
href: path,
title: 'Documents'
},
{
href: `${path}/attributes`,
title: 'Attributes'
},
{
href: `${path}/indexes`,
title: 'Indexes'
},
{
href: `${path}/settings`,
title: 'Settings'
}
]);
}
backButton.set(`${base}/console/${$page.params.project}/database`);
copyData.set({
text: '',
value: ''
});
tabs.set([
{
href: path,
title: 'Documents'
},
{
href: `${path}/attributes`,
title: 'Attributes'
},
{
href: `${path}/indexes`,
title: 'Indexes'
},
{
href: `${path}/settings`,
title: 'Settings'
}
]);
</script>
<svelte:head>
@@ -1,42 +1,44 @@
<script lang="ts">
import { page } from '$app/stores';
import { browser } from '$app/env';
import { tabs, title, backButton, copyData } from '$lib/stores/layout';
import { doc } from './store';
import { onMount } from 'svelte';
import { afterNavigate } from '$app/navigation';
const databaseId = $page.params.database;
const collectionId = $page.params.collection;
const documentId = $page.params.document;
const path = `databases/database/${databaseId}/collection/${collectionId}/document/${documentId}`;
$: {
if (browser) {
doc.load(collectionId, documentId);
}
}
onMount(handle);
afterNavigate(handle);
$: {
if ($doc) {
async function handle() {
if ($doc?.$id !== documentId) {
await doc.load(collectionId, documentId);
title.set(`Document - ${$doc.$id}`);
} else if ($doc) {
title.set(`Document - ${$doc.$id}`);
}
backButton.set('');
copyData.set({
text: '',
value: ''
});
tabs.set([
{
href: path,
title: 'Overview'
},
{
href: `${path}/activity`,
title: 'Activity'
}
]);
}
backButton.set('');
copyData.set({
text: '',
value: ''
});
tabs.set([
{
href: path,
title: 'Overview'
},
{
href: `${path}/activity`,
title: 'Activity'
}
]);
</script>
<svelte:head>
@@ -1,14 +1,22 @@
<script>
import { afterNavigate } from '$app/navigation';
import { tabs, title, backButton, copyData } from '$lib/stores/layout';
import { onMount } from 'svelte';
title.set('Functions');
backButton.set('');
tabs.set([]);
onMount(handle);
afterNavigate(handle);
copyData.set({
text: '',
value: ''
});
function handle() {
title.set('Functions');
backButton.set('');
tabs.set([]);
copyData.set({
text: '',
value: ''
});
}
</script>
<svelte:head>
@@ -1,48 +1,51 @@
<script lang="ts">
import { browser } from '$app/env';
import { afterNavigate } from '$app/navigation';
import { page } from '$app/stores';
import { tabs, title, backButton, copyData } from '$lib/stores/layout';
import { onMount } from 'svelte';
import { func } from './store';
const functionId = $page.params.function;
const path = `functions/function/${functionId}`;
$: {
if (browser) {
func.load(functionId);
}
}
onMount(handle);
afterNavigate(handle);
$: {
if ($func) {
async function handle() {
if ($func?.$id !== functionId) {
await func.load(functionId);
title.set($func.name);
} else if ($func) {
title.set($func.name);
}
backButton.set('');
copyData.set({
text: '',
value: ''
});
tabs.set([
{
href: path,
title: 'Overview'
},
{
href: `${path}/monitors`,
title: 'Monitors'
},
{
href: `${path}/logs`,
title: 'Logs'
},
{
href: `${path}/settings`,
title: 'Settings'
}
]);
}
backButton.set('');
copyData.set({
text: '',
value: ''
});
tabs.set([
{
href: path,
title: 'Overview'
},
{
href: `${path}/monitors`,
title: 'Monitors'
},
{
href: `${path}/logs`,
title: 'Logs'
},
{
href: `${path}/settings`,
title: 'Settings'
}
]);
</script>
{#if $func}
@@ -1,14 +1,22 @@
<script>
import { afterNavigate } from '$app/navigation';
import { tabs, title, backButton, copyData } from '$lib/stores/layout';
import { onMount } from 'svelte';
title.set('API Keys');
backButton.set('');
tabs.set([]);
onMount(handle);
afterNavigate(handle);
copyData.set({
text: '',
value: ''
});
function handle() {
title.set('API Keys');
backButton.set('');
tabs.set([]);
copyData.set({
text: '',
value: ''
});
}
</script>
<slot />
@@ -1,32 +1,41 @@
<script>
import { afterNavigate } from '$app/navigation';
import { tabs, title, backButton, copyData } from '$lib/stores/layout';
import { onMount } from 'svelte';
const path = 'settings';
title.set('Settings');
backButton.set('');
copyData.set({
text: '',
value: ''
});
tabs.set([
{
href: path,
title: 'Overview'
},
{
href: `${path}/services`,
title: 'Services'
},
{
href: `${path}/domains`,
title: 'Custom Domains'
},
{
href: `${path}/members`,
title: 'Members'
}
]);
onMount(handle);
afterNavigate(handle);
function handle() {
title.set('Settings');
backButton.set('');
copyData.set({
text: '',
value: ''
});
tabs.set([
{
href: path,
title: 'Overview'
},
{
href: `${path}/services`,
title: 'Services'
},
{
href: `${path}/domains`,
title: 'Custom Domains'
},
{
href: `${path}/members`,
title: 'Members'
}
]);
}
</script>
<svelte:head>
@@ -1,24 +1,33 @@
<script>
import { afterNavigate } from '$app/navigation';
import { tabs, title, backButton, copyData } from '$lib/stores/layout';
import { onMount } from 'svelte';
const path = 'storage';
title.set('Storage');
backButton.set('');
copyData.set({
text: '',
value: ''
});
tabs.set([
{
href: path,
title: 'Buckets'
},
{
href: `${path}/usage`,
title: 'Usage'
}
]);
onMount(handle);
afterNavigate(handle);
async function handle() {
title.set('Storage');
backButton.set('');
copyData.set({
text: '',
value: ''
});
tabs.set([
{
href: path,
title: 'Buckets'
},
{
href: `${path}/usage`,
title: 'Usage'
}
]);
}
</script>
<svelte:head>
@@ -1,44 +1,45 @@
<script lang="ts">
import { browser } from '$app/env';
import { afterNavigate } from '$app/navigation';
import { page } from '$app/stores';
import { tabs, title, backButton, copyData } from '$lib/stores/layout';
import { onMount } from 'svelte';
import { bucket } from './store';
const bucketId = $page.params.bucket;
const path = `storage/bucket/${bucketId}`;
$: {
if (browser) {
bucket.load(bucketId);
}
}
onMount(handle);
afterNavigate(handle);
$: {
if ($bucket) {
async function handle() {
if ($bucket?.$id !== bucketId) {
await bucket.load(bucketId);
title.set($bucket.name);
} else if ($bucket) {
title.set($bucket.name);
}
backButton.set('');
copyData.set({
text: bucketId,
value: bucketId
});
tabs.set([
{
href: path,
title: 'Files'
},
{
href: `${path}/usage`,
title: 'Usage'
},
{
href: `${path}/settings`,
title: 'Settings'
}
]);
}
backButton.set('');
copyData.set({
text: bucketId,
value: bucketId
});
tabs.set([
{
href: path,
title: 'Files'
},
{
href: `${path}/usage`,
title: 'Usage'
},
{
href: `${path}/settings`,
title: 'Settings'
}
]);
</script>
<svelte:head>
@@ -1,36 +1,44 @@
<script lang="ts">
import { afterNavigate } from '$app/navigation';
import { tabs, title, backButton, copyData } from '$lib/stores/layout';
import { onMount } from 'svelte';
const path = 'users';
title.set('Users');
backButton.set('');
onMount(handle);
afterNavigate(handle);
copyData.set({
text: '',
value: ''
});
tabs.set([
{
href: path,
title: 'Users'
},
{
href: `${path}/teams`,
title: 'Teams'
},
{
href: `${path}/authentication`,
title: 'Authentication'
},
{
href: `${path}/usage`,
title: 'Usage'
},
{
href: `${path}/security`,
title: 'Security'
}
]);
function handle() {
title.set('Users');
backButton.set('');
copyData.set({
text: '',
value: ''
});
tabs.set([
{
href: path,
title: 'Users'
},
{
href: `${path}/teams`,
title: 'Teams'
},
{
href: `${path}/authentication`,
title: 'Authentication'
},
{
href: `${path}/usage`,
title: 'Usage'
},
{
href: `${path}/security`,
title: 'Security'
}
]);
}
</script>
<svelte:head>
@@ -18,13 +18,12 @@
const projectId = $page.params.project;
const update = async () => {
try {
const oauth = await sdkForConsole.projects.updateOAuth2(
await sdkForConsole.projects.updateOAuth2(
projectId,
provider.name.toLowerCase(),
provider.id,
provider.secret
);
console.log(oauth);
showModal = false;
} catch (error) {
addNotification({
@@ -4,43 +4,45 @@
import { base } from '$app/paths';
import { tabs, title, backButton, copyData } from '$lib/stores/layout';
import { team } from './store';
import { afterNavigate } from '$app/navigation';
import { onMount } from 'svelte';
const teamId = $page.params.team;
const path = `users/teams/${teamId}`;
$: {
if (browser) {
team.load(teamId);
}
}
onMount(handle);
afterNavigate(handle);
$: {
if ($team.response) {
async function handle() {
if ($team?.response?.$id !== teamId) {
await team.load(teamId);
title.set($team.response.name);
} else if ($team.response) {
title.set($team.response.name);
}
backButton.set(`${base}/console/${$page.params.project}/users/teams`);
copyData.set({
text: 'Team ID',
value: teamId
});
tabs.set([
{
href: path,
title: 'Overview'
},
{
href: `${path}/members`,
title: 'Members'
},
{
href: `${path}/activity`,
title: 'Activity'
}
]);
}
backButton.set(`${base}/console/${$page.params.project}/users/teams`);
copyData.set({
text: 'Team ID',
value: teamId
});
tabs.set([
{
href: path,
title: 'Overview'
},
{
href: `${path}/members`,
title: 'Members'
},
{
href: `${path}/activity`,
title: 'Activity'
}
]);
</script>
<svelte:head>
@@ -1,50 +1,51 @@
<script lang="ts">
import { browser } from '$app/env';
import { afterNavigate } from '$app/navigation';
import { base } from '$app/paths';
import { page } from '$app/stores';
import { tabs, title, backButton, copyData } from '$lib/stores/layout';
import { onMount } from 'svelte';
import { user } from './store';
const userId = $page.params.user;
const path = `users/user/${userId}`;
$: {
if (browser && $user?.response?.$id !== userId) {
user.load(userId);
}
}
onMount(handle);
afterNavigate(handle);
$: {
if ($user.response) {
async function handle() {
if ($user?.response?.$id !== userId) {
await user.load(userId);
title.set($user.response.name);
} else if ($user.response) {
title.set($user.response.name);
}
backButton.set(`${base}/console/${$page.params.project}/users`);
copyData.set({
text: 'User ID',
value: userId
});
tabs.set([
{
href: path,
title: 'Overview'
},
{
href: `${path}/memberships`,
title: 'Memberships'
},
{
href: `${path}/sessions`,
title: 'Sessions'
},
{
href: `${path}/activity`,
title: 'Activity'
}
]);
}
backButton.set(`${base}/console/${$page.params.project}/users`);
copyData.set({
text: 'User ID',
value: userId
});
tabs.set([
{
href: path,
title: 'Overview'
},
{
href: `${path}/memberships`,
title: 'Memberships'
},
{
href: `${path}/sessions`,
title: 'Sessions'
},
{
href: `${path}/activity`,
title: 'Activity'
}
]);
</script>
<svelte:head>
@@ -22,7 +22,6 @@
let selectedSessionId: string = null;
const limit = 5;
console.log('asd');
const request = sdkForProject.users.getSessions($page.params.user);
//TODO: replace session.expire with "last activity"
+9 -1
View File
@@ -11,8 +11,16 @@ const config = {
paths: {
base: ''
},
vite: {
optimizeDeps: {
include: ['echarts']
},
ssr: {
noExternal: ['echarts']
}
},
prerender: {
default: true
default: false
}
}
};