diff --git a/.vscode/settings.json b/.vscode/settings.json index 1f926c5b..44a9fd24 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "i18n-ally.localesPaths": [ "public/locales" - ] + ], + "typescript.tsdk": "node_modules/typescript/lib" } \ No newline at end of file diff --git a/src/client/lib/bilderHochladen.ts b/src/client/lib/bilderHochladen.ts index f98516ab..0c12ac49 100644 --- a/src/client/lib/bilderHochladen.ts +++ b/src/client/lib/bilderHochladen.ts @@ -1,15 +1,16 @@ import { GebaeudeClient, UploadedGebaeudeBild, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types"; +import { Enums } from "@ibcornelsen/database/client"; import { addNotification, updateNotification } from "@ibcornelsen/ui"; import { client } from "src/trpc"; -export async function bilderHochladen(images: (UploadedGebaeudeBild & { base64?: string })[], gebaeude: GebaeudeClient) { +export async function bilderHochladen(images: (UploadedGebaeudeBild & { base64?: string })[], gebaeude_uid: string) { if (images.length == 0) { return images; } // Wenn Bilder hochgeladen werden konvertieren wir sie zu base64, das heißt, dass die base64 Eigenschaft bei diesen Bildern // existiert. Das müssen wir TypeScript nur wissen lassen, damit es uns in Ruhe lässt. - const imagesToUpload = images.filter(image => !image.uid) as unknown as { base64: string, kategorie: string, uid?: string }[]; + const imagesToUpload = images.filter(image => !image.uid || image.update) as unknown as { base64: string, kategorie: string, uid?: string, update: boolean }[]; if (imagesToUpload.length == 0) { return images; @@ -27,13 +28,21 @@ export async function bilderHochladen(images: (UploadedGebaeudeBild & { base64?: const image = imagesToUpload[i]; try { - const response = await client.v1.bilder.upload.mutate({ - base64: image.base64, - kategorie: image.kategorie, - gebaeude_uid: gebaeude.uid - }) - - image.uid = response.uid + if (image.update) { + await client.v1.bilder.update.mutate({ + uid: image.uid as string, + base64: image.base64, + kategorie: image.kategorie as Enums.BilderKategorie + }) + } else { + const response = await client.v1.bilder.upload.mutate({ + base64: image.base64, + kategorie: image.kategorie as Enums.BilderKategorie, + gebaeude_uid + }) + + image.uid = response.uid + } updateNotification(notification, { dismissable: true, diff --git a/src/client/lib/verbrauchsausweisWohnenSpeichern.ts b/src/client/lib/verbrauchsausweisWohnenSpeichern.ts index 98cb9da0..2ea9b5ba 100644 --- a/src/client/lib/verbrauchsausweisWohnenSpeichern.ts +++ b/src/client/lib/verbrauchsausweisWohnenSpeichern.ts @@ -37,7 +37,7 @@ export async function verbrauchsausweisWohnenSpeichern( }, }); - images = await bilderHochladen(images, gebaeude); + images = await bilderHochladen(images, gebaeude.uid); return { uid: ausweis.uid, gebaeude_uid: gebaeude.uid, gebaeude_aufnahme_uid: gebaeude_aufnahme_allgemein.uid }; } catch (e) { @@ -57,7 +57,7 @@ export async function verbrauchsausweisWohnenSpeichern( }, }); - images = await bilderHochladen(images, gebaeude); + images = await bilderHochladen(images, response.gebaeude_uid); return response; } catch (e: any) { diff --git a/src/components/Ausweis/Verbrauch.svelte b/src/components/Ausweis/Verbrauch.svelte index 2d1925da..a39a5a02 100644 --- a/src/components/Ausweis/Verbrauch.svelte +++ b/src/components/Ausweis/Verbrauch.svelte @@ -270,7 +270,7 @@
- Verbrauch + Verbrauch *
- Verbrauch + Verbrauch *
- Verbrauch + Verbrauch * ["gebaeude_aufnahme_allgemein"]["gebaeude_stammdaten"]["gebaeude_bilder"][0] & { base64?: string }; +>["gebaeude_aufnahme_allgemein"]["gebaeude_stammdaten"]["gebaeude_bilder"][0] & { base64?: string, update?: boolean }; /** diff --git a/src/components/ImageGrid.svelte b/src/components/ImageGrid.svelte index 8589213f..43210ecf 100644 --- a/src/components/ImageGrid.svelte +++ b/src/components/ImageGrid.svelte @@ -2,6 +2,7 @@ import UploadImages from "./UploadImages.svelte"; import type { BedarfsausweisWohnen, Enums, VerbrauchsausweisGewerbe } from "@ibcornelsen/database/client"; import { GebaeudeClient, UploadedGebaeudeBild, VerbrauchsausweisWohnenClient } from "./Ausweis/types"; + import { RotateCounterClockwise, Trash } from "radix-svelte-icons"; export let images: UploadedGebaeudeBild[] = []; export let max: number = 4; @@ -10,8 +11,24 @@ export let gebaeude: GebaeudeClient; export let kategorie: Enums.BilderKategorie - console.log(images); - + async function rotateImage(image: UploadedGebaeudeBild): Promise { + return new Promise((resolve, reject) => { + let img = new Image(); + img.src = image.base64 ? image.base64 : `/bilder/${image.uid}.webp`; + img.onload = () => { + let canvas = document.createElement("canvas"); + let ctx = canvas.getContext("2d"); + canvas.width = img.height; + canvas.height = img.width; + ctx?.translate(img.height / 2, img.width / 2); + ctx?.rotate((-90 * Math.PI) / 180); + ctx?.drawImage(img, -img.width / 2, -img.height / 2); + image.base64 = canvas.toDataURL("image/webp"); + image.update = true; + resolve(image) + }; + }) + }
@@ -23,20 +40,33 @@ {kategorie} - + +
{/if} {/each}
- + \ No newline at end of file diff --git a/src/components/UMBE_Footer.astro b/src/components/UMBE_Footer.astro new file mode 100644 index 00000000..b142c4bc --- /dev/null +++ b/src/components/UMBE_Footer.astro @@ -0,0 +1,10 @@ +--- +const currentYear = new Date().getFullYear(); +--- + + \ No newline at end of file diff --git a/src/components/UMBE_Header.astro b/src/components/UMBE_Header.astro new file mode 100644 index 00000000..40c23968 --- /dev/null +++ b/src/components/UMBE_Header.astro @@ -0,0 +1,45 @@ +
+ +
+ + + + + hamburger +
+
+ + \ No newline at end of file diff --git a/src/components/UMBE_SidebarLeft.astro b/src/components/UMBE_SidebarLeft.astro new file mode 100644 index 00000000..f1a8dda2 --- /dev/null +++ b/src/components/UMBE_SidebarLeft.astro @@ -0,0 +1,9 @@ +--- +import Navigation from "../components/UMBE_navcard.astro"; +--- + +
+ + + +
\ No newline at end of file diff --git a/src/components/UMBE_SidebarRight.astro b/src/components/UMBE_SidebarRight.astro new file mode 100644 index 00000000..57b22141 --- /dev/null +++ b/src/components/UMBE_SidebarRight.astro @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file diff --git a/src/components/UMBE_navcard.astro b/src/components/UMBE_navcard.astro new file mode 100644 index 00000000..72a2214d --- /dev/null +++ b/src/components/UMBE_navcard.astro @@ -0,0 +1,100 @@ + + + +