diff --git a/web/src/lib/components/forms/create-user-form.svelte b/web/src/lib/components/forms/create-user-form.svelte index e63741290e..2d3ab93410 100644 --- a/web/src/lib/components/forms/create-user-form.svelte +++ b/web/src/lib/components/forms/create-user-form.svelte @@ -5,6 +5,7 @@ import { notificationController, NotificationType } from '../shared-components/notification/notification'; import Button from '../elements/buttons/button.svelte'; import { convertToBytes } from '$lib/utils/byte-converter'; + import { serverInfo } from '$lib/stores/server-info.store'; let error: string; let success: string; @@ -13,9 +14,11 @@ let confirmPassowrd = ''; let canCreateUser = false; - + let quotaSize: number | undefined = undefined; let isCreatingUser = false; + $: quotaSizeWarning = quotaSize && convertToBytes(Number(quotaSize), 'GiB') > $serverInfo.diskSizeRaw; + $: { if (password !== confirmPassowrd && confirmPassowrd.length > 0) { error = 'Password does not match'; @@ -121,8 +124,12 @@
- - + +
{#if error} diff --git a/web/src/lib/components/forms/edit-user-form.svelte b/web/src/lib/components/forms/edit-user-form.svelte index b3dda00a03..218cd427fb 100644 --- a/web/src/lib/components/forms/edit-user-form.svelte +++ b/web/src/lib/components/forms/edit-user-form.svelte @@ -10,14 +10,22 @@ import CircleIconButton from '../elements/buttons/circle-icon-button.svelte'; import { handleError } from '$lib/utils/handle-error'; import { convertFromBytes, convertToBytes } from '$lib/utils/byte-converter'; + import { serverInfo } from '$lib/stores/server-info.store'; export let user: UserResponseDto; export let canResetPassword = true; let error: string; let success: string; - let isShowResetPasswordConfirmation = false; + let quotaSize = user.quotaSizeInBytes ? convertFromBytes(user.quotaSizeInBytes, 'GiB') : null; + + const previousQutoa = user.quotaSizeInBytes; + + $: quotaSizeWarning = + previousQutoa !== convertToBytes(Number(quotaSize), 'GiB') && + !!quotaSize && + convertToBytes(Number(quotaSize), 'GiB') > $serverInfo.diskSizeRaw; const dispatch = createEventDispatcher<{ close: void; @@ -25,8 +33,6 @@ editSuccess: void; }>(); - let quotaSize = user.quotaSizeInBytes ? convertFromBytes(user.quotaSizeInBytes, 'GiB') : null; - const editUser = async () => { try { const { id, email, name, storageLabel, externalPath } = user; @@ -102,7 +108,11 @@
- +

Note: Enter 0 for unlimited quota

diff --git a/web/src/lib/components/shared-components/status-box.svelte b/web/src/lib/components/shared-components/status-box.svelte index 92c4575680..a59225d043 100644 --- a/web/src/lib/components/shared-components/status-box.svelte +++ b/web/src/lib/components/shared-components/status-box.svelte @@ -2,13 +2,13 @@ import Icon from '$lib/components/elements/icon.svelte'; import { locale } from '$lib/stores/preferences.store'; import { websocketStore } from '$lib/stores/websocket'; - import { api } from '@api'; import { onMount } from 'svelte'; import { asByteUnitString } from '../../utils/byte-units'; import LoadingSpinner from './loading-spinner.svelte'; import { mdiChartPie, mdiDns } from '@mdi/js'; - import { serverInfoStore } from '$lib/stores/server-info.store'; + import { serverInfo } from '$lib/stores/server-info.store'; import { user } from '$lib/stores/user.store'; + import { requestServerInfo } from '$lib/utils/auth'; const { serverVersion, connected } = websocketStore; @@ -16,8 +16,8 @@ $: version = $serverVersion ? `v${$serverVersion.major}.${$serverVersion.minor}.${$serverVersion.patch}` : null; $: hasQuota = $user?.quotaSizeInBytes !== null; - $: availableBytes = (hasQuota ? $user?.quotaSizeInBytes : $serverInfoStore?.diskSizeRaw) || 0; - $: usedBytes = (hasQuota ? $user?.quotaUsageInBytes : $serverInfoStore?.diskUseRaw) || 0; + $: availableBytes = (hasQuota ? $user?.quotaSizeInBytes : $serverInfo?.diskSizeRaw) || 0; + $: usedBytes = (hasQuota ? $user?.quotaUsageInBytes : $serverInfo?.diskUseRaw) || 0; $: usedPercentage = Math.round((usedBytes / availableBytes) * 100); const onUpdate = () => { @@ -39,19 +39,8 @@ $: $user && onUpdate(); onMount(async () => { - await refresh(); + await requestServerInfo(); }); - - const refresh = async () => { - try { - if (!$serverInfoStore) { - const { data } = await api.serverInfoApi.getServerInfo(); - $serverInfoStore = data; - } - } catch (e) { - console.log('Error [StatusBox] [onMount]'); - } - };
@@ -64,7 +53,7 @@