diff --git a/.env.example b/.env.example index 7808f4e0..c455bdd4 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,4 @@ VITE_API_URI_CONFIG: "https://app.your-domain.com/api/v1" +VITE_API_REPORT_URL: "https://report.com/api/v1/" +VITE_URL_SSO: "https://app-sso.your-domain.com" VITE_MANUAL_URL: "https://app-manual.your-domain.com" \ No newline at end of file diff --git a/.env.production b/.env.production index afa876a1..f466c296 100644 --- a/.env.production +++ b/.env.production @@ -1,5 +1,4 @@ -VITE_API_PUBLISH_URL=VITE_API_PUBLISH_URL -VITE_API_REPORT_URL=VITE_API_REPORT_URL VITE_API_URI_CONFIG=VITE_API_URI_CONFIG +VITE_API_REPORT_URL=VITE_API_REPORT_URL VITE_MANUAL_URL=VITE_MANUAL_URL -VITE_URL_SSO: VITE_URL_SSO \ No newline at end of file +VITE_URL_SSO=VITE_URL_SSO \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2723b808..ce336e88 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,5 +1,5 @@ -name: release-test -run-name: release-test ${{ github.actor }} +name: release +run-name: release ${{ github.actor }} on: push: tags: @@ -9,12 +9,11 @@ env: REGISTRY: docker.frappet.com IMAGE_NAME: ehr/bma-ehr-admin DEPLOY_HOST: frappet.com - # COMPOSE_PATH: /home/frappet/docker/bma-ehr COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-admin jobs: # act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=test-v6.1 -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd - release-test: + release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -68,21 +67,40 @@ jobs: docker compose pull docker compose up -d echo "${{ steps.gen_ver.outputs.image_ver }}"> success - - uses: snow-actions/line-notify@v1.1.0 + - name: Notify Discord Success if: success() - with: - access_token: ${{ secrets.TOKEN_LINE }} - message: | - -Success✅✅✅ - Image: ${{env.IMAGE_NAME}} - Version: ${{ steps.gen_ver.outputs.IMAGE_VER }} - By: ${{github.actor}} - - uses: snow-actions/line-notify@v1.1.0 + run: | + curl -H "Content-Type: application/json" \ + -X POST \ + -d '{ + "embeds": [{ + "title": "✅ Deployment Success!", + "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`", + "color": 3066993, + "footer": { + "text": "Release Notification", + "icon_url": "https://example.com/success-icon.png" + }, + "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" + }] + }' \ + ${{ secrets.DISCORD_WEBHOOK }} + + - name: Notify Discord Failure if: failure() - with: - access_token: ${{ secrets.TOKEN_LINE }} - message: | - -Failure❌❌❌ - Image: ${{env.IMAGE_NAME}} - Version: ${{ steps.gen_ver.outputs.IMAGE_VER }} - By: ${{github.actor}} + run: | + curl -H "Content-Type: application/json" \ + -X POST \ + -d '{ + "embeds": [{ + "title": "❌ Deployment Failed!", + "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`", + "color": 15158332, + "footer": { + "text": "Release Notification", + "icon_url": "https://example.com/failure-icon.png" + }, + "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" + }] + }' \ + ${{ secrets.DISCORD_WEBHOOK }} diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml new file mode 100644 index 00000000..11620175 --- /dev/null +++ b/.onedev-buildspec.yml @@ -0,0 +1,102 @@ +version: 37 +jobs: +- name: CI for UAT + steps: + - !CheckoutStep + name: checkout code + cloneCredential: !DefaultCredential {} + withLfs: false + withSubmodules: false + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !GenerateChecksumStep + name: generate package checksum + files: package-lock.json yarn.lock + targetFile: checksum + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !SetupCacheStep + name: set up npm cache + key: node_modules_@file:checksum@ + loadKeys: + - node_modules + paths: + - node_modules + uploadStrategy: UPLOAD_IF_NOT_HIT + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !SetBuildVersionStep + name: set build version + buildVersion: '@tag@' + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !CommandStep + name: build & test + runInContainer: true + image: node + interpreter: !DefaultInterpreter + commands: | + npm install + npm run build + useTTY: true + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !BuildImageStep + name: build docker image + dockerfile: ./docker/Dockerfile + output: !RegistryOutput + tags: hrms-git.chin.in.th/bma-hrms/hrms-admin:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-admin:latest + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + triggers: + - !TagCreateTrigger + tags: uat-* + branches: main + retryCondition: never + maxRetries: 3 + retryDelay: 30 + timeout: 14400 +- name: CI for PROD + steps: + - !CheckoutStep + name: checkout code + cloneCredential: !DefaultCredential {} + withLfs: false + withSubmodules: false + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !GenerateChecksumStep + name: generate package checksum + files: package-lock.json yarn.lock + targetFile: checksum + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !SetupCacheStep + name: set up npm cache + key: node_modules_@file:checksum@ + loadKeys: + - node_modules + paths: + - node_modules + uploadStrategy: UPLOAD_IF_NOT_HIT + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !SetBuildVersionStep + name: set build version + buildVersion: '@tag@' + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !CommandStep + name: build & test + runInContainer: true + image: node + interpreter: !DefaultInterpreter + commands: | + npm install + npm run build + useTTY: true + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !BuildImageStep + name: build docker image + dockerfile: ./docker/Dockerfile + output: !RegistryOutput + tags: hrms-git.bangkok.go.th/bma-hrms/hrms-admin:@build_version@ hrms-git.bangkok.go.th/bma-hrms/hrms-admin:latest + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + triggers: + - !TagCreateTrigger + tags: prod-* + branches: main + retryCondition: never + maxRetries: 3 + retryDelay: 30 + timeout: 14400 diff --git a/docker/Dockerfile b/docker/Dockerfile index f6ee5555..59211f1b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,7 +1,7 @@ # docker buildx build --platform=linux/amd64 -f docker/Dockerfile . -t hrms-git.chin.in.th/bma-hrms/hrms-admin:0.1 # Build Stage -FROM node:20-alpine as build-stage +FROM node:20-alpine AS build-stage WORKDIR /app COPY package*.json ./ RUN npm install diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index ff6c0d53..2f3ac1ac 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -8,9 +8,8 @@ for file in $ROOT_DIR/assets/app.*.js* $ROOT_DIR/js/app.*.js* $ROOT_DIR/assets/Q do echo "Processing $file ..."; - sed -i 's|VITE_API_PUBLISH_URL|'${VITE_API_PUBLISH_URL}'|g' $file - sed -i 's|VITE_API_REPORT_URL|'${VITE_API_REPORT_URL}'|g' $file sed -i 's|VITE_API_URI_CONFIG|'${VITE_API_URI_CONFIG}'|g' $file + sed -i 's|VITE_API_REPORT_URL|'${VITE_API_REPORT_URL}'|g' $file sed -i 's|VITE_MANUAL_URL|'${VITE_MANUAL_URL}'|g' $file sed -i 's|VITE_URL_SSO|'${VITE_URL_SSO}'|g' $file diff --git a/src/api/03_logs/api.log.ts b/src/api/03_logs/api.log.ts index 956bfea5..4e6f122a 100644 --- a/src/api/03_logs/api.log.ts +++ b/src/api/03_logs/api.log.ts @@ -1,8 +1,9 @@ import env from "../index"; const log = `${env.API_LOG}/log`; -// const log = `${env.API_URI}/log`; +const reportTemplate = `${env.API_REPORT_TEMPLATE_URI}`; export default { log, reportLog: `${log}/report/logsList`, + reportTemplate, }; diff --git a/src/api/index.ts b/src/api/index.ts index aafcee93..8a86b8aa 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -3,8 +3,7 @@ import { ref } from "vue"; const env = ref(process.env.NODE_ENV || "development"); export const apiUrlConfig = import.meta.env.VITE_API_URI_CONFIG; -// export const apiUrlConfigPublish = import.meta.env.VITE_API_PUBLISH_URL; -// export const apiUrlConfigReport = import.meta.env.VITE_API_REPORT_URL; +export const apiUrlConfigReport = import.meta.env.VITE_API_REPORT_URL; // if (process.env.VUE_APP_TEST) { // env = "test"; // } @@ -17,7 +16,6 @@ const config = ref({ API_URI_PROFILE_SERVICE: apiUrlConfig, API_REPORT_URI: apiUrlConfig, MEET_URI: "meet.frappet.com", - API_REPORT2_URI: "https://bma-ehr.frappet.synology.me/api/v2", API_REPORT_TEMPLATE_URI: "https://report-server.frappet.synology.me/api/v1/report-template", API_LOG: apiUrlConfig, @@ -36,9 +34,7 @@ const config = ref({ API_URI_PROFILE_SERVICE: apiUrlConfig, API_REPORT_URI: apiUrlConfig, MEET_URI: "meet.frappet.com", - API_REPORT2_URI: `${window.location.protocol}//${window.location.host}/api/v2`, - API_REPORT_TEMPLATE_URI: - "https://report-server.frappet.synology.me/api/v1/report-template", + API_REPORT_TEMPLATE_URI: apiUrlConfigReport, API_LOG: apiUrlConfig, }, }); @@ -55,7 +51,6 @@ const MEET_URI = ref(config.value[env.value].MEET_URI); const API_URI_PROFILE_SERVICE = ref( config.value[env.value].API_URI_PROFILE_SERVICE ); -const API_REPORT2_URI = ref(config.value[env.value].API_REPORT2_URI); const API_REPORT_TEMPLATE_URI = ref( config.value[env.value].API_REPORT_TEMPLATE_URI ); @@ -70,7 +65,6 @@ export default { API_URI_ORG_EMPLOYEE_SERVICE: API_URI_ORG_EMPLOYEE_SERVICE.value, API_URI_PROFILE_SERVICE: API_URI_PROFILE_SERVICE.value, MEET_URI: MEET_URI.value, - API_REPORT2_URI: API_REPORT2_URI.value, API_REPORT_TEMPLATE_URI: API_REPORT_TEMPLATE_URI.value, API_LOG: API_LOG.value, }; diff --git a/src/api/reports/api.report.ts b/src/api/reports/api.report.ts deleted file mode 100644 index 5508f22b..00000000 --- a/src/api/reports/api.report.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * api รายงานทั้งหมด - */ -import env from "../index"; -const reportOrder = `${env.API_REPORT2_URI}/report/order`; -const reportRetire = `${env.API_REPORT2_URI}/report/retire`; -const reportProbation = `${env.API_REPORT2_URI}/report/probation`; -const reportResign = `${env.API_REPORT2_URI}/report/resign/33`; -const reportTransfer = `${env.API_REPORT2_URI}/report/transfer`; -const reportDeceased = `${env.API_REPORT2_URI}/report/deceased`; -const reportTemplate = `${env.API_REPORT_TEMPLATE_URI}`; - -export default { - reportOrderCover: (fileType: string, id: string, commandCode: string) => - `${reportOrder}/${commandCode}/cover/${fileType}/${id}`, - reportOrderAttachment: (fileType: string, id: string, commandCode: string) => - `${reportOrder}/${commandCode}/attachment/${fileType}/${id}`, - reportRetireList: (fileType: string, id: string) => - `${reportRetire}/${fileType}/${id}`, - reportResignList: (fileType: string, id: string) => - `${reportResign}/${fileType}/${id}`, - - fileCover: (format: string, fileType: string, id: string) => - `${reportOrder}/${format}/cover/${fileType}/${id}`, - fileAttachment: (format: string, fileType: string, id: string) => - `${reportOrder}/${format}/attachment/${fileType}/${id}`, - - //ระบบทดลองงาน - reportAssign: (type: string, id: string) => - `${reportProbation}/13/${type}/${id}`, - reportEvaluateRecord1: (type: string, id: string) => - `${reportProbation}/14/${type}/${id}`, - // reportEvaluateRecord2:(type:string, id:string) => `${reportProbation}/15/${type}/${id}`, - reportEvaluate: (type: string, id: string) => - `${reportProbation}/16/${type}/${id}`, - reportEvaluateChairman: (type: string, id: string) => - `${reportProbation}/17/${type}/${id}`, - reportEvaluateResult: (type: string, id: string) => - `${reportProbation}/19/${type}/${id}`, - // reportSurvey:(type:string, id:string) => `${reportProbation}/19/${type}/${id}`, - - //filetransfer - reportTransferFile: (no: number, type: string, id: string) => - `${reportTransfer}/${no}/${type}/${id}`, - - DeceasedReport: (type: string, id: string) => - `${reportDeceased}/36/${type}/${id}`, - reportTemplate, -}; diff --git a/src/app.config.ts b/src/app.config.ts index 25576725..777b8846 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -21,9 +21,6 @@ import registry from "./api/registry/api.registry"; /** API dashboard */ import message from "./api/00_dashboard/api.message"; -/** API reports */ -import reports from "./api/reports/api.report"; - /** API โครงสร้างอัตรากำลัง*/ import organization from "./api/02_organizational/api.organization"; @@ -55,34 +52,32 @@ export const qualifyDisableExamPanel = import.meta.env .VITE_QUALIFY_DISABLE_EMAM_PANEL; export const qualifyExamPanel = import.meta.env.VITE_QUALIFY_EXAM_PANEL; -const path = - import.meta.env.VITE_MANUAL_URL ?? - "https://bma-ehr-manual.frappet.synology.me"; +const path = import.meta.env.VITE_MANUAL_URL ?? ""; const generatePopupPath = (check: any) => { // if (routeName.includes("viewLogs")) { - // return `${path}/manual/chapter-2-superadmin-maintenance`; + // return `${path}/chapter-2-superadmin-maintenance`; // } // if (routeName.includes("manageUsers")) { - // return `${path}/manual/chapter-2-superadmin-maintenance`; + // return `${path}/chapter-2-superadmin-maintenance`; // } // if (routeName.includes("manageRoles")) { - // return `${path}/manual/chapter-2-superadmin-maintenance`; + // return `${path}/chapter-2-superadmin-maintenance`; // } // if (routeName.includes("managePermission")) { - // return `${path}/manual/chapter-2-superadmin-maintenance`; + // return `${path}/chapter-2-superadmin-maintenance`; // } if (!check) { - return `${path}/manual/chapter-1-superadmin-maintenance`; + return `${path}/chapter-1-superadmin-maintenance`; } else if (check) { - return `${path}/manual/chapter-2-superadmin-maintenance`; + return `${path}/chapter-2-superadmin-maintenance`; } else { return manualConfig[check as keyof typeof manualConfig]; } }; const manualConfig = { - dashboard: `${path}/manual/chapter-2-superadmin-maintenance`, + dashboard: `${path}/chapter-2-superadmin-maintenance`, }; const API = { //Metadata @@ -107,9 +102,6 @@ const API = { //dashboard ...message, - //reports - ...reports, - /*file*/ ...file, diff --git a/src/modules/01_metadata/components/insignia/InsigniaDetail.vue b/src/modules/01_metadata/components/insignia/InsigniaDetail.vue index 2a0e514f..8efd8d9f 100644 --- a/src/modules/01_metadata/components/insignia/InsigniaDetail.vue +++ b/src/modules/01_metadata/components/insignia/InsigniaDetail.vue @@ -18,7 +18,14 @@ const router = useRouter(); const $q = useQuasar(); const store = useInsigniaDataStore(); const mixin = useCounterMixin(); -const { dialogConfirm, showLoader, hideLoader, messageError, success } = mixin; +const { + dialogConfirm, + showLoader, + hideLoader, + messageError, + success, + dialogRemove, +} = mixin; const id = ref(route.params.id.toString()); // ชั้นเครื่องราชอิสริยาภรณ์ const title = ref(""); // ชือชั้นเครื่องราชอิสริยาภรณ์ @@ -179,7 +186,6 @@ async function fetchData(id: string) { /** * ยืนยันการบันทึกข้อมูลเครื่องราชอิสริยาภรณ์ - * * dialogStatus.value เป็น "create" จะเพิ่มข้อมูล ถ้าไม่จะเป็นการแก้ไขข้อมูล */ async function onSubmit() { @@ -217,9 +223,31 @@ async function onSubmit() { }); } +/** + * ลบข้อมูลเครื่องราชอิสริยาภรณ์ + * แล้ว fetch ข้อมูลรายการ ข้อมูลเครื่องราชอิสริยาภรณ์ ใหม่ + * @param id ข้อมูลเครื่องราชอิสริยาภรณ์ + */ +async function onDeleteData(idrow: string) { + dialogRemove($q, async () => { + showLoader(); + await http + .delete(config.API.insigniaNewIdOrg(idrow)) + .then(async () => { + await fetchData(id.value); + success($q, "ลบข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); + }); +} + /** * ปืด popup เพิ่ม,แก้ไข ข้อมูล - * * และ กำหนดฟอร์ม เพิ่มข้อมูล,แก้ไขข้อมูลเป็น defult */ function closeDialog() { @@ -232,7 +260,6 @@ function closeDialog() { /** * hook จำทำเมื่อมีการเรียกใช้ components - * * ทำการดึงรายการข้อมูลเครื่องราชอิสริยาภรณ์ตามลำดับชั้นเครื่องราชอิสริยาภรณ์ */ onMounted(async () => { @@ -294,12 +321,13 @@ onMounted(async () => { -