From 89d3e51b96e90152f17d57710f2765be96ddf03a Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 16 Jun 2022 15:41:22 +0200 Subject: [PATCH] feat: start work on storage page --- .../storage/bucket/[bucket]/__layout.svelte | 4 +- .../storage/bucket/[bucket]/index.svelte | 80 +++++++++++----- .../console/[project]/storage/index.svelte | 93 +++++++++++++++---- 3 files changed, 133 insertions(+), 44 deletions(-) diff --git a/src/routes/console/[project]/storage/bucket/[bucket]/__layout.svelte b/src/routes/console/[project]/storage/bucket/[bucket]/__layout.svelte index 6221ad15e..d4b46e251 100644 --- a/src/routes/console/[project]/storage/bucket/[bucket]/__layout.svelte +++ b/src/routes/console/[project]/storage/bucket/[bucket]/__layout.svelte @@ -22,8 +22,8 @@ backButton.set(''); copyData.set({ - text: '', - value: '' + text: $bucket.$id, + value: $bucket.$id }); tabs.set([ { diff --git a/src/routes/console/[project]/storage/bucket/[bucket]/index.svelte b/src/routes/console/[project]/storage/bucket/[bucket]/index.svelte index c7761f7a5..1147db840 100644 --- a/src/routes/console/[project]/storage/bucket/[bucket]/index.svelte +++ b/src/routes/console/[project]/storage/bucket/[bucket]/index.svelte @@ -38,35 +38,47 @@ -

Files

- - - +
+
+ +
+ +
{#await request}
{:then response} {#if response.total} -

{response.total} files found

- - Name + Filename Type Size Date Created + {#each response.files as file} - - openFile(file)}> - {file.name} - +
+ openFile(file)}> + {file.name} + {file.name} + +
{file.mimeType} {file.sizeOriginal} @@ -76,22 +88,44 @@ {/each}
- - +
+

Total results: {response.total}

+ +
{:else if search} - No results found for {search} +
+ Sorry, we couldn’t find ‘{search}’ +
+

There are no files that match your search.

+
+
+ +
+
+
+

Total results: {response.total}

+ +
{:else} - - No Files Found - Upload your first file to get started. + +
+
+ +
+
+

Upload spme files to get started

+
+
+ +
+
{/if} {/await} - - diff --git a/src/routes/console/[project]/storage/index.svelte b/src/routes/console/[project]/storage/index.svelte index 38e3f0077..9d6a0cc15 100644 --- a/src/routes/console/[project]/storage/index.svelte +++ b/src/routes/console/[project]/storage/index.svelte @@ -2,18 +2,20 @@ import { page } from '$app/stores'; import { goto } from '$app/navigation'; import { sdkForProject } from '$lib/stores/sdk'; - import { Button, InputSearch } from '$lib/elements/forms'; - import { Card, Empty, Pagination, Tile, Tiles } from '$lib/components'; + import { Button } from '$lib/elements/forms'; + import { Empty, Pagination, Tiles } from '$lib/components'; + import { Pill } from '$lib/elements'; import type { Models } from 'src/sdk'; import Create from './_create.svelte'; import { Container } from '$lib/layout'; import { base } from '$app/paths'; + import { addNotification } from '$lib/stores/notifications'; - let search = ''; let showCreate = false; + let search = ''; let offset = 0; - const limit = 25; + const limit = 5; const project = $page.params.project; const bucketCreated = async (event: CustomEvent) => { showCreate = false; @@ -22,41 +24,94 @@ $: request = sdkForProject.storage.listBuckets(search, limit, offset); $: if (search) offset = 0; + + const copy = async (value: string) => { + try { + await navigator.clipboard.writeText(value); + addNotification({ + message: 'Copied to clipboard.', + type: 'success' + }); + } catch (error) { + addNotification({ + message: error.message, + type: 'error' + }); + } + }; -

Buckets

- - - +
+

Buckets

+ +
{#await request}
{:then response} {#if response.total} {#each response.buckets as bucket} - + +
+ XX Files + {#if !bucket.enabled} + Disabled + {/if} +
+

{bucket.name}

+ copy(bucket.$id)} + >User ID + +
{/each}
- +
+

Total results: {response.total}

+ +
{:else if search} - No results found for {search} +
+ Sorry, we couldn’t find ‘{search}’ +
+

There are no buckets that match your search.

+
+
+ +
+
+
+

Total results: {response.total}

+ +
{:else} - - No Buckets Found - You haven't created any buckets for your project yet. + +
+
+ +
+
+

Add Your First Bucket To Get Started

+
+
+ +
+
{/if} {/await} - -