f034_sqlite_database #19

Merged
jared merged 34 commits from f034_sqlite_database into development 2025-07-24 14:34:39 +02:00
2 changed files with 24 additions and 5 deletions
Showing only changes of commit ffa34b3b61 - Show all commits

View File

@@ -2,6 +2,9 @@ import { fail } from '@sveltejs/kit';
import { BUCKET, client, CONFIGFILENAME, TOKENFILENAME } from '$lib/minio'; import { BUCKET, client, CONFIGFILENAME, TOKENFILENAME } from '$lib/minio';
import { checkIfExactDirectoryExists, getContentOfTextObject } from './s3ClientService'; import { checkIfExactDirectoryExists, getContentOfTextObject } from './s3ClientService';
import Database from 'better-sqlite3';
const db = new Database('./src/lib/data/tatort.db');
/** /**
* Get Vorgang and corresponend list of tatorte * Get Vorgang and corresponend list of tatorte
* @param caseId * @param caseId
@@ -17,21 +20,20 @@ export const getVorgangByCaseId = async (caseId: string) => {
const splittedNameParts = chunk.name.split('/'); const splittedNameParts = chunk.name.split('/');
const prefix = splittedNameParts[0]; const prefix = splittedNameParts[0];
const name = splittedNameParts[1]; const name = splittedNameParts[1];
if (name === CONFIGFILENAME || name === TOKENFILENAME) continue; if (name === CONFIGFILENAME || name === TOKENFILENAME) continue;
list.push({ ...chunk, name: name, prefix: prefix, show_button: true }); list.push({ ...chunk, name: name, prefix: prefix, show_button: true });
} }
return list; return list;
}; };
/** /**
* Fetches list of vorgänge from s3 bucket * Fetches list of vorgänge from s3 bucket
* @returns list of available cases * @returns list of available cases
*/ */
export const getListOfVorgänge = async () => { export const getListOfVorgänge = async () => {
const stream = client.listObjectsV2(BUCKET, '', false, ''); const stream = client.listObjectsV2(BUCKET, '', false, '');
const list = []; const list = [];
for await (const chunk of stream) { for await (const chunk of stream) {
const objPath = `${chunk.prefix}${TOKENFILENAME}`; const objPath = `${chunk.prefix}${TOKENFILENAME}`;
@@ -44,6 +46,23 @@ export const getListOfVorgänge = async () => {
return list; return list;
}; };
/**
* Fetches list of vorgänge from database
* @returns list with of available cases
*/
export const getVorgaenge = function () {
let getVorgaenge_stmt = `SELECT token, name, pw from cases`;
const stmt = db.prepare(getVorgaenge_stmt);
const res = stmt.all();
const vorgaenge_list = [];
for (const r of res) {
const vorg = { token: r.token, name: r.name, pw: r.pw };
vorgaenge_list.push(vorg);
}
return vorgaenge_list;
};
/** /**
* Checks if Vorgang exists * Checks if Vorgang exists
* @param request * @param request

View File

@@ -46,12 +46,12 @@
<ul role="list" class="divide-y divide-gray-100"> <ul role="list" class="divide-y divide-gray-100">
{#each caseList as item} {#each caseList as item}
<li> <li>
<a href="/list/{item.name}?token={item.token}" class="flex justify-between gap-x-6 py-5"> <a href="/list/{item.token}?token={item.pw}" class="flex justify-between gap-x-6 py-5">
<div class="flex gap-x-4"> <div class="flex gap-x-4">
<!-- Ordner --> <!-- Ordner -->
<Folder /> <Folder />
<div class="min-w-0 flex-auto"> <div class="min-w-0 flex-auto">
<span class="text-sm font-semibold leading-6 text-gray-900">{item[1]}</span> <span class="text-sm font-semibold leading-6 text-gray-900">{item.name}</span>
<!-- Delete button --> <!-- Delete button -->
<button <button
style="padding: 2px" style="padding: 2px"