From 53fa0c12caa389eaf8e676e93a9e265efd262612 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Wed, 6 Nov 2024 12:02:57 +1100 Subject: [PATCH 01/11] build.sh verbessert --- build.sh | 66 ++++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/build.sh b/build.sh index 38495dd5..603d9fb4 100644 --- a/build.sh +++ b/build.sh @@ -14,38 +14,24 @@ DB_PORT=5432 # ausgeführt zu werden. Außerdem würde es nicht wirklich Sinn ergeben, wenn das # Build Skript sich die Änderungen am build Skript holen würde... # Wir müssen alle lokalen Pakete verlinken + +# --------------------------------- Database --------------------------------- # + cd ../database bun link -cd ../api -bun link -cd ../ui -bun link -cd ../database bun install + +# ------------------------------------ API ----------------------------------- # + cd ../api bun install -cd ../ui -bun install +bun link @ibcornelsen/database + +# ------------------------------------ APP ----------------------------------- # + cd ../$APP_NAME - - -# Als erstes linken wir das package mit yalc, damit wir z.B. in online-energieausweis darauf zugreifen können. -cd ../database -bunx yalc push --scripts -cd ../api -bunx yalc push --scripts -cd ../$APP_NAME -bunx yalc add @ibcornelsen/database -bunx yalc add @ibcornelsen/api -# Dann installieren wir noch einmal alle dependencies, das ist besonders wichtig -# falls wir lokal verlinkte Projekte haben, sonst werden die nicht in unser -# docker image übernommen bun install - -# Dann stoppen wir unser altes docker image und bauen es neu. -docker stop $APP_NAME -docker rm $APP_NAME -docker build -t $APP_NAME . +bun link @ibcornelsen/database # Jeder unserer Applikationen hat ein Verzeichnis in dem alle Dateien dauerhaft, # Versionsunabhängig gespeichert werden. Dieses legen wir hier an, falls es noch @@ -54,10 +40,10 @@ PERSISTENT_DIR="${HOME}/persistent/${APP_NAME}"; mkdir -p $PERSISTENT_DIR; # TODO: Wir legen hier die .env Datei an, die die SSL Zertifikate enthält. -# rm -f ~/$APP_NAME/.env; -# touch ~/$APP_NAME/.env; -# echo "PRIVATE_KEY=$(cat /etc/letsencrypt/live/ibcornelsen.de/privkey.pem | base64 | tr -d '\n')" >> ~/$APP_NAME/.env; -# echo "CERTIFICATE=$(cat /etc/letsencrypt/live/ibcornelsen.de/fullchain.pem | base64 | tr -d '\n')" >> ~/$APP_NAME/.env; +rm -f ~/$APP_NAME/.env; +touch ~/$APP_NAME/.env; +echo "PRIVATE_KEY=$(cat /etc/letsencrypt/live/ibcornelsen.de/privkey.pem | base64 | tr -d '\n')" >> ~/$APP_NAME/.env; +echo "CERTIFICATE=$(cat /etc/letsencrypt/live/ibcornelsen.de/fullchain.pem | base64 | tr -d '\n')" >> ~/$APP_NAME/.env; # Wir müssen sichergehen, dass der Database Container läuft, sonst können wir ihn nicht linken. if [ ! $((docker ps | grep $DB_CONTAINER_NAME) | wc -l) -gt 0 ]; then @@ -66,12 +52,20 @@ if [ ! $((docker ps | grep $DB_CONTAINER_NAME) | wc -l) -gt 0 ]; then cd ../$APP_NAME; fi +# Auch die API sollte bereits laufen +if [ ! $((pm2 pid api | wc -l)) -gt 0 ]; then + cd ../api; + make prod; + cd ../$APP_NAME; +fi # Jetzt wo wir alle Vorbereitungen getroffen haben, starten wir das Docker Image und linken es mit der Datenbank. -docker run -d --name $APP_NAME --link $DB_CONTAINER_NAME \ - -v "${PERSISTENT_DIR}:/persistent" \ - -v "./node_modules/@ibcornelsen/database:/${APP_NAME}/node_modules/@ibcornelsen/database" \ - -v "./node_modules/@ibcornelsen/api:/${APP_NAME}/node_modules/@ibcornelsen/api" \ - -v "./node_modules/@ibcornelsen/ui:/${APP_NAME}/node_modules/@ibcornelsen/ui" \ - -p "${APP_PORT}:3000" \ - $APP_NAME; \ No newline at end of file +# docker run -d --name $APP_NAME --link $DB_CONTAINER_NAME \ +# -v "${PERSISTENT_DIR}:/persistent" \ +# -v "./node_modules/@ibcornelsen/database:/${APP_NAME}/node_modules/@ibcornelsen/database" \ +# -v "./node_modules/@ibcornelsen/api:/${APP_NAME}/node_modules/@ibcornelsen/api" \ +# -v "./node_modules/@ibcornelsen/ui:/${APP_NAME}/node_modules/@ibcornelsen/ui" \ +# -p "${APP_PORT}:3000" \ +# $APP_NAME; + +bun run dev \ No newline at end of file From 726c88da87b0100dbd5251187ae541ecdc4d0bda Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Wed, 6 Nov 2024 12:15:00 +1100 Subject: [PATCH 02/11] Update Makefile --- Makefile | 7 ++++++- build.sh | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 79daca17..976033ef 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: dev database api online-energieausweis all +.PHONY: dev database api online-energieausweis all prod online-energieausweis: bun run dev @@ -16,3 +16,8 @@ api: all: mkdir -p ~/logs bun run dev 2>&1 | tee ~/logs/`date '+%d-%m-%Y_%H:%M:%S'`.log + +prod: + mkdir -p ~/logs + pm2 stop online-energieausweis + pm2 start --name "online-energieausweis" --log ~/logs/`date '+%d-%m-%Y_%H:%M:%S'`.log --time bun -- astro dev \ No newline at end of file diff --git a/build.sh b/build.sh index 603d9fb4..d871c4d0 100644 --- a/build.sh +++ b/build.sh @@ -68,4 +68,4 @@ fi # -p "${APP_PORT}:3000" \ # $APP_NAME; -bun run dev \ No newline at end of file +make prod \ No newline at end of file From fcd187e875e31348cac37a0c6de1da8b4f8af864 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Wed, 6 Nov 2024 12:19:19 +1100 Subject: [PATCH 03/11] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 976033ef..61fd98c8 100644 --- a/Makefile +++ b/Makefile @@ -19,5 +19,5 @@ all: prod: mkdir -p ~/logs - pm2 stop online-energieausweis + - pm2 delete online-energieausweis pm2 start --name "online-energieausweis" --log ~/logs/`date '+%d-%m-%Y_%H:%M:%S'`.log --time bun -- astro dev \ No newline at end of file From 6e9857c582244964574ac2a889117dbb9563cc9d Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Wed, 6 Nov 2024 12:31:27 +1100 Subject: [PATCH 04/11] Update build.sh --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index d871c4d0..55a6df4c 100644 --- a/build.sh +++ b/build.sh @@ -53,7 +53,7 @@ if [ ! $((docker ps | grep $DB_CONTAINER_NAME) | wc -l) -gt 0 ]; then fi # Auch die API sollte bereits laufen -if [ ! $((pm2 pid api | wc -l)) -gt 0 ]; then +if [ $(pm2 pid api) -eq "0" ]; then cd ../api; make prod; cd ../$APP_NAME; From 754f6ab47aae06fb1f8b8395c62de07acdbf3253 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Wed, 6 Nov 2024 12:55:28 +1100 Subject: [PATCH 05/11] =?UTF-8?q?Sidebar=20=C3=BCberarbeitet=20Layout=20na?= =?UTF-8?q?ch=20den=20Vorgabenvon=20Umbe=20angepasst?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/SidebarRight.astro | 11 +++ src/components/SidebarWidgetLogin.svelte | 96 ++++++++++++++++++++++ src/components/SidebarWidgetProfile.svelte | 10 +++ src/components/UMBE_SidebarRight.astro | 2 +- src/components/UMBE_card-login.svelte | 44 ---------- src/layouts/Layout.astro | 1 + src/pages/dashboard/index.astro | 2 +- 7 files changed, 120 insertions(+), 46 deletions(-) create mode 100644 src/components/SidebarWidgetLogin.svelte create mode 100644 src/components/SidebarWidgetProfile.svelte delete mode 100644 src/components/UMBE_card-login.svelte diff --git a/src/components/SidebarRight.astro b/src/components/SidebarRight.astro index b1c968cc..696d5233 100644 --- a/src/components/SidebarRight.astro +++ b/src/components/SidebarRight.astro @@ -1,4 +1,15 @@ +--- +import { validateAccessTokenServer } from "#server/lib/validateAccessToken"; +import SidebarWidgetLogin from "./SidebarWidgetLogin.svelte"; +import SidebarWidgetProfile from "./SidebarWidgetProfile.svelte" + +const loggedin = await validateAccessTokenServer(Astro) +--- +
+ { !loggedin ? + : } +

Rufen Sie uns an
Wir sind gerne für Sie da diff --git a/src/components/SidebarWidgetLogin.svelte b/src/components/SidebarWidgetLogin.svelte new file mode 100644 index 00000000..6cb248dd --- /dev/null +++ b/src/components/SidebarWidgetLogin.svelte @@ -0,0 +1,96 @@ + + + + + diff --git a/src/components/SidebarWidgetProfile.svelte b/src/components/SidebarWidgetProfile.svelte new file mode 100644 index 00000000..18a5f194 --- /dev/null +++ b/src/components/SidebarWidgetProfile.svelte @@ -0,0 +1,10 @@ + + + \ No newline at end of file diff --git a/src/components/UMBE_SidebarRight.astro b/src/components/UMBE_SidebarRight.astro index 58f4a799..efce530b 100644 --- a/src/components/UMBE_SidebarRight.astro +++ b/src/components/UMBE_SidebarRight.astro @@ -1,5 +1,5 @@ --- -import Login from "#components/UMBE_card-login.svelte"; +import Login from "#components/SidebarWidgetLogin.svelte"; import Contact from "#components/UMBE_card-contact.svelte"; import Review from "#components/UMBE_card-review.svelte"; import VApromo from "#components/UMBE_card-VA-promo.svelte"; diff --git a/src/components/UMBE_card-login.svelte b/src/components/UMBE_card-login.svelte deleted file mode 100644 index b7a16687..00000000 --- a/src/components/UMBE_card-login.svelte +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 5e2a8d86..160e81aa 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -1,6 +1,7 @@ --- import i18next from "i18next"; +import "../style/UMBE_global.css"; import "../style/global.scss"; import "../../svelte-dialogs.config" import Footer from "../components/Footer.astro"; diff --git a/src/pages/dashboard/index.astro b/src/pages/dashboard/index.astro index 220a2ca5..30a7137a 100644 --- a/src/pages/dashboard/index.astro +++ b/src/pages/dashboard/index.astro @@ -12,7 +12,7 @@ if (!accessTokenValid) { const caller = createCaller(Astro); -const user = await caller.v1.benutzer.self(); +const user = await caller.v1.benutzer.self(undefined); const gebaeudeArray = await caller.v1.gebaeude.getMany({ limit: 5 }); --- From b0201c250f2f06986294978acd7750660de4a4dc Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 11 Nov 2024 12:15:01 +1100 Subject: [PATCH 06/11] mdx Seiten wieder in pages gepackt und Dependencies upgedated. --- astro.config.mjs | 43 ++++++------ package.json | 68 +++++++++---------- src/env.d.ts | 1 + src/lib/XML/getEmpfehlungen.ts | 2 +- src/lib/pdf/pdfVerbrauchsausweisWohnen.ts | 13 ++-- {mdx => src/pages}/agb.mdx | 0 .../pages}/energieausweis-aussteller.mdx | 0 {mdx => src/pages}/enev-zusammenfassung.mdx | 0 {mdx => src/pages}/kundenbewertungen.mdx | 0 {mdx => src/pages}/welcher-energieausweis.mdx | 0 tsconfig.json | 4 +- 11 files changed, 65 insertions(+), 66 deletions(-) rename {mdx => src/pages}/agb.mdx (100%) rename {mdx => src/pages}/energieausweis-aussteller.mdx (100%) rename {mdx => src/pages}/enev-zusammenfassung.mdx (100%) rename {mdx => src/pages}/kundenbewertungen.mdx (100%) rename {mdx => src/pages}/welcher-energieausweis.mdx (100%) diff --git a/astro.config.mjs b/astro.config.mjs index 5263c603..8dd067e0 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,41 +1,36 @@ import { defineConfig } from "astro/config"; import svelte from "@astrojs/svelte"; // import astroI18next from "astro-i18next"; - import tailwind from "@astrojs/tailwind"; - -// https://astro.build/config import node from "@astrojs/node"; - -// https://astro.build/config import mdx from "@astrojs/mdx"; import { fileURLToPath } from "url"; -// https://astro.build/config +// https://astro.build/config export default defineConfig({ integrations: [svelte(), tailwind(), mdx()], outDir: "./dist", output: "server", - vite: { - optimizeDeps: { - exclude: ["@ibcornelsen/api", "@ibcornelsen/database"] - }, - resolve: { - alias: { - "#": fileURLToPath(new URL("./src", import.meta.url)) - } - }, - build: { - commonjsOptions: { - transformMixedEsModules: true - } - } - }, + vite: { + optimizeDeps: { + exclude: ["@ibcornelsen/api", "@ibcornelsen/database"] + }, + resolve: { + alias: { + "#": fileURLToPath(new URL("./src", import.meta.url)) + } + }, + build: { + commonjsOptions: { + transformMixedEsModules: false + } + } + }, adapter: node({ mode: "middleware" }), - server: { - port: 3000 - } + server: { + port: 3000 + } }); \ No newline at end of file diff --git a/package.json b/package.json index e16fe4e7..0289b913 100644 --- a/package.json +++ b/package.json @@ -17,60 +17,60 @@ }, "private": true, "dependencies": { - "@astrojs/mdx": "^2.1.1", - "@astrojs/node": "^5.1.4", + "@astrojs/mdx": "^3.1.9", + "@astrojs/node": "^8.3.4", "@astrojs/svelte": "^2.2.0", "@astrojs/tailwind": "^3.1.3", "@ibcornelsen/api": "link:@ibcornelsen/api", "@ibcornelsen/database": "link:@ibcornelsen/database", "@ibcornelsen/ui": "^0.0.2", "@mollie/api-client": "^3.7.0", - "@pdfme/common": "^5.1.6", - "@pdfme/generator": "^5.1.6", - "@pdfme/ui": "^5.1.6", - "@trpc/client": "^10.45.0", - "@trpc/server": "^10.45.0", - "astro": "^2.5.1", + "@pdfme/common": "^5.1.7", + "@pdfme/generator": "^5.1.7", + "@pdfme/ui": "^5.1.7", + "@trpc/client": "^10.45.2", + "@trpc/server": "^10.45.2", + "astro": "^4.16.10", "astro-i18next": "1.0.0-beta.21", "body-scroll-lock": "^4.0.0-beta.0", "buffer": "^6.0.3", - "bun": "^1.0.2", + "bun": "^1.1.34", "csvtojson": "^2.0.10", - "express": "^4.18.2", - "flag-icons": "^6.9.2", - "fontkit": "^2.0.2", - "i18next": "^23.4.1", - "i18next-fs-backend": "^2.1.5", - "i18next-http-backend": "^2.2.1", + "express": "^4.21.1", + "flag-icons": "^6.15.0", + "fontkit": "^2.0.4", + "i18next": "^23.16.5", + "i18next-fs-backend": "^2.3.2", + "i18next-http-backend": "^2.6.2", "js-cookie": "^3.0.5", "js-interpolate": "^1.0.1", - "katex": "^0.16.7", - "moment": "^2.29.4", - "moment-timezone": "^0.5.45", + "katex": "^0.16.11", + "moment": "^2.30.1", + "moment-timezone": "^0.5.46", "radix-svelte-icons": "^1.0.0", - "sass": "^1.62.1", - "svelte": "^3.59.1", + "sass": "^1.80.6", + "svelte": "^3.59.2", "svelte-dialogs": "^1.2.2", - "svelte-preprocess": "^5.0.3", - "svelte-ripple-action": "^1.0.5", - "tailwindcss": "^3.3.2", + "svelte-preprocess": "^5.1.4", + "svelte-ripple-action": "^1.0.6", + "tailwindcss": "^3.4.14", "trpc-openapi": "^1.2.0", - "uuid": "^9.0.0", - "zod": "^3.22.4" + "uuid": "^9.0.1", + "zod": "^3.23.8" }, "devDependencies": { - "@faker-js/faker": "^8.3.1", - "@tailwindcss/typography": "^0.5.10", + "@faker-js/faker": "^8.4.1", + "@tailwindcss/typography": "^0.5.15", "@types/body-scroll-lock": "^3.1.2", - "@types/fontkit": "^2.0.6", + "@types/fontkit": "^2.0.7", "@types/js-cookie": "^3.0.6", - "@types/uuid": "^9.0.1", - "@typescript-eslint/eslint-plugin": "^5.59.6", - "@typescript-eslint/parser": "^5.59.6", - "bun-types": "^1.0.22", - "cypress": "^13.6.2", + "@types/uuid": "^9.0.8", + "@typescript-eslint/eslint-plugin": "^5.62.0", + "@typescript-eslint/parser": "^5.62.0", + "bun-types": "^1.1.34", + "cypress": "^13.15.2", "cypress-file-upload": "^5.0.8", - "daisyui": "^4.6.0", + "daisyui": "^4.12.14", "eslint": "~8.15.0", "eslint-config-prettier": "8.1.0", "prettier": "^2.8.8", diff --git a/src/env.d.ts b/src/env.d.ts index 29be4a13..1e58cf75 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -1,3 +1,4 @@ +/// /// /// diff --git a/src/lib/XML/getEmpfehlungen.ts b/src/lib/XML/getEmpfehlungen.ts index 1e7812f8..bdc31705 100644 --- a/src/lib/XML/getEmpfehlungen.ts +++ b/src/lib/XML/getEmpfehlungen.ts @@ -1,4 +1,4 @@ -import { VerbrauchsausweisWohnenClient } from "#components/Ausweis/types"; +import { VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js"; import { Enums } from "@ibcornelsen/database/client"; import moment from "moment"; diff --git a/src/lib/pdf/pdfVerbrauchsausweisWohnen.ts b/src/lib/pdf/pdfVerbrauchsausweisWohnen.ts index 3996cbe5..f9b53a88 100644 --- a/src/lib/pdf/pdfVerbrauchsausweisWohnen.ts +++ b/src/lib/pdf/pdfVerbrauchsausweisWohnen.ts @@ -1,14 +1,17 @@ -import { VerbrauchsausweisWohnenClient } from "#components/Ausweis/types"; +import { VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js"; import { generate } from "@pdfme/generator"; import VerbrauchsausweisWohnen2016Template from "../../lib/pdf/templates/GEG24_Verbrauchsausweis.json"; -import { convertAusweisData } from "#lib/AusweisData"; -import { variable } from "#lib/pdf/plugins/variables"; +import { convertAusweisData } from "#lib/AusweisData.js"; + +/* -------------------------------- Pdf Tools ------------------------------- */ +import { variable } from "#lib/pdf/plugins/variables/index.js"; import { text, image } from "@pdfme/schemas"; import { Schema, Template } from "@pdfme/common"; + import { Moment } from "moment"; -import { endEnergieVerbrauchVerbrauchsausweis_2016 } from "#lib/Berechnungen/VerbrauchsausweisWohnen/VerbrauchsausweisWohnen_2016"; +import { endEnergieVerbrauchVerbrauchsausweis_2016 } from "#lib/Berechnungen/VerbrauchsausweisWohnen/VerbrauchsausweisWohnen_2016.js"; import moment from "moment"; -import { getEmpfehlungen } from "#lib/XML/getEmpfehlungen"; +import { getEmpfehlungen } from "#lib/XML/getEmpfehlungen.js"; export async function pdfVerbrauchsausweisWohnen(ausweis: VerbrauchsausweisWohnenClient) { const template = VerbrauchsausweisWohnen2016Template as Template; diff --git a/mdx/agb.mdx b/src/pages/agb.mdx similarity index 100% rename from mdx/agb.mdx rename to src/pages/agb.mdx diff --git a/mdx/energieausweis-aussteller.mdx b/src/pages/energieausweis-aussteller.mdx similarity index 100% rename from mdx/energieausweis-aussteller.mdx rename to src/pages/energieausweis-aussteller.mdx diff --git a/mdx/enev-zusammenfassung.mdx b/src/pages/enev-zusammenfassung.mdx similarity index 100% rename from mdx/enev-zusammenfassung.mdx rename to src/pages/enev-zusammenfassung.mdx diff --git a/mdx/kundenbewertungen.mdx b/src/pages/kundenbewertungen.mdx similarity index 100% rename from mdx/kundenbewertungen.mdx rename to src/pages/kundenbewertungen.mdx diff --git a/mdx/welcher-energieausweis.mdx b/src/pages/welcher-energieausweis.mdx similarity index 100% rename from mdx/welcher-energieausweis.mdx rename to src/pages/welcher-energieausweis.mdx diff --git a/tsconfig.json b/tsconfig.json index abf900d1..b089c7e8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,9 +2,9 @@ "compilerOptions": { // Enable top-level await, and other modern ESM features "target": "ESNext", - "module": "ESNext", + "module": "NodeNext", // Enable node-style module resolution, for things like npm package imports - "moduleResolution": "node", + "moduleResolution": "NodeNext", // Enable JSON imports "resolveJsonModule": true, // Enable stricter transpilation for better output From a84d9f2c97259bb61eaaa2a2cbef9393bb21ceec Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Wed, 13 Nov 2024 11:23:46 +1100 Subject: [PATCH 07/11] Update Makefile --- Makefile | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 61fd98c8..57f316a6 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: dev database api online-energieausweis all prod +.PHONY: dev database api online-energieausweis all prod bun-install-database bun-install-api online-energieausweis: bun run dev @@ -9,6 +9,16 @@ database: cd ../database docker compose up +bun-install-database: + cd ../database + bun link + bun install + +bun-install-api: bun-install-database + cd ../api + bun install + bun link @ibcornelsen/database + api: cd ../api bun run dev @@ -17,7 +27,28 @@ all: mkdir -p ~/logs bun run dev 2>&1 | tee ~/logs/`date '+%d-%m-%Y_%H:%M:%S'`.log -prod: +prod: bun-install-api bun-install-database mkdir -p ~/logs + mkdir -p ~/persistent/online-energieausweis + +# Wir müssen sichergehen, dass der Database Container läuft, sonst können wir ihn nicht linken. + @if [ ! $$(docker ps | grep database | wc -l) -gt 0 ]; then \ + cd ../database; \ + $(MAKE) prod; \ + cd ../online-energieausweis; \ + fi + +# Auch die API sollte bereits laufen + @if [ $$(pm2 pid api) -eq "0" ]; then \ + cd ../api; \ + $(MAKE) prod; \ + cd ../online-energieausweis; \ + fi + + - rm -f ~/online-energieausweis/.env; + - touch ~/online-energieausweis/.env; + - echo "PRIVATE_KEY=$(cat /etc/letsencrypt/live/ibcornelsen.de/privkey.pem | base64 | tr -d '\n')" >> ~/online-energieausweis/.env; + - echo "CERTIFICATE=$(cat /etc/letsencrypt/live/ibcornelsen.de/fullchain.pem | base64 | tr -d '\n')" >> ~/online-energieausweis/.env; + - pm2 delete online-energieausweis pm2 start --name "online-energieausweis" --log ~/logs/`date '+%d-%m-%Y_%H:%M:%S'`.log --time bun -- astro dev \ No newline at end of file From ec309bfd7c54fa0f2a9e39b8bc3d032e9408eee9 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Wed, 13 Nov 2024 12:25:01 +1100 Subject: [PATCH 08/11] =?UTF-8?q?Update=20Makefile=20und=20Verbrauchsauswe?= =?UTF-8?q?isWohnenModule=20aufger=C3=A4umt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 6 +- src/components/AusweisPruefenBox.svelte | 62 +++++++++---------- .../VerbrauchsausweisWohnenModule.svelte | 30 ++++----- 3 files changed, 46 insertions(+), 52 deletions(-) diff --git a/Makefile b/Makefile index 57f316a6..a6393fe3 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,7 @@ online-energieausweis: dev: online-energieausweis api database database: - cd ../database - docker compose up + $(MAKE) -C ../database dev bun-install-database: cd ../database @@ -20,8 +19,7 @@ bun-install-api: bun-install-database bun link @ibcornelsen/database api: - cd ../api - bun run dev + $(MAKE) -C ../api dev all: mkdir -p ~/logs diff --git a/src/components/AusweisPruefenBox.svelte b/src/components/AusweisPruefenBox.svelte index a9817b4b..0586e338 100644 --- a/src/components/AusweisPruefenBox.svelte +++ b/src/components/AusweisPruefenBox.svelte @@ -5,7 +5,7 @@ VerbrauchsausweisWohnenClient, } from "./Ausweis/types.js"; import AusweisPruefenTooltip from "./AusweisPruefenTooltip.svelte"; - import { addNotification } from "./NotificationProvider/shared"; + import { addNotification } from "./NotificationProvider/shared.js"; import { CheckCircled, CrossCircled, Image } from "radix-svelte-icons"; import ChevronDown from "radix-svelte-icons/src/lib/icons/ChevronDown.svelte"; @@ -158,13 +158,13 @@ if (gebaeude_aufnahme_allgemein.solarsystem_warmwasser) { // Wenn Warmwasser Anteil unbekannt und Solarsystem verbrauchWWGesamt_1 = - calculations?.energetische_nutzfläche + + calculations?.energetischeNutzflaeche + " m² x 12 kWh/m² x 3 Jahre"; solarsystemWarmwasser = "Solarsystem Warmwasser"; } else { // Wenn Warmwasser Anteil unbekannt und **kein** Solarsystem verbrauchWWGesamt_1 = - calculations?.energetische_nutzfläche + + calculations?.energetischeNutzflaeche + " m² x 20 kWh/m² x 3 Jahre"; solarsystemWarmwasser = "kein Solarsystem Warmwasser"; } @@ -181,7 +181,7 @@ ausweis.keller_beheizt + " ) in m²"; table3Z1 = gebaeude_aufnahme_allgemein.flaeche; - table3Z2 = calculations?.energetische_nutzfläche; + table3Z2 = calculations?.energetischeNutzflaeche; tooltip4Z1 = @@ -261,7 +261,7 @@ tooltip8Z1 = - calculations?.energetische_nutzfläche + + calculations?.energetischeNutzflaeche + " m² x 6 kWh/m² x 3 Jahre >> Kühlungszuschlag in kWh"; tooltip8Z2 = ""; table8Z1 = calculations?.kuehlungsZuschlag; @@ -277,7 +277,7 @@ " + " + calculations?.energieVerbrauchHeizungBereinigt_2 + ") / (3 * " + - calculations?.energetische_nutzfläche + + calculations?.energetischeNutzflaeche + ") >> Durchschnittsverbrauch Heizung in kWh"; table9Z1 = calculations?.faktorDurchschnittsEnergieVerbrauchHeizungBereinigt; @@ -288,7 +288,7 @@ "faktorDurchschnittsEnergieVerbrauchHeizungBereinigt" ] + " x " + - calculations.leerstand + + calculations?.leerstand + " x (" + calculations.energieVerbrauchHeizungBereinigt_1 + " + " + @@ -304,21 +304,13 @@ table10Z1 = calculations?.leerstandsZuschlagHeizung; table10Z2 = calculations?.leerstandsZuschlagWarmwasser; - tooltip11Z1 = - "(" + - calculations?.energieVerbrauchHeizungBereinigt_1 + - " + " + - calculations?.energieVerbrauchWarmwasser_1 + - ") / (3 Jahre x " + - calculations?.energetische_nutzfläche + - ") Endenergieverbrauch 1 in kWh/m²a"; tooltip11Z2 = "(" + calculations?.energieVerbrauchHeizungBereinigt_2 + " + " + calculations?.energieVerbrauchWarmwasser_2 + ") / (3 Jahre x " + - calculations?.energetische_nutzfläche + + calculations?.energetischeNutzflaeche + ") Endenergieverbrauch 2 in kWh/m²a"; table11Z1 = calculations?.endEnergieVerbrauch_1; table11Z2 = calculations?.endEnergieVerbrauch_2; @@ -333,7 +325,7 @@ " x " + calculations?.primaerfaktorww + ")) / (3 Jahre x " + - calculations?.energetische_nutzfläche + + calculations?.energetischeNutzflaeche + ") Primärenergieverbrauch 1 in kWh/m²a"; tooltip12Z2 = "((" + @@ -345,7 +337,7 @@ " x " + calculations?.primaerfaktorww_1 + ")) / (3 Jahre x " + - calculations?.energetische_nutzfläche + + calculations?.energetischeNutzflaeche + ") Primärenergieverbrauch 2 in kWh/m²a"; table12Z1 = calculations?.primaerEnergieVerbrauch_1; table12Z2 = calculations?.primaerEnergieVerbrauch_2; @@ -356,13 +348,13 @@ " + " + calculations?.leerstandsZuschlagWarmwasser + ") / (3 Jahre x " + - calculations?.energetische_nutzfläche + + calculations?.energetischeNutzflaeche + ") Endenergieverbrauch Leerstand in kWh/m²a"; tooltip13Z2 = "(" + calculations?.kuehlungsZuschlag + ") / (3 Jahre x " + - calculations?.energetische_nutzfläche + + calculations?.energetischeNutzflaeche + ") Endenergieverbrauch Kühlung in kWh/m²a"; table13Z1 = calculations?.endEnergieVerbrauchLeerstandsZuschlag; table13Z2 = calculations?.endEnergieVerbrauchKuehlungsZuschlag; @@ -509,7 +501,7 @@ {ausweis.faktorKeller} x {gebaeude_aufnahme_allgemein.flaeche}m² Energetische Nutzfläche (Keller {gebaeude_aufnahme_allgemein.keller}) in m²

{gebaeude_aufnahme_allgemein.flaeche} - {calculations?.energetische_nutzfläche} + {calculations?.energetischeNutzflaeche} @@ -604,7 +596,7 @@ >
- {tooltip11Z1} + ({calculations?.energieVerbrauchHeizungBereinigt_1} + {calculations?.energieVerbrauchWarmwasser_1}) / (3 Jahre x {calculations?.energetischeNutzflaeche}) Endenergieverbrauch 1 in kWh/m²a
{tooltip11Z2}
@@ -748,7 +740,7 @@ ausweisAusstellen(gebaeude_aufnahme_allgemein.uid)}>A ausweisAusstellenPost(gebaeude_aufnahme_allgemein.uid)}>P ausweisnichtAusstellen(gebaeude_aufnahme_allgemein.uid)}>N bestellBestaetigung(gebaeude_aufnahme_allgemein.uid)}>B @@ -793,12 +785,16 @@ href="/energieausweis-erstellen/gespeichert?id={gebaeude_aufnahme_allgemein.uid}">F - {@html gebaeude_aufnahme_allgemein.kontrolldatei - ? `` - : ""} - {@html !gebaeude_aufnahme_allgemein.registriernummer - ? `` - : ""} + {#if gebaeude_aufnahme_allgemein.kontrolldatei} + + {/if} + {#if !gebaeude_aufnahme_allgemein.registriernummer} + + {/if} diff --git a/src/modules/Ausweise/VerbrauchsausweisWohnenModule.svelte b/src/modules/Ausweise/VerbrauchsausweisWohnenModule.svelte index 3968f3cf..e46d24b7 100644 --- a/src/modules/Ausweise/VerbrauchsausweisWohnenModule.svelte +++ b/src/modules/Ausweise/VerbrauchsausweisWohnenModule.svelte @@ -10,24 +10,24 @@ import moment from "moment"; import BilderZusatzsysteme from "#components/Ausweis/BilderZusatzsysteme.svelte"; import { RawNotificationWrapper, RawNotification, notifications } from "@ibcornelsen/ui"; - import { auditHeizungGebaeudeBaujahr } from "#components/Verbrauchsausweis/audits/HeizungGebaeudeBaujahr"; - import { auditHeizungJuengerDreiJahre } from "#components/Verbrauchsausweis/audits/HeizungJuengerDreiJahre"; - import { auditZeitraumAktuell } from "#components/Verbrauchsausweis/audits/ZeitraumAktuell"; - import { auditKlimaFaktoren } from "#components/Verbrauchsausweis/audits/KlimaFaktoren"; - import { auditWohnFlaeche } from "#components/Verbrauchsausweis/audits/WohnFlaeche"; - import { auditWarmWasser } from "#components/Verbrauchsausweis/audits/WarmWasser"; - import { auditLeerStand } from "#components/Verbrauchsausweis/audits/LeerStand"; - import { auditPlzNichtErkannt } from "#components/Verbrauchsausweis/audits/PlzNichtErkannt"; - import { AuditType, hidden } from "#components/Verbrauchsausweis/audits/hidden"; - import { auditBedarfsausweisBenoetigt } from "#components/Verbrauchsausweis/audits/BedarfsausweisBenoetigt"; - import { auditVerbrauchAbweichung } from "#components/Verbrauchsausweis/audits/VerbrauchAbweichung"; - import { auditEndEnergie } from "#components/Verbrauchsausweis/audits/EndEnergie"; - import { auditWohnflaecheGroesserGesamtflaeche } from "#components/Verbrauchsausweis/audits/WohnflaecheGroesserGesamtflaeche"; + import { auditHeizungGebaeudeBaujahr } from "#components/Verbrauchsausweis/audits/HeizungGebaeudeBaujahr.js"; + import { auditHeizungJuengerDreiJahre } from "#components/Verbrauchsausweis/audits/HeizungJuengerDreiJahre.js"; + import { auditZeitraumAktuell } from "#components/Verbrauchsausweis/audits/ZeitraumAktuell.js"; + import { auditKlimaFaktoren } from "#components/Verbrauchsausweis/audits/KlimaFaktoren.js"; + import { auditWohnFlaeche } from "#components/Verbrauchsausweis/audits/WohnFlaeche.js"; + import { auditWarmWasser } from "#components/Verbrauchsausweis/audits/WarmWasser.js"; + import { auditLeerStand } from "#components/Verbrauchsausweis/audits/LeerStand.js"; + import { auditPlzNichtErkannt } from "#components/Verbrauchsausweis/audits/PlzNichtErkannt.js"; + import { AuditType, hidden } from "#components/Verbrauchsausweis/audits/hidden.js"; + import { auditBedarfsausweisBenoetigt } from "#components/Verbrauchsausweis/audits/BedarfsausweisBenoetigt.js"; + import { auditVerbrauchAbweichung } from "#components/Verbrauchsausweis/audits/VerbrauchAbweichung.js"; + import { auditEndEnergie } from "#components/Verbrauchsausweis/audits/EndEnergie.js"; + import { auditWohnflaecheGroesserGesamtflaeche } from "#components/Verbrauchsausweis/audits/WohnflaecheGroesserGesamtflaeche.js"; import { Enums } from "@ibcornelsen/database/client" import Overlay from "#components/Overlay.svelte"; import AusweisGespeichertModule from "./AusweisGespeichertModule.svelte"; - import { VerbrauchsausweisWohnenClient, BenutzerClient, UploadedGebaeudeBild } from "#components/Ausweis/types"; - import { verbrauchsausweisWohnenSpeichern } from "src/client/lib/verbrauchsausweisWohnenSpeichern"; + import { VerbrauchsausweisWohnenClient, BenutzerClient, UploadedGebaeudeBild } from "#components/Ausweis/types.js"; + import { verbrauchsausweisWohnenSpeichern } from "src/client/lib/verbrauchsausweisWohnenSpeichern.js"; // TODO: Vom Server sollte ein volles Objekt kommen, dass alle Subobjekte enthält, weil es sonst zu Problemen führen kann // wenn gebaeude_aufnahme_allgemein oder gebaeude_stammdaten nicht existiert... From c6b31acd9c56c6ca956460d10a126578d1749465 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Wed, 13 Nov 2024 13:29:44 +1100 Subject: [PATCH 09/11] Cookie Fehler --- src/client/lib/validateAccessToken.ts | 4 ++-- src/components/Header.astro | 2 +- src/lib/caller.ts | 4 ++-- src/server/lib/validateAccessToken.ts | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/client/lib/validateAccessToken.ts b/src/client/lib/validateAccessToken.ts index 8232ee6b..1e4f334d 100644 --- a/src/client/lib/validateAccessToken.ts +++ b/src/client/lib/validateAccessToken.ts @@ -1,6 +1,6 @@ import Cookies from "js-cookie"; -import { API_ACCESS_TOKEN_COOKIE_NAME, API_REFRESH_TOKEN_COOKIE_NAME, API_UID_COOKIE_NAME } from "../../lib/constants"; -import { client } from "src/trpc"; +import { API_ACCESS_TOKEN_COOKIE_NAME, API_REFRESH_TOKEN_COOKIE_NAME, API_UID_COOKIE_NAME } from "#lib/constants.js"; +import { client } from "../../trpc.js"; import moment from "moment"; diff --git a/src/components/Header.astro b/src/components/Header.astro index 13957a8b..b378595b 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -4,7 +4,7 @@ import ThemeController from "./ThemeController.svelte"; const valid = await validateAccessTokenServer(Astro) -const lightTheme = Astro.cookies.get("theme").value === "light"; +const lightTheme = Astro.cookies.get("theme")?.value === "light"; ---
diff --git a/src/lib/caller.ts b/src/lib/caller.ts index dd16f724..d4571d33 100644 --- a/src/lib/caller.ts +++ b/src/lib/caller.ts @@ -1,11 +1,11 @@ import { appRouter, t } from "@ibcornelsen/api"; -import { API_ACCESS_TOKEN_COOKIE_NAME } from "./constants"; +import { API_ACCESS_TOKEN_COOKIE_NAME } from "./constants.js"; export const createCaller = function (opts: any) { // 1. create a caller-function for your router const createCaller = t.createCallerFactory(appRouter); - const token = Buffer.from(opts.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME).value ?? "", "utf-8").toString("base64"); + const token = Buffer.from(opts.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value ?? "", "utf-8").toString("base64"); // 2. create a caller using your `Context` return createCaller({ authorization: `Bearer ${token}`, diff --git a/src/server/lib/validateAccessToken.ts b/src/server/lib/validateAccessToken.ts index 69946c6b..d284d478 100644 --- a/src/server/lib/validateAccessToken.ts +++ b/src/server/lib/validateAccessToken.ts @@ -1,12 +1,12 @@ -import { createCaller } from "#lib/caller"; -import { API_ACCESS_TOKEN_COOKIE_NAME, API_REFRESH_TOKEN_COOKIE_NAME, API_UID_COOKIE_NAME } from "#lib/constants"; +import { createCaller } from "#lib/caller.js"; +import { API_ACCESS_TOKEN_COOKIE_NAME, API_REFRESH_TOKEN_COOKIE_NAME, API_UID_COOKIE_NAME } from "#lib/constants.js"; import type { AstroGlobal } from "astro"; import moment from "moment"; export async function validateAccessTokenServer(astro: AstroGlobal) { - const accessToken = astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME).value; - const refreshToken = astro.cookies.get(API_REFRESH_TOKEN_COOKIE_NAME).value; + const accessToken = astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value; + const refreshToken = astro.cookies.get(API_REFRESH_TOKEN_COOKIE_NAME)?.value; if (!refreshToken) { // Wir haben keinen Refresh Token, also müssen wir uns neu anmelden. From 9fe5e0b8f65f532c2198f53aa56a7cab1c4bf891 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Thu, 14 Nov 2024 15:05:25 +1100 Subject: [PATCH 10/11] Notification Wrapper auf Lokale Version gesetzt anstatt @ibcornelsen/ui, Config upgedated und Ansichtsausweis repariert. --- astro.config.mjs | 3 +++ src/components/Dashboard/DashboardAusweis.svelte | 8 ++++---- src/components/Notifications/Notification.svelte | 2 +- src/components/Notifications/NotificationWrapper.svelte | 2 +- src/components/Notifications/RawNotification.svelte | 2 +- src/components/Notifications/index.ts | 9 +++++++++ .../Ausweise/VerbrauchsausweisWohnenModule.svelte | 2 +- src/pages/pdf/ansichtsausweis.astro | 2 +- src/pages/pdf/datenblatt.astro | 2 +- tsconfig.json | 2 +- 10 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 src/components/Notifications/index.ts diff --git a/astro.config.mjs b/astro.config.mjs index 8dd067e0..97ddeaa7 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -21,6 +21,9 @@ export default defineConfig({ "#": fileURLToPath(new URL("./src", import.meta.url)) } }, + ssr: { + noExternal: ["@pdfme/generator", "@pdfme/common", "@pdfme/schemas"] + }, build: { commonjsOptions: { transformMixedEsModules: false diff --git a/src/components/Dashboard/DashboardAusweis.svelte b/src/components/Dashboard/DashboardAusweis.svelte index d62040b8..aa6572e6 100644 --- a/src/components/Dashboard/DashboardAusweis.svelte +++ b/src/components/Dashboard/DashboardAusweis.svelte @@ -1,7 +1,7 @@ diff --git a/src/components/Notifications/NotificationWrapper.svelte b/src/components/Notifications/NotificationWrapper.svelte index fda211bc..3ced2ee1 100644 --- a/src/components/Notifications/NotificationWrapper.svelte +++ b/src/components/Notifications/NotificationWrapper.svelte @@ -2,7 +2,7 @@ import Notification from "./Notification.svelte"; import RawNotificationWrapper from "./RawNotificationWrapper.svelte"; - import { notifications } from "./shared"; + import { notifications } from "./shared.js"; diff --git a/src/components/Notifications/RawNotification.svelte b/src/components/Notifications/RawNotification.svelte index f156b583..7f24c7de 100644 --- a/src/components/Notifications/RawNotification.svelte +++ b/src/components/Notifications/RawNotification.svelte @@ -1,5 +1,5 @@