diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index d2ea852..c286741 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -68,7 +68,7 @@ jobs: - name: 👁️ Checkout repository uses: actions/checkout@v4 with: - fetch-depth: 1 # important to fetch tag logs + fetch-depth: 0 # important to fetch tag logs - name: 📦 pnpm install run: pnpm install diff --git a/CHANGELOG.md b/CHANGELOG.md index e50f81d..0540fe4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,28 @@ All notable changes to this project will be documented in this file. +## [v0.3.5](https://code.thetadev.de/HSA/Visitenbuch/compare/v0.3.4..v0.3.5) - 2024-05-20 + +### 🚀 Features + +- Focus filter bar when pressing F - ([ad796dc](https://code.thetadev.de/HSA/Visitenbuch/commit/ad796dcb578b79b566559d1c22c99f0231a03251)) +- Add optional Keycloak endpoint config - ([d746e47](https://code.thetadev.de/HSA/Visitenbuch/commit/d746e4787d70080bbc22b37263bbfa695c1a7d72)) + +### 🐛 Bug Fixes + +- Dont create entry executions if entry is only postponed - ([34e54fa](https://code.thetadev.de/HSA/Visitenbuch/commit/34e54fa4afdf17e7258cbc5ccac5a3d094ee161b)) +- HumanDate capitalization - ([f4f03ab](https://code.thetadev.de/HSA/Visitenbuch/commit/f4f03ab4914f850b15acf7bb39da34b1abb587a7)) +- Filterbar does not exclude present filters from URL, text filters dont confirm when defocused - ([9ed5f15](https://code.thetadev.de/HSA/Visitenbuch/commit/9ed5f15b9ef237cc400b069928baeb920b2d3681)) +- [**breaking**] Ensure category, room and station names are unique - ([98c62ac](https://code.thetadev.de/HSA/Visitenbuch/commit/98c62ac4603fa6d7c97e1a439f613379db7a2587)) +- Allow multiple date filters - ([2a4bda7](https://code.thetadev.de/HSA/Visitenbuch/commit/2a4bda70c6cfd85b4a32989a2e19ba718cc7717e)) +- Add dumb-init to docker image - ([47f0a08](https://code.thetadev.de/HSA/Visitenbuch/commit/47f0a08ea3dbd8b1721a11c52b36c42ad56e8e29)) +- Remove test route - ([03f6c58](https://code.thetadev.de/HSA/Visitenbuch/commit/03f6c5848201eff02999c6b9323ec1515d68fd5a)) + +### ⚙️ Miscellaneous Tasks + +- Remove unused zod-form-data dependency - ([882ae66](https://code.thetadev.de/HSA/Visitenbuch/commit/882ae66a6a137259388525df2c91b8e1ed924d86)) + + ## [v0.3.4](https://code.thetadev.de/HSA/Visitenbuch/compare/v0.3.3..v0.3.4) - 2024-05-16 ### 🚀 Features diff --git a/Dockerfile b/Dockerfile index 6adb62d..f0631df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,8 @@ COPY package.json pnpm-lock.yaml run/entrypoint.sh ./ COPY prisma ./prisma # Setup pnpm, install Prisma CLI (for generating client) and install dependencies -RUN npm config set update-notifier false && \ +RUN apk add dumb-init && \ + npm config set update-notifier false && \ corepack enable && \ pnpm i --prod && \ pnpm audit fix && \ diff --git a/README.md b/README.md index 1f1a26e..cc42fac 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,34 @@ for the university hospital in Augsburg ## Development -The project template was created using [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte). +The project template was created using +[`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte). -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: +Once you've created a project and installed dependencies with `npm install` (or +`pnpm install` or `yarn`), start a development server: ```bash -npm run dev +pnpm run dev # or start the server and open the app in a new browser tab -npm run dev -- --open +pnpm run dev -- --open ``` -### Handle the prisma ORM +### Test environment + +Copy the `.env.example` file to `.env` to get access to the required configuration +variables. + +The project depends on a PostgreSQL database and an OIDC authentication server. You can +setup both using the `run/db_up.sh` script. This creates a new testing environment using +docker-compose and fills the test database with mock data. + +### Use the Pisma ORM + +If you apply changes to the database scheme, you have to create a new migration to apply +these changes to the database. ```bash -./run/db_up.sh # Start the docker container, create a new database and run migrations + insert test data npx prisma migrate dev --name my_migration --create-only # Create a new migration npx prisma migrate dev # Apply migrations to the database ``` @@ -28,12 +41,20 @@ npx prisma migrate dev # Apply migrations to the database To create a production version of your app: ```bash -npm run build +pnpm run build ``` You can preview the production build with `npm run preview`. -> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment. +> To deploy your app, you may need to install an +> [adapter](https://kit.svelte.dev/docs/adapters) for your target environment. + +### Test + +```bash +pnpm test # Unit- und Integrationstests +pnpm test:e2e # End2End-Tests +``` ### Release @@ -42,3 +63,10 @@ To release a new version, tun the release script with the new version as a param ```bash ./release.sh 1.0.0 ``` + +### Building docker image + +```bash +pnpm run build +docker build -t thetadev256/visitenbuch . +``` diff --git a/package.json b/package.json index 722de0f..1bde82a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "visitenbuch", - "version": "0.3.4", + "version": "0.3.5", "private": true, "license": "AGPL-3.0", "scripts": { @@ -28,8 +28,7 @@ "qs": "^6.12.1", "set-cookie-parser": "^2.6.0", "svelte-floating-ui": "^1.5.8", - "zod": "^3.23.8", - "zod-form-data": "^2.0.2" + "zod": "^3.23.8" }, "devDependencies": { "@faker-js/faker": "^8.4.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8e977f6..c90e8bb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,9 +41,6 @@ dependencies: zod: specifier: ^3.23.8 version: 3.23.8 - zod-form-data: - specifier: ^2.0.2 - version: 2.0.2(zod@3.23.8) devDependencies: '@faker-js/faker': @@ -5961,14 +5958,6 @@ packages: dev: true optional: true - /zod-form-data@2.0.2(zod@3.23.8): - resolution: {integrity: sha512-sKTi+k0fvkxdakD0V5rq+9WVJA3cuTQUfEmNqvHrTzPLvjfLmkkBLfR0ed3qOi9MScJXTHIDH/jUNnEJ3CBX4g==} - peerDependencies: - zod: '>= 3.11.0' - dependencies: - zod: 3.23.8 - dev: false - /zod-to-json-schema@3.23.0(zod@3.23.8): resolution: {integrity: sha512-az0uJ243PxsRIa2x1WmNE/pnuA05gUq/JB8Lwe1EDCCL/Fz9MgjYQ0fPlyc2Tcv6aF2ZA7WM5TWaRZVEFaAIag==} requiresBuild: true diff --git a/prisma/migrations/20240518143538_unique_cat_room_station/migration.sql b/prisma/migrations/20240518143538_unique_cat_room_station/migration.sql new file mode 100644 index 0000000..7686fa8 --- /dev/null +++ b/prisma/migrations/20240518143538_unique_cat_room_station/migration.sql @@ -0,0 +1,16 @@ +/* + Warnings: + + - A unique constraint covering the columns `[name]` on the table `categories` will be added. If there are existing duplicate values, this will fail. + - A unique constraint covering the columns `[name]` on the table `rooms` will be added. If there are existing duplicate values, this will fail. + - A unique constraint covering the columns `[name]` on the table `stations` will be added. If there are existing duplicate values, this will fail. + +*/ +-- CreateIndex +CREATE UNIQUE INDEX "categories_name_key" ON "categories"("name"); + +-- CreateIndex +CREATE UNIQUE INDEX "rooms_name_key" ON "rooms"("name"); + +-- CreateIndex +CREATE UNIQUE INDEX "stations_name_key" ON "stations"("name"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 633705d..bfc2700 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -50,7 +50,7 @@ model User { // Hospital station model Station { id Int @id @default(autoincrement()) - name String + name String @unique Room Room[] hidden Boolean @default(false) @@ -60,7 +60,7 @@ model Station { // Hospital room model Room { id Int @id @default(autoincrement()) - name String + name String @unique station Station @relation(fields: [station_id], references: [id], onDelete: Restrict) station_id Int Patient Patient[] @@ -90,7 +90,7 @@ model Patient { // Entry category (e.g. Blood test, Exams, ...) model Category { id Int @id @default(autoincrement()) - name String + name String @unique color String? description String? EntryVersion EntryVersion[] diff --git a/run/entrypoint.sh b/run/entrypoint.sh index c749cb0..f7ebe95 100755 --- a/run/entrypoint.sh +++ b/run/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/dumb-init /bin/sh set -e # Migrate database before starting server npx prisma migrate deploy diff --git a/src/lib/components/filter/FilterBar.svelte b/src/lib/components/filter/FilterBar.svelte index 8a68b01..2791bb2 100644 --- a/src/lib/components/filter/FilterBar.svelte +++ b/src/lib/components/filter/FilterBar.svelte @@ -1,6 +1,7 @@ + +
{#each activeFilters as fdata, i} diff --git a/src/lib/components/filter/FilterChip.svelte b/src/lib/components/filter/FilterChip.svelte index 260015c..4d869f2 100644 --- a/src/lib/components/filter/FilterChip.svelte +++ b/src/lib/components/filter/FilterChip.svelte @@ -41,6 +41,15 @@ } } : undefined; + function acceptTextInput(e: Event): void { + // @ts-expect-error Event is from HTML input + if (e.target?.value) { + // @ts-expect-error Input value is checked + fdata.selection = { id: null, name: e.target.value }; + } + stopEditing(true); + } + $: if (fdata.editing && autocomplete) { autocomplete.open(); } @@ -118,14 +127,10 @@ }} on:keypress={(e) => { if (e.key === "Enter") { - // @ts-expect-error Input value is checked - if (e.target?.value) { - // @ts-expect-error Input value is checked - fdata.selection = { id: null, name: e.target.value }; - } - stopEditing(true); + acceptTextInput(e); } }} + on:blur={acceptTextInput} /> {/if} {:else} diff --git a/src/lib/components/ui/EntryTodoButton.svelte b/src/lib/components/ui/EntryTodoButton.svelte index 6bedd3e..8e185cc 100644 --- a/src/lib/components/ui/EntryTodoButton.svelte +++ b/src/lib/components/ui/EntryTodoButton.svelte @@ -1,6 +1,21 @@ + +
{#each { length: 4 } as _, i} - - -