diff --git a/src/api/06_webservices/api.webservices.ts b/src/api/06_webservices/api.webservices.ts new file mode 100644 index 00000000..3185bd13 --- /dev/null +++ b/src/api/06_webservices/api.webservices.ts @@ -0,0 +1,7 @@ +import env from "../index"; + +const apiKey = `${env.API_URI}/org/apiKey`; + +export default { + apiKeyMain: apiKey, +}; diff --git a/src/app.config.ts b/src/app.config.ts index e989d051..25576725 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -46,6 +46,9 @@ import backup from "./api/04_system/api.backup"; /** API Command/*/ import command from "./api/05_command/api.command"; +/** API Webservices*/ +import webservices from "./api/06_webservices/api.webservices"; + // environment variables export const compettitivePanel = import.meta.env.VITE_COMPETITIVE_EXAM_PANEL; export const qualifyDisableExamPanel = import.meta.env @@ -120,6 +123,8 @@ const API = { ...backup, /** command*/ ...command, + /** webservices*/ + ...webservices, }; export default { diff --git a/src/modules/06_webservices/components/DialogApiKey.vue b/src/modules/06_webservices/components/DialogApiKey.vue index 2320615b..c1687dfa 100644 --- a/src/modules/06_webservices/components/DialogApiKey.vue +++ b/src/modules/06_webservices/components/DialogApiKey.vue @@ -1,76 +1,155 @@ + - + - + + - - API ที่เข้าถึงได้ - - - - - - - - + + * API Key ด้านล่างนี้จะแสดงเพียงครั้งเดียว ขอให้ทำสำเนาไว้ในที่ปลอดภัย @@ -114,21 +179,24 @@ function onCloseDialog() { + API ที่เข้าถึงได้ + + ([]); -const keyword = ref(""); -const visibleColumns = ref(["topic", "access", "amount"]); +const rows = ref([]); //รายการ webservices +const keyword = ref(""); //คำค้นหา รายการ webservices +const visibleColumns = ref([ + "name", + "apiNames", + "amount", + "createdAt", + "createdFullName", +]); const columns = ref([ { - name: "topic", + name: "name", align: "left", label: "ชื่อ-คำอธิบาย", sortable: true, - field: "topic", + field: "name", headerStyle: "font-size: 14px", style: "font-size: 14px", }, { - name: "access", + name: "apiNames", align: "left", label: "API ที่เข้าถึง", sortable: true, - field: "access", + field: "apiNames", headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val) { + return val + .map((e: ResApiName) => `-${e.name}`) + .join(""); + }, }, { name: "amount", @@ -48,36 +69,78 @@ const columns = ref([ headerStyle: "font-size: 14px", style: "font-size: 14px", }, + { + name: "createdAt", + align: "left", + label: "วันที่สร้าง", + sortable: true, + field: "createdAt", + format(val) { + return date2Thai(val, false, true); + }, + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + + { + name: "createdFullName", + align: "left", + label: "ผู้ดำเนินการ", + sortable: true, + field: "createdFullName", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, ]); /** API Key*/ -const modalApiKey = ref(false); +const modalApiKey = ref(false); //popup สร้าง API Key /** usability*/ -const modalUsability = ref(false); +const modalUsability = ref(false); //popup การใช้งาน -function fetchListWebServices() { - const data: ResListWebServices[] = [ - { - id: "", - topic: "รายการ web services 1", - access: ["API1", "API2", "API3"], - amount: "1", - }, - { - id: "", - topic: "รายการ web services 2", - access: ["API1", "API2", "API3"], - amount: "2", - }, - ]; - rows.value = data; +/** ฟังก์ชันเรียกข้อมูลรายการ Web services*/ +async function fetchListWebServices() { + showLoader(); + await http + .get(config.API.apiKeyMain + "/list") + .then(async (res) => { + const data = await res.data.result; + rows.value = data; + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } +/** + * ฟังก์ชัน ลบข้อมูลรายการ Web services + * @param id รายการ Web services ที่ต้องการลบ + * เมื่อสำเร็จจะเรียกฟังก์ชัน 'fetchListWebServices' มาเรียกข้อมูลรายการ web servcice ใหม่ + */ function onDeleteData(id: string) { - dialogRemove($q, () => {}); + dialogRemove($q, () => { + showLoader(); + http + .delete(config.API.apiKeyMain + `/${id}`) + .then(async () => { + // เรียกข้อมูลรายการ web servcice ใหม่ + await fetchListWebServices(); + success($q, "ลบข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); + }); } +/** hook เมื่อเรียก Components จะเรียกฟังก์ชัน 'fetchListWebServices' เรียกข้อมูลรายการ webservices*/ onMounted(() => { fetchListWebServices(); }); @@ -98,6 +161,7 @@ onMounted(() => { + { /> + { - + + - - {{ col.value ? col.value : "-" }} + + - - - + + + + +