diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index 7647117..b2031cb 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -2,12 +2,28 @@ name: 'CD' on: workflow_dispatch: + inputs: + tag: + description: 'Tag to change to' + default: 'latest' + required: false + type: string + +env: + IMAGE_NAME: registry.digitalocean.com/cutu2024/cutu2024-backend jobs: deploy: runs-on: ubuntu-latest steps: + - name: Set new image tag + uses: actions-hub/kubectl@master + env: + KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} + with: + args: set image deployment/cutu2024-backend cutu2024-backend=${{ env.IMAGE_NAME }}:${{ inputs.tag }} + - name: Rollout new deployment uses: actions-hub/kubectl@master env: diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c9ff562..88caf22 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,10 +1,13 @@ name: 'CI' on: - push: - branches: - - main workflow_dispatch: + inputs: + tag: + description: 'Image tag' + default: 'latest' + required: false + type: string env: IMAGE_NAME: registry.digitalocean.com/cutu2024/cutu2024-backend @@ -40,6 +43,6 @@ jobs: with: push: true context: "{{defaultContext}}:apps/server" - tags: ${{ env.IMAGE_NAME }}:latest + tags: ${{ env.IMAGE_NAME }}:${{ inputs.tag }} cache-from: type=gha,ref=${{ env.IMAGE_NAME }}:buildcache cache-to: type=gha,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max diff --git a/apps/web/package.json b/apps/web/package.json index f2a5512..d37be63 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -13,15 +13,14 @@ "lint": "next lint" }, "dependencies": { - "@fingerprintjs/fingerprintjs": "^4.2.2", "axios": "^1.6.8", "js-cookie": "^3.0.5", "next": "14.1.4", "react": "^18", "react-dom": "^18", "socket.io-client": "^4.7.5", - "uuid": "^9.0.1", - "universal-cookie": "^7.1.0" + "universal-cookie": "^7.1.0", + "uuid": "^9.0.1" }, "devDependencies": { "@types/js-cookie": "^3.0.6", diff --git a/apps/web/pnpm-lock.yaml b/apps/web/pnpm-lock.yaml index fba1781..189a5cb 100644 --- a/apps/web/pnpm-lock.yaml +++ b/apps/web/pnpm-lock.yaml @@ -5,9 +5,6 @@ settings: excludeLinksFromLockfile: false dependencies: - '@fingerprintjs/fingerprintjs': - specifier: ^4.2.2 - version: 4.2.2 axios: specifier: ^1.6.8 version: 1.6.8 @@ -26,12 +23,12 @@ dependencies: socket.io-client: specifier: ^4.7.5 version: 4.7.5 - uuid: - specifier: ^9.0.1 - version: 9.0.1 universal-cookie: specifier: ^7.1.0 version: 7.1.0 + uuid: + specifier: ^9.0.1 + version: 9.0.1 devDependencies: '@types/js-cookie': @@ -69,12 +66,6 @@ packages: engines: {node: '>=10'} dev: true - /@fingerprintjs/fingerprintjs@4.2.2: - resolution: {integrity: sha512-scD+pDgNZW78LuFAr7ms2yxmDx2NWC4+K5iiOjPT2ZlTlHFbLsORUzLJI2rcKicxxLtHbvf3A7BU1drVr4iHGg==} - dependencies: - tslib: 2.6.2 - dev: false - /@isaacs/cliui@8.0.2: resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} engines: {node: '>=12'} @@ -240,13 +231,14 @@ packages: tslib: 2.6.2 dev: false - /@types/js-cookie@3.0.6: - resolution: {integrity: sha512-wkw9yd1kEXOPnvEeEV1Go1MmxtBJL0RR79aOTAApecWFVu7w0NNXNqhcWgvw2YgZDYadliXkl14pa3WXw5jlCQ==} - dev: true /@types/cookie@0.6.0: resolution: {integrity: sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==} dev: false + /@types/js-cookie@3.0.6: + resolution: {integrity: sha512-wkw9yd1kEXOPnvEeEV1Go1MmxtBJL0RR79aOTAApecWFVu7w0NNXNqhcWgvw2YgZDYadliXkl14pa3WXw5jlCQ==} + dev: true + /@types/node@20.11.30: resolution: {integrity: sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==} dependencies: diff --git a/apps/web/public/user/qrcode.svg b/apps/web/public/user/qrcode.svg index ba5efa7..246f04b 100644 --- a/apps/web/public/user/qrcode.svg +++ b/apps/web/public/user/qrcode.svg @@ -2,9 +2,9 @@ QR Code - https://cutu-2024.vercel.app/user + https://cutu2024.sgcu.in.th/user - + diff --git a/apps/web/src/app/(screen)/display/components/FootBallSlider.tsx b/apps/web/src/app/(screen)/display/components/FootBallSlider.tsx index a04fa20..f8dec12 100644 --- a/apps/web/src/app/(screen)/display/components/FootBallSlider.tsx +++ b/apps/web/src/app/(screen)/display/components/FootBallSlider.tsx @@ -52,7 +52,7 @@ const FootBallSlider = (props: FootBallSliderProps) => { transition: "left 0.3s ease", }} > -
{ const [state, setState] = useState<'cu' | 'tu' | 'none'>('none'); const { status, tu, cu } = data; + + useEffect(() => { if (status == 'stop') { if (tu > cu) { diff --git a/apps/web/src/app/(screen)/screen/components/Overlay.tsx b/apps/web/src/app/(screen)/screen/components/Overlay.tsx index a2796e4..2f0a309 100644 --- a/apps/web/src/app/(screen)/screen/components/Overlay.tsx +++ b/apps/web/src/app/(screen)/screen/components/Overlay.tsx @@ -10,9 +10,8 @@ interface OverLayProps { } const Page = ({data} : OverLayProps) => { - console.log(data) return ( -
+
{
-
+
{ const OverLay = ({data}: OverLayProps) => { + return (
diff --git a/apps/web/src/app/(screen)/screen/page.tsx b/apps/web/src/app/(screen)/screen/page.tsx index 12a8666..3c76fa8 100644 --- a/apps/web/src/app/(screen)/screen/page.tsx +++ b/apps/web/src/app/(screen)/screen/page.tsx @@ -4,26 +4,26 @@ import { useEffect, useState } from "react"; import OverLay from "./components/Overlay"; import Display from "./components/Display"; import Cookies from "universal-cookie"; -import FingerprintJS from "@fingerprintjs/fingerprintjs"; import { Socket, io } from "socket.io-client"; +import { v4 as uuidv4 } from 'uuid'; const Screen = () => { + let fid: string | null = null; const [showedPage, setShowPage] = useState<"overlay" | "display">("overlay"); const [ data, setData ] = useState({ status: "waiting", - cu: 0, - tu: 0 + cu: 50, + tu: 50 }) - const cookies = new Cookies( null, { path: "/" } ) - //console.log(data) + const cookies = new Cookies( null, {httpOnly: true} ) + console.log(data) + //console.log('show: ', showedPage) useEffect(() => { const handleConnect = (socket: Socket) => { console.log('Client has connected to the server!'); - setTimeout(() => { - console.log('Subscribing'); - socket.emit('subscribe', '123'); - }, 3000); + console.log('Subscribing'); + socket.emit('subscribe', '123'); }; const handleScoreBoard = (scoreString: string) => { @@ -33,13 +33,13 @@ const Screen = () => { const cuScore = Math.round(parseFloat(parts[1])); const tuScore = Math.round(parseFloat(parts[3])); - //console.log({cuScore, tuScore} ) - setData({...data, cu: cuScore, tu: tuScore}) + //console.log({cuScore, tuScore}) + setData(data => ({...data, cu: cuScore, tu: tuScore})) } const handleScreen = (screen: string) => { - //console.log(screen); - //setShowPage('full' ? 'overlay' : 'display') + console.log(screen); + setShowPage(screen == 'overlay' ? 'overlay' : 'display') } const handleCid = (serverCid: string) => { @@ -54,7 +54,7 @@ const Screen = () => { const handleEvents = (events: string) => { console.log(events) - setData({...data, status: events}) + setData(data => ({...data, status: events})) } const handleDisconnect = () => { @@ -62,20 +62,17 @@ const Screen = () => { }; (async () => { - const savedCid = cookies.get('cid'); - - if(!cookies.get('fid')){ - const fp = await FingerprintJS.load(); - const result = await fp.get(); - const fid = result.visitorId; - cookies.set('fid', fid) + fid = cookies.get('fid'); + if (!fid) { + fid = uuidv4(); + cookies.set('fid', fid); } - - const fid = cookies.get('fid') - + + const savedCid = cookies.get('cid'); + const extraHeaders: { [key: string]: string } = { - fid: fid, - name: 'pun1' + fid: fid || '', + name: 'john' }; if (savedCid) { @@ -97,17 +94,17 @@ const Screen = () => { socket.on('events', handleEvents); socket.on('screen', handleScreen); - return () => { socket?.disconnect(); }; + })(); }, []); return ( -
+
{showedPage == "overlay" ? : } - + {/* */}
); } diff --git a/apps/web/src/app/(user)/credit/page.tsx b/apps/web/src/app/(user)/credit/page.tsx index 061760d..b12112f 100644 --- a/apps/web/src/app/(user)/credit/page.tsx +++ b/apps/web/src/app/(user)/credit/page.tsx @@ -1,58 +1,93 @@ import Image from "next/image"; import Link from "next/link"; const Credit = () => { - return ( -
- - arrow-back - -
-
- pink-shake-icon -

Credits

-
-
-
-

พัฒนาโดย

- - ฝ่ายพัฒนาระบบสารสนเทศ
องค์การบริหารสโมสรนิสิต
จุฬาลงกรณ์มหาวิทยาลัย -
-
-
-

Project Manager

-
    -
  • ปณิธิ มักเที่ยงตรง
  • -
-
-
-

UX/UI Designer

-
    -
  • พิชญา พูลเพียร
  • -
-
-
-

Developers

-
    -
  • ธนฤต ตรีมหาฤกษ์
  • -
  • สหรัถ นวมจิตร
  • -
  • ชยพล อาภายะธรรม
  • -
  • สิรวิชญ์ ชนะบูรณาศักดิ์
  • -
  • ชโณทัย กระแจ่ม
  • -
  • นันท์นภัส พีรนพวัฒน์
  • -
  • ธนภัทร โชติพันธ์
  • -
-
-
-
+ return ( +
+ + arrow-back + +
+
+ pink-shake-icon +

Credits

+
+
+
+

พัฒนาโดย

+ + ฝ่ายพัฒนาระบบสารสนเทศ
องค์การบริหารสโมสรนิสิต
{" "} + จุฬาลงกรณ์มหาวิทยาลัย +
+
+
+

Project Manager

+ +
+
+

UX/UI Designer

+ +
+
+

Developers

+ +
- ); -} - -export default Credit; \ No newline at end of file +
+
+ ); +}; + +export default Credit; diff --git a/apps/web/src/app/(user)/shake/[university]/page.tsx b/apps/web/src/app/(user)/shake/[university]/page.tsx index cb9639f..ac9d678 100644 --- a/apps/web/src/app/(user)/shake/[university]/page.tsx +++ b/apps/web/src/app/(user)/shake/[university]/page.tsx @@ -7,9 +7,8 @@ import ShakeComponent from '../../../../components/Shake'; import { useParams, useSearchParams } from "next/navigation"; import { Suspense } from 'react'; import { io, Socket } from "socket.io-client"; -import FingerprintJS from '@fingerprintjs/fingerprintjs'; import Cookies from 'universal-cookie'; - +import { v4 as uuidv4 } from 'uuid'; let shaking: { x: number; y: number; z: number } | undefined; function normalize(x: number, y: number, z: number) { @@ -19,9 +18,18 @@ function normalize(x: number, y: number, z: number) { export default function Shake() { let fid: string | null = null; - //let socket: Socket | null = null; const cookies = new Cookies(); - const [ socketState, setSocketState ] = useState(null) + const [ socketState, setSocketState ] = useState(null) + + /* const temp = setTimeout(() => { + setCount(prevCount => { + const newCount = prevCount + 1; + if (socketState?.connected) { + socketState.emit("submit", `${university} 1`); + } + return newCount; + }); + }, 100) */ useEffect(() => { const handleConnect = () => { @@ -44,20 +52,24 @@ export default function Shake() { }; (async () => { - const fp = await FingerprintJS.load(); - const result = await fp.get(); - fid = result.visitorId; + fid = cookies.get('fid'); + if (!fid) { + fid = uuidv4(); + cookies.set('fid', fid); + } + + const savedCid = cookies.get('cid'); const extraHeaders: { [key: string]: string } = { - fid: fid, + fid: fid || '', name: 'john' }; if (savedCid) { extraHeaders.cid = savedCid; } - console.log(extraHeaders); + const socket = io('wss://api.cutu2024.sgcu.in.th', { auth: extraHeaders, path: "/api/ws", @@ -178,14 +190,6 @@ export default function Shake() { <> Loading...
} > - {/* */} ); diff --git a/apps/web/src/components/Shake.tsx b/apps/web/src/components/Shake.tsx index c6ee60f..45e5c15 100644 --- a/apps/web/src/components/Shake.tsx +++ b/apps/web/src/components/Shake.tsx @@ -25,7 +25,7 @@ export default function ShakeComponent({ arrow-back -
+
cu-tu-ball-logo chula-logo

{university == 'cu' ? '#ทีมจุฬาฯ' : '#ทีมมธ.'}

@@ -47,15 +47,15 @@ export default function ShakeComponent({
)}
- <> -
+
+
fire-icon
- +
)