mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
@@ -24,13 +24,17 @@ export function bytesToSize(value: number, unit: Size) {
|
||||
return value / Math.pow(1024, index);
|
||||
}
|
||||
|
||||
export function humanFileSize(bytes: number): {
|
||||
export function humanFileSize(
|
||||
bytes: number,
|
||||
useBits = false
|
||||
): {
|
||||
value: string;
|
||||
unit: Size;
|
||||
} {
|
||||
if (typeof bytes !== 'number') return { value: '0', unit: 'Bytes' };
|
||||
const value = prettyBytes(bytes, {
|
||||
locale: 'en'
|
||||
locale: 'en',
|
||||
bits: useBits
|
||||
}).split(' ');
|
||||
|
||||
return {
|
||||
|
||||
@@ -73,12 +73,12 @@ export function createTimeUnitPair(initialValue = 0) {
|
||||
return { ...createValueUnitPair(initialValue, units), units };
|
||||
}
|
||||
|
||||
export function createByteUnitPair(initialValue = 0) {
|
||||
export function createByteUnitPair(initialValue = 0, base = 1024) {
|
||||
const units: Unit[] = [
|
||||
{ name: 'Bytes', value: 1 },
|
||||
{ name: 'Kilobytes', value: 1024 },
|
||||
{ name: 'Megabytes', value: 1024 ** 2 },
|
||||
{ name: 'Gigabytes', value: 1024 ** 3 }
|
||||
{ name: 'Kilobytes', value: base },
|
||||
{ name: 'Megabytes', value: base ** 2 },
|
||||
{ name: 'Gigabytes', value: base ** 3 }
|
||||
];
|
||||
return { ...createValueUnitPair(initialValue, units), units };
|
||||
}
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@
|
||||
import { updateBucket } from './+page.svelte';
|
||||
|
||||
const service = getServiceLimit('fileSize');
|
||||
const { value, unit, baseValue, units } = createByteUnitPair($bucket.maximumFileSize);
|
||||
const { value, unit, baseValue, units } = createByteUnitPair($bucket.maximumFileSize, 1000);
|
||||
const options = units.map((v) => ({ label: v.name, value: v.name }));
|
||||
|
||||
function updateMaxSize() {
|
||||
@@ -36,7 +36,7 @@
|
||||
<p class="text">Set the maximum file size allowed in the bucket.</p>
|
||||
<svelte:fragment slot="aside">
|
||||
{#if isCloud}
|
||||
{@const size = humanFileSize(sizeToBytes(service, 'GB', 1024))}
|
||||
{@const size = humanFileSize(sizeToBytes(service, 'MB', 1000))}
|
||||
{@const plan = tierToPlan($organization?.billingPlan)}
|
||||
<Alert type="info">
|
||||
<p class="text">
|
||||
|
||||
Reference in New Issue
Block a user