Merge branch 'dev-log' into develop

This commit is contained in:
Net 2024-07-25 17:16:51 +07:00
commit a1a5e613c9
3 changed files with 25 additions and 7 deletions

View file

@ -214,9 +214,9 @@ function onRestore(name: string) {
? col.value ? col.value
: col.value === "สำเร็จ" : col.value === "สำเร็จ"
? "สำเร็จ" ? "สำเร็จ"
: i === 2 || i === 3 : // : i === 2 || i === 3
? getSize(col.value) // ? getSize(col.value)
: "" ""
}} }}
<q-circular-progress <q-circular-progress
@ -231,6 +231,7 @@ function onRestore(name: string) {
</q-td> </q-td>
<q-td> <q-td>
<q-btn <q-btn
v-if="props.row.status !== 'running'"
dense dense
flat flat
round round
@ -243,6 +244,7 @@ function onRestore(name: string) {
</q-btn> </q-btn>
<q-btn <q-btn
v-if="props.row.status !== 'running'"
dense dense
flat flat
round round

View file

@ -76,7 +76,12 @@ export const useDataStore = defineStore("systemStore", () => {
data: { name: filename }, data: { name: filename },
}) })
.then(async (res) => { .then(async (res) => {
await fetchListBackup(); if (res.status < 400) {
dataBackUp.value = dataBackUp.value.filter((item) => {
if (item.name !== filename) return true;
return false;
});
}
}) })
.finally(() => { .finally(() => {
hideLoader(); hideLoader();
@ -109,8 +114,8 @@ export const useDataStore = defineStore("systemStore", () => {
.then(async (res) => { .then(async (res) => {
backupRunTotal.value = res.data.length; backupRunTotal.value = res.data.length;
if (backupRunTotal.value === 0 && prevBackupRunTotal.value !== 0) { if (backupRunTotal.value === 0) {
cb(); if (prevBackupRunTotal.value !== -1) cb();
prevBackupRunTotal.value = backupRunTotal.value; prevBackupRunTotal.value = backupRunTotal.value;
return; return;
} }
@ -147,7 +152,7 @@ export const useDataStore = defineStore("systemStore", () => {
.get<BackUpRunning[]>(config.API.backup + "/restore-running-list") .get<BackUpRunning[]>(config.API.backup + "/restore-running-list")
.then(async (res) => { .then(async (res) => {
restoreRunTotal.value = res.data.length; restoreRunTotal.value = res.data.length;
if (restoreRunTotal.value === 0 && prevRestoreRunTotal.value !== 0) { if (restoreRunTotal.value === 0) {
cb(); cb();
prevRestoreRunTotal.value = restoreRunTotal.value; prevRestoreRunTotal.value = restoreRunTotal.value;
return; return;
@ -324,9 +329,13 @@ export const useDataStore = defineStore("systemStore", () => {
return { return {
dataBackUp, dataBackUp,
backupRunTotal, backupRunTotal,
restoreRunTotal, restoreRunTotal,
prevBackupRunTotal,
prevRestoreRunTotal,
dataSchedule, dataSchedule,
fetchListBackup, fetchListBackup,

View file

@ -13,12 +13,17 @@ import Card from "@/modules/04_system/components/cardBackupRestore.vue";
import CardAutoBackup from "@/modules/04_system/components/cardAutoBackup.vue"; import CardAutoBackup from "@/modules/04_system/components/cardAutoBackup.vue";
import { useDataStore } from "@/modules/04_system/stores/main"; import { useDataStore } from "@/modules/04_system/stores/main";
import { storeToRefs } from "pinia";
const { fetchListBackup, backupRunningList, restoreRunningList } = const { fetchListBackup, backupRunningList, restoreRunningList } =
useDataStore(); useDataStore();
/** /**
* วแปร * วแปร
*/ */
const storeData = useDataStore();
const { prevBackupRunTotal, prevRestoreRunTotal } = storeToRefs(storeData);
const tab = ref<string>("backup"); const tab = ref<string>("backup");
const tabItems = ref<ItemsTeb[]>([ const tabItems = ref<ItemsTeb[]>([
{ name: "backup", label: "Backup & Restore", icon: "mdi-database" }, { name: "backup", label: "Backup & Restore", icon: "mdi-database" },
@ -26,6 +31,8 @@ const tabItems = ref<ItemsTeb[]>([
]); ]);
onMounted(async () => { onMounted(async () => {
prevBackupRunTotal.value = -1;
prevRestoreRunTotal.value = -1;
await fetchListBackup(); await fetchListBackup();
await backupRunningList(fetchListBackup); await backupRunningList(fetchListBackup);
await restoreRunningList(() => {}); await restoreRunningList(() => {});