refactor login page, change routes to token-based, add service classes
This commit is contained in:
6
src/routes/(token-based)/view/+page.server.ts
Normal file
6
src/routes/(token-based)/view/+page.server.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { getVorgangByCaseNumber } from '$lib/server/vorgangService';
|
||||
|
||||
/** @type {import('./$types').Actions} */
|
||||
export const actions = {
|
||||
default: async ({request}: {request: Request}) => getVorgangByCaseNumber(request)
|
||||
}
|
||||
82
src/routes/(token-based)/view/+page.svelte
Normal file
82
src/routes/(token-based)/view/+page.svelte
Normal file
@@ -0,0 +1,82 @@
|
||||
<script lang="ts">
|
||||
import Button from '$lib/components/Button.svelte';
|
||||
import Exclamation from '$lib/icons/Exclamation.svelte';
|
||||
|
||||
export let form;
|
||||
</script>
|
||||
|
||||
<div class="mx-auto max-w-2xl">
|
||||
<div class="flex flex-col items-center justify-center w-full">
|
||||
<h1 class="text-xl">Vorgang ansehen</h1>
|
||||
</div>
|
||||
|
||||
<form method="POST">
|
||||
<div class="space-y-12">
|
||||
<div class="border-b border-gray-900/10 pb-12">
|
||||
<!-- <h2 class="text-base font-semibold leading-7 text-gray-900">Profile</h2> -->
|
||||
<p class="mt-8 text-sm leading-6 text-gray-600">
|
||||
Anhand der Vorgangsnummer werden Sie zu den Dateien des Vorgangs weitergeleitet und können
|
||||
sich den Vorgang dann ansehen.
|
||||
</p>
|
||||
|
||||
<div class="mt-10 grid grid-cols-1 gap-x-6 gap-y-8">
|
||||
<div>
|
||||
<label for="caseNumber" class="block text-sm font-medium leading-6 text-gray-900"
|
||||
><span class="flex"
|
||||
>{#if form?.error?.caseNumber}
|
||||
<span class="inline-block mr-1"><Exclamation /></span>
|
||||
{/if} Vorgangs-Nr.</span
|
||||
></label
|
||||
>
|
||||
<div class="mt-2 w-full">
|
||||
<div
|
||||
class="flex w-full rounded-md shadow-sm ring-1 ring-inset ring-gray-300 focus-within:ring-2 focus-within:ring-inset focus-within:ring-indigo-600"
|
||||
>
|
||||
<input
|
||||
value={form?.caseNumber ?? ''}
|
||||
type="text"
|
||||
name="caseNumber"
|
||||
id="caseNumber"
|
||||
class="block w-full flex-1 border-0 bg-transparent py-1.5 pl-1 text-gray-900 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{#if form?.error?.caseNumber}
|
||||
<p class="block text-sm leading-6 text-red-900 mt-2">{form.error.caseNumber}</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="token" class="block text-sm font-medium leading-6 text-gray-900"
|
||||
><span class="flex"> Zugangscode</span></label
|
||||
>
|
||||
<div class="mt-2 w-full">
|
||||
<div
|
||||
class="flex w-full rounded-md shadow-sm ring-1 ring-inset ring-gray-300 focus-within:ring-2 focus-within:ring-inset focus-within:ring-indigo-600"
|
||||
>
|
||||
<input
|
||||
value={false || ''}
|
||||
placeholder="optional"
|
||||
type="text"
|
||||
name="token"
|
||||
id="token"
|
||||
class="block w-full flex-1 border-0 bg-transparent py-1.5 pl-1 text-gray-900 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{#if form?.error?.token}
|
||||
<p class="block text-sm leading-6 text-red-900 mt-2">{form.error.token}</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-6 flex items-center justify-end gap-x-6">
|
||||
<Button
|
||||
type="submit"
|
||||
class="rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
|
||||
>Weiter</Button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,9 @@
|
||||
import { client } from '$lib/minio';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
/** @type {import('./$types').PageServerLoad} */
|
||||
export const load: PageServerLoad = async ({ params }) => {
|
||||
const { vorgang, tatort } = params;
|
||||
const url = await client.presignedUrl('GET', 'tatort', `${vorgang}/${tatort}`);
|
||||
return { url };
|
||||
}
|
||||
205
src/routes/(token-based)/view/[vorgang]/[tatort]/+page.svelte
Normal file
205
src/routes/(token-based)/view/[vorgang]/[tatort]/+page.svelte
Normal file
@@ -0,0 +1,205 @@
|
||||
<script lang="ts">
|
||||
import Panel from '$lib/components/Panel.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import Button from '$lib/components/Button.svelte';
|
||||
|
||||
export let data;
|
||||
|
||||
onMount(() => {
|
||||
import('@google/model-viewer');
|
||||
});
|
||||
|
||||
let progress = 0;
|
||||
let hideProgressScreen = false;
|
||||
|
||||
let cameraOrbit = '0deg 0deg 100%';
|
||||
let cameraTarget = '0m 0m 0m';
|
||||
let fieldOfView = '10deg';
|
||||
|
||||
let cameraAzimuth = 0;
|
||||
let cameraPolar = 0;
|
||||
|
||||
let cameraZoom = 100;
|
||||
let xRotation = 0;
|
||||
let yRotation = 0;
|
||||
let zRotation = 0;
|
||||
|
||||
let modelViewer;
|
||||
|
||||
$: style = `width: ${progress}%`;
|
||||
|
||||
const onProgress = ({ detail }) => {
|
||||
progress = Math.ceil(detail.totalProgress * 100.0);
|
||||
if (progress == 100) {
|
||||
setTimeout(() => {
|
||||
hideProgressScreen = true;
|
||||
}, 250);
|
||||
} else hideProgressScreen = false;
|
||||
}
|
||||
|
||||
function onResetView() {
|
||||
cameraAzimuth = 0;
|
||||
cameraPolar = 0;
|
||||
cameraZoom = 100;
|
||||
|
||||
modelViewer.cameraOrbit = cameraOrbit;
|
||||
modelViewer.cameraTarget = cameraTarget;
|
||||
modelViewer.fieldOfView = fieldOfView;
|
||||
cameraAzimuth = 0;
|
||||
cameraPolar = 0;
|
||||
cameraZoom = 100;
|
||||
fieldOfView = '10deg';
|
||||
}
|
||||
|
||||
function updateCameraOrbit(azimuth: number, polar: number, zoom: number) {
|
||||
cameraAzimuth = azimuth;
|
||||
cameraPolar = polar;
|
||||
cameraZoom = zoom;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="h-full model w-full bg-neutral-200 p-4 transition-all delay-250">
|
||||
<!-- xr-environment -->
|
||||
<model-viewer
|
||||
ar
|
||||
shadow-intensity="1"
|
||||
src={data.url}
|
||||
bind:this={modelViewer}
|
||||
touch-action="pan-y"
|
||||
field-of-view={fieldOfView}
|
||||
min-field-of-view="1deg"
|
||||
max-field-of-view="10deg"
|
||||
camera-controls
|
||||
orientation={`${xRotation}deg ${yRotation}deg ${zRotation}deg`}
|
||||
camera-target="0m 0m 0m"
|
||||
camera-orbit={`${cameraAzimuth}deg ${cameraPolar}deg ${cameraZoom}%`}
|
||||
on:progress={onProgress}
|
||||
>
|
||||
<!--Buttons zum Steuern-->
|
||||
<div
|
||||
class=" p-4 flex z-10 absolute bottom-0"
|
||||
class:opacity-0={!hideProgressScreen}
|
||||
class:hidden={!hideProgressScreen}
|
||||
>
|
||||
<button slot="ar-button" id="ar-button"> 👋 Activate AR </button>
|
||||
|
||||
<div id="ar-prompt">AR-Prompt</div>
|
||||
|
||||
<button id="ar-failure"> AR is not tracking! </button>
|
||||
<div class="flex flex-col bg-white/50">
|
||||
<button
|
||||
on:click={() => {
|
||||
console.log(modelViewer.ar, modelViewer.getAttribute('ar-status'));
|
||||
}}>Test</button
|
||||
>
|
||||
|
||||
<!--3 Buttons-->
|
||||
<div class="p-2">
|
||||
<Button
|
||||
on:click={() => {
|
||||
updateCameraOrbit(0, 0, cameraZoom);
|
||||
}}
|
||||
type="button"
|
||||
variant="white"
|
||||
align="left"
|
||||
class="relative cursor-default justify-start py-2 pl-3 pr-10 text-left "
|
||||
>
|
||||
Draufsicht
|
||||
</Button>
|
||||
<Button
|
||||
on:click={() => {
|
||||
onResetView();
|
||||
}}
|
||||
type="button"
|
||||
variant="white"
|
||||
align="left"
|
||||
class="relative cursor-default justify-start py-2 pl-3 pr-10 text-left"
|
||||
>
|
||||
Werte zurücksetzen
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
on:click={() => {
|
||||
updateCameraOrbit(0, 90, cameraZoom);
|
||||
}}
|
||||
type="button"
|
||||
variant="white"
|
||||
align="left"
|
||||
class="relative cursor-default justify-start py-2 pl-3 pr-10 text-left"
|
||||
>
|
||||
Frontansicht
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<!--Horizontal-->
|
||||
<div class="p-2">
|
||||
<label for="cazimuth">Horizontal drehen (Azimut):</label>
|
||||
<input id="cazimuth" type="range" min="0" max="360" bind:value={cameraAzimuth} />
|
||||
</div>
|
||||
<!--Vertikal-->
|
||||
<div class="p-2">
|
||||
<label class=" mb-2" for="polarSlider">Vertikal drehen (Polar):</label>
|
||||
<input id="polarSlider" type="range" min="0" max="90" bind:value={cameraPolar} />
|
||||
</div>
|
||||
<!--Zoom/Distanz-->
|
||||
<div class="p-2">
|
||||
<label for="cZoom">Abstand (zoom):</label>
|
||||
<input id="cZoom" type="range" min="0" max="100" bind:value={cameraZoom} />
|
||||
</div>
|
||||
</div>
|
||||
<!--Rotationen-->
|
||||
<div class="flex flex-col ml-2 p-4 bg-white/50">
|
||||
Modell rotieren lassen:
|
||||
<br />
|
||||
Modell auf dem Kopf? -> y auf 270°
|
||||
<div class="p-2">
|
||||
<label class="" for="polarSlider">Rotation X:</label>
|
||||
<input id="polarSlider" type="range" min="0" max="360" bind:value={xRotation} />
|
||||
</div>
|
||||
<div class="p-2">
|
||||
<label class="" for="polarSlider">Rotation Y:</label>
|
||||
<input id="polarSlider" type="range" min="0" max="360" bind:value={yRotation} />
|
||||
</div>
|
||||
<div class="p-2">
|
||||
<label class="" for="polarSlider">Rotation Z:</label>
|
||||
<input id="polarSlider" type="range" min="0" max="360" bind:value={zRotation} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--Loading-->
|
||||
<div
|
||||
slot="progress-bar"
|
||||
class="flex items-center justify-center h-5/6 w-full transition-all delay-250"
|
||||
class:opacity-0={hideProgressScreen}
|
||||
class:hidden={hideProgressScreen}
|
||||
>
|
||||
<Panel class="w-72 bg-gray-50 flex items-center flex-col"
|
||||
><p class="mb-5">Loading {progress}%</p>
|
||||
<div class="h-1 w-full bg-neutral-200 dark:bg-neutral-600">
|
||||
<div class="h-1 bg-blue-500" {style}></div>
|
||||
</div></Panel
|
||||
>
|
||||
</div>
|
||||
</model-viewer>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
model-viewer {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* .vertical-slider {
|
||||
writing-mode: bt-lr; /* Schreibt von unten nach oben (Vertikale Darstellung)
|
||||
transform: rotate(270deg); /* Slider um 270° drehen
|
||||
height: 200px;
|
||||
} */
|
||||
|
||||
.model {
|
||||
height: calc(100%-84px);
|
||||
}
|
||||
|
||||
/* .active-border {
|
||||
border: 2px blue solid;
|
||||
} */
|
||||
</style>
|
||||
Reference in New Issue
Block a user