Skip to content

Commit

Permalink
Merge develop into test (#8) (#9)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
jakdan99 and yuanchen233 authored Aug 29, 2024
1 parent c89c3c7 commit 1269c54
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 10 deletions.
7 changes: 7 additions & 0 deletions LICENCE.md
Original file line number Diff line number Diff line change
@@ -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.
60 changes: 52 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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= <Keycloak URL>
VITE_KEYCLOAK_REALM= <Name of the Keycloak realm>
VITE_KEYCLOAK_CLIENT_ID= <Keycloak clientID>
VITE_KEYCLOAK_REDIRECT_URI= <Valid Keycloak redirect URL to redirect after login>
```

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/`.
---

Expand All @@ -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 <REPOSITORY>/<CONTAINER-NAME>:${{ env.TAG }} .
docker push <REPOSITORY>/<CONTAINER-NAME>:${{ 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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions src/assets/inputTypeNames.ts
Original file line number Diff line number Diff line change
@@ -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;
}
3 changes: 2 additions & 1 deletion src/pages/Protocol/ProtocolCards/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -116,7 +117,7 @@ const ProtocolCards = () => {
return (
<li key={uuidv4()}>
<Typography variant="h4">
{data.attribute.inputDataType.name}
{getInputDataName(data.attribute.inputDataType.name)}
</Typography>
</li>
);
Expand Down
3 changes: 2 additions & 1 deletion src/pages/StudyProtocol/ProtocolCards/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -120,7 +121,7 @@ const ProtocolCards = ({ protocolId }: Props) => {
return (
<li key={uuidv4()}>
<Typography variant="h4">
{data.attribute.inputDataType.name}
{getInputDataName(data.attribute.inputDataType.name)}
</Typography>
</li>
);
Expand Down

0 comments on commit 1269c54

Please sign in to comment.