From 07126352025c26a1288d1d5a09478a0bbfedde76 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 6 Dec 2022 13:27:28 +0100 Subject: [PATCH] feat: add compression algorithm setting --- .../bucket-[bucket]/settings/+page.svelte | 66 +++++++++++++++---- 1 file changed, 54 insertions(+), 12 deletions(-) diff --git a/src/routes/console/project-[project]/storage/bucket-[bucket]/settings/+page.svelte b/src/routes/console/project-[project]/storage/bucket-[bucket]/settings/+page.svelte index b7fd139e5..5d1aa0c48 100644 --- a/src/routes/console/project-[project]/storage/bucket-[bucket]/settings/+page.svelte +++ b/src/routes/console/project-[project]/storage/bucket-[bucket]/settings/+page.svelte @@ -36,8 +36,9 @@ arePermsDisabled = true, encryption: boolean = null, antivirus: boolean = null, - maxSize: number; - let byteUnit = writable('KB'); + maxSize: number, + compression: string = null; + let byteUnit = writable('MB'); let sizeInBytes: number = null; const options = [ { label: 'Bytes', value: 'Bytes' }, @@ -45,6 +46,11 @@ { label: 'Megabytes', value: 'MB' }, { label: 'Gigabytes', value: 'GB' } ]; + const compressionOptions = [ + { label: 'None', value: 'none' }, + { label: 'Gzip', value: 'gzip' }, + { label: 'Zstd', value: 'zstd' } + ]; let suggestedExtensions = ['jpg', 'png', 'svg', 'gif', 'html', 'pdf', 'mp4']; let extensions = $bucket.allowedFileExtensions; let isExtensionsDisabled = true; @@ -57,8 +63,10 @@ bucketPermissions ??= $bucket.$permissions; encryption ??= $bucket.encryption; antivirus ??= $bucket.antivirus; - maxSize = $bucket.maximumFileSize / 1024; + maxSize = $bucket.maximumFileSize / 1024 / 1024; + compression ??= $bucket.compression; }); + $: if (bucketPermissions) { if (symmetricDifference(bucketPermissions, $bucket.$permissions).length) { arePermsDisabled = false; @@ -192,6 +200,17 @@ ); } + function updateCompression() { + updateBucket( + { + compression + }, + { + trackEventName: 'submit_bucket_update_size' + } + ); + } + function updateAllowedExtensions() { updateBucket( { @@ -234,8 +253,8 @@ id="toggle" bind:value={enabled} /> -

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

-

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

+

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

+

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

@@ -320,7 +339,7 @@
Update Security Settings -

+

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

@@ -381,17 +400,40 @@
+
+ + Update Compression Algorithm +

+ Choose an algorithm for compression. For files larger than 20MB, compression + will be skipped even if it's enabled. +

+ + + + + + + + + +
+
+
Update Maximum File Size -

Set the maximum file size allowed in the bucket.

+

Set the maximum file size allowed in the bucket.

    Update Allowed File Extensions -

    +

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

    @@ -453,7 +495,7 @@ Delete Bucket -

    +

    The bucket will be permanently deleted, including all the files within it. This action is irreversible.

    @@ -462,7 +504,7 @@
    {$bucket.name}
    -

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

    +

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