diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 966ed4e..3b0ebfb 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -18,8 +18,8 @@ env:
DEPLOY_HOST: frappet.com
COMPOSE_PATH: /home/frappet/docker/bma-ehr-qualifying-cms
jobs:
- # act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=v0.2.4-dev -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
- # act --workflows .github/workflows/release.yaml --job release --input IMAGE_VER=v0.2.4-dev -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
+ # act workflow_dispatch --reuse -W .github/workflows/release.yaml --input IMAGE_VER=v0.2.4-dev -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
+ # act --reuse --workflows .github/workflows/release.yaml --job release --input IMAGE_VER=v0.2.4-dev -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
release:
runs-on: ubuntu-latest
@@ -59,7 +59,9 @@ jobs:
uses: docker/build-push-action@v3
with:
context: cms
- # platforms: linux/amd64,linux/arm64
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+ platforms: linux/amd64
push: true
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
- name: Remote Deployment
diff --git a/cms/README.md b/cms/README.md
index 82ac946..14dc2db 100644
--- a/cms/README.md
+++ b/cms/README.md
@@ -9,7 +9,7 @@
- [GitHub Actions](https://github.com/features/actions) ทำ CI/CD ในระบบทดสอบ
- [nektos/act](https://github.com/nektos/act) ใช้ GitHub Actions บนเครื่องของเราเอง
- [Argo CD](https://argo-cd.readthedocs.io/en/stable/) deploy ขึ้นระบบ Production (K8s)
-- [FullCalendar](https://github.com/schooltechx/youtube/blob/main/svelte/component/FullCalendar.md) รองรับพ.ศ. ใช้แค่ฟีเจอร์[ฟรีก็น่าจะพอ](https://fullcalendar.io/license#:~:text=or%20FullCalendar%20Premium.-,FullCalendar%20Standard,all%20copyright%20headers%20are%20preserved.)
+- [FullCalendar](https://github.com/schooltechx/youtube/blob/main/svelte/component/Calendar/FullCalendar.md) รองรับพ.ศ. ใช้แค่ฟีเจอร์[ฟรีก็น่าจะพอ](https://fullcalendar.io/license#:~:text=or%20FullCalendar%20Premium.-,FullCalendar%20Standard,all%20copyright%20headers%20are%20preserved.)
- [Day.js](https://day.js.org/) ในฟอร์แม็ตวันในรูปแบบ local ไทยรองรับ พ.ศ.
## วีดีโอแสดงการทำงานทั้งหมด
@@ -70,7 +70,7 @@ npx vite preview --port=4000 --host=0.0.0.0
ถ้าไม่ build เอง ตอนนี้มี demo อยู่ที่ [https://bma-qualifying.frappet.synology.me/](https://bma-qualifying.frappet.synology.me/) ให้เปลี่ยน base url ให้เหมาะสม
-Data Type ที่ใช้ดูในไฟล์ [CMSDataType.ts](./src/lib/data/CMSDataType.ts)
+การกำหนด path ของ API และ Data Type ที่ใช้ดูในไฟล์ [CMSDataType.ts](./src/lib/data/CMSDataType.ts)
## Browser Testing
diff --git a/cms/src/lib/components/Footer.svelte b/cms/src/lib/components/Footer.svelte
index 1631151..b16be73 100644
--- a/cms/src/lib/components/Footer.svelte
+++ b/cms/src/lib/components/Footer.svelte
@@ -33,7 +33,7 @@
-

+
{title}
diff --git a/cms/src/lib/components/Header.svelte b/cms/src/lib/components/Header.svelte
index fa5d6e2..94d4b30 100644
--- a/cms/src/lib/components/Header.svelte
+++ b/cms/src/lib/components/Header.svelte
@@ -2,7 +2,6 @@
export let logo_url:string = "/images/logo.png"
export let title:string = "ใส่ชื่อองค์กรที่นี้"
export let supervised:string = "ใส่สังกัดที่นี้"
-
@@ -14,7 +13,7 @@
-

+
diff --git a/cms/src/lib/data/CMSDataType.ts b/cms/src/lib/data/CMSDataType.ts
index d1573da..5d4bd01 100644
--- a/cms/src/lib/data/CMSDataType.ts
+++ b/cms/src/lib/data/CMSDataType.ts
@@ -30,4 +30,6 @@ export interface CMSInfo{
divisions:{title:string,url:string}[];
institutes:{title:string,url:string}[];
}
-export const apibase="/api"
+export const cmsBase="https://bma-ehr-exam.frappet.synology.me/api/v1/cms"
+export const competitiveBase="/api"
+export const qualifyingBase="https://bma-ehr-exam.frappet.synology.me/api/v1/cms"
diff --git a/cms/src/routes/+layout.server.ts b/cms/src/routes/+layout.server.ts
index b8afb71..461041d 100644
--- a/cms/src/routes/+layout.server.ts
+++ b/cms/src/routes/+layout.server.ts
@@ -1,8 +1,8 @@
-import {apibase} from '$lib/data/CMSDataType'
+import {cmsBase} from '$lib/data/CMSDataType'
import { error } from '@sveltejs/kit';
import type { PageServerLoad } from './$types'
export const load: PageServerLoad = async ({fetch}) => {
- const res = await fetch(apibase+"/info")
+ const res = await fetch(cmsBase+"/home")
if(!res.ok)
throw error(500, 'ไม่สามารถอ่านข้อมูลตั้งต้นของเวปได้');
diff --git a/cms/src/routes/+layout.svelte b/cms/src/routes/+layout.svelte
index 5128b0a..b5db852 100644
--- a/cms/src/routes/+layout.svelte
+++ b/cms/src/routes/+layout.svelte
@@ -10,7 +10,6 @@
import type { LayoutData } from './$types';
export let data: LayoutData;
let {logo_url,supervised,divisions,institutes,address,title,subtitle} = data
-
diff --git a/cms/src/routes/+page.server.ts b/cms/src/routes/+page.server.ts
index 94628c9..6613e95 100644
--- a/cms/src/routes/+page.server.ts
+++ b/cms/src/routes/+page.server.ts
@@ -1,18 +1,19 @@
-import {apibase} from '$lib/data/CMSDataType'
+import {cmsBase,qualifyingBase,competitiveBase} from '$lib/data/CMSDataType'
import { error } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
import type {Exam} from '$lib/data/CMSDataType'
import dayjs from 'dayjs'
export const load: PageServerLoad = async ({fetch}) => {
- let res = await fetch(apibase+"/info")
+ let res = await fetch("/api/info")
if(!res.ok)
throw error(500, 'ไม่สามารถอ่านข้อมูลตั้งต้นของหน้าหลักได้');
const {title,subtitle} = await res.json()
- res = await fetch(apibase+"/content?page=home")
+ res = await fetch(cmsBase+"/content/home")
if(!res.ok)
throw error(500, 'ไม่สามารถอ่านเนื้อหาหน้าหลักได้');
const {content,image} = await res.json()
+ console.log("xxx",image)
//Inner function reduce code and able to throw here
async function loadExam(api_path:string,err_msg:string){
const res = await fetch(api_path)
@@ -21,16 +22,16 @@ export const load: PageServerLoad = async ({fetch}) => {
const exams:Exam[] = await res.json()
exams.forEach((e)=>{
e.date = e.start? dayjs(e.start).format("DD MMM BBBB"):""
+ e.image = e.image?e.image:"/images/exam_place_holder.png"
})
//This page layout require 3 item, patch with empty
for(let i=exams.length;i<3;i++){
- exams.push({id:"0",title:"",date:"",image:""})
+ exams.push({id:"0",title:"",date:"",image:"/images/exam_place_holder.png"})
}
- return exams
-
+ return exams
}
- const qualify_exams = loadExam(apibase+"/qualifying",'ไม่สามารถอ่านรายการสอบคัดเลือกได้')
- const competitive_exams = loadExam(apibase+"/competitive",'ไม่สามารถอ่านรายการสอบแข่งขันได้')
+ const qualify_exams = loadExam(qualifyingBase+"/qualifying?limit=3",'ไม่สามารถอ่านรายการสอบคัดเลือกได้')
+ const competitive_exams = loadExam(competitiveBase+"/competitive?limit=3",'ไม่สามารถอ่านรายการสอบแข่งขันได้')
return {title,subtitle,content,image, qualify_exams,competitive_exams };
};
diff --git a/cms/src/routes/+page.svelte b/cms/src/routes/+page.svelte
index 4bf6a87..58de954 100644
--- a/cms/src/routes/+page.svelte
+++ b/cms/src/routes/+page.svelte
@@ -36,7 +36,7 @@

diff --git a/cms/src/routes/about/+page.server.ts b/cms/src/routes/about/+page.server.ts
index c05c91e..d63be43 100644
--- a/cms/src/routes/about/+page.server.ts
+++ b/cms/src/routes/about/+page.server.ts
@@ -1,8 +1,8 @@
-import {apibase} from '$lib/data/CMSDataType'
+import {cmsBase} from '$lib/data/CMSDataType'
import type { PageServerLoad } from './$types';
import { error } from '@sveltejs/kit';
export const load = (async ({fetch}) => {
- const res = await fetch(apibase+"/content?page=about")
+ const res = await fetch(cmsBase+"/content/about")
if(!res.ok)
throw error(500, 'ไม่สามารถอ่านเนื้อหาหน้าเกี่ยวกับได้');
const {content} = await res.json()
diff --git a/cms/src/routes/competitive/+page.server.ts b/cms/src/routes/competitive/+page.server.ts
index dd4abbb..bfe3f87 100644
--- a/cms/src/routes/competitive/+page.server.ts
+++ b/cms/src/routes/competitive/+page.server.ts
@@ -1,11 +1,11 @@
-import {apibase} from '$lib/data/CMSDataType'
+import {competitiveBase} from '$lib/data/CMSDataType'
import { error } from '@sveltejs/kit';
import type {CalendarEvent,Exam} from '$lib/data/CMSDataType'
import dayjs from 'dayjs'
import type { PageServerLoad } from './$types'
export const load: PageServerLoad = async ({fetch}) => {
let exams:Exam[] = []
- const res = await fetch(apibase+"/competitive")
+ const res = await fetch(competitiveBase+"/competitive")
if(!res.ok)
throw error(res.status, 'ไม่สามารถอ่านข้อมูลการสอบได้');
exams = await res.json()
diff --git a/cms/src/routes/competitive/[id]/+page.server.ts b/cms/src/routes/competitive/[id]/+page.server.ts
index 0e6601f..5c1ae47 100644
--- a/cms/src/routes/competitive/[id]/+page.server.ts
+++ b/cms/src/routes/competitive/[id]/+page.server.ts
@@ -1,10 +1,10 @@
-import {apibase} from '$lib/data/CMSDataType'
+import {competitiveBase} from '$lib/data/CMSDataType'
import { error } from '@sveltejs/kit'
import dayjs from 'dayjs'
import type { PageServerLoad } from './$types'
export const load: PageServerLoad = async ({params,fetch}) => {
const id = params.id+""
- const res = await fetch(apibase+"/competitive/"+id)
+ const res = await fetch(competitiveBase+"/competitive/"+id)
if(res.status==404){
throw error(404,{message:`ค้นหาข้อมูลสอบคัดเลือก ${id}ไม่พบ`})
}
diff --git a/cms/src/routes/qualifying/+page.server.ts b/cms/src/routes/qualifying/+page.server.ts
index a985fe8..c2b1230 100644
--- a/cms/src/routes/qualifying/+page.server.ts
+++ b/cms/src/routes/qualifying/+page.server.ts
@@ -1,11 +1,11 @@
-import {apibase} from '$lib/data/CMSDataType'
+import {qualifyingBase} from '$lib/data/CMSDataType'
import { error } from '@sveltejs/kit';
import type {CalendarEvent,Exam} from '$lib/data/CMSDataType'
import dayjs from 'dayjs'
import type { PageServerLoad } from './$types'
export const load: PageServerLoad = async ({fetch}) => {
let exams:Exam[] = []
- const res = await fetch(apibase+"/qualifying")
+ const res = await fetch(qualifyingBase+"/qualifying")
if(!res.ok)
throw error(res.status, 'ไม่สามารถอ่านข้อมูลการสอบได้');
exams = await res.json()
diff --git a/cms/src/routes/qualifying/[id]/+page.server.ts b/cms/src/routes/qualifying/[id]/+page.server.ts
index fbd9445..b5cfaa2 100644
--- a/cms/src/routes/qualifying/[id]/+page.server.ts
+++ b/cms/src/routes/qualifying/[id]/+page.server.ts
@@ -1,10 +1,10 @@
-import {apibase} from '$lib/data/CMSDataType'
+import {qualifyingBase} from '$lib/data/CMSDataType'
import { error } from '@sveltejs/kit'
import dayjs from 'dayjs'
import type { PageServerLoad } from './$types'
export const load: PageServerLoad = async ({params,fetch}) => {
const id = params.id+""
- const res = await fetch(apibase+"/qualifying/"+id)
+ const res = await fetch(qualifyingBase+"/qualifying/"+id)
if(res.status==404){
throw error(404,{message:`ค้นหาข้อมูลสอบคัดเลือก ${id}ไม่พบ`})
}
diff --git a/cms/static/images/exam_place_holder.png b/cms/static/images/exam_place_holder.png
new file mode 100644
index 0000000..8530ffd
Binary files /dev/null and b/cms/static/images/exam_place_holder.png differ