mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
initial commit
This commit is contained in:
1 parent
b07a37189b
commit
9e53cf29e7
10 files changed
+227
-59
No files matched your search
@@ -51,7 +51,7 @@
|
||||
class:icon-cheveron-down={!showDropdown} />
|
||||
</button>
|
||||
<svelte:fragment slot="list">
|
||||
<DropListItem icon="plus">New organisation</DropListItem>
|
||||
<DropListItem icon="plus">New organization</DropListItem>
|
||||
<DropListLink href="/console/$me">Your Account</DropListLink>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="other">
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
<script lang="ts">
|
||||
import { navigating, page } from '$app/stores';
|
||||
import { tabs, title, backButton, copyData } from '$lib/stores/layout';
|
||||
import { tabs, title, backButton, copyData, titleDropdown } from '$lib/stores/layout';
|
||||
import { Cover } from '.';
|
||||
import { Copy } from '$lib/components';
|
||||
import { Copy, DropList, DropListItem } from '$lib/components';
|
||||
import { Pill } from '$lib/elements';
|
||||
|
||||
export let isOpen = false;
|
||||
export let showSideNavigation = false;
|
||||
|
||||
$: base = `/console/${$page.params.project}`;
|
||||
// $: base = `/console/${$page.params.project}`;
|
||||
|
||||
let tabsList: HTMLUListElement;
|
||||
let showLeft = false;
|
||||
let showRight = false;
|
||||
let showDropdown = false;
|
||||
|
||||
navigating.subscribe(() => {
|
||||
if (isOpen) isOpen = false;
|
||||
@@ -83,9 +84,38 @@
|
||||
<span class="icon-cheveron-left" aria-hidden="true" />
|
||||
</a>
|
||||
{/if}
|
||||
<h1 class="heading-level-4">
|
||||
<span class="text"> {$title}</span>
|
||||
</h1>
|
||||
{#if $titleDropdown?.length}
|
||||
<DropList bind:show={showDropdown} position="bottom" arrow={false}>
|
||||
<button
|
||||
class="button is-text u-padding-inline-0"
|
||||
on:click={() => (showDropdown = !showDropdown)}>
|
||||
<h1 class="heading-level-4">
|
||||
<span class="text"> drop</span>
|
||||
|
||||
<span
|
||||
class={`icon-cheveron-${showDropdown ? 'up' : 'down'}`}
|
||||
aria-hidden="true" />
|
||||
</h1>
|
||||
</button>
|
||||
<svelte:fragment slot="list">
|
||||
{#each $titleDropdown as organization}
|
||||
<DropListItem>
|
||||
{organization.name}
|
||||
</DropListItem>
|
||||
{/each}
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="other">
|
||||
<section class="drop-section">
|
||||
<ul class="drop-list">
|
||||
<DropListItem icon="plus">New Organizations</DropListItem>
|
||||
</ul>
|
||||
</section></svelte:fragment>
|
||||
</DropList>
|
||||
{:else}
|
||||
<h1 class="heading-level-4">
|
||||
<span class="text"> {$title}</span>
|
||||
</h1>
|
||||
{/if}
|
||||
{#if $copyData?.value}
|
||||
<Copy value={$copyData.value}>
|
||||
<Pill button
|
||||
@@ -122,9 +152,8 @@
|
||||
<li class="tabs-item">
|
||||
<a
|
||||
class="tabs-button"
|
||||
href={`${base}/${tab.href}`}
|
||||
class:is-selected={$page.url.pathname ===
|
||||
`${base}/${tab.href}`}>
|
||||
href={`${tab.href}`}
|
||||
class:is-selected={$page.url.pathname === `${tab.href}`}>
|
||||
<span class="text">{tab.title}</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { project } from '../../routes/console/[project]/store';
|
||||
import { get, writable } from 'svelte/store';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
|
||||
export type Tab = {
|
||||
href: string;
|
||||
@@ -14,6 +15,7 @@ export type Breadcrumb = {
|
||||
|
||||
export type updateLayoutArguments = {
|
||||
title: string;
|
||||
titleDropdown?: Models.Team[];
|
||||
level?: number;
|
||||
tabs?: Tab[];
|
||||
back?: string;
|
||||
@@ -22,6 +24,7 @@ export type updateLayoutArguments = {
|
||||
text: string;
|
||||
value: string;
|
||||
};
|
||||
customBase?: string;
|
||||
navigate?: {
|
||||
from: URL | null;
|
||||
to: URL;
|
||||
@@ -30,6 +33,7 @@ export type updateLayoutArguments = {
|
||||
|
||||
export const level = writable<number>();
|
||||
export const title = writable<string>('');
|
||||
export const titleDropdown = writable<Models.Team[]>([]);
|
||||
export const backButton = writable<string>('');
|
||||
export const tabs = writable<Tab[]>([]);
|
||||
export const breadcrumbs = writable<Map<number, Breadcrumb>>(new Map());
|
||||
@@ -40,7 +44,13 @@ export const copyData = writable({
|
||||
|
||||
export function updateLayout(args: updateLayoutArguments) {
|
||||
const projectId = get(project)?.$id;
|
||||
const base = projectId ? `/console/${projectId}` : `/console`;
|
||||
const base = args?.customBase ?? projectId ? `/console/${projectId}` : ``;
|
||||
|
||||
if (args?.tabs) {
|
||||
args.tabs.map((tab) => {
|
||||
tab.href = `${base}/${tab.href}`;
|
||||
});
|
||||
}
|
||||
|
||||
if (args?.navigate?.to) {
|
||||
const previousTabs = get(tabs);
|
||||
@@ -50,6 +60,7 @@ export function updateLayout(args: updateLayoutArguments) {
|
||||
}
|
||||
|
||||
title.set(args.title);
|
||||
titleDropdown.set(args.titleDropdown ?? []);
|
||||
backButton.set(args.back ?? null);
|
||||
copyData.set(args.copy ?? null);
|
||||
level.set(args.level ?? null);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { sdkForConsole, setProject } from '$lib/stores/sdk';
|
||||
import { collection } from './databases/database/[database]/collection/[collection]/store';
|
||||
import { UploadBox } from '$lib/components';
|
||||
import { organisation, project } from './store';
|
||||
import { organization, project } from './store';
|
||||
import { onMount } from 'svelte';
|
||||
import { afterNavigate } from '$app/navigation';
|
||||
import { updateLayout } from '$lib/stores/layout';
|
||||
@@ -53,18 +53,18 @@
|
||||
setProject(projectId);
|
||||
await project.load(projectId);
|
||||
}
|
||||
if ($organisation?.$id !== $project.teamId) {
|
||||
await organisation.load($project.teamId);
|
||||
if ($organization?.$id !== $project.teamId) {
|
||||
await organization.load($project.teamId);
|
||||
}
|
||||
|
||||
updateLayout({
|
||||
navigate: event,
|
||||
title: $project.name,
|
||||
level: 2,
|
||||
level: 1,
|
||||
breadcrumbs: [
|
||||
{
|
||||
href: path,
|
||||
title: $organisation.name,
|
||||
title: $project.name,
|
||||
level: 1
|
||||
},
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ function createProject() {
|
||||
};
|
||||
}
|
||||
|
||||
function createOrganisation() {
|
||||
function createOrganization() {
|
||||
const { subscribe, set } = writable<Models.Team>();
|
||||
|
||||
return {
|
||||
@@ -29,4 +29,4 @@ function createOrganisation() {
|
||||
}
|
||||
|
||||
export const project = createProject();
|
||||
export const organisation = createOrganisation();
|
||||
export const organization = createOrganization();
|
||||
@@ -2,11 +2,41 @@
|
||||
import Shell from '$lib/layout/shell.svelte';
|
||||
import Header from '$lib/layout/header.svelte';
|
||||
import { updateLayout } from '$lib/stores/layout';
|
||||
import { onMount } from 'svelte';
|
||||
import { afterNavigate } from '$app/navigation';
|
||||
import { organizationList } from './store';
|
||||
|
||||
updateLayout({
|
||||
title: 'Projects',
|
||||
level: 0
|
||||
});
|
||||
onMount(handle);
|
||||
afterNavigate(handle);
|
||||
|
||||
async function handle(event = null) {
|
||||
await organizationList.load();
|
||||
updateLayout({
|
||||
navigate: event,
|
||||
title: `${$organizationList.teams[0].name}`,
|
||||
titleDropdown: $organizationList.teams,
|
||||
level: 0,
|
||||
customBase: '',
|
||||
breadcrumbs: {
|
||||
title: `${$organizationList.teams[0].name}`,
|
||||
href: 'console'
|
||||
},
|
||||
tabs: [
|
||||
{
|
||||
href: 'console',
|
||||
title: 'Projects'
|
||||
},
|
||||
{
|
||||
href: 'console/members',
|
||||
title: 'Members'
|
||||
},
|
||||
{
|
||||
href: 'console/settings',
|
||||
title: 'Settings'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<Shell>
|
||||
|
||||
@@ -1,67 +1,95 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import { Tiles, Tile } from '$lib/components';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { Bucket, EmptyBucket, Pagination } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Container } from '$lib/layout';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
import CreateOrganization from './_createOrganization.svelte';
|
||||
import CreateProject from './_createProject.svelte';
|
||||
import { organizationList, organization, projectList } from './store';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
type Organization = Models.Team & {
|
||||
projects: Models.Project[];
|
||||
};
|
||||
let projects: Models.Project[] = [];
|
||||
|
||||
const request: Promise<Organization[]> = Promise.all([
|
||||
sdkForConsole.projects.list(),
|
||||
sdkForConsole.teams.list()
|
||||
]).then(([{ projects }, { teams }]) => {
|
||||
return teams.map((team) => {
|
||||
return {
|
||||
...team,
|
||||
projects: projects.filter((a) => a.teamId === team.$id)
|
||||
};
|
||||
});
|
||||
onMount(async () => {
|
||||
organizationList.load();
|
||||
if (!$organization) {
|
||||
organization.load($organizationList.teams[0].$id);
|
||||
}
|
||||
projectList.load();
|
||||
|
||||
projects = $projectList.projects.filter((a) => a.teamId === $organization.$id);
|
||||
});
|
||||
|
||||
let addProject = false;
|
||||
let showCreate = false;
|
||||
let addOrganization = false;
|
||||
let currentOrganization = '';
|
||||
let currentOrganization = $organization?.$id;
|
||||
let offset = 0;
|
||||
const limit = 5;
|
||||
|
||||
const createProject = (teamId: string) => {
|
||||
currentOrganization = teamId;
|
||||
addProject = true;
|
||||
};
|
||||
const projectCreated = async (event: CustomEvent<Models.Project>) => {
|
||||
await goto(`${base}/console/${event.detail.$id}`);
|
||||
};
|
||||
//TODO: fix technology icon display
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Appwrite - Console</title>
|
||||
</svelte:head>
|
||||
<Container>
|
||||
<h1>Your Organizations</h1>
|
||||
<Button on:click={() => (addOrganization = true)}>Add Organization</Button>
|
||||
<div class="u-flex u-gap-12 common-section u-main-space-between">
|
||||
<h2 class="heading-level-5">Projects</h2>
|
||||
|
||||
{#await request}
|
||||
<div aria-busy="true" />
|
||||
{:then organizations}
|
||||
{#each organizations as organization}
|
||||
<h1>{organization.name}</h1>
|
||||
<Tiles>
|
||||
{#each organization.projects as project}
|
||||
<Tile href={`${base}/console/${project.$id}`} title={project.name} />
|
||||
{/each}
|
||||
</Tiles>
|
||||
<Button on:click={() => createProject(organization.$id)}>Create Project</Button>
|
||||
{/each}
|
||||
{/await}
|
||||
<Button
|
||||
on:click={() => {
|
||||
showCreate = true;
|
||||
}}>
|
||||
<span class="icon-plus" aria-hidden="true" /> <span class="text">Create project</span>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{#if projects?.length}
|
||||
<ul
|
||||
class="grid-box common-section u-margin-block-start-32"
|
||||
style={`--grid-gap:2rem; --grid-item-size:${projects.length > 3 ? '22rem' : '25rem'};`}>
|
||||
{#each projects as project}
|
||||
<Bucket href={`${base}/console/${project.$id}`}>
|
||||
<svelte:fragment slot="eyebrow">XX apps</svelte:fragment>
|
||||
<svelte:fragment slot="title">
|
||||
{project.name}
|
||||
</svelte:fragment>
|
||||
{#each project.platforms as platform}
|
||||
<Pill>
|
||||
<span class={`icon-${platform.type}`} aria-hidden="true" />
|
||||
{platform.type}</Pill>
|
||||
{/each}
|
||||
</Bucket>
|
||||
{/each}
|
||||
{#if projects.length % 2 !== 0}
|
||||
<EmptyBucket on:click={() => (showCreate = true)}>
|
||||
<div class="common-section">
|
||||
<Button secondary round>
|
||||
<i class="icon-plus" />
|
||||
</Button>
|
||||
</div>
|
||||
<div class="common-section">
|
||||
<p>Add a new bucket</p>
|
||||
</div>
|
||||
</EmptyBucket>
|
||||
{/if}
|
||||
</ul>
|
||||
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<p class="text">Total results: {projects.length}</p>
|
||||
<Pagination {limit} bind:offset sum={projects.length} />
|
||||
</div>
|
||||
{/if}
|
||||
</Container>
|
||||
|
||||
<CreateOrganization bind:show={addOrganization} />
|
||||
<CreateProject
|
||||
bind:show={addProject}
|
||||
bind:show={showCreate}
|
||||
bind:teamId={currentOrganization}
|
||||
on:created={projectCreated} />
|
||||
@@ -0,0 +1,5 @@
|
||||
<svelte:head>
|
||||
<title>Appwrite - Console</title>
|
||||
</svelte:head>
|
||||
|
||||
Members
|
||||
@@ -0,0 +1,5 @@
|
||||
<svelte:head>
|
||||
<title>Appwrite - Console</title>
|
||||
</svelte:head>
|
||||
|
||||
settings
|
||||
@@ -0,0 +1,60 @@
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
import { writable } from 'svelte/store';
|
||||
import { browser } from '$app/env';
|
||||
|
||||
function createOrganizationList() {
|
||||
const { subscribe, set } = writable<Models.TeamList>(
|
||||
browser ? JSON.parse(sessionStorage.getItem('organizationList')) : null
|
||||
);
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
set,
|
||||
load: async () => {
|
||||
const team = await sdkForConsole.teams.list();
|
||||
set(team);
|
||||
}
|
||||
};
|
||||
}
|
||||
function createOrganization() {
|
||||
const { subscribe, set } = writable<Models.Team>(
|
||||
browser ? JSON.parse(sessionStorage.getItem('organization')) : null
|
||||
);
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
set,
|
||||
load: async (teamId: string) => {
|
||||
const team = await sdkForConsole.teams.get(teamId);
|
||||
set(team);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function createProjectList() {
|
||||
const { subscribe, set } = writable<Models.ProjectList>(
|
||||
browser ? JSON.parse(sessionStorage.getItem('projectList')) : null
|
||||
);
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
set,
|
||||
load: async () => {
|
||||
const projects = await sdkForConsole.projects.list();
|
||||
set(projects);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const organizationList = createOrganizationList();
|
||||
export const organization = createOrganization();
|
||||
export const projectList = createProjectList();
|
||||
|
||||
if (browser) {
|
||||
organizationList.subscribe((n) =>
|
||||
sessionStorage?.setItem('organizationList', JSON.stringify(n ?? ''))
|
||||
);
|
||||
organization.subscribe((n) => sessionStorage?.setItem('organization', JSON.stringify(n ?? '')));
|
||||
projectList.subscribe((n) => sessionStorage?.setItem('projectList', JSON.stringify(n ?? '')));
|
||||
}
|
||||
Reference in new issue
Block a user