mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
Merge branch 'migrations' into migrations-bradley
This commit is contained in:
commit
59ccdf8d5c
4 files changed
+173
-220
No files matched your search
@@ -1,3 +1,8 @@
|
||||
import {
|
||||
PUBLIC_MOCK_APIKEY,
|
||||
PUBLIC_MOCK_ENDPOINT,
|
||||
PUBLIC_MOCK_PROJECTID
|
||||
} from '$env/static/public';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { writable } from 'svelte/store';
|
||||
import Wizard from './wizard.svelte';
|
||||
@@ -21,6 +26,8 @@ type SupabaseInput = {
|
||||
port?: number;
|
||||
username?: string;
|
||||
password?: string;
|
||||
endpoint?: string;
|
||||
apiKey?: string;
|
||||
};
|
||||
|
||||
type NhostInput = {
|
||||
@@ -29,22 +36,20 @@ type NhostInput = {
|
||||
port?: number;
|
||||
username?: string;
|
||||
password?: string;
|
||||
endpoint?: string;
|
||||
apiKey?: string;
|
||||
};
|
||||
|
||||
type ProviderInput = AppwriteInput | NhostInput | SupabaseInput | FirebaseInput;
|
||||
|
||||
const initialProvider: ProviderInput = { provider: '' };
|
||||
const initialProvider: ProviderInput = { provider: 'appwrite' };
|
||||
const mockProvider: ProviderInput = {
|
||||
provider: '',
|
||||
endpoint: '',
|
||||
apiKey: '',
|
||||
projectID: '',
|
||||
host: '',
|
||||
port: '',
|
||||
username: '',
|
||||
password: ''
|
||||
provider: 'appwrite',
|
||||
endpoint: PUBLIC_MOCK_ENDPOINT,
|
||||
apiKey: PUBLIC_MOCK_APIKEY,
|
||||
projectID: PUBLIC_MOCK_PROJECTID
|
||||
};
|
||||
export const provider = writable<ProviderInput>({ ...initialProvider });
|
||||
export const provider = writable<ProviderInput>({ ...mockProvider });
|
||||
|
||||
const initialFormData = {
|
||||
users: {
|
||||
|
||||
@@ -16,14 +16,13 @@
|
||||
import { isSameDay, toLocaleDate } from '$lib/helpers/date';
|
||||
import { capitalize } from '$lib/helpers/string';
|
||||
import { Container } from '$lib/layout';
|
||||
import { migrator } from '$lib/stores/migrator';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { isSelfHosted } from '$lib/system';
|
||||
import { openImportWizard } from './(import)';
|
||||
import Details from './details.svelte';
|
||||
|
||||
export let data;
|
||||
let showDetails = false;
|
||||
let details: (typeof data.migrations)[number] | null = null;
|
||||
let showCloudExport = false;
|
||||
|
||||
const mockMigrate = async () => {
|
||||
@@ -34,7 +33,7 @@
|
||||
|
||||
const getStatus = (status: string) => {
|
||||
if (status === 'failed') {
|
||||
return { text: 'Failed', icon: 'clock', iconColor: 'blue' };
|
||||
return { text: 'Failed', icon: 'exclamation', iconColor: 'danger' };
|
||||
}
|
||||
|
||||
return { text: 'Pending', icon: 'clock', iconColor: 'blue' };
|
||||
@@ -43,54 +42,93 @@
|
||||
|
||||
<Container>
|
||||
<Heading tag="h2" size="5">Migrations</Heading>
|
||||
{#if isSelfHosted}
|
||||
<CardGrid>
|
||||
<Heading tag="h3" size="7">Import project data</Heading>
|
||||
<p class="text">
|
||||
Import project data from Cloud to your self-hosted project. Initiate the process of
|
||||
importing project data from the migrations settings of your Cloud project.
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
{#if $migrator.status === 'idle'}
|
||||
<div class="u-flex">
|
||||
<div style="margin-inline-start: auto;">
|
||||
<Button secondary on:click={openImportWizard}>Import data</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Table noStyles>
|
||||
<TableHeader>
|
||||
<TableCellHead>Date</TableCellHead>
|
||||
<TableCellHead>Source</TableCellHead>
|
||||
<TableCellHead>Status</TableCellHead>
|
||||
<TableCellHead />
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<TableCell title="Data">Today</TableCell>
|
||||
<TableCell title="Source">Heaven</TableCell>
|
||||
<TableCell title="Status">Awesome</TableCell>
|
||||
<TableCell title="">
|
||||
<Button secondary on:click={() => (showDetails = true)}
|
||||
>Details</Button>
|
||||
</TableCell>
|
||||
</TableBody>
|
||||
</Table>
|
||||
{:else}
|
||||
<div class="import-box">
|
||||
<div class="u-flex u-cross-center u-gap-8">
|
||||
<div class="avatar" style="--size: {48 / 16}rem">
|
||||
<span class="icon-cloud" />
|
||||
</div>
|
||||
<Arrow direction="right" />
|
||||
<div class="avatar" style="--size: {48 / 16}rem">
|
||||
<span class="icon-server" />
|
||||
</div>
|
||||
</div>
|
||||
<p class="u-margin-block-start-24">No imported data yet</p>
|
||||
<CardGrid>
|
||||
<Heading tag="h3" size="7">Import project data</Heading>
|
||||
<p class="text">Import data from other products or from a different Appwrite instance</p>
|
||||
<svelte:fragment slot="aside">
|
||||
{#if data.migrations.length}
|
||||
<div class="u-flex">
|
||||
<div style="margin-inline-start: auto;">
|
||||
<Button secondary on:click={openImportWizard}>Import data</Button>
|
||||
</div>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</div>
|
||||
|
||||
<Table noStyles>
|
||||
<TableHeader>
|
||||
<TableCellHead>Date</TableCellHead>
|
||||
<TableCellHead>Source</TableCellHead>
|
||||
<TableCellHead>Status</TableCellHead>
|
||||
<TableCellHead />
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.migrations as entry}
|
||||
<TableRow>
|
||||
{@const source = capitalize(JSON.parse(entry.source).type)}
|
||||
{@const status = getStatus(entry.status)}
|
||||
<TableCell title="Data">
|
||||
{isSameDay(new Date(), new Date(entry.$createdAt))
|
||||
? 'Today'
|
||||
: toLocaleDate(entry.$createdAt)}
|
||||
</TableCell>
|
||||
<TableCell title="Source">{source}</TableCell>
|
||||
<TableCell title="Status">
|
||||
<div class="u-flex u-gap-4 u-cross-center">
|
||||
<i
|
||||
class="icon-{status.icon}"
|
||||
style="color: hsl(var(--color-text-{status.iconColor}))" />
|
||||
<span>{status.text}</span>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell title="">
|
||||
<Button secondary on:click={() => (details = entry)}
|
||||
>Details</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
{:else}
|
||||
<div class="import-box">
|
||||
<ul class="avatars-group">
|
||||
<li class="avatars-group-item">
|
||||
<div class="avatar">
|
||||
<img src="/logos/firebase.png" alt="Firebase" width="20" />
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="avatars-group-item">
|
||||
<div class="avatar">
|
||||
<img src="/logos/supabase.png" alt="Supabase" width="20" />
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="avatars-group-item">
|
||||
<div class="avatar">
|
||||
<img src="/logos/nhost.png" alt="nhost" width="20" />
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="avatars-group-item">
|
||||
<div class="avatar">
|
||||
<img src="/logos/appwrite.png" alt="Appwrite" width="18" />
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="u-margin-block-start-8">
|
||||
<Arrow direction="down" />
|
||||
</div>
|
||||
<div class="avatar u-margin-block-start-8" style="--size: {48 / 16}rem">
|
||||
<span class="icon-cloud" />
|
||||
</div>
|
||||
<Button class="u-margin-block-start-20" secondary on:click={openImportWizard}>
|
||||
Import data
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
{#if isSelfHosted}
|
||||
<CardGrid>
|
||||
<Heading tag="h3" size="7">Deploy to Cloud</Heading>
|
||||
<p class="text">Export data from your project to Appwrite Cloud</p>
|
||||
@@ -110,94 +148,6 @@
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
{:else}
|
||||
<CardGrid>
|
||||
<Heading tag="h3" size="7">Import project data</Heading>
|
||||
<p class="text">
|
||||
Import data from other products or from a different Appwrite instance
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
{#if data.migrations.length}
|
||||
<div class="u-flex">
|
||||
<div style="margin-inline-start: auto;">
|
||||
<Button secondary on:click={openImportWizard}>Import data</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Table noStyles>
|
||||
<TableHeader>
|
||||
<TableCellHead>Date</TableCellHead>
|
||||
<TableCellHead>Source</TableCellHead>
|
||||
<TableCellHead>Status</TableCellHead>
|
||||
<TableCellHead />
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.migrations as entry}
|
||||
<TableRow>
|
||||
{@const source = capitalize(JSON.parse(entry.source).type)}
|
||||
{@const status = getStatus(entry.status)}
|
||||
<TableCell title="Data">
|
||||
{isSameDay(new Date(), new Date(entry.$createdAt))
|
||||
? 'Today'
|
||||
: toLocaleDate(entry.$createdAt)}
|
||||
</TableCell>
|
||||
<TableCell title="Source">{source}</TableCell>
|
||||
<TableCell title="Status">
|
||||
<div class="u-flex u-gap-4 u-cross-center">
|
||||
<i class="icon-{status.icon}" />
|
||||
<span>{status.text}</span>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell title="">
|
||||
<Button secondary on:click={() => (showDetails = true)}
|
||||
>Details</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
{:else}
|
||||
<div class="import-box">
|
||||
<ul class="avatars-group">
|
||||
<li class="avatars-group-item">
|
||||
<div class="avatar">
|
||||
<img src="/logos/firebase.png" alt="Firebase" width="20" />
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="avatars-group-item">
|
||||
<div class="avatar">
|
||||
<img src="/logos/supabase.png" alt="Supabase" width="20" />
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="avatars-group-item">
|
||||
<div class="avatar">
|
||||
<img src="/logos/nhost.png" alt="nhost" width="20" />
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="avatars-group-item">
|
||||
<div class="avatar">
|
||||
<img src="/logos/appwrite.png" alt="Appwrite" width="18" />
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="u-margin-block-start-8">
|
||||
<Arrow direction="down" />
|
||||
</div>
|
||||
<div class="avatar u-margin-block-start-8" style="--size: {48 / 16}rem">
|
||||
<span class="icon-cloud" />
|
||||
</div>
|
||||
<Button
|
||||
class="u-margin-block-start-20"
|
||||
secondary
|
||||
on:click={openImportWizard}>
|
||||
Import data
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
<CardGrid>
|
||||
<Heading tag="h3" size="7">Export to self-hosted instance</Heading>
|
||||
<p class="text">Export data from your project to a self-hosted instance</p>
|
||||
@@ -262,7 +212,7 @@
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
<Details bind:show={showDetails} />
|
||||
<Details bind:details />
|
||||
|
||||
<style lang="scss">
|
||||
.import-box {
|
||||
|
||||
@@ -4,9 +4,9 @@ import { sdk } from '$lib/stores/sdk';
|
||||
export async function load({ depends }) {
|
||||
depends(Dependencies.MIGRATIONS);
|
||||
|
||||
// const { migrations } = await sdk.forProject.migrations.list();
|
||||
const { migrations } = await sdk.forProject.migrations.list();
|
||||
|
||||
return {
|
||||
migrations: []
|
||||
migrations
|
||||
};
|
||||
}
|
||||
@@ -1,78 +1,69 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from '$lib/components';
|
||||
import { migrator } from '$lib/stores/migrator';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
export let show = false;
|
||||
export let details: Models.Migration | null = null;
|
||||
$: show = !!details;
|
||||
|
||||
type StatusCounters = {
|
||||
[resource in 'Database' | 'Collection' | 'Function' | 'Users']?: StatusCounter;
|
||||
};
|
||||
type StatusCounter = {
|
||||
[statusType in 'PENDING' | 'SUCCESS' | 'ERROR' | 'SKIP' | 'PROCESSING' | 'WARNING']: number;
|
||||
};
|
||||
|
||||
$: statusCounters = JSON.parse(
|
||||
(details?.statusCounters as unknown as string) || '{}'
|
||||
) as StatusCounters;
|
||||
|
||||
const hasError = (counter: StatusCounter) => {
|
||||
if (!counter) return false;
|
||||
return counter.ERROR > 0 || counter.WARNING > 0;
|
||||
};
|
||||
|
||||
const isLoading = (counter: StatusCounter) => {
|
||||
if (!counter) return false;
|
||||
return counter.PENDING > 0 || counter.PROCESSING > 0;
|
||||
};
|
||||
|
||||
const hasSucceeded = (counter: StatusCounter) => {
|
||||
if (!counter) return false;
|
||||
return counter.SUCCESS > 0;
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal bind:show>
|
||||
<svelte:fragment slot="header">Resolve import issues</svelte:fragment>
|
||||
<div class="box">
|
||||
<div class="u-flex u-cross-center u-gap-16">
|
||||
<div class="icon-wrapper">
|
||||
{#if $migrator.items.databases === 'error'}
|
||||
<i class="icon-exclamation" />
|
||||
{:else if $migrator.items.databases === 'success'}
|
||||
<i class="icon-check" />
|
||||
{:else}
|
||||
<span class="loader" />
|
||||
{/if}
|
||||
</div>
|
||||
<Modal bind:show on:close={() => (details = null)} size="big">
|
||||
<svelte:fragment slot="header">
|
||||
{#if details.status === 'failed'}
|
||||
Resolve import issues
|
||||
{:else}
|
||||
Migration details
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
{#if details}
|
||||
<div class="box">
|
||||
{#each ['Database', 'Collection', 'Function', 'Users'] as entity}
|
||||
<div class="u-flex u-cross-center u-gap-16">
|
||||
<div class="icon-wrapper">
|
||||
{#if hasError(statusCounters[entity])}
|
||||
<i class="icon-exclamation" />
|
||||
{:else if isLoading(statusCounters[entity])}
|
||||
<span class="loader" />
|
||||
{:else if hasSucceeded(statusCounters[entity])}
|
||||
<i class="icon-check" />
|
||||
{:else}
|
||||
<i class="icon-question-mark-circle" />
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<span>Databases</span>
|
||||
<span class="inline-tag">2</span>
|
||||
</div>
|
||||
<div>
|
||||
<span>{entity}</span>
|
||||
<span class="inline-tag">2</span>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<div class="u-flex u-cross-center u-gap-16">
|
||||
<div class="icon-wrapper">
|
||||
{#if $migrator.items.documents === 'error'}
|
||||
<i class="icon-exclamation" />
|
||||
{:else if $migrator.items.documents === 'success'}
|
||||
<i class="icon-check" />
|
||||
{:else}
|
||||
<span class="loader" />
|
||||
{/if}
|
||||
</div>
|
||||
<div>
|
||||
<span>Documents</span>
|
||||
<span class="inline-tag">3000</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="u-flex u-cross-center u-gap-16">
|
||||
<div class="icon-wrapper">
|
||||
{#if $migrator.items.users === 'error'}
|
||||
<i class="icon-exclamation" />
|
||||
{:else if $migrator.items.users === 'success'}
|
||||
<i class="icon-check" />
|
||||
{:else}
|
||||
<span class="loader" />
|
||||
{/if}
|
||||
</div>
|
||||
<div>
|
||||
<span>Users</span>
|
||||
<span class="inline-tag">238</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="u-flex u-cross-center u-gap-16">
|
||||
<div class="icon-wrapper">
|
||||
{#if $migrator.items.storage === 'error'}
|
||||
<i class="icon-exclamation" />
|
||||
{:else if $migrator.items.storage === 'success'}
|
||||
<i class="icon-check" />
|
||||
{:else}
|
||||
<span class="loader" />
|
||||
{/if}
|
||||
</div>
|
||||
<div>
|
||||
<span>Storage</span>
|
||||
<span class="inline-tag">30GB</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</Modal>
|
||||
|
||||
<style lang="scss">
|
||||
@@ -89,11 +80,18 @@
|
||||
}
|
||||
|
||||
.icon-wrapper {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
position: relative;
|
||||
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
|
||||
> * {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
}
|
||||
|
||||
.icon-exclamation {
|
||||
|
||||
Reference in new issue
Block a user