diff --git a/frontend/src/network/network.ts b/frontend/src/network/network.ts index 8cebcf9..42be073 100644 --- a/frontend/src/network/network.ts +++ b/frontend/src/network/network.ts @@ -448,8 +448,14 @@ class Network { } } - async createS3Storage(name: string, endPoint: string, accessKeyID: string, - secretAccessKey: string, bucketName: string, maxSizeInMB: number): Promise> { + async createS3Storage( + name: string, + endPoint: string, + accessKeyID: string, + secretAccessKey: string, + bucketName: string, + maxSizeInMB: number, + domain: string): Promise> { try { const response = await axios.post(`${this.apiBaseUrl}/storage/s3`, { name, @@ -457,7 +463,8 @@ class Network { accessKeyID, secretAccessKey, bucketName, - maxSizeInMB + maxSizeInMB, + domain }); return response.data; } catch (e: any) { diff --git a/frontend/src/pages/manage_storage_page.tsx b/frontend/src/pages/manage_storage_page.tsx index 4de19ad..5d8078c 100644 --- a/frontend/src/pages/manage_storage_page.tsx +++ b/frontend/src/pages/manage_storage_page.tsx @@ -1,10 +1,10 @@ -import {useEffect, useState} from "react"; -import {Storage} from "../network/models.ts"; -import {network} from "../network/network.ts"; +import { useEffect, useState } from "react"; +import { Storage } from "../network/models.ts"; +import { network } from "../network/network.ts"; import showToast from "../components/toast.ts"; import Loading from "../components/loading.tsx"; -import {MdAdd, MdDelete} from "react-icons/md"; -import {ErrorAlert} from "../components/alert.tsx"; +import { MdAdd, MdDelete } from "react-icons/md"; +import { ErrorAlert } from "../components/alert.tsx"; import { useTranslation } from "react-i18next"; import { app } from "../app.ts"; @@ -30,15 +30,15 @@ export default function StorageView() { }, []); if (!app.user) { - return + return } if (!app.user?.is_admin) { - return + return } if (storages == null) { - return + return } const updateStorages = async () => { @@ -77,9 +77,9 @@ export default function StorageView() { return <>
+ className="h-6 w-6 shrink-0 stroke-current"> + d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"> {t("No storage found. Please create a new storage.")} @@ -88,60 +88,60 @@ export default function StorageView() {
- - - - - - + + + + + + - { - storages.map((s) => { - return - - - - + + + + - - }) - } + + + + }) + }
{t("Name")}{t("Created At")}{t("Space")}{t("Action")}
{t("Name")}{t("Created At")}{t("Space")}{t("Action")}
- {s.name} - - {(new Date(s.createdAt)).toLocaleString()} - - {(s.currentSize/1024/1024).toFixed(2)} / {s.maxSize/1024/1024} MB - - - -
-

{t("Delete Storage")}

-

- {t("Are you sure you want to delete this storage? This action cannot be undone.")} -

-
-
- -
- + { + storages.map((s) => { + return
+ {s.name} + + {(new Date(s.createdAt)).toLocaleString()} + + {(s.currentSize / 1024 / 1024).toFixed(2)} / {s.maxSize / 1024 / 1024} MB + + + +
+

{t("Delete Storage")}

+

+ {t("Are you sure you want to delete this storage? This action cannot be undone.")} +

+
+
+ +
+ +
- -
-
- +
} @@ -151,7 +151,7 @@ enum StorageType { s3, } -function NewStorageDialog({onAdded}: { onAdded: () => void }) { +function NewStorageDialog({ onAdded }: { onAdded: () => void }) { const { t } = useTranslation(); const [storageType, setStorageType] = useState(null); @@ -163,6 +163,7 @@ function NewStorageDialog({onAdded}: { onAdded: () => void }) { secretAccessKey: "", bucketName: "", maxSizeInMB: 0, + domain: "", }); const [isLoading, setIsLoading] = useState(false); @@ -189,7 +190,7 @@ function NewStorageDialog({onAdded}: { onAdded: () => void }) { setIsLoading(false); return; } - response = await network.createS3Storage(params.name, params.endPoint, params.accessKeyID, params.secretAccessKey, params.bucketName, params.maxSizeInMB); + response = await network.createS3Storage(params.name, params.endPoint, params.accessKeyID, params.secretAccessKey, params.bucketName, params.maxSizeInMB, params.domain); } if (response!.success) { @@ -206,11 +207,11 @@ function NewStorageDialog({onAdded}: { onAdded: () => void }) { } return <> - @@ -221,13 +222,13 @@ function NewStorageDialog({onAdded}: { onAdded: () => void }) {
{ setStorageType(null); - }}/> + }} /> { setStorageType(StorageType.local); - }}/> + }} /> { setStorageType(StorageType.s3); - }}/> + }} />
{ @@ -239,7 +240,7 @@ function NewStorageDialog({onAdded}: { onAdded: () => void }) { ...params, name: e.target.value, }) - }}/> + }} /> +