From 1269c5418dd3cf241cfc9f2808b5a14851b9e418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Jakab?= <61331998+jakdan99@users.noreply.github.com> Date: Thu, 29 Aug 2024 16:12:40 +0200 Subject: [PATCH] Merge develop into test (#8) (#9) * Use non-technical names for input data types (#6) * Update README and LICENCE (#7) --------- Co-authored-by: Yuan Chen <10835085+yuanchen233@users.noreply.github.com> --- LICENCE.md | 7 +++ README.md | 60 ++++++++++++++++--- package.json | 1 + src/assets/inputTypeNames.ts | 14 +++++ src/pages/Protocol/ProtocolCards/index.tsx | 3 +- .../StudyProtocol/ProtocolCards/index.tsx | 3 +- 6 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 LICENCE.md create mode 100644 src/assets/inputTypeNames.ts diff --git a/LICENCE.md b/LICENCE.md new file mode 100644 index 0000000..628ef94 --- /dev/null +++ b/LICENCE.md @@ -0,0 +1,7 @@ +Copyright (c) 2024 Technical University of Denmark (DTU). + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ”Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED ”AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index d229967..335fb91 100644 --- a/README.md +++ b/README.md @@ -14,19 +14,18 @@ The website is using React v18, Material-UI v5, [Carp Client TS (1.0.0)](https:/ 4. Create an `.env.` file in the root of the project: ``` -VITE_APP_NAME=... -VITE_BASE_URL=... -VITE_BASE_NAME=... -VITE_KEYCLOAK_URL=... -VITE_KEYCLOAK_REALM=... -VITE_KEYCLOAK_CLIENT_ID=... -VITE_KEYCLOAK_REDIRECT_URI=... +VITE_BASE_URL= <`/proxy` for local development or base URL for the backend> +VITE_BASE_NAME=/ +VITE_KEYCLOAK_URL= +VITE_KEYCLOAK_REALM= +VITE_KEYCLOAK_CLIENT_ID= +VITE_KEYCLOAK_REDIRECT_URI= ``` 4. You can now start the portal with `pnpm start` and you can access the portal at `http://localhost:3000`. > **Note** -> Every time a developer uses the `pnpm add`, `pnpm install`, `pnpm rm` (or similar npm commands), `pnpm` will remove the `non_npm_dependencies` from `node_modules/`. There is a post-install script that links the dependencies again, but this only works on UNIX-based systems. On Windows, you must manually copy the `non_npm_dependencies` to `node_modules/`, taking special care not to erase the **node_modules/@types** folder and its original content. +> Every time a developer uses the `pnpm add`, `pnpm install`, `pnpm rm` (or similar npm commands), `pnpm` will remove the `non_npm_dependencies` from `node_modules/`. There is a post-install script that links the dependencies again, but this only works on UNIX-based systems. On Windows, you must manually copy the `non_npm_dependencies` to `node_modules/`. --- @@ -35,3 +34,48 @@ VITE_KEYCLOAK_REDIRECT_URI=... ### Folder structure The [src](src) folder contains all the Typescript source code and static asset for the web interface. The web interface is using custom CARP fonts (MuseoSansRounded), and these custom font files can be found in the [fonts](src/assets/fonts) folder. The carp logo and the image used on the landing page are located in the [images](src/assets/images) folder. The [components](src/components) folder holds all the reusable components for the application and [pages](src/pages) contains the full sites, which are usually build up using the reusable components. + +## Deployment + +The project uses GitHub Actions to build and push the CARP Portal as a docker image, that can be then deployed on a preferred hosting service. To deploy your own version of the Portal fork this project and setup the configuaration for GitHub Actions. + +### Workflow + +To change the docker repository where the docker image is pushed, the following lines needs to be changed in [deployment.yaml](.github/workflows/deployment.yaml): + +``` +- name: Docker build and push + run: | + docker build -t /:${{ env.TAG }} . + docker push /:${{ env.TAG }} +``` + +### Secrets and variables + +#### Secrets + +For GitHub Actions secrets the following secrets needs to be added: +- `DOCKERHUB_TOKEN` API token for DockerHub +- `DOCKERHUB_USERNAME` Username for DockerHub + +#### Variables + +For variables, you need to create a special enviroment file content named `DEV_ENV`, `PLAYGROUND_ENV`, `PROD_ENV`, `TEST_ENV`. +Example: +``` +VITE_APP_NAME=... +VITE_BASE_URL=... +VITE_BASE_NAME=... +VITE_KEYCLOAK_URL=... +VITE_KEYCLOAK_REALM=... +VITE_KEYCLOAK_CLIENT_ID=... +VITE_KEYCLOAK_REDIRECT_URI=... +VITE_PORT=... +TAG=.. +``` + +The different enviroment files correspondes to the different branches in the project. +- `DEV_ENV` for the develop branch +- `TEST_ENV` for the test branch +- `PROD_ENV` for the main branch +- `PLAYGROUND_ENV` for every other branch diff --git a/package.json b/package.json index c025fcf..1c94d83 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "@carp-dk/portal", "version": "1.0.0", "homepage": "/", + "license": "MIT", "scripts": { "start": "cross-env NODE_ENV=development vite serve src --config vite.config.ts", "build": "cross-env NODE_ENV=production vite build src --config vite.config.ts", diff --git a/src/assets/inputTypeNames.ts b/src/assets/inputTypeNames.ts new file mode 100644 index 0000000..0fa9019 --- /dev/null +++ b/src/assets/inputTypeNames.ts @@ -0,0 +1,14 @@ +const enUS: { [key: string]: string } = { + + sex: "Biological Sex", + informed_consent: "Informed Consent", + phone_number: "Phone Number", + ssn: "Social Security Number", + full_name: "Full Name", + address: "Address", + diagnosis: "Diagnosis", +}; + +export const getInputDataName = (key: string): string => { + return enUS[key] || key; +} diff --git a/src/pages/Protocol/ProtocolCards/index.tsx b/src/pages/Protocol/ProtocolCards/index.tsx index f99ef18..8e9b8ec 100644 --- a/src/pages/Protocol/ProtocolCards/index.tsx +++ b/src/pages/Protocol/ProtocolCards/index.tsx @@ -7,6 +7,7 @@ import { Skeleton, Typography } from "@mui/material"; import { useParams } from "react-router-dom"; import { v4 as uuidv4 } from "uuid"; import DeviceDropdown from "../DeviceDropdown"; +import { getInputDataName } from "@Assets/inputTypeNames"; import { CardTitle, ProtocolDescription, @@ -116,7 +117,7 @@ const ProtocolCards = () => { return (
  • - {data.attribute.inputDataType.name} + {getInputDataName(data.attribute.inputDataType.name)}
  • ); diff --git a/src/pages/StudyProtocol/ProtocolCards/index.tsx b/src/pages/StudyProtocol/ProtocolCards/index.tsx index f88ccec..b7716e4 100644 --- a/src/pages/StudyProtocol/ProtocolCards/index.tsx +++ b/src/pages/StudyProtocol/ProtocolCards/index.tsx @@ -15,6 +15,7 @@ import { StyledNameCard, } from "./styles"; import DeviceConnection = carpProtocols.dk.cachet.carp.protocols.application.StudyProtocolSnapshot.DeviceConnection; +import { getInputDataName } from "@Assets/inputTypeNames"; type ParticipantRole = carpCommon.dk.cachet.carp.common.application.users.ParticipantRole; @@ -120,7 +121,7 @@ const ProtocolCards = ({ protocolId }: Props) => { return (
  • - {data.attribute.inputDataType.name} + {getInputDataName(data.attribute.inputDataType.name)}
  • );