fix further type problems
This commit is contained in:
@@ -11,7 +11,7 @@ export function createToken(userData) {
|
|||||||
return jwt.sign(userData, SECRET, { expiresIn: EXPIRES_IN });
|
return jwt.sign(userData, SECRET, { expiresIn: EXPIRES_IN });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function decryptToken(token) {
|
export function decryptToken(token: string) {
|
||||||
return jwt.verify(token, SECRET);
|
return jwt.verify(token, SECRET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
import { readFileSync } from 'fs';
|
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';
|
import { client } from '$lib/minio';
|
||||||
|
|
||||||
/**
|
export default async function caseNumberOccupied (caseNumber: string): Promise<boolean> {
|
||||||
* Check if caseNumber is used
|
|
||||||
* @param {string} caseNumber
|
|
||||||
* @returns {Promise<boolean}
|
|
||||||
*/
|
|
||||||
export default async function caseNumberOccupied(caseNumber: string) {
|
|
||||||
const prefix = `${caseNumber}/config.json`;
|
const prefix = `${caseNumber}/config.json`;
|
||||||
const promise = new Promise((resolve) => {
|
const promise: Promise<boolean> = new Promise((resolve) => {
|
||||||
const stream = client.listObjectsV2('tatort', prefix, false, '');
|
const stream = client.listObjectsV2('tatort', prefix, false, '');
|
||||||
stream.on('data', () => {
|
stream.on('data', () => {
|
||||||
stream.destroy();
|
stream.destroy();
|
||||||
|
|||||||
@@ -2,12 +2,7 @@ const KILO = 1024;
|
|||||||
const MEGA = KILO * KILO;
|
const MEGA = KILO * KILO;
|
||||||
const GIGA = MEGA * KILO;
|
const GIGA = MEGA * KILO;
|
||||||
|
|
||||||
/**
|
export default function shortenFileSize(size: number): string {
|
||||||
* Shortens the size in bytes
|
|
||||||
* @param {number} size
|
|
||||||
* @returns{string}
|
|
||||||
*/
|
|
||||||
export default function shortenFileSize(size: number) {
|
|
||||||
const giga = Math.floor(size / GIGA);
|
const giga = Math.floor(size / GIGA);
|
||||||
let remainder = size % GIGA;
|
let remainder = size % GIGA;
|
||||||
const mega = Math.floor(remainder / MEGA);
|
const mega = Math.floor(remainder / MEGA);
|
||||||
|
|||||||
@@ -4,12 +4,7 @@ const DAY = 24 * HOUR;
|
|||||||
const YEAR = 365 * DAY;
|
const YEAR = 365 * DAY;
|
||||||
const MONTH = YEAR / 12;
|
const MONTH = YEAR / 12;
|
||||||
|
|
||||||
/**
|
export default function timeElapsed(date: Date): string {
|
||||||
* get readable string of time elapsed since date
|
|
||||||
* @param {Date} date
|
|
||||||
* @returns string
|
|
||||||
*/
|
|
||||||
export default function timeElapsed(date: Date) {
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const age = Math.floor((now.getTime() - date.getTime()) / 1000);
|
const age = Math.floor((now.getTime() - date.getTime()) / 1000);
|
||||||
|
|
||||||
|
|||||||
@@ -55,22 +55,22 @@
|
|||||||
<div>
|
<div>
|
||||||
<label for="description" class="block text-sm font-medium leading-6 text-gray-900"
|
<label for="description" class="block text-sm font-medium leading-6 text-gray-900"
|
||||||
><span class="flex"
|
><span class="flex"
|
||||||
>{#if form?.error?.description}
|
>{#if form?.description}
|
||||||
<span class="inline-block mr-1"><Exclamation /></span>
|
<span class="inline-block mr-1"><Exclamation /></span>
|
||||||
{/if} Beschreibung</span
|
{/if} Beschreibung</span
|
||||||
></label
|
></label
|
||||||
>
|
>
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<textarea
|
<textarea
|
||||||
value={form?.description ?? ''}
|
value={form?.description?.toString() ?? ''}
|
||||||
id="description"
|
id="description"
|
||||||
name="description"
|
name="description"
|
||||||
rows="3"
|
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"
|
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>
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
{#if form?.error?.description}
|
{#if form?.error}
|
||||||
<p class="block text-sm leading-6 text-red-900 mt-2">{form.error.description}</p>
|
<p class="block text-sm leading-6 text-red-900 mt-2">{form.description}</p>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ const isRequiredFieldValid = (value: unknown) => {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {import('./$types').Actions} */
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
url: async ({ request }: {request: Request}) => {
|
url: async ({ request }: {request: Request}) => {
|
||||||
const data = await request.formData();
|
const data = await request.formData();
|
||||||
@@ -62,11 +61,9 @@ export const actions = {
|
|||||||
const data = Object.fromEntries(requestData);
|
const data = Object.fromEntries(requestData);
|
||||||
const vorgang = data.vorgang;
|
const vorgang = data.vorgang;
|
||||||
const name = data.name;
|
const name = data.name;
|
||||||
console.log('I:', vorgang, name);
|
|
||||||
|
|
||||||
const url = await client.presignedPutObject('tatort', `${vorgang}/${name}`, 60);
|
const url = await client.presignedPutObject('tatort', `${vorgang}/${name}`, 60);
|
||||||
|
|
||||||
console.log('O:', url);
|
|
||||||
return { url };
|
return { url };
|
||||||
},
|
},
|
||||||
upload3: async ({ request }: {request: Request}) => {
|
upload3: async ({ request }: {request: Request}) => {
|
||||||
@@ -74,7 +71,6 @@ export const actions = {
|
|||||||
const data = Object.fromEntries(requestData);
|
const data = Object.fromEntries(requestData);
|
||||||
const name = data.name;
|
const name = data.name;
|
||||||
const stream = data.file.stream();
|
const stream = data.file.stream();
|
||||||
console.log('Data:', stream);
|
|
||||||
const metaData = { 'Content-Type': 'model-gtlf-binary', 'X-VorgangsNr': '4711' };
|
const metaData = { 'Content-Type': 'model-gtlf-binary', 'X-VorgangsNr': '4711' };
|
||||||
const result = new Promise((resolve, reject) => {
|
const result = new Promise((resolve, reject) => {
|
||||||
client.putObject('tatort', name, Readable.from(stream), metaData, function (err, etag) {
|
client.putObject('tatort', name, Readable.from(stream), metaData, function (err, etag) {
|
||||||
@@ -86,7 +82,6 @@ export const actions = {
|
|||||||
let error = null;
|
let error = null;
|
||||||
try {
|
try {
|
||||||
etag = await result;
|
etag = await result;
|
||||||
console.log(etag);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
error = err;
|
error = err;
|
||||||
console.log('Error:', err);
|
console.log('Error:', err);
|
||||||
|
|||||||
@@ -20,8 +20,7 @@
|
|||||||
|
|
||||||
$: inProgress = form === null;
|
$: inProgress = form === null;
|
||||||
|
|
||||||
/** @type {?Record<string,any>}*/
|
let formErrors: Record<string,any> | null;
|
||||||
let formErrors;
|
|
||||||
|
|
||||||
async function validateForm() {
|
async function validateForm() {
|
||||||
let data = new FormData();
|
let data = new FormData();
|
||||||
@@ -39,7 +38,6 @@
|
|||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('File', files);
|
|
||||||
if (!files?.length) {
|
if (!files?.length) {
|
||||||
formErrors = { file: 'Sie haben keine Datei ausgewählt.', ...formErrors };
|
formErrors = { file: 'Sie haben keine Datei ausgewählt.', ...formErrors };
|
||||||
success = false;
|
success = false;
|
||||||
@@ -75,7 +73,6 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const url = await getUrl();
|
const url = await getUrl();
|
||||||
console.log('URL', url);
|
|
||||||
open = true;
|
open = true;
|
||||||
inProgress = true;
|
inProgress = true;
|
||||||
|
|
||||||
@@ -83,7 +80,6 @@
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
inProgress = false;
|
inProgress = false;
|
||||||
etag = '123';
|
etag = '123';
|
||||||
console.log('SUCCESS', response);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
inProgress = false;
|
inProgress = false;
|
||||||
@@ -93,7 +89,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function uploadSuccessful() {
|
function uploadSuccessful() {
|
||||||
console.log('reset');
|
|
||||||
open = false;
|
open = false;
|
||||||
vorgang = '';
|
vorgang = '';
|
||||||
name = '';
|
name = '';
|
||||||
|
|||||||
@@ -28,9 +28,6 @@
|
|||||||
|
|
||||||
$: style = `width: ${progress}%`;
|
$: style = `width: ${progress}%`;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {any} detail
|
|
||||||
*/
|
|
||||||
const onProgress = ({ detail }) => {
|
const onProgress = ({ detail }) => {
|
||||||
progress = Math.ceil(detail.totalProgress * 100.0);
|
progress = Math.ceil(detail.totalProgress * 100.0);
|
||||||
if (progress == 100) {
|
if (progress == 100) {
|
||||||
@@ -41,21 +38,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onResetView() {
|
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;
|
cameraAzimuth = 0;
|
||||||
cameraPolar = 0;
|
cameraPolar = 0;
|
||||||
cameraZoom = 100;
|
cameraZoom = 100;
|
||||||
@@ -69,12 +51,7 @@
|
|||||||
fieldOfView = '10deg';
|
fieldOfView = '10deg';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
function updateCameraOrbit(azimuth: number, polar: number, zoom: number) {
|
||||||
* @param {number} azimuth
|
|
||||||
* @param {number} polar
|
|
||||||
* @param {number} zoom
|
|
||||||
*/
|
|
||||||
function updateCameraOrbit(azimuth, polar, zoom) {
|
|
||||||
cameraAzimuth = azimuth;
|
cameraAzimuth = azimuth;
|
||||||
cameraPolar = polar;
|
cameraPolar = polar;
|
||||||
cameraZoom = zoom;
|
cameraZoom = zoom;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
/** @type {import('./$types').ActionData} */
|
import type { ActionData } from "./$types";
|
||||||
export let form;
|
|
||||||
|
export let form: ActionData;
|
||||||
|
|
||||||
let user = form?.user ?? '';
|
let user = form?.user ?? '';
|
||||||
|
|
||||||
function buttonClick() {}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
Reference in New Issue
Block a user