Compare commits
2 Commits
e4d74e4331
...
31ca124511
| Author | SHA1 | Date | |
|---|---|---|---|
| 31ca124511 | |||
| 07247486ab |
@@ -11,7 +11,7 @@ export function createToken(userData) {
|
||||
return jwt.sign(userData, SECRET, { expiresIn: EXPIRES_IN });
|
||||
}
|
||||
|
||||
export function decryptToken(token) {
|
||||
export function decryptToken(token: string) {
|
||||
return jwt.verify(token, SECRET);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import { readFileSync } from 'fs';
|
||||
|
||||
export default JSON.parse(readFileSync('./config.json'));
|
||||
export default JSON.parse(readFileSync('./config.json').toString());
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
import { client } from '$lib/minio';
|
||||
|
||||
/**
|
||||
* Check if caseNumber is used
|
||||
* @param {string} caseNumber
|
||||
* @returns {Promise<boolean}
|
||||
*/
|
||||
export default async function caseNumberOccupied(caseNumber: string) {
|
||||
export default async function caseNumberOccupied (caseNumber: string): Promise<boolean> {
|
||||
const prefix = `${caseNumber}/config.json`;
|
||||
const promise = new Promise((resolve) => {
|
||||
const promise: Promise<boolean> = new Promise((resolve) => {
|
||||
const stream = client.listObjectsV2('tatort', prefix, false, '');
|
||||
stream.on('data', () => {
|
||||
stream.destroy();
|
||||
|
||||
@@ -2,12 +2,7 @@ const KILO = 1024;
|
||||
const MEGA = KILO * KILO;
|
||||
const GIGA = MEGA * KILO;
|
||||
|
||||
/**
|
||||
* Shortens the size in bytes
|
||||
* @param {number} size
|
||||
* @returns{string}
|
||||
*/
|
||||
export default function shortenFileSize(size: number) {
|
||||
export default function shortenFileSize(size: number): string {
|
||||
const giga = Math.floor(size / GIGA);
|
||||
let remainder = size % GIGA;
|
||||
const mega = Math.floor(remainder / MEGA);
|
||||
|
||||
@@ -4,12 +4,7 @@ const DAY = 24 * HOUR;
|
||||
const YEAR = 365 * DAY;
|
||||
const MONTH = YEAR / 12;
|
||||
|
||||
/**
|
||||
* get readable string of time elapsed since date
|
||||
* @param {Date} date
|
||||
* @returns string
|
||||
*/
|
||||
export default function timeElapsed(date: Date) {
|
||||
export default function timeElapsed(date: Date): string {
|
||||
const now = new Date();
|
||||
const age = Math.floor((now.getTime() - date.getTime()) / 1000);
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
|
||||
let url = `/api/list/${filename}`;
|
||||
|
||||
console.log(`--- ${filename} + ${url}`);
|
||||
try {
|
||||
const response = await fetch(url, { method: 'DELETE' });
|
||||
if (response.status == 204) {
|
||||
|
||||
@@ -62,7 +62,6 @@
|
||||
});
|
||||
|
||||
function uploadSuccessful() {
|
||||
console.log('reset');
|
||||
open = false;
|
||||
}
|
||||
|
||||
@@ -97,7 +96,6 @@
|
||||
return;
|
||||
}
|
||||
if (ev.key == 'Enter') {
|
||||
console.log('--- hitted');
|
||||
let name_field = ev.currentTarget as HTMLElement | null;
|
||||
let new_name = name_field
|
||||
? name_field.textContent || (name_field as any).innerText || ''
|
||||
@@ -117,7 +115,6 @@
|
||||
|
||||
// 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;
|
||||
@@ -250,7 +247,6 @@
|
||||
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) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import { json } from '@sveltejs/kit';
|
||||
export async function PUT({ request }: {request: Request}) {
|
||||
const data = await request.json();
|
||||
|
||||
console.log(`--- ${request.url.split('/').at(-1)} +++ ${JSON.stringify(data)}`);
|
||||
|
||||
// Vorgang
|
||||
const vorgang = request.url.split('/').at(-1);
|
||||
|
||||
@@ -55,22 +55,22 @@
|
||||
<div>
|
||||
<label for="description" class="block text-sm font-medium leading-6 text-gray-900"
|
||||
><span class="flex"
|
||||
>{#if form?.error?.description}
|
||||
>{#if form?.description}
|
||||
<span class="inline-block mr-1"><Exclamation /></span>
|
||||
{/if} Beschreibung</span
|
||||
></label
|
||||
>
|
||||
<div class="mt-2">
|
||||
<textarea
|
||||
value={form?.description ?? ''}
|
||||
value={form?.description?.toString() ?? ''}
|
||||
id="description"
|
||||
name="description"
|
||||
rows="3"
|
||||
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"
|
||||
></textarea>
|
||||
</div>
|
||||
{#if form?.error?.description}
|
||||
<p class="block text-sm leading-6 text-red-900 mt-2">{form.error.description}</p>
|
||||
{#if form?.error}
|
||||
<p class="block text-sm leading-6 text-red-900 mt-2">{form.description}</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -10,7 +10,6 @@ const isRequiredFieldValid = (value: unknown) => {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @type {import('./$types').Actions} */
|
||||
export const actions = {
|
||||
url: async ({ request }: {request: Request}) => {
|
||||
const data = await request.formData();
|
||||
@@ -62,11 +61,9 @@ export const actions = {
|
||||
const data = Object.fromEntries(requestData);
|
||||
const vorgang = data.vorgang;
|
||||
const name = data.name;
|
||||
console.log('I:', vorgang, name);
|
||||
|
||||
const url = await client.presignedPutObject('tatort', `${vorgang}/${name}`, 60);
|
||||
|
||||
console.log('O:', url);
|
||||
return { url };
|
||||
},
|
||||
upload3: async ({ request }: {request: Request}) => {
|
||||
@@ -74,7 +71,6 @@ export const actions = {
|
||||
const data = Object.fromEntries(requestData);
|
||||
const name = data.name;
|
||||
const stream = data.file.stream();
|
||||
console.log('Data:', stream);
|
||||
const metaData = { 'Content-Type': 'model-gtlf-binary', 'X-VorgangsNr': '4711' };
|
||||
const result = new Promise((resolve, reject) => {
|
||||
client.putObject('tatort', name, Readable.from(stream), metaData, function (err, etag) {
|
||||
@@ -86,7 +82,6 @@ export const actions = {
|
||||
let error = null;
|
||||
try {
|
||||
etag = await result;
|
||||
console.log(etag);
|
||||
} catch (err) {
|
||||
error = err;
|
||||
console.log('Error:', err);
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
|
||||
$: inProgress = form === null;
|
||||
|
||||
/** @type {?Record<string,any>}*/
|
||||
let formErrors;
|
||||
let formErrors: Record<string,any> | null;
|
||||
|
||||
async function validateForm() {
|
||||
let data = new FormData();
|
||||
@@ -39,7 +38,6 @@
|
||||
success = false;
|
||||
}
|
||||
|
||||
console.log('File', files);
|
||||
if (!files?.length) {
|
||||
formErrors = { file: 'Sie haben keine Datei ausgewählt.', ...formErrors };
|
||||
success = false;
|
||||
@@ -75,7 +73,6 @@
|
||||
return;
|
||||
}
|
||||
const url = await getUrl();
|
||||
console.log('URL', url);
|
||||
open = true;
|
||||
inProgress = true;
|
||||
|
||||
@@ -83,7 +80,6 @@
|
||||
.then((response) => {
|
||||
inProgress = false;
|
||||
etag = '123';
|
||||
console.log('SUCCESS', response);
|
||||
})
|
||||
.catch((err) => {
|
||||
inProgress = false;
|
||||
@@ -93,7 +89,6 @@
|
||||
}
|
||||
|
||||
function uploadSuccessful() {
|
||||
console.log('reset');
|
||||
open = false;
|
||||
vorgang = '';
|
||||
name = '';
|
||||
|
||||
@@ -28,9 +28,6 @@
|
||||
|
||||
$: style = `width: ${progress}%`;
|
||||
|
||||
/**
|
||||
* @param {any} detail
|
||||
*/
|
||||
const onProgress = ({ detail }) => {
|
||||
progress = Math.ceil(detail.totalProgress * 100.0);
|
||||
if (progress == 100) {
|
||||
@@ -41,21 +38,6 @@
|
||||
}
|
||||
|
||||
function onResetView() {
|
||||
console.log(
|
||||
'show cameraOrbit:',
|
||||
modelViewer.getCameraOrbit(),
|
||||
modelViewer.cameraOrbit,
|
||||
modelViewer.getDimensions()
|
||||
);
|
||||
console.log(
|
||||
'Camera-orbit: ',
|
||||
modelViewer.getAttribute('camera-orbit'),
|
||||
'camera-target: ',
|
||||
modelViewer.getAttribute('camera-target'),
|
||||
'object-rotation: ',
|
||||
modelViewer.getAttribute('rotation')
|
||||
);
|
||||
|
||||
cameraAzimuth = 0;
|
||||
cameraPolar = 0;
|
||||
cameraZoom = 100;
|
||||
@@ -69,12 +51,7 @@
|
||||
fieldOfView = '10deg';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} azimuth
|
||||
* @param {number} polar
|
||||
* @param {number} zoom
|
||||
*/
|
||||
function updateCameraOrbit(azimuth, polar, zoom) {
|
||||
function updateCameraOrbit(azimuth: number, polar: number, zoom: number) {
|
||||
cameraAzimuth = azimuth;
|
||||
cameraPolar = polar;
|
||||
cameraZoom = zoom;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<script lang="ts">
|
||||
/** @type {import('./$types').ActionData} */
|
||||
export let form;
|
||||
import type { ActionData } from "./$types";
|
||||
|
||||
export let form: ActionData;
|
||||
|
||||
let user = form?.user ?? '';
|
||||
|
||||
function buttonClick() {}
|
||||
</script>
|
||||
|
||||
<!--
|
||||
|
||||
@@ -52,9 +52,6 @@ export async function DELETE({ params }) {
|
||||
items_str.on('end', async () => {
|
||||
resolve(res)
|
||||
})
|
||||
|
||||
console.log(`+++ ${vorgang}`)
|
||||
|
||||
})
|
||||
|
||||
await client.removeObjects('tatort', object_list)
|
||||
|
||||
@@ -5,7 +5,6 @@ export async function GET() {
|
||||
const result = new ReadableStream({
|
||||
start(controller) {
|
||||
stream.on('data', (data) => {
|
||||
//console.log(data);
|
||||
controller.enqueue(`${JSON.stringify(data)}\n`);
|
||||
});
|
||||
stream.on('end', () => {
|
||||
|
||||
Reference in New Issue
Block a user