diff --git a/src/lib/elements/forms/inputTags.svelte b/src/lib/elements/forms/inputTags.svelte index 0ad75a294..b9dc93686 100644 --- a/src/lib/elements/forms/inputTags.svelte +++ b/src/lib/elements/forms/inputTags.svelte @@ -88,7 +88,7 @@ export let disabled = false; + export let selected = false; export let success = false; export let warning = false; export let danger = false; @@ -18,6 +19,7 @@ rel={external ? 'noopener noreferrer' : ''} class="tag" class:is-disabled={disabled} + class:is-selected={selected} class:is-success={success} class:is-warning={warning} class:is-danger={danger} @@ -31,6 +33,7 @@ type={submit ? 'submit' : 'button'} class="tag" class:is-disabled={disabled} + class:is-selected={selected} class:is-success={success} class:is-warning={warning} class:is-danger={danger} @@ -41,6 +44,7 @@
-

Max file size: {bytesToSize($bucket.maximumFileSize)}

+

Max file size: {calculateSize($bucket.maximumFileSize)}

{#if !showDropdown} diff --git a/src/routes/console/[project]/storage/bucket/[bucket]/file/[file]/index.svelte b/src/routes/console/[project]/storage/bucket/[bucket]/file/[file]/index.svelte index d8dce4d29..95b977653 100644 --- a/src/routes/console/[project]/storage/bucket/[bucket]/file/[file]/index.svelte +++ b/src/routes/console/[project]/storage/bucket/[bucket]/file/[file]/index.svelte @@ -7,7 +7,7 @@ import { toLocaleDate, toLocaleDateTime } from '$lib/helpers/date'; import { sdkForProject } from '$lib/stores/sdk'; import { addNotification } from '$lib/stores/notifications'; - import { bytesToSize } from '$lib/helpers/sizeConvertion'; + import { calculateSize } from '$lib/helpers/sizeConvertion'; import Delete from './_deleteFile.svelte'; import { page } from '$app/stores'; import { onMount } from 'svelte'; @@ -101,7 +101,7 @@

MIME Type: {$file.mimeType}

-

Size: {bytesToSize($file.sizeOriginal)}

+

Size: {calculateSize($file.sizeOriginal)}

Created: {toLocaleDate($file.$createdAt)}

Last Updated: {toLocaleDate($file.$updatedAt)}

diff --git a/src/routes/console/[project]/storage/bucket/[bucket]/index.svelte b/src/routes/console/[project]/storage/bucket/[bucket]/index.svelte index 3d8647b4e..6e248005e 100644 --- a/src/routes/console/[project]/storage/bucket/[bucket]/index.svelte +++ b/src/routes/console/[project]/storage/bucket/[bucket]/index.svelte @@ -17,7 +17,7 @@ TableCell } from '$lib/elements/table'; import { toLocaleDate } from '$lib/helpers/date'; - import { bytesToSize } from '$lib/helpers/sizeConvertion'; + import { calculateSize } from '$lib/helpers/sizeConvertion'; import { Container } from '$lib/layout'; import { base } from '$app/paths'; import { files } from './store'; @@ -97,7 +97,7 @@ {file.mimeType} {bytesToSize(file.sizeOriginal)} + >{calculateSize(file.sizeOriginal)} {toLocaleDate(file.$createdAt)} @@ -132,7 +132,7 @@ {file.mimeType} {bytesToSize(file.sizeOriginal)} + >{calculateSize(file.sizeOriginal)} {toLocaleDate(file.$createdAt)} diff --git a/src/routes/console/[project]/storage/bucket/[bucket]/settings.svelte b/src/routes/console/[project]/storage/bucket/[bucket]/settings.svelte index fce6a9482..584a46bd4 100644 --- a/src/routes/console/[project]/storage/bucket/[bucket]/settings.svelte +++ b/src/routes/console/[project]/storage/bucket/[bucket]/settings.svelte @@ -2,27 +2,26 @@ import { Alert, CardGrid, Box } from '$lib/components'; import { Container } from '$lib/layout'; import { + Form, Button, InputText, InputTags, InputNumber, InputSelect, - InputSwitch, - Helper + InputSwitch } from '$lib/elements/forms'; import { bucket } from './store'; import { toLocaleDateTime } from '$lib/helpers/date'; - import { sizeToBytes } from '$lib/helpers/sizeConvertion'; + import { sizeToBytes, bytesToSize } from '$lib/helpers/sizeConvertion'; import { sdkForProject } from '$lib/stores/sdk'; import { addNotification } from '$lib/stores/notifications'; import Delete from './_deleteBucket.svelte'; import { onMount } from 'svelte'; import { page } from '$app/stores'; + import Pill from '$lib/elements/pill.svelte'; let showDelete = false; - let showError: false | 'name' | 'size' = false, - errorMessage = 'Something went wrong', - errorType: 'error' | 'warning' | 'success' = 'error'; + let enabled: boolean = null, bucketName: string = null, bucketPermissions: string = null, @@ -32,13 +31,14 @@ encryption: boolean = null, antivirus: boolean = null, maxSize: number; - let byteUnit: 'Bytes' | 'KB' | 'MB' | 'GB' = 'Bytes', + let byteUnit: 'Bytes' | 'KB' | 'MB' | 'GB' = 'MB', options = [ { label: 'Bytes', value: 'Bytes' }, { label: 'Kilobytes', value: 'KB' }, { label: 'Megabytes', value: 'MB' }, { label: 'Gigabytes', value: 'GB' } ]; + let suggestedExtensions = ['jpg', 'png', 'svg', 'gif', 'html', 'pdf', 'mp4']; let extensions = $bucket.allowedFileExtensions; let isExtensionsDisabled = true; @@ -53,7 +53,7 @@ encryption ??= $bucket.encryption; antivirus ??= $bucket.antivirus; }); - + $: maxSizePlaceholder = bytesToSize($bucket.maximumFileSize, byteUnit); $: if (bucketPermissions || bucketRead || bucketWrite) { if (bucketPermissions !== $bucket.permission) { arePermsDisabled = false; @@ -73,12 +73,6 @@ } else isExtensionsDisabled = true; } - function addError(location: typeof showError, message: string, type: typeof errorType) { - showError = location; - errorMessage = message; - errorType = type; - } - async function toggleBucket() { try { await sdkForProject.storage.updateBucket( @@ -105,13 +99,15 @@ try { await sdkForProject.storage.updateBucket($bucket.$id, $bucket.name, $bucket.permission); $bucket.name = bucketName; - showError = false; addNotification({ message: 'Name has been updated', type: 'success' }); } catch (error) { - addError('name', error.message, 'error'); + addNotification({ + message: error.message, + type: 'error' + }); } } async function updatePermissions() { @@ -156,7 +152,7 @@ $bucket.encryption = encryption; $bucket.antivirus = antivirus; addNotification({ - message: `${$bucket.name} has been updatede`, + message: `${$bucket.name} has been updated`, type: 'success' }); } catch (error) { @@ -181,7 +177,7 @@ ); $bucket.maximumFileSize = maxSize; addNotification({ - message: `${$bucket.name} has been updatede`, + message: `${$bucket.name} has been updated`, type: 'success' }); } catch (error) { @@ -206,7 +202,7 @@ ); $bucket.allowedFileExtensions = extensions; addNotification({ - message: `${$bucket.name} has been updatede`, + message: `${$bucket.name} has been updated`, type: 'success' }); } catch (error) { @@ -220,230 +216,233 @@ {#if $bucket} - -

{$bucket.name}

+
+ +

{$bucket.name}

- -
    - -
-

Created: {toLocaleDateTime($bucket.$createdAt)}

-

Last Updated: {toLocaleDateTime($bucket.$updatedAt)}

-
+ +
    + +
+

Created: {toLocaleDateTime($bucket.$createdAt)}

+

Last Updated: {toLocaleDateTime($bucket.$updatedAt)}

+
- - - -
+ + + + +
- -
Update Name
+
+ +
Update Name
+ +
    + +
+
- -
    - - {#if showError === 'name'} - {errorMessage} + + + + + + +
    + +
    Update Permissions
    +

    + Assign read or write permissions at the Bucket Level or + File Level. If Bucket Level permissions are assigned, file permissions + will be ignored. +

    + +
      +
    • + +
    • +
    • + +
    • +
    + +

    + Tip: Add role:all for wildcards access. Check out our + documentation for more on Permissions +

    +
    + {#if bucketPermissions === 'bucket'} +
      + + +
    {/if} -
-
+
+ + + + + - - - - - -
Update Permissions
-

- Assign read or write permissions at the Bucket Level or - File Level. If Bucket Level permissions are assigned, file permissions will - be ignored. -

- - - -

- Tip: Add role:all for wildcards access. Check out our documentation - for more on Permissions -

-
- {#if bucketPermissions === 'bucket'} +
+ +

Update Security Settings

+

+ Enable or disable security services for the bucket including Ecryption + and Antivirus scanning. +

+ +
    +
  • + +
  • +
  • + +
  • + +
  • +
+
+ + + + +
+
+ +
+ +

Update Maximum File Size

+

Set the maximum file size allowed in the bucket.

+ +
    + + +
+
+ + + + +
+
+ +
+ +
Update Allowed File Extensions
+

+ A maxiumum of 100 file extensions can be added. Leave blank to allow all file + types. +

+
    - + label="Allowed file extensions" + placeholder="Allowed file extensions (mp4, jpg, pdf, etc.)" + bind:tags={extensions} /> +
  • + {#each suggestedExtensions as ext} + { + if (!extensions.includes(ext)) + extensions = [...extensions, ext]; + }}> + + {/each} +
- {/if} -
- - - -
- -

Update Security Settings

-

- Enable or disable security services for the bucket including Ecryption - and Antivirus scanning. -

- -
    -
  • - -
  • -
  • - -
  • - -
  • -
-
- - - - -
- -

Update Maximum File Size

-

Set the maximum file size allowed in the bucket.

- -
    - - -
-
- - - - -
- -
Update Allowed File Extensions
-

- A maxiumum of 100 file extensions can be added. Leave blank to allow all file types. -

- - -

- Tip: Commonly added extensions include JPG, PNG, SVG, GIF, HTML, PDF, MP4. -

-
-
    - -
-
- - - - -
Delete Bucket