Remove unused code. Add utils.ts
This commit is contained in:
parent
0348e6b72e
commit
ea07766fd8
9 changed files with 34 additions and 112 deletions
|
|
@ -8,7 +8,7 @@ export interface Exam {
|
||||||
exam_date?:string;
|
exam_date?:string;
|
||||||
announcement_date?:string;
|
announcement_date?:string;
|
||||||
category_id?:string
|
category_id?:string
|
||||||
category?:string
|
category:string
|
||||||
image?:string;
|
image?:string;
|
||||||
images?:{title:string,url:string}[];
|
images?:{title:string,url:string}[];
|
||||||
files?:{title:string,url:string}[];
|
files?:{title:string,url:string}[];
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
# กองสรรหาบุคคล
|
|
||||||
## (Recruitment Division)
|
|
||||||
มีหน้าที่รับผิดชอบเกี่ยวกับการสรรหาและเลือกสรร บุคคลเข้ารับราชการเป็นข้าราชการกรุงเทพมหานครสามัญ และข้าราชการครูกรุงเทพมหานครเฉพาะสังกัดสำนักพัฒนาชุมชน การดำเนินการเกี่ยวกับทุน จากแหล่งทุนภายนอกการดำเนินการเกี่ยวกับมาตรฐานคุณสมบัติบุคคและปฎิบัติหน้าที่อื่นที่เกี่ยวข้อง โดยแบ่งงานภายในส่วนราชการดังนี้
|
|
||||||
|
|
||||||
## กลุ่มงานวิชาการการสอบ
|
|
||||||
ศึกษาวิจัย ข้อสอบเทคนิกการวัดผมและประมวลผล สร้างและพัฒนาระบบคังข้อสอบรวมถึงจัดทำฐานข้อมูลด้วยระบบอีเล็กทรอนิก
|
|
||||||
|
|
||||||
## กลุ่มงานดำเนินการสรรหา 1
|
|
||||||
ดำเนินการสอบและสรรหาบุคคลเข้ารับราชการครูและบุคคลากรทางการศึกษา ออกหนังสือรับรองผล จัดทำและปรับปรุงหลักเกณท์วิธีการสอบและการคัดเลือก
|
|
||||||
|
|
||||||
|
|
||||||
## กลุ่มงานดำเนินการสรรหา 2
|
|
||||||
ดำเนินการสอบและสรรหาบุคคลเข้ารับราชการเป็นข้าราชการกรุงเทพมหานครสามัญ รวมถึงดำเนินการสอบวัดควสามรู้ความสามารถเฉพาะตำแหน่ง
|
|
||||||
จัดทำ และปรับปรุงหลักเกณท์วิธีการสอบและการคัดเลือก พิจจารณาการให้ทุนจากภัยนอกแก่ข้าราชการกรุงเทพมหานคร
|
|
||||||
|
|
||||||
ฝ่ายบริหารงานทั่วไป
|
|
||||||
งานด้านสารบรรณ ธุรการทั่วไป การจัดประชุม ควบคุมดูแลสถานที่และยานพาหนะ การเงิน บัญชี งบประมาณบัญชี งบประมาณบัญชีและพัสดุ
|
|
||||||
จัดทำรายงาน และประเมินผลแผนปฎิบัติราชการประจำปี
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
import users from "./users.json"
|
|
||||||
let userid =100
|
|
||||||
|
|
||||||
export interface User {
|
|
||||||
id: number;
|
|
||||||
email: string;
|
|
||||||
username: string;
|
|
||||||
name:string;
|
|
||||||
last_name: string;
|
|
||||||
phone:string
|
|
||||||
}
|
|
||||||
export async function getUser(id:number){
|
|
||||||
return users.find(u=>u.id===id)
|
|
||||||
}
|
|
||||||
export async function getUsers(){
|
|
||||||
return users
|
|
||||||
}
|
|
||||||
export async function createUser(u:User){
|
|
||||||
u.id= userid++
|
|
||||||
return users.push(u)
|
|
||||||
}
|
|
||||||
export async function updateUser(u:User){
|
|
||||||
const user = await getUser(u.id)
|
|
||||||
if(!user)
|
|
||||||
return user
|
|
||||||
user.phone = u.phone
|
|
||||||
return user
|
|
||||||
}
|
|
||||||
15
cms/src/lib/utils.ts
Normal file
15
cms/src/lib/utils.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
/**
|
||||||
|
* getColorDict()
|
||||||
|
* get color base on name, add to nameColor if name not exist.
|
||||||
|
* Use for event background color of FullCalendar
|
||||||
|
* @param name string of color name
|
||||||
|
* @param nameColor dictionary like object for name and color
|
||||||
|
*/
|
||||||
|
export function getBgColorDict(name:string,nameColor:{ [index: string]:string}){
|
||||||
|
const eventBg = ["#23ccef","rgba(251,64,75,.2)","rgba(68,125,247,.2)","rgba(64,251,75,.2)"]
|
||||||
|
if(!nameColor[name]){
|
||||||
|
const len = Object.keys(nameColor).length
|
||||||
|
nameColor[name]=len>eventBg.length?eventBg[0]:eventBg[len]
|
||||||
|
}
|
||||||
|
return nameColor[name]
|
||||||
|
}
|
||||||
|
|
@ -25,7 +25,7 @@ export const load: PageServerLoad = async ({fetch}) => {
|
||||||
})
|
})
|
||||||
//This page layout require 3 item, patch with empty
|
//This page layout require 3 item, patch with empty
|
||||||
for(let i=exams.length;i<3;i++){
|
for(let i=exams.length;i<3;i++){
|
||||||
exams.push({id:"0",title:"",date:"",image:"/images/exam_place_holder.png"})
|
exams.push({id:"0",title:"",date:"",category:" ",image:"/images/exam_place_holder.png"})
|
||||||
}
|
}
|
||||||
return exams
|
return exams
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
import type { RequestEvent, RequestHandler } from './$types'
|
|
||||||
import {json} from '@sveltejs/kit'
|
|
||||||
import { createUser, getUsers } from '$lib/data/users'
|
|
||||||
|
|
||||||
//api/users
|
|
||||||
export const POST: RequestHandler = async ({ request }: RequestEvent) => {
|
|
||||||
const data = await request.json()
|
|
||||||
return json(await createUser( data))
|
|
||||||
}
|
|
||||||
export const GET: RequestHandler = async () => {
|
|
||||||
return json(await getUsers())
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
import type { RequestEvent, RequestHandler } from './$types'
|
|
||||||
import {json} from '@sveltejs/kit'
|
|
||||||
import { getUser, updateUser } from '$lib/data/users'
|
|
||||||
|
|
||||||
//api/users/1
|
|
||||||
export const PUT: RequestHandler = async ({ request }: RequestEvent) => {
|
|
||||||
const o = await request.json()
|
|
||||||
if(!updateUser(o))
|
|
||||||
return json({message:"call updateUser fail "},{status:400})
|
|
||||||
return json({message:"Update Success"})
|
|
||||||
}
|
|
||||||
export const GET: RequestHandler = async ({params}: RequestEvent) => {
|
|
||||||
const id = Number(params.id)
|
|
||||||
const u = await getUser(id)
|
|
||||||
if(!u)
|
|
||||||
return json({message:`User ${id} not found`},{status:404})
|
|
||||||
return json(u)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import {competitiveBase} from '$lib/data/CMSDataType'
|
import {competitiveBase} from '$lib/data/CMSDataType'
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
import type {CalendarEvent,Exam} from '$lib/data/CMSDataType'
|
import type {CalendarEvent,Exam} from '$lib/data/CMSDataType'
|
||||||
|
import {getBgColorDict} from '$lib/utils'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import type { PageServerLoad } from './$types'
|
import type { PageServerLoad } from './$types'
|
||||||
export const load: PageServerLoad = async ({fetch}) => {
|
export const load: PageServerLoad = async ({fetch}) => {
|
||||||
|
|
@ -10,22 +11,12 @@ export const load: PageServerLoad = async ({fetch}) => {
|
||||||
|
|
||||||
const exams:Exam[] = await res.json()
|
const exams:Exam[] = await res.json()
|
||||||
const events:CalendarEvent[]=[]
|
const events:CalendarEvent[]=[]
|
||||||
|
const catColor = {};
|
||||||
exams.forEach((ex)=>{
|
exams.forEach((ex)=>{
|
||||||
const {id,title,start,end,category_id} = ex
|
const {id,title,start,end,category} = ex
|
||||||
let backgroundColor ="#23ccef"
|
if(!category)
|
||||||
switch (String(category_id)) {
|
return
|
||||||
case "1":
|
const backgroundColor = getBgColorDict(category,catColor)
|
||||||
backgroundColor="rgba(251,64,75,.2)"
|
|
||||||
break;
|
|
||||||
case "2":
|
|
||||||
backgroundColor="#23ccef"
|
|
||||||
break;
|
|
||||||
case "3":
|
|
||||||
backgroundColor="rgba(68,125,247,.2)"
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const url = "/competitive/"+id
|
const url = "/competitive/"+id
|
||||||
if(start){
|
if(start){
|
||||||
ex.date = dayjs(start).format("DD MMM BBBB")
|
ex.date = dayjs(start).format("DD MMM BBBB")
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import {qualifyingBase} from '$lib/data/CMSDataType'
|
import {qualifyingBase} from '$lib/data/CMSDataType'
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
import type {CalendarEvent,Exam} from '$lib/data/CMSDataType'
|
import type {CalendarEvent,Exam} from '$lib/data/CMSDataType'
|
||||||
|
import {getBgColorDict} from '$lib/utils'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import type { PageServerLoad } from './$types'
|
import type { PageServerLoad } from './$types'
|
||||||
export const load: PageServerLoad = async ({fetch}) => {
|
export const load: PageServerLoad = async ({fetch}) => {
|
||||||
|
|
@ -8,28 +9,20 @@ export const load: PageServerLoad = async ({fetch}) => {
|
||||||
if(!res.ok)
|
if(!res.ok)
|
||||||
throw error(res.status, 'ไม่สามารถอ่านข้อมูลการสอบได้');
|
throw error(res.status, 'ไม่สามารถอ่านข้อมูลการสอบได้');
|
||||||
const exams:Exam[] = await res.json()
|
const exams:Exam[] = await res.json()
|
||||||
|
const catColor = {};
|
||||||
const events:CalendarEvent[]=[]
|
const events:CalendarEvent[]=[]
|
||||||
|
|
||||||
exams.forEach((ex)=>{
|
exams.forEach((ex)=>{
|
||||||
const {id,title,start,end,category_id} = ex
|
const {id,title,start,end,category} = ex
|
||||||
let backgroundColor ="#23ccef"
|
if(!category)
|
||||||
switch (String(category_id)) {
|
return
|
||||||
case "1":
|
const backgroundColor = getBgColorDict(category,catColor)
|
||||||
backgroundColor="rgba(251,64,75,.2)"
|
|
||||||
break;
|
|
||||||
case "2":
|
|
||||||
backgroundColor="#23ccef"
|
|
||||||
break;
|
|
||||||
case "3":
|
|
||||||
backgroundColor="rgba(68,125,247,.2)"
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const url = "/qualifying/"+id
|
const url = "/qualifying/"+id
|
||||||
if(start){
|
if(start){
|
||||||
ex.date = dayjs(start).format("DD MMM BBBB")
|
ex.date = dayjs(start).format("DD MMM BBBB")
|
||||||
events.push({id,title,start,end,url,backgroundColor})
|
console.log({id,title,start,end,url,backgroundColor})
|
||||||
|
events.push({id,title,start,url,backgroundColor})
|
||||||
}
|
}
|
||||||
if(ex.exam_date){
|
if(ex.exam_date){
|
||||||
events.push({id,"title":"วันสอบคัดเลือก","start":ex.exam_date,url,backgroundColor})
|
events.push({id,"title":"วันสอบคัดเลือก","start":ex.exam_date,url,backgroundColor})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue