mirror of
https://github.com/UniversityOfHelsinkiCS/oodikone.git
synced 2026-10-12 19:03:39 +03:00
[Frontend] Add oodikone-shared
This commit is contained in:
@@ -4,6 +4,7 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- oodikone-shared-2
|
||||
paths:
|
||||
- '.github/workflows/test.yaml'
|
||||
- '.github/workflows/staging.yaml'
|
||||
@@ -41,7 +42,7 @@ jobs:
|
||||
with:
|
||||
image: oodikone-frontend
|
||||
tags: staging ${{ github.sha }}
|
||||
context: services/frontend
|
||||
context: services
|
||||
containerfiles: |
|
||||
services/frontend/Dockerfile
|
||||
build-args: |
|
||||
@@ -88,40 +89,39 @@ jobs:
|
||||
registry: quay.io/toska
|
||||
username: toska+github
|
||||
password: ${{ secrets.QUAY_IO_TOKEN }}
|
||||
|
||||
report_success:
|
||||
name: 'Report deployment success to oodikone notifications'
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- release_frontend
|
||||
- release_backend
|
||||
|
||||
if: success()
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: 'Send notification to slack'
|
||||
uses: UniversityOfHelsinkiCS/slackbot-action@v1.5
|
||||
with:
|
||||
webhook-url: ${{ secrets.WEBHOOK_URL }}
|
||||
message-type: deployment
|
||||
softa-url: https://toska-staging.cs.helsinki.fi/oodikone
|
||||
deployment-target: staging
|
||||
|
||||
report_failure:
|
||||
name: 'Report deployment failure to oodikone notifications'
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- release_frontend
|
||||
- release_backend
|
||||
|
||||
if: failure()
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: 'Send notification to slack'
|
||||
uses: UniversityOfHelsinkiCS/slackbot-action@v1.5
|
||||
with:
|
||||
webhook-url: ${{ secrets.WEBHOOK_URL }}
|
||||
message-type: deployment-failure
|
||||
deployment-target: staging
|
||||
# report_success:
|
||||
# name: 'Report deployment success to oodikone notifications'
|
||||
# runs-on: ubuntu-latest
|
||||
# needs:
|
||||
# - release_frontend
|
||||
# - release_backend
|
||||
#
|
||||
# if: success()
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
# - name: 'Send notification to slack'
|
||||
# uses: UniversityOfHelsinkiCS/slackbot-action@v1.5
|
||||
# with:
|
||||
# webhook-url: ${{ secrets.WEBHOOK_URL }}
|
||||
# message-type: deployment
|
||||
# softa-url: https://toska-staging.cs.helsinki.fi/oodikone
|
||||
# deployment-target: staging
|
||||
#
|
||||
# report_failure:
|
||||
# name: 'Report deployment failure to oodikone notifications'
|
||||
# runs-on: ubuntu-latest
|
||||
# needs:
|
||||
# - release_frontend
|
||||
# - release_backend
|
||||
#
|
||||
# if: failure()
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
# - name: 'Send notification to slack'
|
||||
# uses: UniversityOfHelsinkiCS/slackbot-action@v1.5
|
||||
# with:
|
||||
# webhook-url: ${{ secrets.WEBHOOK_URL }}
|
||||
# message-type: deployment-failure
|
||||
# deployment-target: staging
|
||||
|
||||
@@ -29,7 +29,8 @@ services:
|
||||
<<: *defaults
|
||||
container_name: frontend
|
||||
build:
|
||||
context: services/frontend
|
||||
context: services
|
||||
dockerfile: frontend/Dockerfile
|
||||
|
||||
kone-db:
|
||||
<<: *defaults
|
||||
|
||||
@@ -60,6 +60,7 @@ services:
|
||||
volumes:
|
||||
- frontend-nodemod:/opt/app-root/src/node_modules
|
||||
- ./services/frontend/:/opt/app-root/src
|
||||
- ./services/oodikone-shared/:/opt/app-root/oodikone-shared
|
||||
|
||||
kone-db:
|
||||
<<: *defaults
|
||||
|
||||
@@ -29,9 +29,10 @@ ENV REACT_APP_SENTRY_DSN=$SENTRY_DSN
|
||||
ARG SERVICE_PROVIDER
|
||||
ENV REACT_APP_SERVICE_PROVIDER=$SERVICE_PROVIDER
|
||||
|
||||
COPY ./package* ./
|
||||
COPY ./oodikone-shared/ ../oodikone-shared
|
||||
COPY ./frontend/package* ./
|
||||
RUN npm ci --include=dev
|
||||
COPY . .
|
||||
COPY ./frontend .
|
||||
|
||||
RUN npm run build && npm install -g serve@12.0.0
|
||||
|
||||
|
||||
Generated
+6
@@ -14,6 +14,7 @@
|
||||
"immer": "^10.0.4",
|
||||
"lodash": "^4.17.21",
|
||||
"moment": "^2.30.1",
|
||||
"oodikone-shared": "file:../oodikone-shared",
|
||||
"prop-types": "^15.8.1",
|
||||
"query-string": "^9.0.0",
|
||||
"react": "^18.2.0",
|
||||
@@ -39,6 +40,7 @@
|
||||
"vite": "^5.2.10"
|
||||
}
|
||||
},
|
||||
"../oodikone-shared": {},
|
||||
"node_modules/@babel/runtime": {
|
||||
"version": "7.24.7",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.7.tgz",
|
||||
@@ -2286,6 +2288,10 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/oodikone-shared": {
|
||||
"resolved": "../oodikone-shared",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/parse-entities": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-4.0.1.tgz",
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"immer": "^10.0.4",
|
||||
"lodash": "^4.17.21",
|
||||
"moment": "^2.30.1",
|
||||
"oodikone-shared": "file:../oodikone-shared",
|
||||
"prop-types": "^15.8.1",
|
||||
"query-string": "^9.0.0",
|
||||
"react": "^18.2.0",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { mapToProviders } from 'oodikone-shared/util/mapToProviders'
|
||||
import { useState } from 'react'
|
||||
import { Button, Dropdown, Form, Message, Segment } from 'semantic-ui-react'
|
||||
|
||||
@@ -8,7 +9,6 @@ import { useGetAuthorizedUserQuery } from '@/redux/auth'
|
||||
import { useGetProvidersQuery } from '@/redux/providers'
|
||||
import { useGetSemestersQuery } from '@/redux/semesters'
|
||||
import { useLazyGetTeacherStatisticsQuery } from '@/redux/teachers'
|
||||
import { mapToProviders } from './mapToProviders'
|
||||
|
||||
export const TeacherStatistics = () => {
|
||||
const { getTextIn } = useLanguage()
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
// Identical logic can be found in the backend (src/util/map.js)
|
||||
// If the logic changes, remember to update the backend as well
|
||||
|
||||
const handleUnderscoreProgrammeCode = programmeCode => {
|
||||
const [left, right] = programmeCode.split('_')
|
||||
const prefix = [...left].filter(char => !Number.isNaN(Number(char))).join('')
|
||||
const suffix = `${left[0]}${right}`
|
||||
return `${prefix}0-${suffix}`
|
||||
}
|
||||
|
||||
const handleDoctoralProgrammeCode = programmeCode => {
|
||||
const numbers = programmeCode.substring(1)
|
||||
const courseProvider = Number(`7${numbers}`)
|
||||
if (courseProvider < 7920111 && courseProvider > 7920102) {
|
||||
return `${courseProvider + 1}`
|
||||
}
|
||||
if (courseProvider === 7920111) {
|
||||
return '7920103'
|
||||
}
|
||||
return `${courseProvider}`
|
||||
}
|
||||
|
||||
export const mapToProviders = programmeCodes => {
|
||||
return programmeCodes.map(programmeCode => {
|
||||
if (programmeCode.includes('_')) {
|
||||
return handleUnderscoreProgrammeCode(programmeCode)
|
||||
}
|
||||
if (/^(T)[0-9]{6}$/.test(programmeCode)) {
|
||||
return handleDoctoralProgrammeCode(programmeCode)
|
||||
}
|
||||
return programmeCode
|
||||
})
|
||||
}
|
||||
@@ -23,6 +23,7 @@ export default defineConfig({
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
},
|
||||
preserveSymlinks: true,
|
||||
},
|
||||
build: {
|
||||
outDir: 'build',
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
/* eslint-disable no-console */
|
||||
const helloWorld = () => {
|
||||
console.log('Hello World!')
|
||||
}
|
||||
|
||||
module.exports = { helloWorld }
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "oodikone-shared",
|
||||
"description": "Shared code between frontend and backend",
|
||||
"main": "index.js"
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2021",
|
||||
"lib": ["ES2023"],
|
||||
"allowJs": true,
|
||||
"moduleResolution": "nodenext",
|
||||
"module": "nodenext",
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noImplicitAny": false,
|
||||
"noErrorTruncation": true,
|
||||
"sourceMap": true,
|
||||
"sourceRoot": "/",
|
||||
"inlineSources": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": ["./**/*.ts"]
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
const handleUnderscoreProgrammeCode = (programmeCode: string) => {
|
||||
const [left, right] = programmeCode.split('_')
|
||||
const prefix = [...left!].filter(char => !Number.isNaN(Number(char))).join('')
|
||||
const suffix = `${left![0]}${right}`
|
||||
return `${prefix}0-${suffix}`
|
||||
}
|
||||
|
||||
const handleDoctoralProgrammeCode = (programmeCode: string) => {
|
||||
const numbers = programmeCode.substring(1)
|
||||
const courseProvider = Number(`7${numbers}`)
|
||||
if (courseProvider < 7920111 && courseProvider > 7920102) {
|
||||
return `${courseProvider + 1}`
|
||||
}
|
||||
if (courseProvider === 7920111) {
|
||||
return '7920103'
|
||||
}
|
||||
return `${courseProvider}`
|
||||
}
|
||||
|
||||
export const programmeCodeToProviderCode = (programmeCode: string) => {
|
||||
if (programmeCode.includes('_')) {
|
||||
return handleUnderscoreProgrammeCode(programmeCode)
|
||||
}
|
||||
if (/^(T)[0-9]{6}$/.test(programmeCode)) {
|
||||
return handleDoctoralProgrammeCode(programmeCode)
|
||||
}
|
||||
return programmeCode
|
||||
}
|
||||
|
||||
export const mapToProviders = (programmeCodes: string[]) => {
|
||||
return programmeCodes.map(programmeCodeToProviderCode)
|
||||
}
|
||||
Reference in New Issue
Block a user