From 2765d745f41be166efb80d080fcbb8927c0a8d47 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Wed, 10 Jul 2024 17:42:25 +0700 Subject: [PATCH 1/5] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20=20backUp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.config.ts | 142 ++++++++++++++++++++++++---------------------- 1 file changed, 74 insertions(+), 68 deletions(-) diff --git a/src/app.config.ts b/src/app.config.ts index fba62b74..10f02edb 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -1,107 +1,113 @@ /**ใช้รวมไฟล์ย่อยๆ ของ api แต่ละไฟล์ */ /** API Metadata */ -import manageOrganization from "./api/manage/api.organization" -import managePerson from "./api/manage/api.person" -import managePosition from "./api/manage/api.position" -import managePositionEmployee from "./api/manage/api.positionEmployee" -import manageInsignia from "./api/manage/api.insignia" -import manageHoliday from "./api/manage/api.holiday" +import manageOrganization from "./api/manage/api.organization"; +import managePerson from "./api/manage/api.person"; +import managePosition from "./api/manage/api.position"; +import managePositionEmployee from "./api/manage/api.positionEmployee"; +import manageInsignia from "./api/manage/api.insignia"; +import manageHoliday from "./api/manage/api.holiday"; /** API Tree List */ -import organizationTreeList from "./api/02_organizational/api.treelist" +import organizationTreeList from "./api/02_organizational/api.treelist"; /** API Structure & Org Chart */ -import organizationChart from "./api/02_organizational/api.chart" +import organizationChart from "./api/02_organizational/api.chart"; /** API Profile List */ -import profile from "./api/registry/api.profile" -import registry from "./api/registry/api.registry" +import profile from "./api/registry/api.profile"; +import registry from "./api/registry/api.registry"; /** API dashboard */ -import message from "./api/00_dashboard/api.message" +import message from "./api/00_dashboard/api.message"; /** API reports */ -import reports from "./api/reports/api.report" +import reports from "./api/reports/api.report"; /** API โครงสร้างอัตรากำลัง*/ -import organization from "./api/02_organizational/api.organization" +import organization from "./api/02_organizational/api.organization"; -import file from "./api/file/api.file" +import file from "./api/file/api.file"; /** API ManagementUsers*/ -import menagement from "./api/manage/api.management" +import menagement from "./api/manage/api.management"; /** API ระเมินผลการปฏิบัติราชการระดับบุคคล*/ -import KPI from "./api/14_KPI/api.KPI" +import KPI from "./api/14_KPI/api.KPI"; /** API เงินเดือน/ค่าจ้าง*/ -import development from "./api/15_development/api.development" +import development from "./api/15_development/api.development"; + +/** API BackUp/*/ +import backup from "./api/04_system/api.backup"; // environment variables -export const compettitivePanel = import.meta.env.VITE_COMPETITIVE_EXAM_PANEL -export const qualifyDisableExamPanel = import.meta.env.VITE_QUALIFY_DISABLE_EMAM_PANEL -export const qualifyExamPanel = import.meta.env.VITE_QUALIFY_EXAM_PANEL +export const compettitivePanel = import.meta.env.VITE_COMPETITIVE_EXAM_PANEL; +export const qualifyDisableExamPanel = import.meta.env + .VITE_QUALIFY_DISABLE_EMAM_PANEL; +export const qualifyExamPanel = import.meta.env.VITE_QUALIFY_EXAM_PANEL; -const path = "http://chamomind.ddns.net:20006" +const path = "http://chamomind.ddns.net:20006"; const generatePopupPath = (routeName: any) => { - if (routeName.includes("viewLogs")) { - return `${path}/build-and-deploy` - } - if (routeName.includes("manageUsers")) { - return `${path}/build-and-deploy` - } - if (routeName.includes("manageRoles")) { - return `${path}/build-and-deploy` - } - if (routeName.includes("managePermission")) { - return `${path}/build-and-deploy` - } else { - return manualConfig[routeName as keyof typeof manualConfig] - } -} + if (routeName.includes("viewLogs")) { + return `${path}/build-and-deploy`; + } + if (routeName.includes("manageUsers")) { + return `${path}/build-and-deploy`; + } + if (routeName.includes("manageRoles")) { + return `${path}/build-and-deploy`; + } + if (routeName.includes("managePermission")) { + return `${path}/build-and-deploy`; + } else { + return manualConfig[routeName as keyof typeof manualConfig]; + } +}; const manualConfig = { - dashboard: `${path}/build-and-deploy`, -} + dashboard: `${path}/build-and-deploy`, +}; const API = { - //Metadata - ...manageOrganization, - ...managePerson, - ...managePosition, - ...managePositionEmployee, - ...manageInsignia, - ...manageHoliday, + //Metadata + ...manageOrganization, + ...managePerson, + ...managePosition, + ...managePositionEmployee, + ...manageInsignia, + ...manageHoliday, - // โครงสร้างอัตรากำลัง - ...organization, + // โครงสร้างอัตรากำลัง + ...organization, - //Tree List - ...organizationTreeList, - ...organizationChart, + //Tree List + ...organizationTreeList, + ...organizationChart, - //profile - ...profile, - ...registry, + //profile + ...profile, + ...registry, - //dashboard - ...message, + //dashboard + ...message, - //reports - ...reports, + //reports + ...reports, - /*file*/ - ...file, + /*file*/ + ...file, - /** menagement*/ - ...menagement, - /** KPI*/ - ...KPI, - ...development, -} + /** menagement*/ + ...menagement, + /** KPI*/ + ...KPI, + ...development, + /** backup*/ + ...backup, +}; export default { - API: API, - generatePopupPath, -} + API: API, + generatePopupPath, +}; From 3ad75ba89016242cf74de6933ea68195827cdcd1 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Wed, 10 Jul 2024 17:42:43 +0700 Subject: [PATCH 2/5] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20=20api=20=20backUp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/04_system/api.backup.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/api/04_system/api.backup.ts diff --git a/src/api/04_system/api.backup.ts b/src/api/04_system/api.backup.ts new file mode 100644 index 00000000..ffc431a8 --- /dev/null +++ b/src/api/04_system/api.backup.ts @@ -0,0 +1,9 @@ +import env from "../index"; + +const backup = `http://192.168.1.90:20007/api/v1/backup`; +const restore = `http://192.168.1.90:20007/api/v1/backup/restore`; + +export default { + backup, + restore, +}; From f28d426b176385be726eec536686e3c2544d0caa Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Wed, 10 Jul 2024 17:43:10 +0700 Subject: [PATCH 3/5] =?UTF-8?q?=E0=B8=95=E0=B9=88=E0=B8=AD=20api=20=20back?= =?UTF-8?q?Up?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/04_system/stores/main.ts | 68 ++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/modules/04_system/stores/main.ts diff --git a/src/modules/04_system/stores/main.ts b/src/modules/04_system/stores/main.ts new file mode 100644 index 00000000..5e7287af --- /dev/null +++ b/src/modules/04_system/stores/main.ts @@ -0,0 +1,68 @@ +import { defineStore } from "pinia"; +import http from "@/plugins/http"; +import config from "@/app.config"; + +import { useCounterMixin } from "@/stores/mixin"; + +import type { DataBackup } from "@/modules/04_system/interface/response/Main"; + +import { ref } from "vue"; + +const mixin = useCounterMixin(); +const { + dialogRemove, + messageError, + showLoader, + hideLoader, + success, + dialogConfirm, +} = mixin; + +export const useDataStore = defineStore("storeData", () => { + const dataBackUp = ref([]); + + async function fetchListBackup() { + showLoader(); + await http + .get(config.API.backup) + .then((res) => { + dataBackUp.value = res.data; + }) + .finally(() => { + hideLoader(); + }); + } + + async function createBackUp() { + showLoader(); + await http + .post(config.API.backup + "/create") + .then(async (res) => { + fetchListBackup(); + }) + .finally(() => { + console.log("aye"); + hideLoader(); + }); + } + + async function restore(filename: string) { + showLoader(); + await http + .post(config.API.restore + "?filename=" + filename + "") + .then((res) => { + fetchListBackup(); + }) + .finally(() => { + hideLoader(); + }); + } + + return { + dataBackUp, + + fetchListBackup, + createBackUp, + restore, + }; +}); From 662d8fa7b3062b1c272c8d29162318d33535fe60 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Wed, 10 Jul 2024 17:43:26 +0700 Subject: [PATCH 4/5] =?UTF-8?q?by=20=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1?= =?UTF-8?q?=E0=B8=B9=E0=B8=A5=20=20backUp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/cardBackupRestore.vue | 58 +++++-------------- 1 file changed, 14 insertions(+), 44 deletions(-) diff --git a/src/modules/04_system/components/cardBackupRestore.vue b/src/modules/04_system/components/cardBackupRestore.vue index 2f540a4f..17b6bcc4 100644 --- a/src/modules/04_system/components/cardBackupRestore.vue +++ b/src/modules/04_system/components/cardBackupRestore.vue @@ -12,6 +12,8 @@ import type { DataBackup } from "@/modules/04_system/interface/response/Main"; * importStore */ import { useCounterMixin } from "@/stores/mixin"; +import { useDataStore } from "@/modules/04_system/stores/main"; +import { storeToRefs } from "pinia"; /** * use @@ -19,6 +21,9 @@ import { useCounterMixin } from "@/stores/mixin"; const $q = useQuasar(); const { showLoader, hideLoader, date2Thai, dialogRemove, dialogConfirm } = useCounterMixin(); +const { fetchListBackup, createBackUp, restore } = useDataStore(); +const storeData = useDataStore(); +const { dataBackUp } = storeToRefs(storeData); /** * props @@ -28,7 +33,6 @@ const tab = defineModel("tab", { required: true }); /** * Table */ -const rows = ref([]); const filter = ref(""); const visibleColumns = ref(["name", "createAt", "status"]); const baseColumns = ref([ @@ -50,15 +54,6 @@ const baseColumns = ref([ headerStyle: "font-size: 14px", style: "font-size: 14px", }, - { - name: "status", - align: "left", - label: "สถานะ", - sortable: true, - field: "status", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, ]); const columns = computed(() => { if (tab.value === "restore") { @@ -69,40 +64,15 @@ const columns = computed(() => { return baseColumns.value; }); -/** - * function เรียกข้อมูลรายการสำรอง - */ -function fetchListBackup() { - showLoader(); - const data: DataBackup[] = [ - { - id: "1", - name: "สำรอง1", - createAt: new Date(), - status: "ดำเนินการ", - }, - { - id: "2", - name: "สำรอง2", - createAt: new Date(), - status: "ดำเนินการ", - }, - ]; - rows.value = data; - setTimeout(() => { - hideLoader(); - }, 500); -} - /** * function สร้างรายการข้อมูสำรอง */ function onCreateBackup() { dialogConfirm( $q, - () => { + async () => { showLoader(); - fetchListBackup(); + await createBackUp(); }, "ยืนยันการสร้างข้อมูสำรอง", "ต้องการยืนยันการสร้างข้อมูสำรองใช่หรือไม่?" @@ -124,20 +94,20 @@ function onDelete(id: string) { * function คืนค่าข้อมูสำรอง * @param id ข้อมูสำรอง */ -function onRestore(id: string) { +function onRestore(name: string) { dialogConfirm( $q, - () => { + async () => { showLoader(); - fetchListBackup(); + await restore(name); }, "ยืนยันการคืนค่าข้อมูสำรอง", "ต้องการยืนยันการคืนค่าข้อมูสำรองนี้ใช่หรือไม่?" ); } -onMounted(() => { - fetchListBackup(); +onMounted(async () => { + await fetchListBackup(); }); @@ -184,7 +154,7 @@ onMounted(() => { { icon="restore" color="primary" size="12px" - @click.petvent="onRestore(props.row.id)" + @click.petvent="onRestore(props.row.name)" > คืนค่า From c417262c6ab81a40357b0ad95f04ad1dd0949394 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Wed, 10 Jul 2024 17:51:13 +0700 Subject: [PATCH 5/5] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20=E0=B8=A5=E0=B8=9A=20=20backUp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/cardBackupRestore.vue | 10 +++++----- src/modules/04_system/stores/main.ts | 20 +++++++++++++++++-- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/modules/04_system/components/cardBackupRestore.vue b/src/modules/04_system/components/cardBackupRestore.vue index 17b6bcc4..90fdf943 100644 --- a/src/modules/04_system/components/cardBackupRestore.vue +++ b/src/modules/04_system/components/cardBackupRestore.vue @@ -21,7 +21,7 @@ import { storeToRefs } from "pinia"; const $q = useQuasar(); const { showLoader, hideLoader, date2Thai, dialogRemove, dialogConfirm } = useCounterMixin(); -const { fetchListBackup, createBackUp, restore } = useDataStore(); +const { fetchListBackup, createBackUp, restore, deleteBackUp } = useDataStore(); const storeData = useDataStore(); const { dataBackUp } = storeToRefs(storeData); @@ -83,10 +83,10 @@ function onCreateBackup() { * function ลบรายการข้อมูสำรอง * @param id รายการสำรอง */ -function onDelete(id: string) { - dialogRemove($q, () => { +function onDelete(name: string) { + dialogRemove($q, async () => { showLoader(); - fetchListBackup(); + deleteBackUp(name); }); } @@ -184,7 +184,7 @@ onMounted(async () => { icon="delete" color="red" size="12px" - @click.petvent="onDelete(props.row.id)" + @click.petvent="onDelete(props.row.name)" > ลบข้อมูลสำรอง diff --git a/src/modules/04_system/stores/main.ts b/src/modules/04_system/stores/main.ts index 5e7287af..d43c7683 100644 --- a/src/modules/04_system/stores/main.ts +++ b/src/modules/04_system/stores/main.ts @@ -41,7 +41,20 @@ export const useDataStore = defineStore("storeData", () => { fetchListBackup(); }) .finally(() => { - console.log("aye"); + hideLoader(); + }); + } + + async function deleteBackUp(filename: string) { + showLoader(); + await http + .delete(config.API.backup + "/delete", { + data: { filename: filename }, + }) + .then(async (res) => { + fetchListBackup(); + }) + .finally(() => { hideLoader(); }); } @@ -49,7 +62,9 @@ export const useDataStore = defineStore("storeData", () => { async function restore(filename: string) { showLoader(); await http - .post(config.API.restore + "?filename=" + filename + "") + .post(config.API.restore, { + filename: filename, + }) .then((res) => { fetchListBackup(); }) @@ -64,5 +79,6 @@ export const useDataStore = defineStore("storeData", () => { fetchListBackup, createBackUp, restore, + deleteBackUp, }; });