mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
mock deploy to cloud & self-hosted
This commit is contained in:
1 parent
311d5c8086
commit
c8e9da2a76
13 files changed
+115
-215
No files matched your search
@@ -50,3 +50,15 @@ export function deepMap<T extends object, U extends object = T>(
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function parseIfString(value: unknown): any {
|
||||
if (typeof value === 'string') {
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -61,6 +61,8 @@ export const migrationFormToResources = (formData: MigrationFormData): Resource[
|
||||
}
|
||||
if (formData.databases.documents) {
|
||||
resources.push('collection');
|
||||
resources.push('attribute');
|
||||
resources.push('index');
|
||||
resources.push('document');
|
||||
}
|
||||
if (formData.functions.root) {
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
import { onMount } from 'svelte';
|
||||
import { onCLS, onFCP, onFID, onINP, onLCP, onTTFB } from 'web-vitals';
|
||||
import Loading from './loading.svelte';
|
||||
import { loading } from './store';
|
||||
import { loading, requestedMigration } from './store';
|
||||
import { openMigrationWizard } from './console/organization-[organization]/(migration-wizard)';
|
||||
|
||||
if (browser) {
|
||||
window.VERCEL_ANALYTICS_ID = import.meta.env.VERCEL_ANALYTICS_ID?.toString() ?? false;
|
||||
|
||||
@@ -16,6 +16,7 @@ export const load: LayoutLoad = async ({ depends, url }) => {
|
||||
if (url.searchParams.has('migrate')) {
|
||||
requestedMigration.set(true);
|
||||
}
|
||||
|
||||
try {
|
||||
const account = await sdk.forConsole.account.get();
|
||||
|
||||
|
||||
@@ -45,14 +45,6 @@
|
||||
$log.data = null;
|
||||
$log.func = null;
|
||||
}
|
||||
|
||||
$: {
|
||||
if ($requestedMigration) {
|
||||
console.log('hey fuckface');
|
||||
} else {
|
||||
console.log('banana');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Shell
|
||||
|
||||
@@ -1,206 +1,72 @@
|
||||
<script lang="ts">
|
||||
import SvgIcon from '$lib/components/svgIcon.svelte';
|
||||
import { Button, FormList, InputNumber, InputText } from '$lib/elements/forms';
|
||||
import { page } from '$app/stores';
|
||||
import { InputSelect } from '$lib/elements/forms';
|
||||
import InputText from '$lib/elements/forms/inputText.svelte';
|
||||
import { WizardStep } from '$lib/layout';
|
||||
import { provider, type Provider } from '.';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
const providers: Record<Provider, string> = {
|
||||
appwrite: 'Appwrite',
|
||||
firebase: 'Firebase',
|
||||
supabase: 'Supabase',
|
||||
nhost: 'NHost'
|
||||
};
|
||||
const projects = $page.data.allProjects as Models.ProjectList;
|
||||
const hasProjects = projects.total > 0;
|
||||
|
||||
let showAuth = false;
|
||||
let projectType = 'existing';
|
||||
|
||||
let selectedProject: string = null;
|
||||
</script>
|
||||
|
||||
<WizardStep>
|
||||
<svelte:fragment slot="title">Choose provider</svelte:fragment>
|
||||
<div class="cards">
|
||||
{#each Object.entries(providers) as [key, value]}
|
||||
<label
|
||||
class="card is-allow-focus u-height-100-percent u-flex u-flex-vertical u-cursor-pointer">
|
||||
<input
|
||||
class="is-small"
|
||||
type="radio"
|
||||
name="provider"
|
||||
bind:group={$provider.provider}
|
||||
value={key} />
|
||||
<div class="content">
|
||||
<img src="/logos/{key}.png" width="33" class="u-margin-inline-auto" alt="" />
|
||||
<p>{value}</p>
|
||||
</div>
|
||||
<svelte:fragment slot="title">
|
||||
{hasProjects ? 'Select project' : 'Create project'}
|
||||
</svelte:fragment>
|
||||
<div class="radios">
|
||||
<div class="u-flex u-gap-8">
|
||||
<input
|
||||
type="radio"
|
||||
name="project_type"
|
||||
id="project_type--existing"
|
||||
bind:group={projectType}
|
||||
value="existing" />
|
||||
<label for="project_type--existing">
|
||||
<p class="u-bold">Existing project</p>
|
||||
<p>Import data to an existing project</p>
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="u-flex u-gap-8">
|
||||
<input
|
||||
type="radio"
|
||||
name="project_type"
|
||||
id="project_type--new"
|
||||
bind:group={projectType}
|
||||
value="new" />
|
||||
<label for="project_type--new">
|
||||
<p class="u-bold">Create new project</p>
|
||||
<span>Import data to a new project</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if $provider.provider === 'appwrite'}
|
||||
<FormList class="u-margin-block-start-24">
|
||||
<div class="u-margin-block-start-24">
|
||||
{#if projectType === 'existing'}
|
||||
<InputSelect
|
||||
id="project"
|
||||
bind:value={selectedProject}
|
||||
label="Select a project"
|
||||
options={projects.projects.map((p) => ({
|
||||
label: p.name,
|
||||
value: p.$id
|
||||
}))} />
|
||||
{:else}
|
||||
<InputText
|
||||
id="endpoint"
|
||||
label="Endpoint"
|
||||
required
|
||||
placeholder="Enter endpoint"
|
||||
bind:value={$provider.endpoint} />
|
||||
<InputText
|
||||
id="project-id"
|
||||
label="Project ID"
|
||||
required
|
||||
placeholder="Enter project ID"
|
||||
bind:value={$provider.projectID} />
|
||||
<InputText
|
||||
id="api-key"
|
||||
label="API Key"
|
||||
required
|
||||
placeholder="Enter API Key"
|
||||
bind:value={$provider.apiKey} />
|
||||
</FormList>
|
||||
{:else if $provider.provider === 'firebase'}
|
||||
<div class="box u-flex u-flex-vertical u-gap-16 u-cross-center u-margin-block-start-24">
|
||||
<p class="u-text-center u-bold">Sign in with Google to get started</p>
|
||||
<Button secondary>
|
||||
<SvgIcon name="google" />Sign in
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<button
|
||||
class="tag u-margin-block-start-16"
|
||||
type="button"
|
||||
on:click={() => (showAuth = !showAuth)}
|
||||
class:is-selected={showAuth}>
|
||||
<span class="icon-lock-closed" aria-hidden="true" />
|
||||
<span class="text">Manual authentication</span>
|
||||
</button>
|
||||
|
||||
{#if showAuth}
|
||||
<div class="u-margin-block-start-16">
|
||||
<InputText
|
||||
id="credentials"
|
||||
label="Account credentials"
|
||||
required
|
||||
placeholder="TODO" />
|
||||
</div>
|
||||
label="Project name"
|
||||
placeholder="Enter project name"
|
||||
id="project_name"
|
||||
required />
|
||||
{/if}
|
||||
{:else if $provider.provider === 'supabase'}
|
||||
<FormList class="u-margin-block-start-24">
|
||||
<p class="body-text-1 u-bold">Postgres credentials</p>
|
||||
|
||||
<InputText
|
||||
id="host"
|
||||
label="Host"
|
||||
required
|
||||
placeholder="Enter host"
|
||||
bind:value={$provider.host} />
|
||||
<InputNumber
|
||||
id="port"
|
||||
label="Port"
|
||||
required
|
||||
placeholder="Enter port"
|
||||
bind:value={$provider.port} />
|
||||
<InputText
|
||||
id="username"
|
||||
label="Username"
|
||||
required
|
||||
placeholder="Enter username"
|
||||
bind:value={$provider.username} />
|
||||
<InputText
|
||||
id="password"
|
||||
label="Password"
|
||||
required
|
||||
placeholder="Enter password"
|
||||
bind:value={$provider.password} />
|
||||
<p class="body-text-1 u-bold">Supabase credentials</p>
|
||||
|
||||
<InputText
|
||||
id="endpoint"
|
||||
label="Endpoint"
|
||||
required
|
||||
placeholder="Enter endpoint"
|
||||
bind:value={$provider.endpoint} />
|
||||
<InputText
|
||||
id="api-key"
|
||||
label="API Key"
|
||||
required
|
||||
placeholder="Enter API Key"
|
||||
bind:value={$provider.apiKey} />
|
||||
</FormList>
|
||||
{:else if $provider.provider === 'nhost'}
|
||||
<FormList class="u-margin-block-start-24">
|
||||
<InputText
|
||||
id="region"
|
||||
label="Region"
|
||||
required
|
||||
placeholder="Enter region"
|
||||
bind:value={$provider.region} />
|
||||
<InputText
|
||||
id="subdomain"
|
||||
label="Subdomain"
|
||||
required
|
||||
placeholder="Enter subdomain"
|
||||
bind:value={$provider.subdomain} />
|
||||
<InputText
|
||||
id="database"
|
||||
label="Database"
|
||||
required
|
||||
placeholder="Enter database"
|
||||
bind:value={$provider.database} />
|
||||
<InputNumber
|
||||
id="port"
|
||||
label="Port"
|
||||
required
|
||||
placeholder="Enter port"
|
||||
bind:value={$provider.port} />
|
||||
<InputText
|
||||
id="username"
|
||||
label="Username"
|
||||
required
|
||||
placeholder="Enter username"
|
||||
bind:value={$provider.username} />
|
||||
<InputText
|
||||
id="password"
|
||||
label="Password"
|
||||
required
|
||||
placeholder="Enter password"
|
||||
bind:value={$provider.password} />
|
||||
<InputText
|
||||
id="adminSecret"
|
||||
label="Admin secret"
|
||||
required
|
||||
placeholder="Enter admin secret"
|
||||
bind:value={$provider.adminSecret} />
|
||||
</FormList>
|
||||
{/if}
|
||||
</div>
|
||||
</WizardStep>
|
||||
|
||||
<style lang="scss">
|
||||
.cards {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.card {
|
||||
--card-padding: 2.5rem 0.5rem;
|
||||
--card-border-radius: var(--border-radius-small);
|
||||
display: block;
|
||||
|
||||
position: relative;
|
||||
|
||||
input {
|
||||
position: absolute;
|
||||
top: 0.5rem;
|
||||
left: 0.5rem;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 9.125rem;
|
||||
height: 4rem;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
}
|
||||
.radios {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
</style>
|
||||
@@ -2,14 +2,13 @@
|
||||
import { EyebrowHeading } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { deepMap } from '$lib/helpers/object';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { DeepKeys, WritableValue } from '$lib/helpers/types';
|
||||
|
||||
import { WizardStep } from '$lib/layout';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
import { formData } from '.';
|
||||
import { migrationFormToResources } from '$lib/stores/migration';
|
||||
import { formData } from '.';
|
||||
|
||||
type FormData = WritableValue<typeof formData>;
|
||||
type FormKeys = DeepKeys<FormData>;
|
||||
@@ -68,17 +67,17 @@
|
||||
onMount(async () => {
|
||||
const resources = migrationFormToResources($formData);
|
||||
|
||||
switch ($provider.provider) {
|
||||
case 'appwrite': {
|
||||
const res = await sdk.forProject.migrations.generateAppwriteReport(
|
||||
resources,
|
||||
$provider.endpoint,
|
||||
$provider.projectID,
|
||||
$provider.apiKey
|
||||
);
|
||||
report = res;
|
||||
}
|
||||
}
|
||||
// switch ($provider.provider) {
|
||||
// case 'appwrite': {
|
||||
// const res = await sdk.forProject.migrations.generateAppwriteReport(
|
||||
// resources,
|
||||
// $provider.endpoint,
|
||||
// $provider.projectID,
|
||||
// $provider.apiKey
|
||||
// );
|
||||
// report = res;
|
||||
// }
|
||||
// }
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
import { newOrgModal, newMemberModal } from '$lib/stores/organization';
|
||||
import CreateMember from './createMember.svelte';
|
||||
import Create from '../createOrganization.svelte';
|
||||
import { openMigrationWizard } from './(migration-wizard)';
|
||||
import { requestedMigration } from '$routes/store';
|
||||
|
||||
$: if ($requestedMigration) {
|
||||
openMigrationWizard();
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { migrationFormToResources } from '$lib/stores/migration';
|
||||
import { started } from '../stores';
|
||||
|
||||
const onExit = () => {
|
||||
resetImportStores();
|
||||
@@ -70,6 +71,7 @@
|
||||
}
|
||||
resetImportStores();
|
||||
wizard.hide();
|
||||
started.set(performance.now());
|
||||
};
|
||||
|
||||
onDestroy(onExit);
|
||||
|
||||
@@ -17,8 +17,13 @@
|
||||
import { capitalize } from '$lib/helpers/string';
|
||||
import { Container } from '$lib/layout';
|
||||
import { isSelfHosted } from '$lib/system';
|
||||
import { onMount } from 'svelte';
|
||||
import { openImportWizard } from './(import)';
|
||||
import Details from './details.svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { parseIfString } from '$lib/helpers/object';
|
||||
|
||||
export let data;
|
||||
let details: (typeof data.migrations)[number] | null = null;
|
||||
@@ -33,6 +38,14 @@
|
||||
|
||||
return { text: 'Pending', icon: 'clock', iconColor: 'blue' };
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
return sdk.forConsole.client.subscribe(['project', 'console'], (response) => {
|
||||
if (response.events.includes('migrations.*')) {
|
||||
invalidate(Dependencies.MIGRATIONS);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
@@ -59,7 +72,7 @@
|
||||
<TableBody>
|
||||
{#each data.migrations as entry}
|
||||
<TableRow>
|
||||
{@const source = capitalize(JSON.parse(entry.source).type)}
|
||||
{@const source = capitalize(parseIfString(entry.source).type)}
|
||||
{@const status = getStatus(entry.status)}
|
||||
<TableCell title="Data">
|
||||
{isSameDay(new Date(), new Date(entry.$createdAt))
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { Dependencies } from '$lib/constants.js';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { get } from 'svelte/store';
|
||||
import { started } from './stores.js';
|
||||
|
||||
export async function load({ depends }) {
|
||||
depends(Dependencies.MIGRATIONS);
|
||||
|
||||
const { migrations } = await sdk.forProject.migrations.list();
|
||||
|
||||
console.log(migrations);
|
||||
console.log(migrations, (performance.now() - get(started)) / 1000);
|
||||
|
||||
return {
|
||||
migrations
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from '$lib/components';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { parseIfString } from '$lib/helpers/object';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
export let details: Models.Migration | null = null;
|
||||
@@ -13,7 +14,7 @@
|
||||
[statusType in 'pending' | 'success' | 'error' | 'skip' | 'processing' | 'warning']: number;
|
||||
};
|
||||
|
||||
$: statusCounters = JSON.parse(
|
||||
$: statusCounters = parseIfString(
|
||||
(details?.statusCounters as unknown as string) || '{}'
|
||||
) as StatusCounters;
|
||||
|
||||
@@ -37,7 +38,7 @@
|
||||
return Object.values(counter).reduce((acc, curr) => acc + curr, 0);
|
||||
};
|
||||
|
||||
$: parsedSource = JSON.parse(details?.source || '{}');
|
||||
$: parsedSource = parseIfString(details?.source || '{}');
|
||||
</script>
|
||||
|
||||
<Modal bind:show on:close={() => (details = null)} size="big">
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export const started = writable(performance.now());
|
||||
Reference in new issue
Block a user