38 Commits

Author SHA1 Message Date
34f8fd5490 refactor login page, change routes to token-based, add service classes 2025-06-17 16:19:22 +02:00
6d3e6ad047 Merge branch 'development' into refactor-login-page 2025-06-12 13:51:20 +02:00
ca74e873be Merge pull request 'f03_user-management' (#6) from f03_user-management into development
Reviewed-on: #6
2025-06-12 13:31:17 +02:00
c373b49f1c deleted comment 2025-06-12 13:29:47 +02:00
03a304f6fe fixed some error from merge request 2025-06-12 13:02:23 +02:00
ecc2564c70 fixed merge conflicts 2025-06-12 11:32:37 +02:00
fd8298906a formatting 2025-06-11 09:55:00 +02:00
5ce5c78698 fix layout by reordering anker element 2025-06-11 09:25:33 +02:00
aeabbd6d1f disable/uncomment input field in vorgang list 2025-06-11 08:18:28 +02:00
c1958e848a refactoring: rename code retrieval function 2025-06-10 08:08:11 +02:00
20c273407f remove config check 2025-06-10 07:58:35 +02:00
d5b39575c7 fix typo 2025-06-06 11:44:59 +02:00
d05776ad3a fix permission code check 2025-06-06 11:42:37 +02:00
10f090a64e insert token to overwrite entered code 2025-06-06 08:27:32 +02:00
c991e3d778 add token back 2025-06-05 08:26:53 +02:00
5ef5476d92 delete token 2025-06-02 17:24:34 +02:00
db90bae19f fix debug 2025-06-02 17:23:01 +02:00
efdb4e29e2 fuer Mina, zum Spielen 2025-06-02 14:11:52 +02:00
180a9d7ce4 fix race condition of token generation 2025-05-30 10:56:30 +02:00
15f2c6e549 improve get_code function 2025-05-30 10:28:25 +02:00
4b8099481c add code generation on frontend 2025-05-30 08:19:32 +02:00
7413733eb0 remove status logging 2025-05-28 13:14:17 +02:00
d5601b8fae format code 2025-05-27 14:05:50 +02:00
c3202333d9 change timeout back to 1 hour 2025-05-27 14:00:57 +02:00
52222f0236 store permission file and hide it from being listed 2025-05-27 14:00:31 +02:00
63638cfba5 Merge branch 'f03_user-management' into f03_temp_Chico-lokal 2025-05-26 14:30:02 +02:00
0557d42207 temp Commit Mina 2025-05-26 14:11:01 +02:00
b966d19792 Ende des Tages 26.05. 2025-05-26 13:55:19 +02:00
def4e22226 initila check if vorgang exists 2025-05-23 11:24:57 +02:00
59fc791b85 sdf 2025-05-23 11:22:20 +02:00
c437926002 verbindungsprobleme test mina 2025-05-23 11:21:55 +02:00
b44187b010 remove admin user output 2025-05-23 10:22:05 +02:00
99a27fc079 update frontend 2025-05-22 17:25:33 +02:00
bebd226c80 fixed fluechtigkeitsfehler 2025-05-22 14:16:44 +02:00
4adea19981 temp 22.05 2025-05-22 14:13:53 +02:00
6b7188350f temporär zum Testen 2025-05-22 10:22:45 +02:00
20c74d49d9 Merge branch 'development' into f03_user-management 2025-05-21 10:21:51 +02:00
131318da14 input field fuer Zugangscode beim Anlegen 2025-05-21 10:13:50 +02:00
50 changed files with 900 additions and 477 deletions

View File

@@ -8,7 +8,7 @@
},
"jwt": {
"secret": "@S2!q@@wXz$dCQ8JoVsHLpzaJ6JCfB",
"expiresIn": 3600
"expiresIn": 36000
},
"auth": {
"admin": { "password": "A-InnoHUB_2025!", "admin": true },

4
src/error.html Normal file
View File

@@ -0,0 +1,4 @@
<h1>Du wurdest automatisch ausgeloggt</h1>
<p>Lösche deine Cookies aus dem Browser und logge dich neu ein</p>
<p>Code %sveltekit.status%</p>
<p>%sveltekit.error.message%</p>

View File

@@ -1,7 +1,7 @@
import { decryptToken } from '$lib/auth';
import type { Handle } from '@sveltejs/kit';
export const handle: Handle = ({ event, resolve }) => {
export const handle: Handle = async ({ event, resolve }) => {
const jwt = event.cookies.get('session');
try {
if (jwt) {
@@ -12,5 +12,5 @@ export const handle: Handle = ({ event, resolve }) => {
event.cookies.delete('session', {path: '/'});
event.locals.user = null;
}
return resolve(event);
return await resolve(event);
}

View File

@@ -0,0 +1,32 @@
<script lang="ts">
import Exclamation from '$lib/icons/Exclamation.svelte';
let { label = '', error = null, value, name, id, type = 'text'} = $props();
</script>
<div>
<label for={name} class="block text-sm font-medium leading-6 text-gray-900"
><span class="flex"
>{#if error}
<span class="inline-block mr-1"><Exclamation /></span>
{/if}
{label}</span
></label
>
<div class="mt-2">
<div
class="flex 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
class="block flex-1 border-0 bg-transparent py-1.5 pl-1 text-gray-900 placeholder:text-gray-400 focus:ring-0 text-sm leading-6"
bind:value
{type}
{name}
{id}
/>
</div>
</div>
{#if error}
<p class="block text-sm leading-6 text-red-900 mt-2">{error}</p>
{/if}
</div>

View File

@@ -14,8 +14,8 @@
<script lang="ts">
import { page } from '$app/stores';
import Trash from '$lib/icons/Trash.svelte';
import Panel from '$lib/components/ui/Panel.svelte';
import Button from '$lib/components/ui/Button.svelte';
import Panel from '$lib/components/Panel.svelte';
import Button from '$lib/components/Button.svelte';
import { clickOutside } from '$lib/helpers/clickOutside.js';
const { adminMode, prediction, predictionRemove } = $page.data;

View File

@@ -0,0 +1,37 @@
<script>
import Profile from "$lib/icons/Profile.svelte";
export let data;
</script>
<div class="flex-none">
<footer class="justify-end">
<div class="bg-gray-100">
<div class="mx-auto max-w-7xl px-6 lg:px-8">
<div class="flex justify-between divide-x divide-gray-900/5 border-x border-gray-900/5">
<a
href="/list"
class="px-4 py-1 -ml-4 flex items-center justify-center gap-x-2.5 text-sm font-semibold leading-6 text-gray-500 hover:bg-gray-200 hover:text-gray-700"
>
&copy; 2023 Innovation Hub Niedersachen
</a>
<a
href="/"
class="px-4 py-1 flex items-center justify-center gap-x-2.5 text-sm font-semibold leading-6 text-gray-500 hover:bg-gray-200 hover:text-gray-700"
>
back
</a>
<a
href="/"
class="px-4 py-1 -mr-4 flex items-center justify-center gap-x-2.5 text-sm font-semibold leading-6 text-gray-500 hover:bg-gray-200 hover:text-gray-700"
>
<!--icon-->
<Profile />
{data?.user?.id}
</a>
</div>
</div>
</div>
</footer>
</div>

View File

@@ -0,0 +1,36 @@
<script lang="ts">
import Chevron from '$lib/icons/Chevron-right.svelte';
export let data;
</script>
<div class="flex flex-col">
<header class="flex-none relative isolate z-10 bg-white px-8">
<nav
class="mx-auto flex max-w-7xl items-center justify-between p-6 lg:px-8"
aria-label="Global"
>
<div class="flex w-48">
<a href="/" class="-m-1.5 p-1.5 w-10">
<span class="sr-only">Tatort Niedersachen</span>
<img class="h-8 w-auto" src="/Landeswappen_NI.svg" alt="Landeswappen Niedersachsen" />
</a>
</div>
<h1 class="text-3xl text-slate-400 font-bold">Tatort</h1>
<div class="lg:flex lg:justify-end w-48">
{#if data.user}
<form method="POST" action="/anmeldung?/logout">
<input type="hidden" />
<button type="submit" class="text-sm font-semibold leading-6 text-gray-900"
><span
><span class="align-middle inline-block">Abmelden</span><span
class="align-middle inline-block"><Chevron /></span
></span
></button
>
</form>
{/if}
</div>
</nav>
</header>
</div>

View File

@@ -1,7 +1,7 @@
import { client } from '$lib/minio';
export default async function caseNumberOccupied (caseNumber: string): Promise<boolean> {
const prefix = `${caseNumber}/config.json`;
const prefix = `${caseNumber}`;
const promise: Promise<boolean> = new Promise((resolve) => {
const stream = client.listObjectsV2('tatort', prefix, false, '');
stream.on('data', () => {

10
src/lib/helper/getCode.ts Normal file
View File

@@ -0,0 +1,10 @@
export default async function get_code(case_no) {
let url = `/api/list/${case_no}/code`;
const response = await fetch(url);
if (response.status == 200) {
return response.text();
} else {
return -1;
}
}

View File

@@ -0,0 +1,19 @@
<script>
let classNames = '';
export { classNames as class };
</script>
<svg
class="h-6 w-6 text-gray-600 {classNames}"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M13.5 16.875h3.375m0 0h3.375m-3.375 0V13.5m0 3.375v3.375M6 10.5h2.25a2.25 2.25 0 002.25-2.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v2.25A2.25 2.25 0 006 10.5zm0 9.75h2.25A2.25 2.25 0 0010.5 18v-2.25a2.25 2.25 0 00-2.25-2.25H6a2.25 2.25 0 00-2.25 2.25V18A2.25 2.25 0 006 20.25zm9.75-9.75H18a2.25 2.25 0 002.25-2.25V6A2.25 2.25 0 0018 3.75h-2.25A2.25 2.25 0 0013.5 6v2.25a2.25 2.25 0 002.25 2.25z"
/>
</svg>

14
src/lib/icons/Cube.svelte Normal file
View File

@@ -0,0 +1,14 @@
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class=" w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M21 7.5l-2.25-1.313M21 7.5v2.25m0-2.25l-2.25 1.313M3 7.5l2.25-1.313M3 7.5l2.25 1.313M3 7.5v2.25m9 3l2.25-1.313M12 12.75l-2.25-1.313M12 12.75V15m0 6.75l2.25-1.313M12 21.75V19.5m0 2.25l-2.25-1.313m0-16.875L12 2.25l2.25 1.313M21 14.25v2.25l-2.25 1.313m-13.5 0L3 16.5v-2.25"
/>
</svg>

After

Width:  |  Height:  |  Size: 483 B

View File

@@ -0,0 +1,7 @@
<svg height="20" width="20" xmlns="http://www.w3.org/2000/svg"
><path
d="m14.996094 3-11.9921878 11.992188h-.0039062v4.007812h1 2 1.0078125v-.0039l11.9921875-11.9921938-.001953-.0019531.001953-.0019531-4-4-.002.00195zm-1.998047 3.4121094 2.589844 2.5898437-7.587891 7.5878909v-1.589844h-1-1v-1-.589844zm-7.998047 7.9980466v1.589844h1 1v1 .589844l-.4101562.410156h-1.5898438l-1-1v-1.589844z"
fill="#373737"
transform="translate(1 1)"
/></svg
>

After

Width:  |  Height:  |  Size: 451 B

View File

@@ -0,0 +1,35 @@
<script>
export let outline = false;
let classNames = '';
export { classNames as class };
</script>
{#if outline}
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6 {classNames}"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V8.25zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"
/>
</svg>
{:else}
<svg
class="mx-auto h-12 w-12 text-gray-300 {classNames}"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden="true"
>
<path
fill-rule="evenodd"
d="M1.5 6a2.25 2.25 0 012.25-2.25h16.5A2.25 2.25 0 0122.5 6v12a2.25 2.25 0 01-2.25 2.25H3.75A2.25 2.25 0 011.5 18V6zM3 16.06V18c0 .414.336.75.75.75h16.5A.75.75 0 0021 18v-1.94l-2.69-2.689a1.5 1.5 0 00-2.12 0l-.88.879.97.97a.75.75 0 11-1.06 1.06l-5.16-5.159a1.5 1.5 0 00-2.12 0L3 16.061zm10.125-7.81a1.125 1.125 0 112.25 0 1.125 1.125 0 01-2.25 0z"
clip-rule="evenodd"
/>
</svg>
{/if}

View File

@@ -0,0 +1,14 @@
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M2.25 12.75V12A2.25 2.25 0 014.5 9.75h15A2.25 2.25 0 0121.75 12v.75m-8.69-6.44l-2.12-2.12a1.5 1.5 0 00-1.061-.44H4.5A2.25 2.25 0 002.25 6v12a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9a2.25 2.25 0 00-2.25-2.25h-5.379a1.5 1.5 0 01-1.06-.44z"
/>
</svg>

After

Width:  |  Height:  |  Size: 460 B

View File

@@ -0,0 +1,19 @@
<script>
let classNames = '';
export { classNames as class };
</script>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6 {classNames}"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M8.25 6.75h12M8.25 12h12m-12 5.25h12M3.75 6.75h.007v.008H3.75V6.75zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zM3.75 12h.007v.008H3.75V12zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm-.375 5.25h.007v.008H3.75v-.008zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"
/>
</svg>

View File

@@ -0,0 +1,14 @@
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M17.982 18.725A7.488 7.488 0 0012 15.75a7.488 7.488 0 00-5.982 2.975m11.963 0a9 9 0 10-11.963 0m11.963 0A8.966 8.966 0 0112 21a8.966 8.966 0 01-5.982-2.275M15 9.75a3 3 0 11-6 0 3 3 0 016 0z"
/>
</svg>

After

Width:  |  Height:  |  Size: 402 B

View File

@@ -0,0 +1,29 @@
import { dev } from '$app/environment';
import { fail, redirect, type Cookies, type RequestEvent } from '@sveltejs/kit';
import { authenticate } from '$lib/auth';
const COOKIE_NAME = 'session';
export const loginUser = async ({ request, cookies }: { request: Request; cookies: Cookies }) => {
const data = await request.formData();
const user = data.get('user');
const password = data.get('password');
const token = authenticate(user, password);
if (!token) return fail(400, { user, incorrect: true });
cookies.set(COOKIE_NAME, token, {
path: '/',
httpOnly: true,
sameSite: 'strict',
secure: !dev
});
return redirect(303, '/');
};
export const logoutUser = async (event: RequestEvent) => {
event.cookies.delete(COOKIE_NAME, { path: '/' });
event.locals.user = null;
return { success: true };
};

View File

@@ -0,0 +1,58 @@
import { client } from '$lib/minio';
const BUCKET = 'tatort';
export const getVorgang = ({ params }) => {
const prefix = params.vorgang ? `${params.vorgang}/` : '';
const stream = client.listObjectsV2('tatort', prefix, false, '');
const result = new ReadableStream({
start(controller) {
stream.on('data', (data) => {
if (prefix === '') {
if (data.prefix)
controller.enqueue(`${JSON.stringify({ ...data, name: data.prefix.slice(0, -1) })}\n`);
return;
}
const name = data.name.slice(prefix.length);
if (name === 'config.json') return;
// zugangscode datei
if (name === '__perm__') return;
controller.enqueue(`${JSON.stringify({ ...data, name, prefix })}\n`);
});
stream.on('end', () => {
controller.close();
});
},
cancel() {
stream.destroy();
}
});
return new Response(result, {
headers: {
'content-type': 'text/event-stream'
}
});
};
export const checkIfExactDirectoryExists = (dir: string): Promise<boolean> => {
return new Promise<boolean>((resolve, reject) => {
const prefix = dir.endsWith('/') ? dir : `${dir}/`;
const stream = client.listObjectsV2(BUCKET, prefix, false, '');
stream.on('data', (obj) => {
if (obj.prefix === undefined && obj.name.startsWith(prefix)) {
stream.destroy();
resolve(true);
}
});
stream.on('error', (err) => reject(err));
stream.on('end', () => resolve(false));
});
}

View File

@@ -0,0 +1,68 @@
import { fail, redirect } from '@sveltejs/kit';
import { client } from '$lib/minio';
import { checkIfExactDirectoryExists } from './s3ClientService';
/**
*
* @param request
* @returns
*/
export const getVorgangByCaseNumber = async ( request: Request) => {
const data = await request.formData();
const caseNumber = data.get('caseNumber');
const user_token = data.get('token');
if (!caseNumber) {
return fail(400, {
success: false,
caseNumber,
error: { message: 'Die Vorgangsnummer darf nicht leer sein.' }
});
}
if (typeof caseNumber === 'string' && !(await checkIfExactDirectoryExists(caseNumber))) {
return fail(400, {
success: false,
caseNumber,
error: { message: 'Die Vorgangsnummer existiert in dieser Anwendung nicht.' }
});
}
const token = await getTokenOrNull(caseNumber);
if (token && token != user_token) {
return fail(400, {
success: false,
caseNumber,
error: { message: 'Der Token ist falsch.' }
});
}
redirect(303, `/list/${caseNumber}`);
}
const getTokenOrNull = async (vorgang) => {
const code_name = '__perm__';
const obj_path = `${vorgang}/${code_name}`;
let resp = null;
let code_saved = '';
try {
resp = await client.getObject('tatort', obj_path);
code_saved = await new Response(resp).text();
} catch (error) {
if (error.name == 'S3Error') {
resp = null;
}
}
if (resp != null) {
return code_saved;
} else {
return null;
}
}

View File

@@ -1,5 +1,5 @@
import { redirect, type ServerLoadEvent } from '@sveltejs/kit';
import type { PageServerLoad } from './view/[vorgang]/[tatort]/$types';
import type { PageServerLoad } from '../anmeldung/$types';
export const load: PageServerLoad = (event: ServerLoadEvent) => {
if (!event.locals.user && event.url.pathname !== '/anmeldung') throw redirect(303, '/anmeldung');

View File

@@ -1,83 +1,18 @@
<script lang="ts">
import Chevron from '$lib/icons/Chevron-right.svelte';
import Footer from '$lib/components/Footer.svelte';
import Header from '$lib/components/Header.svelte';
export let data;
</script>
<div class="h-screen v-screen flex flex-col">
<div class="flex flex-col h-full">
<header class="flex-none relative isolate z-10 bg-white px-8">
<nav
class="mx-auto flex max-w-7xl items-center justify-between p-6 lg:px-8"
aria-label="Global"
>
<div class="flex w-48">
<a href="/" class="-m-1.5 p-1.5 w-10">
<span class="sr-only">Tatort Niedersachen</span>
<img class="h-8 w-auto" src="/Landeswappen_NI.svg" alt="Landeswappen Niedersachsen" />
</a>
</div>
<h1 class="text-3xl text-slate-400 font-bold">Tatort</h1>
<div class="lg:flex lg:justify-end w-48">
{#if data.user}
<form method="POST" action="/anmeldung?/logout">
<input type="hidden" />
<button type="submit" class="text-sm font-semibold leading-6 text-gray-900"
><span
><span class="align-middle inline-block">Abmelden</span><span
class="align-middle inline-block"><Chevron /></span
></span
></button
>
</form>
{/if}
</div>
</nav>
</header>
<Header {data}/>
<div class="h-full grow overflow-scroll">
<slot />
</div>
<div class="flex-none">
<footer class="justify-end">
<div class="bg-gray-100">
<div class="mx-auto max-w-7xl px-6 lg:px-8">
<div class="flex justify-between divide-x divide-gray-900/5 border-x border-gray-900/5">
<a
href="/list"
class="px-4 py-1 -ml-4 flex items-center justify-center gap-x-2.5 text-sm font-semibold leading-6 text-gray-500 hover:bg-gray-200 hover:text-gray-700"
>
&copy; 2023 Innovation Hub Niedersachen
</a>
<a
href="/"
class="px-4 py-1 flex items-center justify-center gap-x-2.5 text-sm font-semibold leading-6 text-gray-500 hover:bg-gray-200 hover:text-gray-700"
>
back
</a>
<a
href="/"
class="px-4 py-1 -mr-4 flex items-center justify-center gap-x-2.5 text-sm font-semibold leading-6 text-gray-500 hover:bg-gray-200 hover:text-gray-700"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M17.982 18.725A7.488 7.488 0 0012 15.75a7.488 7.488 0 00-5.982 2.975m11.963 0a9 9 0 10-11.963 0m11.963 0A8.966 8.966 0 0112 21a8.966 8.966 0 01-5.982-2.275M15 9.75a3 3 0 11-6 0 3 3 0 016 0z"
/>
</svg>
{data.user.id}
</a>
</div>
</div>
</div>
</footer>
</div>
<Footer {data}/>
</div>
</div>

View File

@@ -1,9 +1,11 @@
<style>
</style>
<script lang="ts">
import AddProcess from '$lib/icons/Add-Process.svelte';
import FileRect from '$lib/icons/File-rect.svelte';
import ListIcon from '$lib/icons/List-icon.svelte';
export let data;
export let outline = true;
</script>
<div
@@ -15,20 +17,7 @@
<div
class="flex h-11 w-11 items-center justify-center rounded-lg bg-gray-50 group-hover:bg-white"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M8.25 6.75h12M8.25 12h12m-12 5.25h12M3.75 6.75h.007v.008H3.75V6.75zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zM3.75 12h.007v.008H3.75V12zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm-.375 5.25h.007v.008H3.75v-.008zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"
/>
</svg>
<ListIcon class=" group-hover:text-indigo-600" />
</div>
<a href="/list" class="mt-6 block font-semibold text-gray-900">
Liste
@@ -44,47 +33,7 @@
<div
class="flex h-11 w-11 items-center justify-center rounded-lg bg-gray-50 group-hover:bg-white"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m3.75 9v6m3-3H9m1.5-12H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"
/>
</svg>
</div>
<a href="/tatorte" class="mt-6 block font-semibold text-gray-900">
Neueer Vorgang
<span class="absolute inset-0"></span>
</a>
<p class="mt-1 text-gray-600">Stelle einen weiteren Tatort für die Anwendung bereit.</p>
</div>
{/if}
{#if data.user.admin}
<div class="group relative rounded-lg p-6 text-sm leading-6 hover:bg-gray-50 w-1/4">
<div
class="flex h-11 w-11 items-center justify-center rounded-lg bg-gray-50 group-hover:bg-white"
>
<svg
class="h-6 w-6 text-gray-600 group-hover:text-indigo-600"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M13.5 16.875h3.375m0 0h3.375m-3.375 0V13.5m0 3.375v3.375M6 10.5h2.25a2.25 2.25 0 002.25-2.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v2.25A2.25 2.25 0 006 10.5zm0 9.75h2.25A2.25 2.25 0 0010.5 18v-2.25a2.25 2.25 0 00-2.25-2.25H6a2.25 2.25 0 00-2.25 2.25V18A2.25 2.25 0 006 20.25zm9.75-9.75H18a2.25 2.25 0 002.25-2.25V6A2.25 2.25 0 0018 3.75h-2.25A2.25 2.25 0 0013.5 6v2.25a2.25 2.25 0 002.25 2.25z"
/>
</svg>
<AddProcess class=" group-hover:text-indigo-600" />
</div>
<a href="/upload" class="mt-6 block font-semibold text-gray-900">
Hinzufügen
@@ -97,20 +46,7 @@
<div
class="flex h-11 w-11 items-center justify-center rounded-lg bg-gray-50 group-hover:bg-white"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V8.25zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"
/>
</svg>
<FileRect class=" group-hover:text-indigo-600" {outline} />
</div>
<a href="/view" class="mt-6 block font-semibold text-gray-900">
Ansicht
@@ -120,3 +56,6 @@
</div>
</div>
</div>
<style>
</style>

View File

@@ -1,10 +1,10 @@
<script lang="ts">
import Alert from '$lib/components/ui/Alert.svelte';
import Button from '$lib/components/ui/Button.svelte';
import Modal from '$lib/components/ui/Modal/Modal.svelte';
import ModalTitle from '$lib/components/ui/Modal/ModalTitle.svelte';
import ModalContent from '$lib/components/ui/Modal/ModalContent.svelte';
import ModalFooter from '$lib/components/ui/Modal/ModalFooter.svelte';
import Alert from '$lib/components/Alert.svelte';
import Button from '$lib/components/Button.svelte';
import Modal from '$lib/components/Modal/Modal.svelte';
import ModalTitle from '$lib/components/Modal/ModalTitle.svelte';
import ModalContent from '$lib/components/Modal/ModalContent.svelte';
import ModalFooter from '$lib/components/Modal/ModalFooter.svelte';
import Exclamation from '$lib/icons/Exclamation.svelte';
export let form;
@@ -73,8 +73,24 @@
<p class="block text-sm leading-6 text-red-900 mt-2">{form.description}</p>
{/if}
</div>
<label for="code">
<span >Zugangscode (optional) </span>
</label>
<div class="mt-2">
<div
>
<input
type="text"
id="code"
/>
</div>
</div>
</div>
</div>
<div class="mt-6 flex items-center justify-end gap-x-6">
<button type="button" class="text-sm font-semibold leading-6 text-gray-900">Cancel</button>
<Button

View File

@@ -1,3 +1,4 @@
import { Buffer } from 'buffer';
import { Readable } from 'stream';
import { client } from '$lib/minio';
import { fail } from '@sveltejs/kit';
@@ -16,6 +17,7 @@ export const actions = {
const vorgang = data.get('vorgang');
const name = data.get('name');
const type = data.get('type');
const code = data.get('zugangscode');
const fileName = data.get('fileName');
let objectName = `${vorgang}/${name}`;
@@ -29,6 +31,14 @@ export const actions = {
const url = await client.presignedPutObject('tatort', objectName);
// store code in S3
// tatort/<vorgang>/__perm__
const code_filename = '__perm__';
const buf = Buffer.from(code, 'utf-8');
const code_stream = Readable.from(buf);
const code_path = `${vorgang}/${code_filename}`;
await client.putObject('tatort', code_path, code_stream);
return { url };
},
validate: async ({ request }: {request: Request}) => {
@@ -36,6 +46,7 @@ export const actions = {
const data = Object.fromEntries(requestData);
const vorgang = data.vorgang;
const name = data.name;
const zugangscode = data.zugangscode;
let success = true;
const err = {};
@@ -51,6 +62,12 @@ export const actions = {
success = false;
}
if (isRequiredFieldValid(zugangscode)) err.zugangscode = null;
else {
err.zugangscode = 'Das Feld Zugangscode darf nicht leer bleiben.';
success = false;
}
if (success) return { success };
return fail(400, err);
@@ -88,6 +105,5 @@ export const actions = {
}
return { etag, error };
//await writeFile(filePath, Buffer.from(await data.file.arrayBuffer()));
}
};

View File

@@ -1,19 +1,35 @@
<script lang="ts">
import { deserialize } from '$app/forms';
import Alert from '$lib/components/ui/Alert.svelte';
import Button from '$lib/components/ui/Button.svelte';
import Modal from '$lib/components/ui/Modal/Modal.svelte';
import ModalTitle from '$lib/components/ui/Modal/ModalTitle.svelte';
import ModalContent from '$lib/components/ui/Modal/ModalContent.svelte';
import ModalFooter from '$lib/components/ui/Modal/ModalFooter.svelte';
import Alert from '$lib/components/Alert.svelte';
import Button from '$lib/components/Button.svelte';
import Modal from '$lib/components/Modal/Modal.svelte';
import ModalTitle from '$lib/components/Modal/ModalTitle.svelte';
import ModalContent from '$lib/components/Modal/ModalContent.svelte';
import ModalFooter from '$lib/components/Modal/ModalFooter.svelte';
import shortenFileSize from '$lib/helper/shortenFileSize.js';
import Exclamation from '$lib/icons/Exclamation.svelte';
import FileRect from '$lib/icons/File-rect.svelte';
export let form;
let open = false;
let inProgress = false;
let vorgang = '';
const code_len = 8;
function generate_token() {
return Math.random()
.toString(36)
.slice(2, 2 + code_len);
}
let zugangscode = ''
let zugangscode_old = ''
$: zugangscode_old = generate_token();
$: zugangscode = zugangscode_old
let case_existing = undefined;
$: case_existing = false;
let name = '';
let etag: string | null = null;
let files: FileList | null = null;
@@ -26,6 +42,7 @@
let data = new FormData();
data.append('vorgang', vorgang);
data.append('name', name);
data.append('zugangscode', zugangscode);
const response = await fetch('?/validate', { method: 'POST', body: data });
/** @type {import('@sveltejs/kit').ActionResult} */
const result = deserialize(await response.text());
@@ -55,6 +72,7 @@
let data = new FormData();
data.append('vorgang', vorgang);
data.append('name', name);
data.append('zugangscode', zugangscode);
if (files?.length === 1) {
data.append('type', files[0].type);
data.append('fileName', files[0].name);
@@ -99,40 +117,85 @@
function swap_endian(val) {
// from https://www.geeksforgeeks.org/bit-manipulation-swap-endianness-of-a-number/
let leftmost_byte = (val & eval(0x000000FF)) >> 0;
let left_middle_byte = (val & eval(0x0000FF00)) >> 8;
let right_middle_byte = (val & eval(0x00FF0000)) >> 16;
let rightmost_byte = (val & eval(0xFF000000)) >> 24;
let leftmost_byte = (val & eval(0x000000ff)) >> 0;
let left_middle_byte = (val & eval(0x0000ff00)) >> 8;
let right_middle_byte = (val & eval(0x00ff0000)) >> 16;
let rightmost_byte = (val & eval(0xff000000)) >> 24;
leftmost_byte <<= 24;
left_middle_byte <<= 16;
right_middle_byte <<= 8;
rightmost_byte <<= 0;
let res = (leftmost_byte | left_middle_byte | right_middle_byte | rightmost_byte)
let res = leftmost_byte | left_middle_byte | right_middle_byte | rightmost_byte;
return res
return res;
}
async function check_valid_glb_file() {
// GLD Header, magic value 0x46546C67, identifies data as binary glTF, 4 bytes
// little endian!
const GLD_MAGIC = 0x46546C67;
const GLD_MAGIC = 0x46546c67;
// big endian!
let file = files[0];
let file_header = file.slice(0, 4)
let header_bytes = await file_header.bytes()
let file_header = file.slice(0, 4);
let header_bytes = await file_header.bytes();
let file_header_hex = '0x' + header_bytes.toHex().toString();
if (GLD_MAGIC == swap_endian(file_header_hex)) {
return true;
} else {
return false;
}
}
// `/(angemeldet)/view` return true or false
async function case_exists(case_no) {
if (case_no == '') {
zugangscode = zugangscode_old;
}
// ping `/view` with caseNumber in POST body
let url = '/view';
let data = new FormData();
data.append('caseNumber', case_no);
// fetch code in parallel
const code = await get_code(case_no);
if (code != -1) {
zugangscode = code;
case_existing = true;
return true
}
const response = await fetch(url, { method: 'POST', body: data });
const res_json = await response.json();
const status = res_json.status;
if (status != 303) {
case_existing = false;
zugangscode = zugangscode_old;
}
return false;
}
async function get_code(case_no) {
if (case_no == '') return;
let url = `/api/list/${case_no}/code`;
const response = await fetch(url);
if (response.status == 200) {
return response.text();
} else {
return -1;
}
}
</script>
@@ -169,18 +232,24 @@
id="vorgang"
autocomplete={vorgang}
class="block 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"
on:input={() => case_exists(vorgang)}
/>
</div>
</div>
{#if formErrors?.vorgang}
<p class="block text-sm leading-6 text-red-900 mt-2">{formErrors.vorgang}</p>
{/if}
{#if case_existing && vorgang.length > 0}
<span>Datei wird zum existierenden Vorgang hinzugefügt.</span>
{:else if vorgang.length > 0}
<span>Neuer Vorgang wird angelegt.</span>
{/if}
</div>
<div>
<label for="name" class="block text-sm font-medium leading-6 text-gray-900"
><span class="flex"
>{#if formErrors?.name}
><span class="flex"
>{#if formErrors?.name}
<span class="inline-block mr-1"><Exclamation /></span>
{/if} Name</span
></label
@@ -204,6 +273,41 @@
{/if}
</div>
<div>
<label for="zugangscode" class="block text-sm font-medium leading-6 text-gray-900"
><span class="flex"
>{#if formErrors?.zugangscode}
<span class="inline-block mr-1"><Exclamation /></span>
{/if} Zugangscode</span
></label
>
<div class="mt-2">
<div
class="flex 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
bind:value={zugangscode}
type="text"
name="zugangscode"
id="zugangscode"
on:input="{ (ev) => { zugangscode_old = ev.target.value }}"
class="block 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>
<button
class="rounded-md bg-blue-500 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"
on:click="{() => {
zugangscode = zugangscode_old = generate_token(); }}"
type="button">
Generiere Zugangscode
</button>
</div>
{#if formErrors?.code}
<p class="block text-sm leading-6 text-red-900 mt-2">{formErrors.code}</p>
{/if}
</div>
<div class="col-span-full">
<label for="file" class="block text-sm font-medium leading-6 text-gray-900"
><span class="flex"
@@ -216,18 +320,7 @@
class="mt-2 flex justify-center rounded-lg border border-dashed border-gray-900/25 px-6 py-10"
>
<div class="text-center">
<svg
class="mx-auto h-12 w-12 text-gray-300"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden="true"
>
<path
fill-rule="evenodd"
d="M1.5 6a2.25 2.25 0 012.25-2.25h16.5A2.25 2.25 0 0122.5 6v12a2.25 2.25 0 01-2.25 2.25H3.75A2.25 2.25 0 011.5 18V6zM3 16.06V18c0 .414.336.75.75.75h16.5A.75.75 0 0021 18v-1.94l-2.69-2.689a1.5 1.5 0 00-2.12 0l-.88.879.97.97a.75.75 0 11-1.06 1.06l-5.16-5.159a1.5 1.5 0 00-2.12 0L3 16.061zm10.125-7.81a1.125 1.125 0 112.25 0 1.125 1.125 0 01-2.25 0z"
clip-rule="evenodd"
/>
</svg>
<FileRect />
<div class="mt-4 flex text-sm leading-6 text-gray-600">
<label
for="file"

View File

@@ -1,27 +0,0 @@
import caseNumberOccupied from '$lib/helper/caseNumberOccupied';
import { fail, redirect } from '@sveltejs/kit';
/** @type {import('./$types').Actions} */
export const actions = {
default: async ({ request }: {request: Request}) => {
const data = await request.formData();
const caseNumber = data.get('caseNumber');
if (!caseNumber) {
return fail(400, {
success: false,
caseNumber,
error: { caseNumber: 'Die Vorgangsnummer darf nicht leer sein.' }
});
}
if (typeof caseNumber === 'string' && !(await caseNumberOccupied(caseNumber))) {
return fail(400, {
success: false,
caseNumber,
error: { caseNumber: 'Die Vorgangsnummer existiert in dieser Anwendung nicht.' }
});
}
throw redirect(303, `/list/${caseNumber}`);
}
};

View File

@@ -0,0 +1,10 @@
import { type ServerLoadEvent } from '@sveltejs/kit';
import type { PageServerLoad } from '../anmeldung/$types';
export const load: PageServerLoad = (event: ServerLoadEvent) => {
if (event.locals.user) {
return {
user: event.locals.user
};
}
};

View File

@@ -0,0 +1,16 @@
<script lang="ts">
import Footer from '$lib/components/Footer.svelte';
import Header from '$lib/components/Header.svelte';
export let data;
</script>
<div class="h-screen v-screen flex flex-col">
<Header {data} />
<div class="mt-10 flex-grow items-center justify-center">
<slot />
</div>
<Footer {data} />
</div>

View File

@@ -1,5 +1,7 @@
<script lang="ts">
import { onMount } from 'svelte';
import Trash from '$lib/icons/Trash.svelte';
import Folder from '$lib/icons/Folder.svelte';
/**
* @type any[]
@@ -35,7 +37,7 @@
const target = ev.currentTarget as HTMLElement | null;
if (!target) return;
let filename = target.id.split('del__')[1];
// delete request
// --------------
@@ -69,20 +71,8 @@
<li>
<a href="/list/{item.name}" class="flex justify-between gap-x-6 py-5">
<div class="flex gap-x-4">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M2.25 12.75V12A2.25 2.25 0 014.5 9.75h15A2.25 2.25 0 0121.75 12v.75m-8.69-6.44l-2.12-2.12a1.5 1.5 0 00-1.061-.44H4.5A2.25 2.25 0 002.25 6v12a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9a2.25 2.25 0 00-2.25-2.25h-5.379a1.5 1.5 0 01-1.06-.44z"
/>
</svg>
<!-- Ordner -->
<Folder />
<div class="min-w-0 flex-auto">
<span class="text-sm font-semibold leading-6 text-gray-900">{item.name}</span>
<!-- Delete button -->
@@ -92,13 +82,7 @@
on:click|preventDefault={delete_item}
aria-label="Vorgang {item.name} löschen"
>
<svg height="20" width="20" xmlns="http://www.w3.org/2000/svg"
><path
d="m8 3v1 1h1v-1h4v1h1v-1-1zm-4 3v1h14v-1zm2 2v11h1 9v-1-10h-1v10h-8v-10z"
fill="#373737"
transform="translate(1 1)"
/></svg
>
<Trash />
</button>
</div>
</div>

View File

@@ -5,14 +5,19 @@
import timeElapsed from '$lib/helper/timeElapsed';
import Alert from '$lib/components/ui/Alert.svelte';
import Button from '$lib/components/ui/Button.svelte';
import Modal from '$lib/components/ui/Modal/Modal.svelte';
import ModalTitle from '$lib/components/ui/Modal/ModalTitle.svelte';
import ModalContent from '$lib/components/ui/Modal/ModalContent.svelte';
import ModalFooter from '$lib/components/ui/Modal/ModalFooter.svelte';
import Alert from '$lib/components/Alert.svelte';
import Button from '$lib/components/Button.svelte';
import Modal from '$lib/components/Modal/Modal.svelte';
import ModalTitle from '$lib/components/Modal/ModalTitle.svelte';
import ModalContent from '$lib/components/Modal/ModalContent.svelte';
import ModalFooter from '$lib/components/Modal/ModalFooter.svelte';
import Cube from '$lib/icons/Cube.svelte';
import Edit from '$lib/icons/Edit.svelte';
import Trash from '$lib/icons/Trash.svelte';
/** export let data; */
/** @type {import('./$types').PageData} */
export let data;
interface ListItem {
name: string;
@@ -115,6 +120,7 @@
// construct PUT URL
const url = $page.url;
console.log(url);
let data_obj: { new_name: string; old_name: string } = { new_name: '', old_name: '' };
data_obj['new_name'] = new_name;
@@ -134,7 +140,6 @@
err = true;
if (response.status == 400) {
let json_res = await response.json();
// alert(json_res['msg'])
return;
}
throw new Error(`Fehlgeschlagen: ${response.status}`);
@@ -162,117 +167,114 @@
<li>
<a
href="/view/{$page.params.vorgang}/{item.name}"
class="flex justify-between gap-x-6 py-5"
class=" flex justify-between gap-x-6 py-5"
aria-label="zum 3D-modell"
>
<div class="flex gap-x-4">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M21 7.5l-2.25-1.313M21 7.5v2.25m0-2.25l-2.25 1.313M3 7.5l2.25-1.313M3 7.5l2.25 1.313M3 7.5v2.25m9 3l2.25-1.313M12 12.75l-2.25-1.313M12 12.75V15m0 6.75l2.25-1.313M12 21.75V19.5m0 2.25l-2.25-1.313m0-16.875L12 2.25l2.25 1.313M21 14.25v2.25l-2.25 1.313m-13.5 0L3 16.5v-2.25"
/>
</svg>
<div class=" flex gap-x-4">
<Cube />
<button on:click="{() => console.log('test')}">test</button>
<div class="min-w-0 flex-auto">
<span
style="display: inline-block; min-width: 5px;"
id="label__{item.name}"
class="text-sm font-semibold leading-6 text-gray-900"
contenteditable={!item.show_button}
role="textbox"
tabindex="0"
aria-label="Dateiname bearbeiten"
on:focusout={() => {
defocus_element(i);
}}
{#if data?.user?.admin}
<span
id="label__{item.name}"
class="text-sm font-semibold leading-6 text-gray-900 inline-block min-w-1"
contenteditable={!item.show_button}
role="textbox"
tabindex="0"
aria-label="Dateiname bearbeiten"
on:focusout={() => {
defocus_element(i);
}}
on:keydown|stopPropagation={// event needed to identify ID
// TO-DO: check if event is needed or if index is sufficient
async (ev) => {
handle_input(ev, i);
}}>{item.name}</span
>
<!--<input
class="text-sm font-semibold leading-6 text-gray-900 inline-block min-w-1"
type="text"
name=""
on:keydown|stopPropagation={// event needed to identify ID
// TO-DO: check if event is needed or if index is sufficient
async (ev) => {
handle_input(ev, i);
}}>{item.name}</span
>
<!-- https://iconduck.com/icons/192863/edit-rename -->
}}
bind:value={item.name}
id="label__{item.name}"
/>-->
<!-- disabled={item.show_button} -->
<!-- https://iconduck.com/icons/192863/edit-rename -->
{#if item.show_button}
{#if item.show_button}
<button
style="padding: 2px"
id="edit__{item.name}"
aria-label="Datei umbenennen"
on:click|preventDefault={(ev) => {
let text_field_id = `label__${item.name}`;
let text_field = document.getElementById(text_field_id);
if (text_field) {
text_field.setAttribute('contenteditable', 'true');
text_field.focus();
text_field.textContent = '';
}
// hide button
item.show_button = false;
}}
>
<Edit />
</button>
{/if}
<button
style="padding: 2px"
id="edit__{item.name}"
aria-label="Datei umbenennen"
on:click|preventDefault={(ev) => {
let text_field_id = `label__${item.name}`;
id="del__{item.name}"
on:click|preventDefault={async (ev) => {
let delete_item = window.confirm('Bist du sicher?');
let text_field = document.getElementById(text_field_id);
if (text_field) {
text_field.setAttribute('contenteditable', 'true');
text_field.focus();
text_field.textContent = '';
if (delete_item) {
// bucket: tatort, name: <vorgang>/item-name
let vorgang = $page.params.vorgang;
let filename = '';
if (ev && ev.currentTarget && (ev.currentTarget as HTMLElement).id) {
filename = (ev.currentTarget as HTMLElement).id.split('del__')[1];
}
// delete request
// --------------
let url = new URL($page.url);
url.pathname += `/${filename}`;
console.log(`--- ${vorgang} + ${filename} + ${url}`);
try {
const response = await fetch(url, { method: 'DELETE' });
if (response.status == 204) {
setTimeout(() => {
window.location.reload();
}, 500);
}
} catch (error) {
if (error instanceof Error) {
console.log(error.message);
} else {
console.log(error);
}
}
}
// hide button
item.show_button = false;
}}
aria-label="Datei löschen"
>
<svg height="20" width="20" xmlns="http://www.w3.org/2000/svg"
><path
d="m14.996094 3-11.9921878 11.992188h-.0039062v4.007812h1 2 1.0078125v-.0039l11.9921875-11.9921938-.001953-.0019531.001953-.0019531-4-4-.002.00195zm-1.998047 3.4121094 2.589844 2.5898437-7.587891 7.5878909v-1.589844h-1-1v-1-.589844zm-7.998047 7.9980466v1.589844h1 1v1 .589844l-.4101562.410156h-1.5898438l-1-1v-1.589844z"
fill="#373737"
transform="translate(1 1)"
/></svg
>
<Trash />
</button>
{/if}
<button
style="padding: 2px"
id="del__{item.name}"
on:click|preventDefault={async (ev) => {
let delete_item = window.confirm('Bist du sicher?');
if (delete_item) {
// bucket: tatort, name: <vorgang>/item-name
let vorgang = $page.params.vorgang;
let filename = '';
if (ev && ev.currentTarget && (ev.currentTarget as HTMLElement).id) {
filename = (ev.currentTarget as HTMLElement).id.split('del__')[1];
}
// delete request
// --------------
let url = new URL($page.url);
url.pathname += `/${filename}`;
try {
const response = await fetch(url, { method: 'DELETE' });
if (response.status == 204) {
setTimeout(() => {
window.location.reload();
}, 500);
}
} catch (error) {
if (error instanceof Error) {
console.log(error.message);
} else {
console.log(error);
}
}
}
}}
aria-label="Datei löschen"
>
<svg height="20" width="20" xmlns="http://www.w3.org/2000/svg"
><path
d="m8 3v1 1h1v-1h4v1h1v-1-1zm-4 3v1h14v-1zm2 2v11h1 9v-1-10h-1v10h-8v-10z"
fill="#373737"
transform="translate(1 1)"
/></svg
{:else}
<span class="text-sm font-semibold leading-6 text-gray-900 inline-block min-w-1"
>{item.name}</span
>
</button>
{/if}
<p class="mt-1 truncate text-xs leading-5 text-gray-500">
{shortenFileSize(item.size)}
</p>

View 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)
}

View File

@@ -1,5 +1,5 @@
<script lang="ts">
import Button from '$lib/components/ui/Button.svelte';
import Button from '$lib/components/Button.svelte';
import Exclamation from '$lib/icons/Exclamation.svelte';
export let form;
@@ -45,6 +45,29 @@
<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">

View File

@@ -1,7 +1,7 @@
<script lang="ts">
import Panel from '$lib/components/ui/Panel.svelte';
import Panel from '$lib/components/Panel.svelte';
import { onMount } from 'svelte';
import Button from '$lib/components/ui/Button.svelte';
import Button from '$lib/components/Button.svelte';
export let data;
@@ -59,7 +59,10 @@
</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"
@@ -78,7 +81,18 @@
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

View File

@@ -1,32 +1,9 @@
import { dev } from '$app/environment';
import { fail, redirect, type Cookies } from '@sveltejs/kit';
import { authenticate } from '$lib/auth';
import type { RequestEvent } from '../(angemeldet)/$types';
import { loginUser, logoutUser } from '$lib/server/authService';
import { getVorgangByCaseNumber } from '$lib/server/vorgangService.js';
const COOKIE_NAME = 'session';
/** @type {import('./$types').Actions} */
export const actions = {
login: async ({ request, cookies }: {request: Request, cookies: Cookies}) => {
const data = await request.formData();
const user = data.get('user');
const password = data.get('password');
const token = authenticate(user, password);
if (!token) return fail(400, { user, incorrect: true });
cookies.set(COOKIE_NAME, token, {
path: '/',
httpOnly: true,
sameSite: 'strict',
secure: !dev
});
throw redirect(303, '/');
},
logout: async (event: RequestEvent) => {
event.cookies.delete(COOKIE_NAME, {path: '/'});
event.locals.user = null;
return { success: true };
}
};
login: ({ request, cookies }) => loginUser({request, cookies}),
logout: (event) => logoutUser(event),
getVorgang: ({request}) => getVorgangByCaseNumber(request)
} as const;

View File

@@ -1,19 +1,16 @@
<script lang="ts">
import Button from '$lib/components/ui/Button.svelte';
import Modal from '$lib/components/ui/Modal/Modal.svelte';
import ModalContent from '$lib/components/ui/Modal/ModalContent.svelte';
import ModalFooter from '$lib/components/ui/Modal/ModalFooter.svelte';
import ModalTitle from '$lib/components/ui/Modal/ModalTitle.svelte';
import Exclamation from '$lib/icons/Exclamation.svelte';
import BaseInputField from '$lib/components/BaseInputField.svelte';
import Button from '$lib/components/Button.svelte';
import Modal from '$lib/components/Modal/Modal.svelte';
import ModalContent from '$lib/components/Modal/ModalContent.svelte';
import ModalFooter from '$lib/components/Modal/ModalFooter.svelte';
import ModalTitle from '$lib/components/Modal/ModalTitle.svelte';
import ArrowRight from '$lib/icons/Arrow-right.svelte';
import Login from '$lib/icons/Login.svelte';
import type { ActionData } from './$types';
export let form: ActionData;
export let form;
let user = form?.user ?? '';
let open = false;
$: open = form?.success ?? false;
export let open = false;
</script>
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
@@ -21,88 +18,75 @@
<img class="mx-auto h-10 w-auto" src="/Landeswappen_NI.svg" alt="Landeswappen Niedersachsen" />
<h2 class="mt-10 text-center text-2xl font-bold leading-9 tracking-tight text-gray-900">
Anmeldung zum 3D Tatort
Willkommen beim 3D Tatort
</h2>
</div>
<div class="mt-10 sm:mx-auto sm:w-full sm:max-w-sm">
<form class="space-y-6" action="?/login" method="POST">
<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">
<div
class="flex 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 flex-1 border-0 bg-transparent py-1.5 pl-1 text-gray-900 placeholder:text-gray-400 focus:ring-0 text-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>
</form>
<div class="flex justify-end pt-4">
<Button on:click={() => (open = true)}><Login /></Button>
</div>
</div>
<Modal {open}>
<ModalTitle>Anmelden</ModalTitle>
<ModalContent>
<div class="content-center">
<form action="">
<div>
<label for="user" class="text-sm font-medium leading-6 text-gray-900">Kennung</label>
<div class="mt-2">
<input
id="user"
name="user"
type="text"
autocomplete="email"
required
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
/>
</div>
</div>
<div>
<label for="password" class="block text-sm font-medium leading-6 text-gray-900"
>Passwort</label
>
<div class="mt-2">
<input
id="password"
name="password"
type="password"
autocomplete="current-password"
required
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
/>
</div>
</div>
<div>
<button
type="submit"
class="mt-10 flex w-full justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-semibold leading-6 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"
>Anmelden</button
>
<div class="w-full max-w-sm mx-auto">
<div class="relative mt-5 bg-gray-50 rounded-xl shadow-xl p-3 pt-1">
<div class="mt-10">
<form action="?/getVorgang" method="POST">
<BaseInputField
id="caseNumber"
name="caseNumber"
label="Vorgangs-Nr."
type="text"
value={form?.caseNumber}
error={form?.error?.message}
/>
<div class="flex justify-end pt-4">
<Button type="submit"><ArrowRight /></Button>
</div>
</form>
</div>
</ModalContent>
<ModalFooter><Button on:click={() => (open = false)}>Ok</Button></ModalFooter>
</Modal>
</div>
<div class="flex justify-end mt-10 px-3">
<Button on:click={() => (open = true)} ><Login /></Button>
</div>
</div>
</div>
<Modal {open}>
<ModalTitle>Anmelden</ModalTitle>
<ModalContent class="flex justify-center">
<form action="?/login" method="POST">
<div>
<label for="user" class="text-sm font-medium leading-6 text-gray-900">Kennung</label>
<div class="mt-2">
<input
id="user"
name="user"
type="text"
autocomplete="email"
required
class="rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
/>
</div>
</div>
<div>
<label for="password" class="block text-sm font-medium leading-6 text-gray-900"
>Passwort</label
>
<div class="mt-2">
<input
id="password"
name="password"
type="password"
autocomplete="current-password"
required
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
/>
</div>
</div>
<div class="flex justify-end">
<Button
type="submit"
class="mt-5"
>Anmelden</Button
>
</div>
</form>
</ModalContent>
<ModalFooter><Button on:click={() => (open = false)}>Ok</Button></ModalFooter>
</Modal>

View File

@@ -15,6 +15,8 @@ export async function GET({ params }) {
const name = data.name.slice(prefix.length);
if (name === 'config.json') return;
// zugangscode datei
if (name === '__perm__') return;
controller.enqueue(`${JSON.stringify({ ...data, name, prefix })}\n`);
});
@@ -34,27 +36,25 @@ export async function GET({ params }) {
});
}
export async function DELETE({ params }) {
const vorgang = params.vorgang
const vorgang = params.vorgang;
const object_list = await new Promise((resolve, reject) => {
const res = []
const items_str = client.listObjects('tatort', vorgang, true)
const res = [];
const items_str = client.listObjects('tatort', vorgang, true);
items_str.on('data', (obj) => {
res.push(obj.name)
})
res.push(obj.name);
});
items_str.on('error', reject)
items_str.on('error', reject);
items_str.on('end', async () => {
resolve(res)
})
})
resolve(res);
});
});
await client.removeObjects('tatort', object_list)
await client.removeObjects('tatort', object_list);
return new Response(null, { status: 204 });
};
return new Response(null, { status: 204 });
}

View File

@@ -0,0 +1,25 @@
import { client } from '$lib/minio';
/** @type {import('./$types').RequestHandler} */
export async function GET({ params }) {
const prefix = params.vorgang ? `${params.vorgang}` : '';
const code_name = '__perm__';
const obj_path = `${prefix}/${code_name}`;
let result = null;
try {
result = await client.getObject('tatort', obj_path);
} catch (error) {
if (error.name == 'S3Error') {
result = null;
}
}
if (result != null) {
return new Response(result, { status: 200 });
} else {
return new Response(null, { status: 404 });
}
}

14
static/1.svg Normal file
View File

@@ -0,0 +1,14 @@
<svg
class="h-6 w-6 text-gray-600 group-hover:text-indigo-600"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M13.5 16.875h3.375m0 0h3.375m-3.375 0V13.5m0 3.375v3.375M6 10.5h2.25a2.25 2.25 0 002.25-2.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v2.25A2.25 2.25 0 006 10.5zm0 9.75h2.25A2.25 2.25 0 0010.5 18v-2.25a2.25 2.25 0 00-2.25-2.25H6a2.25 2.25 0 00-2.25 2.25V18A2.25 2.25 0 006 20.25zm9.75-9.75H18a2.25 2.25 0 002.25-2.25V6A2.25 2.25 0 0018 3.75h-2.25A2.25 2.25 0 0013.5 6v2.25a2.25 2.25 0 002.25 2.25z"
/>
</svg>

After

Width:  |  Height:  |  Size: 714 B