Upgrade package, Implement fake API, version info get from API. Waiting for real API
This commit is contained in:
parent
faaae95956
commit
5b2d7ea68d
16 changed files with 853 additions and 615 deletions
4
.github/workflows/release.yaml
vendored
4
.github/workflows/release.yaml
vendored
|
|
@ -17,10 +17,10 @@ env:
|
|||
IMAGE_NAME: demo/qualifying-exam-cms
|
||||
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
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
|
|
|||
1303
cms/package-lock.json
generated
1303
cms/package-lock.json
generated
File diff suppressed because it is too large
Load diff
9
cms/src/lib/components/Exam.ts
Normal file
9
cms/src/lib/components/Exam.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
export interface Exam {
|
||||
id:string;
|
||||
title:string;
|
||||
img?:string;
|
||||
start:Date|string;
|
||||
date?:string;
|
||||
institute_id?:number
|
||||
institute?:string
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
//TDD
|
||||
//TDD Implement unitest here
|
||||
import {it,expect } from 'vitest'
|
||||
import {getContact} from './info'
|
||||
it('test getContact() ',async ()=>{
|
||||
const result = await getContact()
|
||||
const result = {company_name:"กองสรรหาบุคคล",Country:"Thailand"}
|
||||
expect(result.company_name).toBe("กองสรรหาบุคคล")
|
||||
expect(result.Country).toBe("Thailand")
|
||||
})
|
||||
|
|
@ -1,9 +1,22 @@
|
|||
import content from "$lib/data/content/home.html?raw"
|
||||
import { getQualifyExams,getCompetitiveExams } from '$lib/data/info';
|
||||
//import content from "$lib/data/content/home.html?raw"
|
||||
//import { getQualifyExams,getCompetitiveExams } from '$lib/data/info';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
export const load: PageServerLoad = async () => {
|
||||
const qualify_exams = await getQualifyExams(3);
|
||||
const competitive_exams = await getCompetitiveExams(3);
|
||||
import type {Exam} from '$lib/components/Exam'
|
||||
export const load: PageServerLoad = async ({fetch}) => {
|
||||
let qualify_exams: Exam[] = []
|
||||
let competitive_exams: Exam[] = []
|
||||
let content = ""
|
||||
let res = await fetch("/api/content?page=home")
|
||||
if(res.ok){
|
||||
content = (await res.json()).content
|
||||
}
|
||||
res = await fetch("/api/qualifying")
|
||||
if(res.ok){
|
||||
qualify_exams = await res.json()
|
||||
}
|
||||
res = await fetch("/api/competitive")
|
||||
if(res.ok){
|
||||
competitive_exams = await res.json()
|
||||
}
|
||||
return { content , qualify_exams,competitive_exams };
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
Recruitment Division
|
||||
</h2>
|
||||
<p class="mt-4 text-lg leading-relaxed text-blueGray-500">
|
||||
{data.content}
|
||||
{@html data.content}
|
||||
</p>
|
||||
<div class="mt-12">
|
||||
<a
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
<script lang="ts">
|
||||
|
||||
import ver from "$lib/ver.json"
|
||||
import type { PageData } from './$types'
|
||||
export let data: PageData;
|
||||
|
||||
</script>
|
||||
<section>
|
||||
<div class="p-one parallax-inner">
|
||||
|
|
@ -32,8 +29,6 @@
|
|||
<div>
|
||||
{@html data.content}
|
||||
</div>
|
||||
<div class="pt-12">{ver.version}</div>
|
||||
<div>{ver.builddate}</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
|
|
|||
6
cms/src/routes/api/competitive/+server.ts
Normal file
6
cms/src/routes/api/competitive/+server.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import type {RequestHandler } from './$types'
|
||||
import {json} from '@sveltejs/kit'
|
||||
import exams from "$lib/data/competitive-exam.json"
|
||||
export const GET: RequestHandler = async () => {
|
||||
return json(exams)
|
||||
}
|
||||
14
cms/src/routes/api/competitive/[id]/+server.ts
Normal file
14
cms/src/routes/api/competitive/[id]/+server.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import type { RequestEvent, RequestHandler } from './$types'
|
||||
import {json} from '@sveltejs/kit'
|
||||
import exams from "$lib/data/competitive-exam.json"
|
||||
export const GET: RequestHandler = async ({params}: RequestEvent) => {
|
||||
const id = params.id+""
|
||||
//const exams = await getCompetitiveExams()
|
||||
const post = exams.find((q)=>{
|
||||
return q.id===id
|
||||
})
|
||||
if(!post)
|
||||
return json({message:`ไม่พบการสอบแข่งขัน ID= ${id}`},{status:404})
|
||||
return json(post)
|
||||
}
|
||||
|
||||
31
cms/src/routes/api/content/+server.ts
Normal file
31
cms/src/routes/api/content/+server.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import type { RequestEvent, RequestHandler } from './$types'
|
||||
import {json} from '@sveltejs/kit'
|
||||
import home_content from "$lib/data/content/home.html?raw"
|
||||
import about_content from "$lib/data/content/about.html?raw"
|
||||
import qualifying_content from "$lib/data/content/qualifying.html?raw"
|
||||
import competitive_content from "$lib/data/content/competitive.html?raw"
|
||||
export const GET: RequestHandler = async ({url}: RequestEvent) => {
|
||||
let content = ""
|
||||
const page= url.searchParams.get("page") ?? 'nopage'
|
||||
switch (page) {
|
||||
case "home":
|
||||
content = home_content
|
||||
break;
|
||||
case "qualifying":
|
||||
content = qualifying_content
|
||||
break;
|
||||
case "competitive":
|
||||
content = competitive_content
|
||||
break;
|
||||
case "about":
|
||||
content = about_content
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//slience error just send empty content if not found
|
||||
if(!content)
|
||||
console.log(`Request content ${page} not found`)
|
||||
return json({content})
|
||||
|
||||
}
|
||||
8
cms/src/routes/api/info/+server.ts
Normal file
8
cms/src/routes/api/info/+server.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import ver from "$lib/ver.json"
|
||||
import {json} from '@sveltejs/kit'
|
||||
import type { RequestHandler } from './$types'
|
||||
export const GET: RequestHandler = async () => {
|
||||
const version = ver.version
|
||||
const builddate = ver.builddate
|
||||
return json({version,builddate})
|
||||
}
|
||||
6
cms/src/routes/api/qualifying/+server.ts
Normal file
6
cms/src/routes/api/qualifying/+server.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import type { RequestHandler } from './$types'
|
||||
import {json} from '@sveltejs/kit'
|
||||
import exams from "$lib/data/qualify-exam.json"
|
||||
export const GET: RequestHandler = async () => {
|
||||
return json(exams)
|
||||
}
|
||||
14
cms/src/routes/api/qualifying/[id]/+server.ts
Normal file
14
cms/src/routes/api/qualifying/[id]/+server.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import type { RequestEvent, RequestHandler } from './$types'
|
||||
import {json} from '@sveltejs/kit'
|
||||
import exams from "$lib/data/qualify-exam.json"
|
||||
export const GET: RequestHandler = async ({params}: RequestEvent) => {
|
||||
const id = params.id+""
|
||||
//const exams = await getCompetitiveExams()
|
||||
const post = exams.find((q)=>{
|
||||
return q.id===id
|
||||
})
|
||||
if(!post)
|
||||
return json({message:`ไม่พบการสอบแข่งขัน ID= ${id}`},{status:404})
|
||||
return json(post)
|
||||
}
|
||||
|
||||
|
|
@ -1,9 +1,20 @@
|
|||
import content from "$lib/data/content/competitive.html?raw"
|
||||
import {getCompetitiveExams} from "$lib/data/info"
|
||||
import type { PageServerLoad } from './$types'
|
||||
import type {CalendarEvent} from '$lib/components/CalendarEvent'
|
||||
export const load: PageServerLoad = async () => {
|
||||
const exams = await getCompetitiveExams()
|
||||
import type {Exam} from '$lib/components/Exam'
|
||||
|
||||
export const load: PageServerLoad = async ({fetch}) => {
|
||||
let content = ""
|
||||
let exams:Exam[] = []
|
||||
let res = await fetch("/api/content?page=competitive")
|
||||
if(res.ok){
|
||||
content = (await res.json()).content
|
||||
}
|
||||
|
||||
res = await fetch("/api/competitive")
|
||||
if(res.ok){
|
||||
exams = await res.json()
|
||||
}
|
||||
|
||||
const events:CalendarEvent[]=[]
|
||||
exams.forEach(({id,title,start})=>{
|
||||
const backgroundColor ="#9999FF"
|
||||
|
|
|
|||
|
|
@ -1,9 +1,17 @@
|
|||
import content from "$lib/data/content/qualifying.html?raw"
|
||||
import {getQualifyExams} from "$lib/data/info"
|
||||
import type { PageServerLoad } from './$types'
|
||||
import type {CalendarEvent} from '$lib/components/CalendarEvent'
|
||||
export const load: PageServerLoad = async () => {
|
||||
const exams = await getQualifyExams()
|
||||
import type {Exam} from '$lib/components/Exam'
|
||||
export const load: PageServerLoad = async ({fetch}) => {
|
||||
let content = ""
|
||||
let exams:Exam[] = []
|
||||
let res = await fetch("/api/content?page=qualifying")
|
||||
if(res.ok){
|
||||
content = (await res.json()).content
|
||||
}
|
||||
res = await fetch("/api/qualifying")
|
||||
if(res.ok){
|
||||
exams = await res.json()
|
||||
}
|
||||
const events:CalendarEvent[]=[]
|
||||
exams.forEach(({id,title,start,institute_id})=>{
|
||||
let backgroundColor =""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"extends": "./.svelte-kit/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"ignoreDeprecations": "5.0",
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"esModuleInterop": true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue