refactor-login-page #7
@@ -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);
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
<!--
|
||||
|
||||
Reference in New Issue
Block a user