From 388df9722b23b3e5817ce0f7ca278851c57c032f Mon Sep 17 00:00:00 2001 From: Net Date: Fri, 19 Jul 2024 14:33:29 +0700 Subject: [PATCH 01/19] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=E0=B8=AB=E0=B8=99=E0=B9=89=E0=B8=B2=E0=B9=81=E0=B8=AA?= =?UTF-8?q?=E0=B8=94=E0=B8=87=20schedule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../04_system/components/cardAutoBackup.vue | 401 ++++++++++++++++++ 1 file changed, 401 insertions(+) create mode 100644 src/modules/04_system/components/cardAutoBackup.vue diff --git a/src/modules/04_system/components/cardAutoBackup.vue b/src/modules/04_system/components/cardAutoBackup.vue new file mode 100644 index 00000000..116c1f2c --- /dev/null +++ b/src/modules/04_system/components/cardAutoBackup.vue @@ -0,0 +1,401 @@ + + + + + From f86a0d70cad53c216cd575702173c04ae6bad67b Mon Sep 17 00:00:00 2001 From: Net Date: Fri, 19 Jul 2024 14:33:29 +0700 Subject: [PATCH 02/19] =?UTF-8?q?=E0=B8=A5=E0=B8=9A=E0=B9=80=E0=B8=87?= =?UTF-8?q?=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=99=E0=B9=84=E0=B8=82=20?= =?UTF-8?q?=E0=B8=95=E0=B8=A3=E0=B8=A7=E0=B8=88=20backup=20=E0=B8=82?= =?UTF-8?q?=E0=B8=AD=E0=B8=87=20=E0=B8=9B=E0=B8=B8=E0=B9=88=E0=B8=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/04_system/components/cardBackupRestore.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/04_system/components/cardBackupRestore.vue b/src/modules/04_system/components/cardBackupRestore.vue index bda1b0a9..d6e139dc 100644 --- a/src/modules/04_system/components/cardBackupRestore.vue +++ b/src/modules/04_system/components/cardBackupRestore.vue @@ -156,7 +156,6 @@ onMounted(async () => {
Date: Fri, 19 Jul 2024 14:33:29 +0700 Subject: [PATCH 03/19] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20form=20=E0=B8=AA=E0=B8=A3=E0=B9=89=E0=B8=B2?= =?UTF-8?q?=E0=B8=87=20schedule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../04_system/components/formDialog.vue | 46 +++ .../04_system/components/formSchedule .vue | 269 ++++++++++++++++++ 2 files changed, 315 insertions(+) create mode 100644 src/modules/04_system/components/formDialog.vue create mode 100644 src/modules/04_system/components/formSchedule .vue diff --git a/src/modules/04_system/components/formDialog.vue b/src/modules/04_system/components/formDialog.vue new file mode 100644 index 00000000..ee4e0cb2 --- /dev/null +++ b/src/modules/04_system/components/formDialog.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/src/modules/04_system/components/formSchedule .vue b/src/modules/04_system/components/formSchedule .vue new file mode 100644 index 00000000..afb18b07 --- /dev/null +++ b/src/modules/04_system/components/formSchedule .vue @@ -0,0 +1,269 @@ + + + + + From 84e8af2e5b22dd1363b89bfa9fab162c048195d5 Mon Sep 17 00:00:00 2001 From: Net Date: Fri, 19 Jul 2024 14:33:29 +0700 Subject: [PATCH 04/19] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20type=20=20Schedule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/04_system/interface/request/Main.ts | 13 +++++++++++++ src/modules/04_system/interface/response/Main.ts | 13 ++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/modules/04_system/interface/request/Main.ts b/src/modules/04_system/interface/request/Main.ts index e69de29b..83547771 100644 --- a/src/modules/04_system/interface/request/Main.ts +++ b/src/modules/04_system/interface/request/Main.ts @@ -0,0 +1,13 @@ +interface ScheduleCreate { + name: string; + time: string; + timeStartEvery: string; + + timezone?: string; + type: string; + date: string[]; + schedule: string; + startAt?: string; +} + +export type { ScheduleCreate }; diff --git a/src/modules/04_system/interface/response/Main.ts b/src/modules/04_system/interface/response/Main.ts index b34204ef..690e30f4 100644 --- a/src/modules/04_system/interface/response/Main.ts +++ b/src/modules/04_system/interface/response/Main.ts @@ -32,4 +32,15 @@ interface BackUpRunning { tag: string; } -export type { DataBackup, BackUpRunning }; +interface Schedule { + type: string; + date: string; + time: string; + schedule: string; + name: string; + id: string; + timeStartEvery: string; + startAt?: string; +} + +export type { DataBackup, BackUpRunning, Schedule }; From a9ecba3a17ec8bfdfaef288bb841148e245ce70d Mon Sep 17 00:00:00 2001 From: Net Date: Fri, 19 Jul 2024 14:33:29 +0700 Subject: [PATCH 05/19] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20function=20Schedule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/04_system/stores/main.ts | 127 +++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/src/modules/04_system/stores/main.ts b/src/modules/04_system/stores/main.ts index 63de26a6..348a39bb 100644 --- a/src/modules/04_system/stores/main.ts +++ b/src/modules/04_system/stores/main.ts @@ -7,8 +7,10 @@ import { useCounterMixin } from "@/stores/mixin"; import type { DataBackup, BackUpRunning, + Schedule, } from "@/modules/04_system/interface/response/Main"; +import type { ScheduleCreate } from "@/modules/04_system/interface/request/Main"; import { ref } from "vue"; const mixin = useCounterMixin(); @@ -23,6 +25,7 @@ const { export const useDataStore = defineStore("systemStore", () => { const dataBackUp = ref([]); + const dataSchedule = ref([]); const prevBackupRunTotal = ref(-1); const backupRunTotal = ref(0); @@ -178,11 +181,130 @@ export const useDataStore = defineStore("systemStore", () => { return sizeNumber.toFixed(2) + " " + units[i]; } + function convertCronToForm(schedule: string, typeReturn: string): string { + let allValues = schedule.split(" "); + + if (typeReturn === "typeOfSchedule") { + if ( + allValues[3].includes("*") && + allValues[4].includes("*") && + allValues[5].includes("*") + ) { + return `daily`; + } + if ( + allValues[3].includes("*") && + allValues[4].includes("*") && + !allValues[5].includes("*") + ) { + return `weekly`; + } + if ( + !allValues[3].includes("*") && + allValues[4].includes("*") && + allValues[5].includes("*") + ) { + return `monthly`; + } + } + + console.log(allValues); + + if (typeReturn === "time") { + if (allValues[2].includes("/")) { + console.log(allValues[2]); + return ""; + } else { + return `${allValues[2]}:${allValues[1]}`; + } + } + + if (typeReturn === "timeStartEvery") { + return allValues[2].split("/")[1]; + } + + if (typeReturn === "date") { + return `${allValues[5].split(",")}`; + } + + return ""; + } + + async function getSchedule() { + showLoader(); + await http + .get(config.API.backup + "/schedule") + .then((res) => { + dataSchedule.value = res.data.map((item) => { + return { + id: item.id, + name: item.name, + schedule: item.schedule, + type: convertCronToForm(item.schedule, "typeOfSchedule") || "", + time: convertCronToForm(item.schedule, "time") || "", + date: convertCronToForm(item.schedule, "date") || "", + timeStartEvery: + convertCronToForm(item.schedule, "timeStartEvery") || "", + startAt: item.startAt, + }; + }); + + console.log(dataSchedule.value); + }) + .finally(() => { + hideLoader(); + }); + } + + async function createSchedule(data: ScheduleCreate) { + showLoader(); + await http + .post(config.API.backup + "/schedule", { + name: data.name, + schedule: data.schedule, + startAt: data.startAt !== undefined ? data.startAt : undefined, + }) + .then(async (res) => { + return res.data; + }) + .finally(() => { + hideLoader(); + }); + } + + async function editSchedule(data: ScheduleCreate) { + showLoader(); + await http + .put(config.API.backup + "/schedule", { + data, + }) + .then(async (res) => { + return res.data; + }) + .finally(() => { + hideLoader(); + }); + } + + async function deleteSchedule(id: string) { + showLoader(); + await http + .delete(config.API.backup + "/schedule/" + id) + .then(async (res) => { + await fetchListBackup(); + }) + .finally(() => { + hideLoader(); + }); + } + return { dataBackUp, backupRunTotal, restoreRunTotal, + dataSchedule, + fetchListBackup, createBackUp, restore, @@ -192,5 +314,10 @@ export const useDataStore = defineStore("systemStore", () => { restoreRunningList, getSize, + + getSchedule, + createSchedule, + editSchedule, + deleteSchedule, }; }); From a8db817f0b1fdde4ccdab1a6f32d66c5411df3bb Mon Sep 17 00:00:00 2001 From: Net Date: Fri, 19 Jul 2024 14:33:29 +0700 Subject: [PATCH 06/19] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20=20tab=20=E0=B8=82=E0=B8=AD=E0=B8=87=20=20Schedule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/04_system/views/MainView.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/04_system/views/MainView.vue b/src/modules/04_system/views/MainView.vue index f99f1856..e2a5a6ce 100644 --- a/src/modules/04_system/views/MainView.vue +++ b/src/modules/04_system/views/MainView.vue @@ -10,6 +10,7 @@ import type { ItemsTeb } from "@/modules/04_system/interface/index/Main"; * import components */ import Card from "@/modules/04_system/components/cardBackupRestore.vue"; +import CardAutoBackup from "@/modules/04_system/components/cardAutoBackup.vue"; /** * ตัวแปร @@ -17,6 +18,7 @@ import Card from "@/modules/04_system/components/cardBackupRestore.vue"; const tab = ref("backup"); const tabItems = ref([ { name: "backup", label: "Backup & Restore", icon: "mdi-database" }, + { name: "autoBackUp", label: "Schedule ", icon: "mdi-clock-outline" }, ]); @@ -48,11 +50,11 @@ const tabItems = ref([ - +
คืนค่า
- +
From 08ade18e871b5b5cf5c61a1f7a25b08d14d2ef12 Mon Sep 17 00:00:00 2001 From: Net Date: Fri, 19 Jul 2024 14:33:29 +0700 Subject: [PATCH 07/19] =?UTF-8?q?=E0=B8=97=E0=B8=B1=E0=B8=9A=20class=20=20?= =?UTF-8?q?=E0=B8=82=E0=B8=AD=E0=B8=87=20dialog=20=E0=B9=83=E0=B8=99=20Sch?= =?UTF-8?q?edule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/style/quasar-variables.sass | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/style/quasar-variables.sass b/src/style/quasar-variables.sass index 6ba90184..b5532343 100644 --- a/src/style/quasar-variables.sass +++ b/src/style/quasar-variables.sass @@ -174,3 +174,6 @@ h3.resigtry-tab-title overflow: hidden text-overflow: ellipsis width: 200px + +.dialog-content-top .q-dialog__inner + align-items: start \ No newline at end of file From 76a986033b85a17abd604a4740745ceb1f0e0c89 Mon Sep 17 00:00:00 2001 From: Net Date: Fri, 19 Jul 2024 14:33:29 +0700 Subject: [PATCH 08/19] =?UTF-8?q?=E0=B8=A5=E0=B8=9A=20code=20=E0=B9=84?= =?UTF-8?q?=E0=B8=A1=E0=B9=88=E0=B9=84=E0=B8=94=E0=B9=89=E0=B9=83=E0=B8=8A?= =?UTF-8?q?=E0=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../04_system/components/cardAutoBackup.vue | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/src/modules/04_system/components/cardAutoBackup.vue b/src/modules/04_system/components/cardAutoBackup.vue index 116c1f2c..466bfda8 100644 --- a/src/modules/04_system/components/cardAutoBackup.vue +++ b/src/modules/04_system/components/cardAutoBackup.vue @@ -14,7 +14,6 @@ import type { ItemsTeb } from "@/modules/04_system/interface/index/Main"; * import components */ import FormDialog from "@/modules/04_system/components/formDialog.vue"; -import FormAutoBackup from "@/modules/04_system/components/formAutoBackup.vue"; import formSchedule from "./formSchedule .vue"; /** * importStore @@ -371,30 +370,7 @@ onMounted(async () => { v-model:tab="tab" />
- - - - From ce00f149d3a97ac77107f9ddd8d17542e2a80a2b Mon Sep 17 00:00:00 2001 From: Net Date: Fri, 19 Jul 2024 14:33:29 +0700 Subject: [PATCH 09/19] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=84?= =?UTF-8?q?=E0=B8=B3=20=E0=B9=80=E0=B8=A3=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B9=80=E0=B8=A7=E0=B8=A5=E0=B8=B2=20->=20=20=E0=B8=97?= =?UTF-8?q?=E0=B8=B3=E0=B8=8B=E0=B9=89=E0=B8=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/04_system/components/formSchedule .vue | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/modules/04_system/components/formSchedule .vue b/src/modules/04_system/components/formSchedule .vue index afb18b07..ccc7b7a4 100644 --- a/src/modules/04_system/components/formSchedule .vue +++ b/src/modules/04_system/components/formSchedule .vue @@ -43,7 +43,7 @@ watch(tab, () => {
- เริ่มเวลา + ทำซ้ำ
@@ -75,6 +75,7 @@ watch(tab, () => { option-label="value" option-value="value" map-options + suffix="ชั่วโมง" />
@@ -83,7 +84,7 @@ watch(tab, () => {
- เริ่มเวลา + ทำซ้ำ {
- เริ่มเวลา + ทำซ้ำ {
- วันที่เริ่มการสำรองข้อมูล + วันที่ - เวลาเริ่มการสำรองข้อมูล