From fc1f30b6b43cc5cb721b25f94ae586531cd6f7c7 Mon Sep 17 00:00:00 2001 From: Net Date: Tue, 16 Jul 2024 14:59:33 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=20restore=20?= =?UTF-8?q?=E0=B8=AA=E0=B9=88=E0=B8=87=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/04_system/stores/main.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/modules/04_system/stores/main.ts b/src/modules/04_system/stores/main.ts index 57682bf5..c6baf993 100644 --- a/src/modules/04_system/stores/main.ts +++ b/src/modules/04_system/stores/main.ts @@ -79,7 +79,7 @@ export const useDataStore = defineStore("systemStore", () => { async function restore(filename: string) { await http .post(config.API.restore, { - filename: filename, + name: filename, }) .then(async (res) => { const tempValue = dataBackUp.value.find((item) => { @@ -122,6 +122,8 @@ export const useDataStore = defineStore("systemStore", () => { dataBackUp.value.unshift({ id: item.created_at.toString(), name: "-", + databaseSize: 0, + storageSize: 0, timestamp: item.created_at, status: item.running ? "running" : "success", }); @@ -163,6 +165,19 @@ export const useDataStore = defineStore("systemStore", () => { }); } + function getSize(size: number): string { + if (size === undefined) return "Unknow size"; + + const units = ["B", "KB", "MB", "GB", "TB"]; + + let i = 0; + let sizeNumber = typeof size === "string" ? parseFloat(size) : size; + while (sizeNumber >= 1024 && i++ < units.length - 1) { + sizeNumber /= 1024; + } + return sizeNumber.toFixed(2) + " " + units[i]; + } + return { dataBackUp, backupRunTotal, @@ -175,5 +190,7 @@ export const useDataStore = defineStore("systemStore", () => { backupRunningList, restoreRunningList, + + getSize, }; });