457 Commits

Author SHA1 Message Date
776cc7a1f0 Merge pull request 'fix file upload for Chrome' (#45) from b119_model_upload_chrome into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #45
2025-12-15 12:19:11 +01:00
eaa75833df fix file upload for Chrome 2025-12-15 12:18:00 +01:00
30d457f562 Merge pull request 'sync dev with main' (#44) from main into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #44
2025-12-15 10:43:14 +01:00
titver968
c1dd9092ea config_prod und dev auf s3 minio 2025-12-10 14:37:03 +01:00
79e0b01796 Merge pull request 'development' (#43) from development into main
Reviewed-on: #43
2025-12-10 10:28:32 +01:00
f008cee404 make share-button secondary style for less emphasis
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-12-10 08:36:43 +01:00
bb91162438 copy link into clipboard and open mail client
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-12-09 11:37:47 +01:00
c078266449 change config to new minio setup for prod
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-12-09 10:26:30 +01:00
922b840c9a fix jenkins pipeline: update packages
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-12-09 10:18:30 +01:00
68823d6ced change config to new minio setup
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-12-09 10:01:56 +01:00
9bb4d23a2d Merge pull request 'main' (#42) from main into development
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
Reviewed-on: #42
2025-12-09 09:34:26 +01:00
titver968
e2cd6945f5 Dockerfile.prod 2025-12-02 14:44:35 +01:00
titver968
ba21f797de src/lib/config.ts -> config.json 2025-12-02 14:36:02 +01:00
titver968
646ff668f7 Dockerfile.prod und tailwind.config.cjs 2025-12-02 14:23:12 +01:00
8b6d35b66f remove old configs 2025-11-25 11:44:32 +01:00
e0d6e3cc62 Merge branch 'development' 2025-11-25 11:43:18 +01:00
1158c88d43 fix SonarQube issues: mainly unused imports
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-11-24 08:41:46 +01:00
e6add823a5 update packages 2025-11-24 08:36:42 +01:00
b1c246113c Merge pull request 'f112_vorgang_operationen' (#41) from f112_vorgang_operationen into development
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
Reviewed-on: #41
2025-11-21 13:12:25 +01:00
5c76e77766 add tests for Vorgang operation: change name and pin 2025-11-21 12:00:14 +01:00
3aee87aaed clarify test case description 2025-11-21 09:39:13 +01:00
97aaf2cd12 fix ´onDelete´ function type 2025-11-21 09:33:41 +01:00
9d35079058 change function parameter name to make it more descriptive: newName -> newValue 2025-11-21 09:26:08 +01:00
73cb398aa0 position PIN code on the same line as the label 2025-11-20 13:05:40 +01:00
365fb0f2c7 allow vorgangPIN to be changed on Vorgang page
includes:
- UI and backend logic
- adjustment to `NameItemEditor` to disallow deletion
2025-11-20 12:54:53 +01:00
c81196343f adjust minor test config: global mock of HTML functions and addition of test-id 2025-11-20 09:52:37 +01:00
c7526be3c9 adjust test to work with adjusted NameItemEditor 2025-11-20 09:50:20 +01:00
b6996902cc implement renaming feature for vorgang
UI and backend logic
make ´NameItemEditor´ reusable to be able to use with Vorgang
2025-11-20 09:46:28 +01:00
b3ba6256e0 remove unused import 2025-11-20 09:37:08 +01:00
9d72a99626 Merge pull request 'f113_UI_fixes' (#40) from f113_UI_fixes into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #40
2025-11-13 12:51:29 +01:00
320f6d6c8b remove Vorgang label 2025-11-13 12:46:58 +01:00
ac79f10153 adjust ´edit´ and ´delete´ button on Vorgang page with crimesList 2025-11-13 12:45:07 +01:00
dac1c57c98 align Vorgang item on list page and remove ´Vorgang´ description 2025-11-13 12:03:51 +01:00
4582306dc8 Merge pull request 'f111_frontend_ueberarbeitung' (#39) from f111_frontend_ueberarbeitung into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #39
2025-11-13 10:11:05 +01:00
64ff7c6e97 add some tests for crimes ´add´-button, further tests to be defined 2025-11-13 09:41:46 +01:00
e1f207f6fe tests for + (plus) button onVorgang list 2025-11-12 08:10:43 +01:00
2e16a0bc03 adjust UI test for removal of ´Hinzufügen´ button 2025-11-11 08:13:14 +01:00
1c4b154e41 add + (plus) button for addition of Vorgaenge and Crimes 2025-11-11 07:57:29 +01:00
b26080f4c1 successful upload modal for crimes 2025-11-10 08:40:52 +01:00
f92bcd5876 successful file upload 2025-11-07 11:17:39 +01:00
939b3174f2 Merge branch 'development' into f111_frontend_ueberarbeitung 2025-11-07 08:24:19 +01:00
44a9669ea4 remove ´Hinzufügen´ button on home view 2025-11-06 12:45:46 +01:00
cc469f67a5 allow for addition of Vorgaenge on Vorgang overview 2025-11-05 12:19:34 +01:00
6b22da6a34 Merge pull request 'f110_undo_skipped_test_API_endpoints' (#38) from f110_undo_skipped_test_API_endpoints into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #38
2025-11-05 10:24:20 +01:00
808b56934c remove unused locals parameter 2025-11-05 09:18:05 +01:00
fd907c9851 move API protection check into hooks, adjusting corresponding tests 2025-11-04 09:22:53 +01:00
3c16bc89e5 undo skipped tests, only allow API calls for admin-views, refactor viewer-page to use page.server 2025-11-03 14:21:08 +01:00
a9e3d8264c Merge pull request 'f092_ViewAuth-von-User-vereinfachen' (#37) from f092_ViewAuth-von-User-vereinfachen into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #37
2025-10-30 13:04:08 +01:00
332a3e5c15 change description of test case: load() now returns undefined if not logged-in 2025-10-30 12:16:21 +01:00
4fc6da850b change invalid user login 2025-10-30 12:04:58 +01:00
36273fd426 fix tests for refactoring of viewer Vorgang-PIN-validation 2025-10-30 11:15:07 +01:00
793ddb17d6 magic strings for login and logout 2025-10-30 10:56:23 +01:00
349d2cea6a named actions for logging in and out 2025-10-30 10:38:11 +01:00
23f2feeefb remove ununsed import 2025-10-30 10:36:50 +01:00
48fe999b5b protect admin pages after refactoring 2025-10-30 10:35:45 +01:00
c857041e21 refactor viewer-login page with error messages and validation 2025-10-30 08:57:58 +01:00
e26b36121a refactor homepage for admin-user and login mask if not logged in 2025-10-29 12:34:38 +01:00
d3e7a3b4ae update packages
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-27 08:42:35 +01:00
35859cf13c fix SonarCube issues
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-10-27 08:37:12 +01:00
416118197b test Login angepasst, return fail wenn formaDaten leer 2025-10-17 12:12:07 +02:00
01afbea9a3 Merge branch 'development' into f092_ViewAuth-von-User-vereinfachen 2025-10-17 10:37:39 +02:00
549ea896c7 select storage path depending on local testing or prod
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-14 10:39:07 +02:00
662211e1c3 make sure the DB is initiated
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-14 09:48:04 +02:00
5082e6d526 select path for DB depending on local or dev environment 2025-10-14 09:40:23 +02:00
9bf85c79e4 clean up, remove console.logs and debugging code 2025-10-14 09:39:06 +02:00
3b0b9d724a testing PV: kick off build
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-14 08:50:55 +02:00
915153cb62 testing PV: kick off build
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-14 08:15:08 +02:00
c0a25c7a26 testing PV: run DB init before server run
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-14 07:46:20 +02:00
b44bac760d testing PV: remove DB init run during build
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-13 13:47:46 +02:00
ddee170aea testing: run DB init script before server start
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-13 13:41:46 +02:00
04b5aaa0dc testing PV: debug DB init script
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-13 13:31:12 +02:00
5128398516 add DB init during container start
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-13 13:10:02 +02:00
69422d1f92 refactoring UUID Anzeige, noch keine Tests angepasst 2025-10-13 13:01:12 +02:00
5d6ac9438d testing PV: temporarily disable test creating dir
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-13 12:58:54 +02:00
76c2e26e8c test persistent storage
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-10-13 12:44:48 +02:00
0ec9692db3 Merge pull request 'f091_PIN-verstecken-in-URL' (#36) from f091_PIN-verstecken-in-URL into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #36
2025-10-13 10:44:43 +02:00
bc53c309df Merge branch 'development' into f091_PIN-verstecken-in-URL 2025-10-13 10:44:20 +02:00
5e3205ae3f Revert "move sqlite DB file to persistent storage"
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
This reverts commit 5d5f140091.
2025-10-13 10:37:10 +02:00
5d5f140091 move sqlite DB file to persistent storage
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-13 09:57:34 +02:00
bb912841f4 test PV: kick off build
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-13 09:16:54 +02:00
e9b42ff85a test persistent volume (PV): modify static text for kick off build
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-10 09:44:32 +02:00
a66f79896a test persistent volume (PV): add static text
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-10 09:27:57 +02:00
cf00f6f12c test persistent volume (PV): skip test for building
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-10 09:13:52 +02:00
01eb80f8ab test: check dir
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-10-10 08:49:41 +02:00
5b9f5e70ec update package-lock.json
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-10 08:41:46 +02:00
9c6b2ebd4f Revert "test persistent directory"
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
This reverts commit 57368ca3e4.
2025-10-10 08:04:41 +02:00
b5ee0bd6a7 Revert "testing: display path availability on screen"
This reverts commit 59585e26f1.
2025-10-10 08:04:28 +02:00
59585e26f1 testing: display path availability on screen
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-10-09 14:18:05 +02:00
57368ca3e4 test persistent directory
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-10-09 14:14:11 +02:00
468427622f fix PR remarks 2025-10-09 13:05:21 +02:00
45b5a36d04 add tests for PIN handling via cookies 2025-10-06 09:40:30 +02:00
4c4be8ba42 remove attachment of to URLs on list-view and routes 2025-10-01 13:48:06 +02:00
45bcce0fb2 hide PIN during Anmeldung and within route guards 2025-10-01 13:48:06 +02:00
e288d768bf Merge pull request 'f090_magic_strings_refactoring' (#35) from f090_magic_strings_refactoring into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #35
2025-09-30 13:33:26 +02:00
2863eae3fb organize tests into units 2025-09-30 11:43:54 +02:00
e1e76612d6 create alias for imports in test files 2025-09-30 11:37:20 +02:00
8fbc59499b fix fake URL in test fixtures pointing to 404-page and refactoring magic strings URLs 2025-09-30 10:40:29 +02:00
66b0d1cb3c refactoring magic strings URL in Anmeldung view 2025-09-30 09:34:01 +02:00
45a5c46489 refactoring magic strings: in Vorgang view load() function 2025-09-30 09:09:02 +02:00
c93a5c50de refactoring magic strings: in Vorgang View, add CRIME API route 2025-09-30 09:07:04 +02:00
2ad5a67340 refactoring magic strings: Anmeldung URL with Vorgang in view guard 2025-09-30 08:31:33 +02:00
e1694552c9 refactoring magic strings: User API URLs in user-management view 2025-09-30 08:22:56 +02:00
50a9286895 refactoring magic strings API URLs in upload view 2025-09-30 08:16:28 +02:00
e79d0a1a2d refactoring magic urls:. anmeldung actions 2025-09-29 08:49:26 +02:00
1d2769d114 refactoring magic strings in upload actions 2025-09-29 08:42:54 +02:00
387a9b21a8 refactoring in auth-service magic urls: path 2025-09-29 08:07:04 +02:00
7d0ec1283b refactoring hooks.server.ts magic urls: path 2025-09-29 08:00:00 +02:00
0e13744a79 refactor test 2025-09-26 12:47:55 +02:00
f737e4da4c refactoring: magic strings in Vorgang-View 2025-09-26 12:34:15 +02:00
f43497d69c refactoring magic strings in layout.server file (guard), including new routes and tests 2025-09-26 11:59:21 +02:00
59abf0880d add conditional route and crimeList View refactoring + tests 2025-09-26 10:04:24 +02:00
ca88a541c8 refactoring: magic strings and tests for Vorgang overview page 2025-09-26 08:32:42 +02:00
0820622ace make param in routes optional 2025-09-26 08:31:21 +02:00
67a24f3650 test links on Home-Page View 2025-09-25 14:05:38 +02:00
f0b133101d remove option 2025-09-25 13:53:59 +02:00
7396e15241 use userData from fixtures in Footer and Header 2025-09-25 13:44:50 +02:00
e1ce9373c0 refactor magic links in Header file, incl. routes 2025-09-25 13:29:07 +02:00
ec537901a6 add UI test 2025-09-25 08:11:18 +02:00
bd0c324705 add testing ID to component 2025-09-25 08:07:19 +02:00
5e7eeabda5 Merge branch 'development' into f090_magic_strings_refactoring 2025-09-24 12:45:17 +02:00
dc44a2f4ce Merge pull request 'f086_Zusatz-Edit-der-Namen' (#34) from f086_Zusatz-Edit-der-Namen into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #34
2025-09-24 12:40:12 +02:00
3a6b10e860 deleted debug comments 2025-09-24 12:37:14 +02:00
0c05cf6661 Merge branch 'development' into f086_Zusatz-Edit-der-Namen 2025-09-24 12:35:53 +02:00
011c07b753 formatting 2025-09-24 11:01:45 +02:00
f4e1917357 Merge pull request 'f102_test_KeineListeVorhanden' (#33) from f102_test_KeineListeVorhanden into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #33
2025-09-24 10:01:56 +02:00
406e7f8e4d formatting: VorgangList.view.test.ts 2025-09-24 09:56:18 +02:00
b4591d044b formatting: fixtures.ts file 2025-09-24 09:48:47 +02:00
6f5176fcb9 chenge URL und baseData magic string in testData.name 2025-09-23 16:50:34 +02:00
5d2cfa6dfd comment usage of props with old syntax 2025-09-23 13:23:09 +02:00
67b027e33f formatting 2025-09-23 10:38:59 +02:00
961ed39615 formatting 2025-09-23 09:39:33 +02:00
90745e02d5 rename test description to match tests done 2025-09-23 09:36:46 +02:00
df24fcf7e8 formatting 2025-09-23 09:36:04 +02:00
02e05930f1 formatting 2025-09-23 09:14:33 +02:00
33b40ee29f refactor magic links in Footer component and associated tests 2025-09-23 09:04:22 +02:00
ef5971d41c initial ROUTE_NAMES contant 2025-09-22 12:44:06 +02:00
03835fe624 fixed crimesList aktualisiert sich nach dem Editing 2025-09-22 11:15:07 +02:00
6377bba1a9 make $lib alias in Svelte available in Vitest 2025-09-22 09:40:29 +02:00
012f7ee3e8 implement testsNameItemEditor funktionalität 2025-09-12 10:23:47 +02:00
bcf24122bc fixed tests and Code edit and delete Name in TatortList 2025-09-11 16:52:54 +02:00
47ca05f2d4 save changes, bin aber noch nicht fertig 2025-09-10 17:50:10 +02:00
8803187ce1 implement tests TatortList.view, check delete/edit Item 2025-09-09 18:25:04 +02:00
650cfd0061 implement tests, Tatort List , ComponentEmptyList refactoring 2025-09-08 17:46:33 +02:00
38cdaa538a implement test verschiedene Buttons beim click von editButton 2025-09-05 17:30:17 +02:00
14509fdffe kleine Änderungen, copied baseData, change names of tests 2025-09-05 14:58:26 +02:00
18a37a0e6b change VorgangsListPage in VorgangListPage 2025-09-05 14:50:35 +02:00
7c20aa08b4 add tetId now tests client-view all passed 2025-09-05 14:45:51 +02:00
eaf74c9a5a Merge branch 'development' into f102_test_KeineListeVorhanden 2025-09-05 14:38:04 +02:00
fedc781d74 implement test VorgangList view 2025-09-05 14:37:19 +02:00
e66de4059e add testing state for Jenkins
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-09-05 08:41:37 +02:00
98794a29e1 fix SonarQube issues (unused imports, commented file)
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-09-05 08:29:38 +02:00
0483fe7766 correct test setup: remove test:e2e, skip auth tests (see prev. commit), ´BUCKET´ const mock
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-09-05 08:24:43 +02:00
edb37d8117 implement test View Leere Liste in TatortListe 2025-09-04 19:07:43 +02:00
0bbbe0064b Merge pull request 'f105_umstellung_seaweedS3' (#32) from f105_umstellung_seaweedS3 into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #32
2025-09-04 15:17:38 +02:00
92f5f8e5ed Merge pull request 'f100_backend_api-endpoints_tests' (#31) from f100_backend_api-endpoints_tests into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #31
2025-09-04 15:16:49 +02:00
e935adf8df hotfix: viewer cannot access Vorgang with correct PIN, temp remove check if logged-in
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-09-04 12:44:33 +02:00
d007513e82 formatting 2025-09-04 10:56:11 +02:00
b9c03831cb switch from minio to seaweed S3 storage: configs and buckets (dev vs. prod, refactoring magic strings) 2025-09-04 10:55:45 +02:00
1e85df9127 remove unrelated View tests 2025-09-04 09:59:46 +02:00
3d22aab5b3 stop tracking tatort.db
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-09-04 08:11:38 +02:00
5a1b27f81c Merge branch 'development' into f094_create_tests 2025-09-03 13:05:02 +02:00
0290616890 Merge branch 'b086_Nachbearbeitung_edit-der-Namen' into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-09-03 13:01:08 +02:00
8eef717e50 kleine Nachbesserungen: page.server.ts reset, config_prod zurück in config 2025-09-03 12:55:26 +02:00
283755c7db edit Leere Liste in Vorgang und Crime 2025-09-03 12:27:13 +02:00
f18ef07116 add tests for API endpoint: vorgang/[vorgang]/vorgangPIN 2025-09-03 10:16:18 +02:00
821b8a6440 refactoring: extract common locals.user definition and translatation of comments 2025-09-03 08:41:57 +02:00
e0b490a353 add tests for API endpoint: users 2025-09-03 08:31:53 +02:00
1e96f13d22 remove unused import 2025-09-02 11:49:11 +02:00
c222d75ac5 add tests for API endpoint: user 2025-09-02 11:10:07 +02:00
877c350824 rename test file for ViewAngemeldet 2025-09-02 10:58:38 +02:00
418e91c504 add tests for API endpoint: list/[vorgang]/[tatort] 2025-09-02 10:47:08 +02:00
9be9676f6c add more tests for API endpoint: list/[vorgang], HEAD and DELETE 2025-08-29 10:19:45 +02:00
52bffcd4f0 reorder import, vi.mock is being hoisted 2025-08-29 08:25:52 +02:00
66a4c014ad add tests for API endpoint: list/[vorgang] 2025-08-28 12:43:56 +02:00
a85ef8eab1 rename api-list test file to use CamelCase 2025-08-28 12:40:56 +02:00
9bb691055a add tests for API endpoint: list vorgang 2025-08-28 12:09:43 +02:00
0aa49643ca add tests for API endpoint: list vorgang 2025-08-28 12:03:40 +02:00
cfe00b5424 Add Landing Page View tests, admin and viewer access 2025-08-28 10:09:34 +02:00
b43cfe345a configure vite.config to include toplevel ´tests´ folder 2025-08-27 13:56:39 +02:00
37e103a494 properly format mail-to link
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-08-26 10:55:42 +02:00
d4dba5aef8 Merge branch 'b084_zugangsPIN_vorhandener_Vorgang' into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-08-26 08:34:44 +02:00
f2aa7df441 add guard to dbService checking for directory existence
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-08-26 08:23:39 +02:00
323264150b add guard in init_DB, check for existing folder before db creation
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-08-22 10:03:39 +02:00
0c000f72a2 more unused imports
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-08-21 14:32:58 +02:00
3d59beb3a6 remove unused import 2025-08-21 13:57:42 +02:00
a790bb0974 fix zugangsPIN for existing Vorgang in upload page 2025-08-21 12:35:24 +02:00
e966a1817c remove unused import in DB init file
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-08-21 11:46:58 +02:00
e5d3c494ec replace plain-text password with hashed one
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-08-21 11:21:12 +02:00
e3f4a97772 Merge pull request 'f052_admin_area' (#27) from f052_admin_area into development
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
Reviewed-on: #27
2025-08-21 11:08:44 +02:00
7995aab697 remove unused import
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-08-21 11:03:05 +02:00
ec15095da3 remove jssha and add bcrypt for password hashing with salt 2025-08-21 10:52:29 +02:00
723ec0773d add error handling and formatting 2025-08-19 13:19:23 +02:00
9d54a0fdb8 refactor addUser API endpoint to return user object if successful 2025-08-19 12:56:28 +02:00
ef0b981d84 fix user not found during auth 2025-08-19 12:24:51 +02:00
df03a833d2 update .gitignore for IDE workspace settings and remove db
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-08-19 09:38:39 +02:00
b703fdcb3d Merge pull request 'f047_neu_Edit-der-Namen' (#28) from f047_neu_Edit-der-Namen into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #28
2025-08-19 09:30:13 +02:00
be9e64cfd8 Überarbeitung des Pull Request, für Chico bitte offen lassen. 2025-08-13 16:56:35 +02:00
6c9afda777 Teilbearbeitung des Pull-Requests, nicht fertig da meeting 2025-08-13 12:03:14 +02:00
7bdfa1f69b refactoring branch, tatort page-svelte, Datenaktualisierung durch api, page.ts, choose better names 2025-08-12 17:36:24 +02:00
35a55d0676 vorgaenge and crimesList API endpoints, auto-formatting 2025-08-12 09:26:41 +02:00
84588cedfd fix vorgangPIN API endpoint 2025-08-12 09:11:28 +02:00
ac857cd384 Merge branch '_f047_neu_Edit-der-Namen__API-endpoints' into f047_neu_Edit-der-Namen 2025-08-12 09:04:04 +02:00
6ffeeb1d71 remove unnecessary console.log 2025-08-12 08:43:18 +02:00
45166c0cac implement rename backend PUT function for crime 2025-08-08 10:17:16 +02:00
a91d7292c5 integrate Editable Input, Netzwerkfehler bei PUT 2025-08-07 16:28:15 +02:00
18a1e4ea1c implement getVorgang API endpoit 2025-08-07 14:17:56 +02:00
4d1f002781 implement getVorgaenge API endpoint 2025-08-07 14:06:55 +02:00
e45e401569 kommentare eingefügt 2025-08-07 13:20:38 +02:00
171b0e8546 wechsel daher commit 2025-08-07 12:41:07 +02:00
3c8e521ced init DB 2025-08-07 12:11:28 +02:00
61363cc400 check if new account data is non-empty 2025-08-07 08:00:30 +02:00
885ad40543 add typing for userList and change userId parameter type 2025-08-07 07:58:27 +02:00
cbea96f892 implement deletion of admin user, frontend and backend 2025-08-06 11:52:39 +02:00
7e87a01c59 rename userList variable to CamelCase 2025-08-06 11:44:48 +02:00
4f0526c71f rename loop item variable for userlist-user 2025-08-06 09:59:18 +02:00
dd06c93b1c fix currentUser fetching from loaded data 2025-08-06 09:58:00 +02:00
26b94938a9 user list and possibility of adding new users implemented on FE and BE 2025-08-06 08:37:24 +02:00
b5ff4a72fb Merge branch 'development' into f052_admin_area 2025-08-05 08:34:16 +02:00
eea1621339 Merge branch 'f078_delete_unused_views' into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-08-05 08:31:35 +02:00
c53400d7b7 Merge pull request 'replace copy-to-clipboard with share-via-link-mail-to' (#24) from f054_mail-to-link into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #24
2025-08-05 08:22:47 +02:00
ef1ddb58a0 encode body in mail-to-link button 2025-08-05 08:21:28 +02:00
8c4f95d52e Merge pull request 'f076_api_endpoints_for_renaming_crimes' (#25) from f076_api_endpoints_for_renaming_crimes into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #25
2025-08-05 08:13:26 +02:00
5b408b096e remove console.log 2025-08-05 08:12:34 +02:00
aae8237aae Merge pull request 'fix SonarQube issue, mainly type annotations' (#26) from f079_sonarqube_issues_fixen into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #26
Reviewed-by: jared <jared.busch@polizei.niedersachsen.de>
2025-08-04 14:10:49 +02:00
e45b0e34c9 add ´unique´ constraint in db init script for username 2025-08-04 09:41:13 +02:00
54e3a64dac remove unused link button to deleted view 2025-08-01 12:40:36 +02:00
5927f1dacd fix SonarQube issue, mainly type annotations 2025-08-01 10:29:34 +02:00
f39debd0b8 fix renaming PUT endpoint to work around parameters 2025-08-01 09:44:45 +02:00
7d265341cc rename index looping variable 2025-08-01 08:45:17 +02:00
d6f2956bcb replace copy-to-clipboard with share-via-link-mail-to 2025-07-31 13:15:00 +02:00
e1cf6dc16f remove old unused ´view´ and ´tatorte´ views 2025-07-31 10:47:31 +02:00
5a06c99fb7 Merge pull request 'f077_default_admin_password' (#22) from f077_default_admin_password into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #22
Reviewed-by: jared <jared.busch@polizei.niedersachsen.de>
2025-07-31 08:40:14 +02:00
b3e2b297a3 change default admin password 2025-07-31 08:33:03 +02:00
b655df1087 fix changing of PIN on upload page 2025-07-31 08:13:55 +02:00
77c57cb58b fix pipeline: Docker npm run init-db
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-30 09:04:11 +02:00
0f2cf87a78 Merge pull request 'r70_variable_names' (#20) from r70_variable_names into development
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
Reviewed-on: #20
Reviewed-by: jared <jared.busch@polizei.niedersachsen.de>
2025-07-30 08:56:54 +02:00
1fd6cb3ab3 adjust to renaming of object keys of vorgangItem in list view 2025-07-30 08:23:08 +02:00
d402282efe minor adjustments: pin parameter, async and await functions 2025-07-29 14:00:11 +02:00
Daniel
952c3901c1 Update Dockerfile.dev
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-29 08:14:40 +02:00
dfa5c9ade1 revised init db pw to pin, and check name routine 2025-07-28 11:39:33 +02:00
4406a86f44 renaming pw to vorgangPIN, case to vorgang, password to vorgangToken 2025-07-25 14:21:37 +02:00
08d83c9ed4 renaming pw to vorgangPIN, case to vorgang, password to vorgangToken 2025-07-25 14:21:23 +02:00
Daniel
cf567451bb Update Dockerfile.dev
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-25 10:07:23 +02:00
52e9eba7ed next try
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit was not built
2025-07-24 15:34:30 +02:00
962dc35324 next try
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-24 15:26:23 +02:00
12217cb7a6 next try
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-24 15:21:07 +02:00
e9b4289727 add docker npm unsafe perm
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-24 15:17:15 +02:00
9b57a988f3 add docker node:22
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-24 15:12:37 +02:00
4f9e919bfe docker use npm i
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-24 15:08:53 +02:00
9e6318d516 docker node version 24
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-24 15:04:39 +02:00
c715295c72 add dockerignore for node_modules
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-24 15:02:28 +02:00
e3eac5b441 change Dockerfile and copy only package.json
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-24 14:51:57 +02:00
f6ed438908 fix build process
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-24 14:48:35 +02:00
542c12cc5f Merge pull request 'f034_sqlite_database' (#19) from f034_sqlite_database into development
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
Reviewed-on: #19
2025-07-24 14:34:38 +02:00
ee9d9fa8fc fix package-lock.json
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-24 14:30:24 +02:00
addcc26a07 Merge branch 'development' into f034_sqlite_database
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-23 12:55:20 +02:00
db1cc78f2c move ´code´ api endpoint to ´casepw´
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-23 12:54:40 +02:00
e8170de947 rename .js to .ts and remove console.logs statements 2025-07-23 09:27:11 +02:00
26c05b4999 remove unused and deprecated crypto package 2025-07-22 12:27:50 +02:00
809c355849 provide init command for database
All checks were successful
InnoHub Processor/tatort/pipeline/pr-main This commit was not built
InnoHub Processor/tatort/pipeline/head This commit was not built
2025-07-21 11:39:13 +02:00
bd9275c378 refactoring part 3: delete function of vorgang uses caseToken 2025-07-17 08:23:13 +02:00
143bb128a5 refactoring part 2: mainly consolidation of token, ids and passwort 2025-07-17 08:09:17 +02:00
b2f624a7d1 Update Jenkinsfile
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit was not built
2025-07-16 09:54:56 +02:00
a7527ccf22 Update Jenkinsfile
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-16 09:40:46 +02:00
34d5034a71 refactoring part 1: camelcase naming, token vs pw naming 2025-07-16 09:39:02 +02:00
6786f768f0 Update Jenkinsfile
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-15 12:07:53 +02:00
552350354b Update Jenkinsfile
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-15 11:54:50 +02:00
d9bcad9f77 Update Jenkinsfile
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-15 11:42:23 +02:00
4633769366 Update Jenkinsfile
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-15 11:28:34 +02:00
2444349694 Update Jenkinsfile
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-15 11:08:26 +02:00
c5202bb757 Update Jenkinsfile
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-15 10:53:14 +02:00
73c551c9de Update Jenkinsfile
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-15 10:49:51 +02:00
51af112610 Update Jenkinsfile
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-15 10:24:50 +02:00
b8e5031669 document DB initialization script 2025-07-15 09:48:29 +02:00
51d3f19f3e delete functionality for Vorgang in DB 2025-07-15 09:06:45 +02:00
5070ac9f7a remove console.logs 2025-07-15 08:03:27 +02:00
873a382f69 refactor 'Datei zu Vorgang hinzufügen': Add model files to existing cases 2025-07-14 13:54:08 +02:00
fa59db7a88 make 'Vorgangsname' column unique 2025-07-14 13:25:19 +02:00
484acd3bcf refactoring: 'Datei zu Vorgang hinzufügen' an DB angepasst 2025-07-14 13:21:49 +02:00
cd5389666e fix import error from default to explicit import 2025-07-14 08:23:27 +02:00
a7eb81151f refactor DB access 2025-07-11 11:39:42 +02:00
8408d63f40 add copy button for sharing vorgang 2025-07-11 11:24:25 +02:00
f2bde76969 prefill homepage with token 2025-07-11 10:35:50 +02:00
83bcaca918 remove console.log 2025-07-11 10:25:42 +02:00
9ddec90214 rewrite vorgang exist and token validation check to use DB 2025-07-11 10:19:43 +02:00
f7245fac90 correctly display Vorgangsname in Vorgang page 2025-07-10 11:03:15 +02:00
564716e853 store tatort under case token name 2025-07-10 10:45:24 +02:00
ffa34b3b61 refactor getVorgaenge to return vorgaenge as objects 2025-07-10 08:40:36 +02:00
307894c980 listing of cases based on db 2025-07-10 08:31:45 +02:00
40599f4ffa adding new vorgang in database 2025-07-10 08:30:41 +02:00
8b1b3532fc refactor init-script and display tables with data 2025-07-10 08:29:07 +02:00
f6513c9ed8 add uuid-package for token generation 2025-07-10 08:28:01 +02:00
c034064d41 refactor db design 2025-07-09 12:20:16 +02:00
dc2d038b1b remove old, commented implementation of authenticate 2025-07-09 12:13:19 +02:00
0c6dbe30ab replace with 2025-07-09 12:07:34 +02:00
64aa1d404e Merge branch 'development' into f034_merge_dev 2025-07-09 08:12:02 +02:00
fa69fa9dcd include packages 2025-07-09 08:08:59 +02:00
8d92e94bd6 populate db with default user 2025-07-09 08:07:22 +02:00
7c1b8669c0 Merge branch 'development' of ssh://gitea.innovation-hub-niedersachsen.de:4422/innohub/tatort into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit was not built
2025-07-04 10:11:46 +02:00
5f996e7007 added sonar to pipeline 2025-07-04 10:09:06 +02:00
f0df67fb86 Update Jenkinsfile
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit was not built
2025-07-02 08:12:56 +02:00
b63834eb51 Update Jenkinsfile
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-02 07:52:09 +02:00
e9eb2c1163 Update Jenkinsfile
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit was not built
2025-07-02 07:41:05 +02:00
3e926844b8 Merge pull request 'fixed tatort api route for deletion' (#16) from b038-check-api-route into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #16
2025-07-01 16:23:09 +02:00
ba4d810164 Merge pull request 'jenkins-docker' (#17) from jenkins-docker into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #17
2025-07-01 13:30:25 +02:00
b6a52822f1 fixed merge conflicts
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-01 13:29:57 +02:00
b843e3abc0 push docker image only in dev branch
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-01 13:11:36 +02:00
7a25dbf68c change gitea user
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-01 13:07:02 +02:00
32d6245b5a get gitea json object
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-01 12:54:25 +02:00
45644c9695 get gitea json object
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-01 12:53:19 +02:00
0622fce790 get gitea json object
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-01 12:51:42 +02:00
0de66fe533 get gitea json object 2025-07-01 12:50:17 +02:00
0aa03aea19 fix pipeline 2025-07-01 12:39:24 +02:00
2ad9e5d86d added check if pipeline job was running 2025-07-01 09:58:38 +02:00
b57a30338e added check if pipeline job was running 2025-07-01 09:56:01 +02:00
eee820b39e added check if pipeline job was running 2025-07-01 09:52:45 +02:00
c25c8498f3 added check if pipeline job was running 2025-07-01 09:49:43 +02:00
95a9364391 added check if pipeline job was running
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-01 09:25:21 +02:00
49907da1b1 added check if pipeline job was running
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-01 09:21:44 +02:00
93be24a8de added check if pipeline job was running
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-01 09:19:09 +02:00
22fc1f490c activate post message
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-01 08:58:09 +02:00
0235b56637 deactivte post message 2025-07-01 08:55:53 +02:00
7ca8b295db no post statement
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-01 08:53:31 +02:00
abd756462b post statement only if changes 2025-07-01 08:47:45 +02:00
2939869816 renamed image tag
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-01 08:29:26 +02:00
3bd369c9e2 added params
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-01 08:13:51 +02:00
517654bfbf fixed config names
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-07-01 08:00:16 +02:00
739f67169e added confi for dev and prod
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-01 07:57:05 +02:00
2d003a619f set audit level to moderate
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-01 07:44:28 +02:00
bb5ade22c6 test jenkins pipeline
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-01 07:39:38 +02:00
be4e351217 test jenkins pipeline
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-01 07:34:58 +02:00
30b49029b2 fixed jenkinsfile
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-01 07:29:07 +02:00
890380609f added build id to image, set correct dockerfile
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-01 07:25:04 +02:00
2667db5755 added git ref to message
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-01 07:16:05 +02:00
021ec3d383 fixed jenkinsfile
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-01 07:11:01 +02:00
7018c74884 added webhook to get discrod message
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-01 07:07:07 +02:00
2b2fa7a82b added Dockerfile dev and prod
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-07-01 06:56:31 +02:00
fe9f8add88 fixed tatort api route for deletion
Some checks failed
InnoHub Processor/tatort/pipeline/pr-development There was a failure building this commit
2025-06-30 08:35:20 +02:00
de7b27bd71 Jenkinsfile aktualisiert
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
Added additional Infos in pull request
2025-06-30 07:17:53 +02:00
f995b58d0f return user data
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-27 09:09:31 +02:00
efcbc4d60f test jenkins webhook
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-26 10:01:03 +02:00
02d4957315 test jenkins webhook
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-26 08:19:27 +02:00
de35986633 test jenkins webhook
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-26 08:12:03 +02:00
843c4ecaf4 test jenkins webhook 2025-06-26 08:11:40 +02:00
173f36fb50 test jenkins webhook
Some checks failed
InnoHub Processor/tatort/pipeline/head Something is wrong with the build of this commit
2025-06-26 08:07:54 +02:00
35c5323a19 added options and test push event webhook 2025-06-26 08:06:15 +02:00
5a1cd22dc6 Jenkinsfile aktualisiert
Added options to delete old build
2025-06-26 08:04:19 +02:00
1fabe234e0 Merge pull request 'disord pull request test' (#14) from ci043-add-jenkins-ci into development
Reviewed-on: #14
2025-06-25 17:00:30 +02:00
036798d330 disord pull request test 2025-06-25 16:59:55 +02:00
fee152553b Merge pull request 'ci043-add-jenkins-ci' (#13) from ci043-add-jenkins-ci into development
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
Reviewed-on: #13
2025-06-25 16:40:38 +02:00
2ed49394d7 Merge branch 'development' into ci043-add-jenkins-ci
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 16:40:13 +02:00
c74322228f activate ci and audit, deactivate docker 2025-06-25 16:34:17 +02:00
95936b09b5 fixed push image
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-06-25 15:47:14 +02:00
1d84b67a94 fixed push image
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 15:44:18 +02:00
083efb3aec fixed push image
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 15:41:09 +02:00
fd17d10119 fixed push image
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 15:38:55 +02:00
9ad96abb77 fixed push image
Some checks failed
InnoHub Processor/tatort/pipeline/head Something is wrong with the build of this commit
2025-06-25 15:26:26 +02:00
4dcd2e1a63 fixed push image
Some checks failed
InnoHub Processor/tatort/pipeline/head Something is wrong with the build of this commit
2025-06-25 15:22:35 +02:00
331b9c22e1 fixed push image
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 15:18:54 +02:00
997ef6e30d fixed push image
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 15:15:58 +02:00
1c394dff72 fixed push image
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 15:11:12 +02:00
8c29d39bf6 fixed push image job
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 15:08:38 +02:00
0181fb288b fixed push image job
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 15:08:01 +02:00
1de66b11b3 fixed push image job
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 15:06:17 +02:00
f2dd50c16e fixed push image job
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 15:05:31 +02:00
be61814b58 fixed push image job
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 15:03:20 +02:00
62bca02625 fixed push image job 2025-06-25 14:59:31 +02:00
15529541ed fixed push image job
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 14:58:09 +02:00
b432554cca fixed push image job
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 14:25:28 +02:00
b991904921 fixed push image job
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 14:21:47 +02:00
66794ef0f6 fixed push image job
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 14:12:09 +02:00
b46852e385 fixed push image job
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 14:11:19 +02:00
d0c6feee33 fixed push image job
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 14:09:05 +02:00
38f9f61e8a added push to gitea job
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 14:06:31 +02:00
2effdb12c1 fixed typo
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-06-25 13:44:37 +02:00
b273b8046a Merge pull request 'f037-access-tatort-via-token' (#12) from f037-access-tatort-via-token into development
Reviewed-on: #12
Reviewed-by: trachi93 <chi-cong.tran@polizei.niedersachsen.de>
2025-06-25 13:35:49 +02:00
0b4df7b714 added admin as submitter
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 13:25:29 +02:00
ea9b61fe79 added docker job
Some checks failed
InnoHub Processor/tatort/pipeline/head Something is wrong with the build of this commit
2025-06-25 13:20:46 +02:00
017d5ce458 Merge branch 'development' into f037-access-tatort-via-token 2025-06-25 13:09:39 +02:00
72169c4e64 fixed get user infos for token based routes 2025-06-25 13:05:09 +02:00
titver968
2d9acb402d Merge branch 'main' of ssh://gitea.innovation-hub-niedersachsen.de:4422/innohub/tatort 2025-06-25 12:27:00 +02:00
titver968
a71807c63a Dockerfile end config.json for prod and dev 2025-06-25 12:26:18 +02:00
8b276f9828 added docker
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-06-25 11:50:13 +02:00
56cfd79687 added docker 2025-06-25 11:49:58 +02:00
b2e00eb030 added nodeJS as tool
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 10:50:26 +02:00
d5a7058f2d fixed node agent
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 10:41:00 +02:00
355e4f3287 fixed node agent
Some checks failed
InnoHub Processor/tatort/pipeline/head Something is wrong with the build of this commit
2025-06-25 10:13:21 +02:00
7d15e0369d fixed node agent
Some checks failed
InnoHub Processor/tatort/pipeline/head Something is wrong with the build of this commit
2025-06-25 10:07:31 +02:00
d6baaef992 fixed node agent
Some checks failed
InnoHub Processor/tatort/pipeline/head Something is wrong with the build of this commit
2025-06-25 10:04:59 +02:00
533d94c6a5 fixed echo statement
Some checks failed
InnoHub Processor/tatort/pipeline/head Something is wrong with the build of this commit
2025-06-25 09:56:29 +02:00
41a98d3d1d added first Jenkins ci
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-06-25 09:52:46 +02:00
78bf7c7dbc Jenkinsfile gelöscht 2025-06-25 09:29:34 +02:00
b4c669226f Merge pull request 'f004_CameraSteuerung-neu' (#11) from f004_CameraSteuerung-neu into development
Reviewed-on: #11
Reviewed-by: jared <jared.busch@polizei.niedersachsen.de>
2025-06-25 09:14:08 +02:00
aeccb684b4 Jenkinsfile aktualisiert
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
rename file
2025-06-25 09:11:37 +02:00
ee6b9fcec1 fixed Comments of Jared 2025-06-24 18:06:59 +02:00
425b1ee8fa Jenkins hinzugefügt 2025-06-24 17:20:25 +02:00
ded024bc67 removed duplicate validation of vorgang and token 2025-06-24 16:53:03 +02:00
ff891bc164 refactoring 2025-06-24 10:27:01 +02:00
0aec68eb8a Merge branch 'CameraSteuerung' into f004_CameraSteuerung-neu 2025-06-23 19:28:28 +02:00
bb98c3656e tatorte only available via token 2025-06-23 14:46:09 +02:00
5be47343c4 Merge pull request 'vorgang-via-url' (#9) from vorgang-via-url into development
Reviewed-on: #9
2025-06-19 16:20:41 +02:00
e471a450d1 fix view redirect to vorgang 2025-06-19 16:15:55 +02:00
09d93e3a52 added comment 2025-06-19 16:07:28 +02:00
b82d9a7708 delete unnecessary code 2025-06-19 16:06:32 +02:00
c5dd8b9424 change case loading in server side mode, made case list functional 2025-06-19 16:01:07 +02:00
a2ac88af50 revised backend service getObjects 2025-06-19 10:31:31 +02:00
28e93fe943 vorgang accessible via url 2025-06-18 16:33:35 +02:00
98ccf6a0b0 Merge pull request 'refactor-login-page' (#8) from refactor-login-page into development
Reviewed-on: #8
2025-06-18 13:18:49 +02:00
6b1a49583e Merge pull request 'refactor-login-page' (#7) from refactor-login-page into main
Reviewed-on: #7
2025-06-18 13:10:25 +02:00
e01d4b1d76 revised comment 2025-06-18 13:07:20 +02:00
3dbaf7a01b added token validation with input fields 2025-06-18 08:48:53 +02:00
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
fd0572939e change login page frontend 2025-06-12 10:57:25 +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
af50e0fab9 Merge pull request 'fix-some-errors' (#5) from fix-some-errors into development
Reviewed-on: #5
2025-06-10 14:45:15 +02:00
31ca124511 deleted unnecessary console.log statements 2025-06-10 14:34:25 +02:00
07247486ab fix further type problems 2025-06-10 14:33:40 +02:00
e4d74e4331 deleted unnecessary console.log statements 2025-06-10 14:10:48 +02:00
d58be34fe5 fixed some type errors 2025-06-10 14:07:40 +02:00
841446082e delete unused code 2025-06-10 12:16:03 +02:00
bcb83ca6a7 Merge pull request 'package-update-and-cleaning' (#4) from package-update-and-cleaning into development
Reviewed-on: #4
2025-06-10 12:07:24 +02:00
89ca2bfd7c update dependencies 2025-06-10 12:05:06 +02:00
fb72296e57 removed playwright package because of unused 2025-06-10 11:25:13 +02:00
9524441fc1 Merge pull request 'add-typescript' (#3) from add-typescript into development
Reviewed-on: #3
2025-06-10 11:17:46 +02:00
97dc5aa6c4 fix merge conflicts 2025-06-10 11:16:44 +02:00
8ef0845909 deleted unused svelte preprocessor 2025-06-10 11:09:02 +02:00
acef68dc26 add typescript support in svelte files, .js to .ts 2025-06-10 11:05:23 +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
59fc791b85 sdf 2025-05-23 11:22:20 +02:00
c437926002 verbindungsprobleme test mina 2025-05-23 11:21:55 +02:00
527c2b438d verbindungsprobleme test 2025-05-23 11:20:17 +02:00
5a5ae9901a testing 2025-05-23 11:05:04 +02:00
99a27fc079 update frontend 2025-05-22 17:25:33 +02:00
122 changed files with 6813 additions and 2864 deletions

3
.dockerignore Normal file
View File

@@ -0,0 +1,3 @@
node_modules
build
config.json

6
.gitignore vendored
View File

@@ -1,5 +1,8 @@
test-results
node_modules
config.json
src/lib/data/tatort.db
# Output
.output
@@ -22,3 +25,6 @@ Thumbs.db
# Vite
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
# Jetbrains
/.idea

17
Dockerfile.dev Normal file
View File

@@ -0,0 +1,17 @@
# --- Build stage ---
FROM node:24-alpine AS build
ENV NODE_ENV=development
ENV ORIGIN=https://tatort-dev.innovation-hub-niedersachsen.de
WORKDIR /app
COPY package.json ./
RUN npm i --unsafe-perm
COPY . ./
COPY config_dev.json ./config.json
RUN npm run build
# --- Production stage ---
FROM node:24-alpine
COPY --from=build /app .
ENV HOST=0.0.0.0
EXPOSE 3000
CMD ["sh", "-c", "npm run init-db && ORIGIN=https://tatort-dev.innovation-hub-niedersachsen.de node build/index.js"]

View File

@@ -1,17 +1,21 @@
# --- Build stage ---
FROM node:22 AS build
ENV NODE_ENV=production
ENV ORIGIN=https://tatort.innovation-hub-niedersachsen.de
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . ./
COPY config_prod.json ./config.json
RUN npm run build
# --- Production stage ---
FROM node:22-alpine3.20
COPY --from=build /app .
WORKDIR /app
ENV NODE_ENV=production
ENV ORIGIN=https://tatort.innovation-hub-niedersachsen.de
COPY --from=build /app/build ./build
COPY --from=build /app/package*.json ./
COPY --from=build /app/config.json ./config.json
RUN npm ci --omit=dev
ENV HOST=0.0.0.0
EXPOSE 3000
CMD ["sh", "-c", "ORIGIN=https://tatort.innovation-hub-niedersachsen.de node build/index.js"]
CMD ["node", "build/index.js"]

143
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,143 @@
/* groovylint-disable-next-line UnusedVariable */
@Library('InnoHub-Library') _
def didRun = false
def versionTag = 'null'
pipeline {
agent any
tools {
nodejs 'NodeJS-24.2.0'
}
environment {
REGISTRY = 'https://gitea.innovation-hub-niedersachsen.de/'
USER = 'jenkins'
TOKEN = credentials('JenkinsGitea')
}
parameters {
string(name: 'REPO_NAME', defaultValue: '', description: 'Repo Name')
string(name: 'GIT_REF', defaultValue: '', description: 'Git Ref')
}
options {
buildDiscarder(
BuildHistoryManager([
[ continueAfterMatch: false, matchAtMost: 5 ],
[ actions: [ DeleteBuild() ] ]
])
)
}
stages {
stage('Set Version Tag') {
steps {
script {
versionTag = generateVersionTag(params.GIT_REF)
echo "[INFO] Using VERSION_TAG: ${versionTag}"
}
}
}
stage('Validate Repository') {
steps {
script {
checkRepoName(params.REPO_NAME, true)
}
}
}
stage('Install Dependencies') {
steps {
script {
didRun = true
}
sh 'npm ci'
}
}
stage('Security Audit') {
steps {
script {
didRun = true
}
echo 'Start checking security vulnerabilities in npm packages'
sh 'npm audit --audit-level=moderate'
}
}
stage('Run Tests') {
steps {
sh 'npm run test'
}
}
stage('SonarQube Analysis') {
steps {
withSonarQubeEnv('sonarqube') {
sh 'sonar-scanner -Dsonar.projectKey=tatort -Dsonar.sources=src'
}
}
}
stage('Push image to gitea registry') {
when {
branch 'development'
}
steps {
script {
def imageName = "gitea.innovation-hub-niedersachsen.de/innohub/tatort-dev"
docker.withRegistry(REGISTRY, 'JenkinsGitea') {
def img = docker.build("${imageName}:${versionTag}", '-f Dockerfile.dev .')
img.push()
img.push('latest')
}
didRun = true
}
}
}
stage('Update Helm Chart Repository') {
when {
branch 'development'
}
steps {
script {
updateHelmChart([
tag: versionTag,
repoUrl: 'gitea.innovation-hub-niedersachsen.de/innohub/charts.git',
chartPath: 'tatort-dev/tatort',
chartName: 'tatort',
imageRepo: 'gitea.innovation-hub-niedersachsen.de/innohub/tatort-dev',
credentialsId: 'JenkinsGitea',
branch: 'main'
])
didRun = true
}
}
}
}
post {
success {
script {
if (didRun) {
echo 'Pipeline erfolgreich!'
discordSend description: "Running ${env.BUILD_ID} on ${env.JENKINS_URL}, ${params.GIT_REF}", footer: 'Pipeline succeeded', link: env.BUILD_URL, result: currentBuild.currentResult, title: env.JOB_NAME, webhookURL: 'https://discordapp.com/api/webhooks/1389470542691831819/NdMO17sLBG2dplp_-oh6Ff0cbPOoADl0QwXKM9UzduxU44av_ZQkQjKTmpdK7YuwcZDc'
}
}
}
failure {
script {
if (didRun) {
echo 'Pipeline fehlgeschlagen!'
discordSend description: "Running ${env.BUILD_ID} on ${env.JENKINS_URL}, ${params.GIT_REF}", footer: 'Pipeline failed', link: env.BUILD_URL, result: currentBuild.currentResult, title: env.JOB_NAME, webhookURL: 'https://discordapp.com/api/webhooks/1389470542691831819/NdMO17sLBG2dplp_-oh6Ff0cbPOoADl0QwXKM9UzduxU44av_ZQkQjKTmpdK7YuwcZDc'
}
}
}
}
}

View File

@@ -36,3 +36,24 @@ npm run build
You can preview the production build with `npm run preview`.
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
## Initializing the SQLite DB
A database initialization script `init_db.ts` in included in the `src/init` folder. It will create a users database (if not existing) and populate it with a default admin user. Additionally, an empty cases table will be created.
It can be run with `node init_db.ts`
Database schema:
Users
- id
- name
- pw
Cases
- id
- token
- name
- pin

View File

@@ -3,8 +3,8 @@
"endPoint": "api-s3.innovation-hub-niedersachsen.de",
"port": 443,
"useSSL": true,
"accessKey": "GxKhfnfkNvlDU7qzsz0D",
"secretKey": "cqSM5rIRr4MPtqzu2sNKgmB9k2OghPbyxwAWogeM"
"accessKey": "AbCdEfGhIjKlMnOpQrSt",
"secretKey": "UvWxYz1234567890AbCdEfGhIjKlMnOpQrStUvWx"
},
"jwt": {
"secret": "@S2!q@@wXz$dCQ8JoVsHLpzaJ6JCfB",

17
config_dev.json Normal file
View File

@@ -0,0 +1,17 @@
{
"minio": {
"endPoint": "api-s3.innovation-hub-niedersachsen.de",
"port": 443,
"useSSL": true,
"accessKey": "AbCdEfGhIjKlMnOpQrSt",
"secretKey": "UvWxYz1234567890AbCdEfGhIjKlMnOpQrStUvWx"
},
"jwt": {
"secret": "@S2!q@@wXz$dCQ8JoVsHLpzaJ6JCfB",
"expiresIn": 3600
},
"auth": {
"admin": { "password": "A-InnoHUB_2025!", "admin": true },
"user": { "password": "U-InnoHUB_2025!", "admin": false }
}
}

17
config_prod.json Normal file
View File

@@ -0,0 +1,17 @@
{
"minio": {
"endPoint": "api-s3.innovation-hub-niedersachsen.de",
"port": 443,
"useSSL": true,
"accessKey": "GxKhfnfkNvlDU7qzsz0D",
"secretKey": "cqSM5rIRr4MPtqzu2sNKgmB9k2OghPbyxwAWogeM"
},
"jwt": {
"secret": "@S2!q@@wXz$dCQ8JoVsHLpzaJ6JCfB",
"expiresIn": 3600
},
"auth": {
"admin": { "password": "A-InnoHUB_2025!", "admin": true },
"user": { "password": "U-InnoHUB_2025!", "admin": false }
}
}

View File

@@ -1,6 +0,0 @@
import { expect, test } from '@playwright/test';
test('home page has expected h1', async ({ page }) => {
await page.goto('/');
await expect(page.locator('h1')).toBeVisible();
});

View File

@@ -20,7 +20,21 @@ export default ts.config(
languageOptions: {
globals: { ...globals.browser, ...globals.node }
},
rules: { 'no-undef': 'off' }
rules: {
'no-undef': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true
}
]
}
},
{
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],

3684
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -13,41 +13,47 @@
"format": "prettier --write .",
"lint": "prettier --check . && eslint .",
"test:unit": "vitest",
"test": "npm run test:unit -- --run && npm run test:e2e",
"test:e2e": "playwright test"
"test": "npm run test:unit -- --run",
"init-db": "tsx ./src/init/init_db.ts"
},
"devDependencies": {
"@eslint/compat": "^1.2.5",
"@eslint/compat": "^1.2.9",
"@eslint/js": "^9.18.0",
"@playwright/test": "^1.49.1",
"@sveltejs/adapter-auto": "^4.0.0",
"@sveltejs/kit": "^2.16.0",
"@sveltejs/vite-plugin-svelte": "^5.0.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/svelte": "^5.2.4",
"eslint": "^9.18.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-svelte": "^3.0.0",
"globals": "^16.0.0",
"jsdom": "^26.0.0",
"prettier": "^3.4.2",
"prettier-plugin-svelte": "^3.3.3",
"svelte": "^5.0.0",
"svelte-check": "^4.0.0",
"typescript": "^5.0.0",
"typescript-eslint": "^8.20.0",
"vite": "^6.2.5",
"vitest": "^3.0.0"
"@sveltejs/kit": "^2.21.3",
"@sveltejs/vite-plugin-svelte": "^5.1.0",
"@testing-library/jest-dom": "^6.8.0",
"@testing-library/svelte": "^5.2.8",
"@tsconfig/svelte": "^5.0.4",
"@types/better-sqlite3": "^7.6.13",
"@types/jsonwebtoken": "^9.0.9",
"eslint": "^9.28.0",
"eslint-config-prettier": "^10.1.5",
"eslint-plugin-svelte": "^3.9.2",
"globals": "^16.2.0",
"jsdom": "^26.1.0",
"prettier": "^3.5.3",
"prettier-plugin-svelte": "^3.4.0",
"svelte": "^5.33.18",
"svelte-check": "^4.2.1",
"tsx": "^4.20.3",
"typescript": "^5.8.3",
"typescript-eslint": "^8.34.0",
"vite": "^6.3.5",
"vitest": "^3.2.4"
},
"dependencies": {
"@google/model-viewer": "^4.1.0",
"@sveltejs/adapter-node": "^5.2.12",
"@tailwindcss/forms": "^0.5.10",
"autoprefixer": "^10.4.21",
"bcrypt": "^6.0.0",
"better-sqlite3": "^12.2.0",
"jsonwebtoken": "^9.0.2",
"minio": "^8.0.5",
"postcss": "^8.5.3",
"svelte-cubed": "^0.2.1",
"tailwindcss": "^3.4.17"
"postcss": "^8.5.4",
"sqlite3": "^5.1.7",
"tailwindcss": "^3.4.17",
"uuid": "^11.1.0"
}
}

View File

@@ -1,11 +0,0 @@
/** @type {import('@playwright/test').PlaywrightTestConfig} */
const config = {
webServer: {
command: 'npm run build && npm run preview',
port: 4173
},
testDir: 'tests',
testMatch: /(.+\.)?(test|spec)\.[jt]s/
};
export default config;

View File

@@ -1,9 +0,0 @@
import { defineConfig } from '@playwright/test';
export default defineConfig({
webServer: {
command: 'npm run build && npm run preview',
port: 4173
},
testDir: 'e2e'
});

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,16 +0,0 @@
import { decryptToken } from '$lib/auth';
/** @type {import('@sveltejs/kit').Handle} */
export async function handle({ event, resolve }) {
const jwt = event.cookies.get('session');
try {
if (jwt) {
event.locals.user = decryptToken(jwt);
return resolve(event);
}
} catch (err) {
await event.cookies.delete('session');
event.locals.user = null;
}
return resolve(event);
}

28
src/hooks.server.ts Normal file
View File

@@ -0,0 +1,28 @@
import { decryptToken } from '$lib/auth';
import type { Handle } from '@sveltejs/kit';
import { ROUTE_NAMES } from './routes';
export const handle: Handle = async ({ event, resolve }) => {
const jwt = event.cookies.get('session');
try {
if (jwt) {
event.locals.user = decryptToken(jwt);
return resolve(event);
}
} catch (_) {
event.cookies.delete('session', {path: ROUTE_NAMES.ROOT});
event.locals.user = null;
}
if (event.url.pathname.startsWith('/api')) {
if (!event.locals.user) {
return new Response(JSON.stringify({ error: 'Unauthorized' }), {
status: 401,
headers: { 'Content-Type': 'application/json' }
});
}
}
return await resolve(event);
}

46
src/init/init_db.ts Normal file
View File

@@ -0,0 +1,46 @@
import Database from 'better-sqlite3';
import fs from 'fs';
import path from 'path';
import { DB_FULLPATH } from '../routes';
const fullPath = DB_FULLPATH;
const dir = path.dirname(fullPath);
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
const db = new Database(fullPath);
let createSQLStmt = `CREATE TABLE IF NOT EXISTS users
(id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL UNIQUE,
pw TEXT NOT NULL)`;
db.exec(createSQLStmt);
// check if there are any users; if not add one default admin one
// const saltRounds = 12;
// const hashedUserPassword = bcrypt.hashSync(userPasswordHashed, saltRounds);
const hashedUserPassword = '$2b$12$d6bDzoDluXeCTuoxmWSVtOp5Cpian3mZm8qxzox6B37BIf6qtOnnG';
const checkInsertSQLStmt = `INSERT INTO users (name, pw) SELECT 'admin', '${hashedUserPassword}'
WHERE NOT EXISTS (SELECT * FROM users);`;
db.exec(checkInsertSQLStmt);
const usersSQLStmt = `SELECT * FROM USERS`;
let SQLStatement = db.prepare(usersSQLStmt);
// cases table
createSQLStmt = `CREATE TABLE IF NOT EXISTS cases
(id INTEGER PRIMARY KEY AUTOINCREMENT,
token TEXT NOT NULL UNIQUE,
name TEXT NOT NULL UNIQUE,
pin TEXT NOT NULL)`;
db.exec(createSQLStmt);
const vorgangSQLStmt = `SELECT * FROM cases`;
SQLStatement = db.prepare(vorgangSQLStmt);
db.close();

View File

@@ -1,29 +0,0 @@
import jwt from 'jsonwebtoken';
import config from '$lib/config';
const SECRET = config.jwt.secret;
const EXPIRES_IN = config.jwt.expiresIn;
const AUTH = config.auth;
export function createToken(userData) {
return jwt.sign(userData, SECRET, { expiresIn: EXPIRES_IN });
}
export function decryptToken(token) {
return jwt.verify(token, SECRET);
}
export function authenticate(user, pass) {
let userData = null;
if (AUTH[user]) {
const { password, ...data } = AUTH[user];
if (password && password === pass) userData = data;
}
if (userData == null) return null;
return createToken({ id: user, ...userData });
}

35
src/lib/auth.ts Normal file
View File

@@ -0,0 +1,35 @@
import jwt from 'jsonwebtoken';
import bcrypt from 'bcrypt';
import { db } from '$lib/server/dbService';
import config from '$lib/config';
const SECRET = config.jwt.secret;
const EXPIRES_IN = config.jwt.expiresIn;
export function createToken(userData) {
return jwt.sign(userData, SECRET, { expiresIn: EXPIRES_IN });
}
export function decryptToken(token: string) {
return jwt.verify(token, SECRET);
}
export function authenticate(user, password) {
let JWTToken;
const getUserSQLStmt = 'SELECT name, pw FROM users WHERE name = ?';
const row = db.prepare(getUserSQLStmt).get(user);
if (!row) {
return null;
}
const storedPW = row.pw;
const isValid = bcrypt.compareSync(password, storedPW)
if (isValid) {
JWTToken = createToken({ id: user, admin: true });
}
return JWTToken;
}

View File

@@ -46,7 +46,7 @@
}
</style>
<script>
<script lang="ts">
export let type = 'info';
let classNames = '';
export { classNames as class };

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

@@ -1,3 +1,31 @@
<script lang="ts">
export let href = null;
export let type: 'button' | 'submit' | 'reset' = 'button';
export let size = 'md';
export let variant = 'primary';
export let fullWidth = false;
export let align = 'center';
export let disabled = false;
let classNames = '';
export { classNames as class };
</script>
{#if href}
<a on:click {href} class:w-full={fullWidth} class="button {variant} {size} {classNames} {align}"
><slot />
</a>
{:else}
<button
on:click
{type}
{disabled}
class:w-full={fullWidth}
class="button {variant} {size} {classNames} {align}"
>
<slot />
</button>
{/if}
<style>
.button {
@apply inline-flex;
@@ -172,31 +200,3 @@
@apply justify-end;
}
</style>
<script>
export let href = null;
export let type = 'button';
export let size = 'md';
export let variant = 'primary';
export let fullWidth = false;
export let align = 'center';
export let disabled = false;
let classNames = '';
export { classNames as class };
</script>
{#if href}
<a on:click {href} class:w-full={fullWidth} class="button {variant} {size} {classNames} {align}"
><slot />
</a>
{:else}
<button
on:click
{type}
{disabled}
class:w-full={fullWidth}
class="button {variant} {size} {classNames} {align}"
>
<slot />
</button>
{/if}

View File

@@ -11,11 +11,11 @@
}
</style>
<script>
<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,3 @@
<p data-testid="empty-list" class="flex justify-center m-4">
In dieser Liste sind keine Einträge vorhanden
</p>

View File

@@ -0,0 +1,54 @@
<script lang="ts">
import { fly, scale, fade } from 'svelte/transition';
import { cubicOut } from 'svelte/easing';
import { tick } from 'svelte';
let expanded = false;
let formContainer: HTMLDivElement;
async function toggle() {
expanded = !expanded;
if (expanded) {
// Wait for DOM to update
await tick();
// Scroll smoothly into view
formContainer?.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
}
</script>
<div data-testid="expand-container" class="flex flex-col items-center">
<!-- + / × button -->
<button
data-testid="expand-button"
class="flex items-center justify-center w-12 h-12 rounded-full bg-blue-600 text-white text-2xl font-bold hover:bg-blue-700 transition"
on:click={toggle}
aria-expanded={expanded}
aria-label="Add item"
>
{#if expanded}
{:else}
+
{/if}
</button>
<!-- Expandable content below button -->
{#if expanded}
<div
bind:this={formContainer}
class="w-full mt-4 flex justify-center"
transition:fade
>
<div
in:fly={{ y: 10, duration: 200, easing: cubicOut }}
out:scale={{ duration: 150 }}
class="w-full max-w-2xl"
>
<slot />
</div>
</div>
{/if}
</div>

View File

@@ -0,0 +1,39 @@
<script>
import Profile from "$lib/icons/Profile.svelte";
import { ROUTE_NAMES } from "../../routes";
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="{ROUTE_NAMES.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="{ROUTE_NAMES.ROOT}"
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="{ROUTE_NAMES.ROOT}"
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,38 @@
<script lang="ts">
import Chevron from '$lib/icons/Chevron-right.svelte';
import { ROUTE_NAMES } from '../../routes';
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="{ROUTE_NAMES.ROOT}" 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="{ROUTE_NAMES.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

@@ -41,7 +41,7 @@
}
</style>
<script>
<script lang="ts">
import { fade } from 'svelte/transition';
export let size = 'xl'; // https://tailwindcss.com/docs/max-width#class-reference
export let open = false;

View File

@@ -15,7 +15,7 @@
}
</style>
<script>
<script lang="ts">
export let scroll = true;
export let padding = true;

View File

@@ -0,0 +1,116 @@
<script lang="ts">
import Check from '$lib/icons/Check.svelte';
import Edit from '$lib/icons/Edit.svelte';
import Trash from '$lib/icons/Trash.svelte';
import X from '$lib/icons/X.svelte';
import { tick } from 'svelte';
interface ListItem {
name: string;
token?: string;
}
// props, old syntax
export let list: ListItem[] = [];
export let currentName: string;
export let vorgangToken: string | null;
export let onSave: (n: string, o: string, t?: string) => unknown = () => {};
export let onDelete: ((n: string) => unknown) | null = () => {};
let localName = currentName;
let isEditing = false;
let inputRef: HTMLInputElement | null = null;
$: error = validateName(localName);
function validateName(name: string): string {
const trimmed = name?.trim() ?? '';
if (!trimmed) return 'Name darf nicht leer sein.';
if (list.some((item) => item.name === trimmed && item.name !== currentName)) {
return 'Name existiert bereits.';
}
return '';
}
async function startEdit() {
isEditing = true;
await tick();
inputRef?.focus();
}
function cancelEdit() {
localName = currentName;
isEditing = false;
}
function commitEdit() {
if (!error && localName != currentName) onSave(localName, currentName, vorgangToken);
// restore original value
if (error) { localName = currentName }
isEditing = false;
}
function handleKeydown(event: KeyboardEvent) {
if (event.key === 'Enter') commitEdit();
if (event.key === 'Escape') cancelEdit();
}
function handleDeleteClick() {
// vorgangToken defined when deleting Vorgang, otherwise Crime
onDelete(vorgangToken || currentName);
}
</script>
<div data-testid="test-nameItemEditor" class="flex flex-col gap-1">
{#if isEditing}
<div class="flex items-center gap-1">
<input
data-testid="test-input"
bind:this={inputRef}
bind:value={localName}
onkeydown={handleKeydown}
class="flex-1 border border-gray-300 rounded px-1.5 py-0.5 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500"
/>
<button
data-testid="commit-button"
disabled={!!error || localName === currentName}
onclick={commitEdit}
class="text-gray-500 hover:text-green-600 transition disabled:opacity-40"
>
<Check class="w-4 h-4" />
</button>
<button
data-testid="cancel-button"
onclick={cancelEdit}
class="text-gray-500 hover:text-red-600 transition"
>
<X class="w-4 h-4" />
</button>
</div>
{:else}
<div class="flex items-center gap-1">
<span class="text-sm font-medium text-gray-900 truncate">{localName}</span>
<button
data-testid="edit-button"
onclick={startEdit}
class="text-gray-500 hover:text-blue-600 transition"
>
<Edit class="w-4 h-4" />
</button>
{#if onDelete}
<button
data-testid="delete-button"
onclick={handleDeleteClick}
class="text-gray-500 hover:text-red-600 transition"
>
<Trash class="w-4 h-4" />
</button>
{/if}
</div>
{/if}
{#if error}
<p class="text-xs text-red-500 mt-1">{error}</p>
{/if}
</div>

View File

@@ -1,4 +1,4 @@
<script>
<script lang="ts">
export let title = 'Erfolgreich';
export let show = false;

View File

@@ -5,7 +5,7 @@
}
</style>
<script>
<script lang="ts">
export let padding = 'p-6';
export let shadow = true;
let classNames = '';

View File

@@ -6,7 +6,7 @@
}
</style>
<script>
<script lang="ts">
import { clickOutside } from '$lib/helpers/clickOutside.js';
import Check from '$lib/icons/Check.svelte';
import Selector from '$lib/icons/Selector.svelte';

View File

@@ -1,3 +0,0 @@
import { readFileSync } from 'fs';
export default JSON.parse(readFileSync('./config.json'));

3
src/lib/config.ts Normal file
View File

@@ -0,0 +1,3 @@
import { readFileSync } from 'fs';
export default JSON.parse(readFileSync('./config.json').toString());

View File

@@ -1,22 +0,0 @@
import { client } from '$lib/minio';
/**
* Check if caseNumber is used
* @param {string} caseNumber
* @returns {Promise<boolean}
*/
export default async function caseNumberOccupied(caseNumber) {
const prefix = `${caseNumber}/config.json`;
const promise = new Promise((resolve) => {
let stream = client.listObjectsV2('tatort', prefix, false, '');
stream.on('data', () => {
stream.destroy();
resolve(true);
});
stream.on('end', () => {
resolve(false);
});
});
return promise;
}

View File

@@ -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) {
export default function shortenFileSize(size: number): string {
const giga = Math.floor(size / GIGA);
let remainder = size % GIGA;
const mega = Math.floor(remainder / MEGA);

View File

@@ -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) {
export default function timeElapsed(date: Date): string {
const now = new Date();
const age = Math.floor((now.getTime() - date.getTime()) / 1000);

View File

@@ -0,0 +1,17 @@
import { client, BUCKET } from '$lib/minio';
export default async function vorgangNumberOccupied(vorgangNumber: string): Promise<boolean> {
const prefix = `${vorgangNumber}`;
const promise: Promise<boolean> = new Promise((resolve) => {
const stream = client.listObjectsV2(BUCKET, prefix, false, '');
stream.on('data', () => {
stream.destroy();
resolve(true);
});
stream.on('end', () => {
resolve(false);
});
});
return promise;
}

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,15 @@
<svg
data-testid="profile-component"
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: 435 B

View File

@@ -6,3 +6,11 @@ import config from '$lib/config';
/** export const client = new Minio.Client(config.minio); */
export const client = new Client(config.minio);
const isProd = process.env.NODE_ENV == 'production';
const BUCKET = isProd ? 'tatort' : 'tatort-dev';
export { BUCKET };
export const TOKENFILENAME = '__perm__';
export const CONFIGFILENAME = 'config.json';

View File

@@ -0,0 +1,31 @@
import { dev } from '$app/environment';
import { fail, redirect, type Cookies, type RequestEvent } from '@sveltejs/kit';
import { authenticate } from '$lib/auth';
import { ROUTE_NAMES } from '../../routes';
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,
message: "Ungültige Zugangsdaten" });
cookies.set(COOKIE_NAME, token, {
path: ROUTE_NAMES.ROOT,
httpOnly: true,
sameSite: 'strict',
secure: !dev
});
return redirect(303, ROUTE_NAMES.ROOT);
};
export const logoutUser = async (event: RequestEvent) => {
event.cookies.delete(COOKIE_NAME, { path: ROUTE_NAMES.ROOT });
event.locals.user = null;
return redirect(303, ROUTE_NAMES.ROOT);
};

View File

@@ -0,0 +1,7 @@
import Database from 'better-sqlite3';
import { DB_FULLPATH } from '../../routes';
// make sure the DB is initiated
import '../../init/init_db'
export const db = new Database(DB_FULLPATH);

View File

@@ -0,0 +1,27 @@
import { BUCKET, client } from '$lib/minio';
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));
});
};
export const getContentOfTextObject = async (bucket: string, objPath: string) => {
const res = await client.getObject(bucket, objPath);
const text = await new Response(res).text();
return text;
};

View File

@@ -0,0 +1,51 @@
import { db } from '$lib/server/dbService';
export const getUsers = (): { userId: string; userName: string }[] => {
const getUsersSQLStmt = `SELECT id, name
FROM users;`;
const statement = db.prepare(getUsersSQLStmt);
const result = statement.all() as { id: string; name: string }[];
const userList: { userId: string; userName: string }[] = [];
for (const resultItem of result) {
const user = { userId: resultItem.id, userName: resultItem.name };
userList.push(user);
}
return userList;
};
export const addUser = (userName: string, userPassword: string) => {
const addUserSQLStmt = `INSERT into users(name, pw)
values (?, ?)`;
const statement = db.prepare(addUserSQLStmt);
let rowInfo;
try {
rowInfo = statement.run(userName, userPassword);
return rowInfo;
} catch (error) {
console.error('ERROR: ', error);
}
};
export const deleteUser = (userId: string) => {
// make sure to not delete the last entry
const deleteUserSQLStmt = `DELETE
FROM users
WHERE id = ?
AND (SELECT COUNT(*) FROM users) > 1;`;
const statement = db.prepare(deleteUserSQLStmt);
let rowCount;
try {
const info = statement.run(userId);
rowCount = info.changes;
} catch (error) {
console.log(error);
rowCount = 0;
}
return rowCount;
};

View File

@@ -0,0 +1,260 @@
import { fail } from '@sveltejs/kit';
import { BUCKET, client, CONFIGFILENAME, TOKENFILENAME } from '$lib/minio';
import { checkIfExactDirectoryExists, getContentOfTextObject } from './s3ClientService';
import { v4 as uuidv4 } from 'uuid';
import { db } from './dbService';
/**
* Get Vorgang and corresponend list of tatorte
* @param vorgangToken
* @returns
*/
export const getCrimesListByToken = async (vorgangToken: string) => {
const prefix = `${vorgangToken}/`;
const stream = client.listObjectsV2(BUCKET, prefix, false, '');
const list = [];
for await (const chunk of stream) {
const splittedNameParts = chunk.name.split('/');
const prefix = splittedNameParts[0];
const name = splittedNameParts[1];
if (name === CONFIGFILENAME || name === TOKENFILENAME) continue;
list.push({ ...chunk, name: name, prefix: prefix, show_button: true });
}
return list;
};
/**
* Get Vorgang
* @param vorgangToken
* @returns vorgangObj with keys `token`, `name`, `pin` || undefined
*/
export const getVorgangByToken = (
vorgangToken: string
): { token: string; name: string; pin: string } | undefined => {
const getVorgangSQLStmt = `SELECT token, name, pin
FROM cases
WHERE token = ?`;
const statement = db.prepare(getVorgangSQLStmt);
const result = statement.get(vorgangToken) as
| { token: string; name: string; pin: string }
| undefined;
return result;
};
/**
* Create Vorgang, using a vorgangName and vorgangPIN
* @param vorgangName
* @param vorgangPIN
* @returns {string || false} vorgangToken if successful
*/
export const createVorgang = (vorgangName: string, vorgangPIN: string): string | boolean => {
const vorgangExists = vorgangNameExists(vorgangName);
if (vorgangExists) {
return false;
}
const vorgangToken = uuidv4();
const insertSQLStatement = `INSERT INTO cases (token, name, pin) VALUES (?, ?, ?)`;
const statement = db.prepare(insertSQLStatement);
const info = statement.run(vorgangToken, vorgangName, vorgangPIN);
if (info.changes) {
return vorgangToken;
} else {
return false;
}
};
/**
* Get Vorgang
* @param vorgangName
* @returns vorgangObj with keys `token`, `name`, `pin` || undefined
*/
export const getVorgangByName = (
vorgangName: string
): { token: string; name: string; pin: string } | undefined => {
const getVorgangByNameSQLStmt = `SELECT token, name, pin
FROM cases
WHERE name = ?`;
const statement = db.prepare(getVorgangByNameSQLStmt);
const result = statement.get(vorgangName) as
| { token: string; name: string; pin: string }
| undefined;
return result;
};
/**
* Delete Vorgang
* @param vorgangToken
* @returns int: number of changes
*/
export const deleteVorgangByToken = function (vorgangToken: string) {
const deleteSQLStmt = 'DELETE FROM cases WHERE token = ?';
const statement = db.prepare(deleteSQLStmt);
const info = statement.run(vorgangToken);
return info.changes;
};
/**
* Fetches list of vorgänge from s3 bucket
* @returns list of available vorgaenge
*/
export const getListOfVorgänge = async () => {
const stream = client.listObjectsV2(BUCKET, '', false, '');
const list = [];
for await (const chunk of stream) {
const objPath = `${chunk.prefix}${TOKENFILENAME}`;
const token = await getContentOfTextObject(BUCKET, objPath);
const cleanedChunkPrefix = chunk.prefix.replace(/\/$/, '');
list.push({ name: cleanedChunkPrefix, token: token });
}
return list;
};
/**
* Fetches list of vorgänge from database
* @returns list with of available vorgaenge
*/
export const getVorgaenge = (): {
vorgangToken: string;
vorgangName: string;
vorgangPIN: string;
}[] => {
const getVorgaengeSQLStmt = `SELECT token, name, pin
from cases`;
const statement = db.prepare(getVorgaengeSQLStmt);
const result = statement.all() as { token: string; name: string; pin: string }[];
const vorgaenge_list: { vorgangToken: string; vorgangName: string; vorgangPIN: string }[] = [];
for (const resultItem of result) {
const vorg = {
vorgangToken: resultItem.token,
vorgangName: resultItem.name,
vorgangPIN: resultItem.pin
};
vorgaenge_list.push(vorg);
}
return vorgaenge_list;
};
/**
* Checks if Vorgang exists
* @param request
* @returns fail or true
*/
export const checkIfVorgangExists = async (vorgangId: string | null) => {
if (!vorgangId) {
return fail(400, {
success: false,
vorgangId,
error: { message: 'Die Vorgangsnummer darf nicht leer sein.' }
});
}
if (typeof vorgangId === 'string' && !(await checkIfExactDirectoryExists(vorgangId))) {
return fail(400, {
success: false,
vorgangId,
error: { message: 'Die Vorgangsnummer existiert in dieser Anwendung nicht.' }
});
}
return true;
};
export const vorgangExists = function (vorgangToken: string | null) {
if (!vorgangToken) {
return fail(400, {
success: false,
vorgangId: vorgangToken,
error: { message: 'Die Vorgangsnummer darf nicht leer sein.' }
});
}
const vorgaenge = getVorgaenge();
const vorgaengeTokens = vorgaenge.map((vorgang) => vorgang.vorgangToken);
const found = vorgaengeTokens.indexOf(vorgangToken) != -1;
return found;
};
export const vorgangNameExists = (vorgangName: string) => {
const vorgaenge = getVorgaenge();
const vorgaengeNames = vorgaenge.map((vorgang) => vorgang.vorgangName);
const found = vorgaengeNames.indexOf(vorgangName) != -1;
return found;
};
export const hasValidToken = async (vorgangId: string, vorgangToken: string) => {
const objPath = `${vorgangId}/${TOKENFILENAME}`;
try {
if (!vorgangToken) {
return false;
}
const token = await getContentOfTextObject(BUCKET, objPath);
if (!token || token !== vorgangToken) {
return false;
}
return true;
} catch (error) {
if (error.name == 'S3Error') {
console.log(error);
return false;
}
}
};
export const vorgangPINValidation = function (vorgangToken: string, vorgangPIN: string) {
if (!vorgangPIN) {
return false;
}
const vorgang = getVorgangByToken(vorgangToken);
if (!vorgang || vorgang.pin !== vorgangPIN) {
return false;
}
return true;
};
/**
* Change VorgangName or VorgangPIN
* @param vorgangToken
* @param newValue
* @returns {int} number of affected lines
*/
export const updateVorgangAttrByToken = function (vorgangToken: string,
newValue: string,
column: string) {
const renameSQLStmt = `UPDATE cases set ${column} = ? WHERE token = ?`;
const statement = db.prepare(renameSQLStmt);
let info;
try {
info = statement.run(newValue, vorgangToken);
} catch (err) {
console.log(`error: ${err}`)
return 0;
}
return info.changes;
};

View File

@@ -1,9 +0,0 @@
import { redirect } from '@sveltejs/kit';
/** @type {import('./$types').PageServerLoad} */
export function load(event) {
if (!event.locals.user && event.url.pathname !== '/anmeldung') throw redirect(303, '/anmeldung');
return {
user: event.locals.user
};
}

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

@@ -1,84 +1,27 @@
<script>
import Chevron from '$lib/icons/Chevron-right.svelte';
import Login from '$lib/icons/Login.svelte';
<script lang="ts">
import Footer from '$lib/components/Footer.svelte';
import Header from '$lib/components/Header.svelte';
export let data;
</script>
{#if data.user?.admin}
<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>
{:else}
<div class="h-screen bg-white"><slot /></div>
{/if}

View File

@@ -0,0 +1,6 @@
import { loginUser, logoutUser } from '$lib/server/authService';
export const actions = {
login: ({ request, cookies }) => loginUser({ request, cookies }),
logout: (event) => logoutUser(event),
} as const;

View File

@@ -1,123 +1,109 @@
<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';
import Button from '$lib/components/Button.svelte';
import ArrowRight from '$lib/icons/Arrow-right.svelte';
<script>
import Panel from '$lib/components/ui/Panel.svelte';
import { ROUTE_NAMES } from '../index.js';
export let data;
export let form;
export let outline = true;
</script>
{#if data.user?.admin}
<div
class=" inset-x-0 top-0 -z-10 h-full flex items-center justify-center bg-white shadow-lg ring-1 ring-gray-900/5"
>
<div class="mx-auto flex justify-center max-w-7xl py-10 px-8 w-full">
{#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
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
<a href="{ROUTE_NAMES.LIST}" class="mt-6 block font-semibold text-gray-900">
Vorgänge
<span class="absolute inset-0"></span>
</a>
<p class="mt-1 text-gray-600">
Verschaffe Dir einen Überblick über alle gespeicherten Tatorte.
</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
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>
<FileRect class=" group-hover:text-indigo-600" {outline} />
</div>
<a href="/tatorte" class="mt-6 block font-semibold text-gray-900">
Neueer Vorgang
<a href="{ROUTE_NAMES.USERMGMT}" class="mt-6 block font-semibold text-gray-900">
Benutzerverwaltung
<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>
</div>
<a href="/upload" class="mt-6 block font-semibold text-gray-900">
Hinzufügen
<span class="absolute inset-0"></span>
</a>
<p class="mt-1 text-gray-600">Fügen Sie einem Tatort Bilder hinzu.</p>
</div>
{/if}
<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
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>
</div>
<a href="/view" class="mt-6 block font-semibold text-gray-900">
Ansicht
<span class="absolute inset-0"></span>
</a>
<p class="mt-1 text-gray-600">Schau Dir einen Tatort in der 3D Ansicht an.</p>
<p class="mt-1 text-gray-600">Füge neue Benutzer hinzu oder entferne welche.</p>
</div>
</div>
</div>
{:else}
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
<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">
Willkommen beim 3D Tatort
</h2>
</div>
<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="{ROUTE_NAMES.LOGIN}" method="POST">
<div>
<label for="user" class="text-sm font-medium leading-6 text-gray-900">Name</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>
{#if form?.incorrect}
<p class="block text-sm leading-6 text-red-900 mt-2">{form.message}</p>
{/if}
<div class="flex justify-end">
<Button type="submit" class="mt-5">Anmelden</Button>
</div>
</form>
</div>
</div>
</div>
</div>
{/if}
<style>
</style>

View File

@@ -0,0 +1,35 @@
import { createVorgang, getVorgaenge } from '$lib/server/vorgangService';
import type { PageServerLoad } from '../../(token-based)/view/$types';
import { error, fail } from '@sveltejs/kit';
export const load: PageServerLoad = async (event) => {
if (!event.locals.user) {
error(404, 'Not Found')
}
const vorgangList = getVorgaenge();
return {
vorgangList
};
};
export const actions = {
default: async ({ request }: { request: Request }) => {
const data = await request.formData();
const vorgangName: string | null = data.get('vorgang') as string;
const vorgangPIN: string | null = data.get('pin') as string;
const err = {};
const token = createVorgang(vorgangName, vorgangPIN);
if (!token) {
err.message = "Der Vorgang konnte nicht angelegt werden"
return fail(400, err)
} else {
// success
return { token }
}
}
};

View File

@@ -1,61 +1,101 @@
<style>
ul {
min-width: 24rem;
}
</style>
<script lang="ts">
import { onMount } from 'svelte';
import { page } from '$app/stores';
import ExpandableForm from '$lib/components/ExpandableForm.svelte';
import Trash from '$lib/icons/Trash.svelte';
import Folder from '$lib/icons/Folder.svelte';
import EmptyList from '$lib/components/EmptyList.svelte';
import NameItemEditor from '$lib/components/NameItemEditor.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 { API_ROUTES, ROUTE_NAMES } from '../../index.js';
import { invalidateAll } from '$app/navigation';
/**
* @type any[]
*/
let list: any[] = [];
//$: list;
let { data, form } = $props();
onMount(async () => {
const response = await fetch('/api/list');
const stream = await response.body;
if (!stream) return;
let vorgangList = $state(data.vorgangList);
const reader = stream.getReader();
// same as `vorgangList` but with one different property to be used
// with ´NameItemEditor`
const derivedList = $derived.by(
() => {
return vorgangList.map(
({ vorgangName, ...rest }) => (
{
name: vorgangName,
...rest
}
)
)
}
);
while (true) {
const { done, value } = await reader.read();
if (done) return;
let isEmptyList = vorgangList.length === 0;
const objs = new TextDecoder()
.decode(value)
.split('\n')
.filter((i) => i.length > 0)
.map((i) => JSON.parse(i));
let vorgangName = $state('');
let vorgangPIN = $state('');
let errorMsg = $state('');
console.log(objs);
list = list.concat(objs);
// reset input fields when submission successful
$effect(() => {
if (form?.token) {
vorgangName = '';
vorgangPIN = '';
errorMsg = '';
}
});
async function delete_item(ev: Event) {
let delete_item = window.confirm("Bist du sicher?");
async function submitVorgang(ev: Event) {
const isValid = inputValid(vorgangName, vorgangPIN);
if (!isValid) {
ev.preventDefault();
return;
}
// continue form action on server
}
/**
* Check for required fields
* @param vorgangName
* @param vorgangPIN
* @returns {boolean} Indicates whether input is valid
*/
function inputValid(vorgangName, vorgangPIN) {
if (!(vorgangName || vorgangPIN)) {
errorMsg = 'Bitte beide Felder ausfüllen.';
return false;
} else if (!vorgangName) {
errorMsg = 'Bitte einen Vorgangsnamen vergeben.';
return false;
} else if (!vorgangPIN) {
errorMsg = 'Bitte einen Vorgangs-PIN eingeben.';
return false;
}
const existing = vorgangList.some((vorg) => vorg.vorgangName === vorgangName);
if (existing) {
errorMsg = 'Der Name existiert bereits.';
return false;
}
return true;
}
async function deleteVorgang(vorgangToken: string) {
let delete_item = window.confirm('Bist du sicher?');
if (delete_item) {
const target = ev.currentTarget as HTMLElement | null;
if (!target) return;
let filename = target.id.split('del__')[1]
let url = API_ROUTES.VORGANG(vorgangToken);
// delete request
// --------------
let url = `/api/list/${filename}`
console.log(`--- ${filename} + ${url}`)
try {
const response = await fetch(url,
{method: 'DELETE'}
)
const response = await fetch(url, { method: 'DELETE' });
if (response.status == 204) {
setTimeout(() => {window.location.reload()}, 500)
setTimeout(() => {
window.location.reload();
}, 500);
}
} catch (error) {
if (error instanceof Error) {
@@ -64,10 +104,48 @@
console.log(error);
}
}
}
}
//Variablen für Modal
let open = $state(false);
let inProgress = $state(false);
let isError = $state(false);
async function handleSave(newName: string, oldName: string, vorgangToken: string) {
open = true;
inProgress = true;
isError = false;
try {
const res = await fetch(API_ROUTES.VORGANG(vorgangToken), {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ vorgangToken, oldName, newName })
});
if (!res.ok) {
throw new Error('Fehler beim Speichern');
}
await invalidateAll();
vorgangList = data.vorgangList;
open = false;
} catch (err) {
console.error('⚠️ Netzwerkfehler beim Speichern', err);
isError = true;
} finally {
inProgress = false;
}
}
async function closeModal() {
open = false;
isError = false;
}
</script>
<div class="-z-10 bg-white">
@@ -76,44 +154,111 @@
</div>
<div class="mx-auto flex justify-center max-w-7xl h-full">
<ul role="list" class="divide-y divide-gray-100">
{#each list as item}
<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"
{#if isEmptyList}
<EmptyList></EmptyList>
{:else}
{#each vorgangList as vorgangItem}
<li data-testid="test-list-item">
<div class="flex items-center justify-center gap-3">
<a
href="{ROUTE_NAMES.VORGANG(vorgangItem.vorgangToken)}"
class="flex flex-col items-center justify-center gap-2 py-4 rounded-lg hover:bg-gray-50 transition text-center"
>
<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>
<div class="min-w-0 flex-auto">
<span class="text-sm font-semibold leading-6 text-gray-900">{item.name}</span>
<!-- Delete button -->
<button
style="padding: 2px"
id="del__{item.name}"
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>
</button>
</div>
</div>
<div class="hidden sm:flex sm:flex-col sm:items-end">
<p class="text-sm leading-6 text-gray-900">Vorgang</p>
</div>
<Folder class="w-6 h-6 text-gray-600" />
</a>
<NameItemEditor
list={derivedList}
currentName={vorgangItem.vorgangName}
vorgangToken={vorgangItem.vorgangToken}
onSave={handleSave}
onDelete={deleteVorgang}
/>
</div>
</li>
{/each}
{/if}
</ul>
</div>
</div>
<ExpandableForm>
<form class="flex flex-col items-center" method="POST">
<div class="flex flex-col sm:flex-row sm:space-x-4 w-full max-w-lg">
<div class="flex-1">
<label for="vorgang" class="block text-sm font-medium leading-6 text-gray-900">
<span class="flex"> Vorgangsname </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
required
bind:value={vorgangName}
type="text"
name="vorgang"
id="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"
/>
</div>
</div>
</div>
<div class="flex-1 mt-4 sm:mt-0">
<label for="pin" class="block text-sm font-medium leading-6 text-gray-900">
<span class="flex"> PIN </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
required
type="password"
bind:value={vorgangPIN}
name="pin"
id="pin"
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>
</div>
</div>
</div>
{#if errorMsg}
<p>{errorMsg}</p>
{/if}
{#if form?.message}
<p>{form.message}</p>
{/if}
<button
type="submit"
on:click={submitVorgang}
class="mt-4 bg-indigo-600 text-white px-6 py-2 rounded hover:bg-indigo-700 transition"
>
Neuen Vorgang hinzufügen
</button>
</form>
</ExpandableForm>
<Modal {open}
><ModalTitle>Umbenennen</ModalTitle><ModalContent>
{#if inProgress}
<p class="py-2 mb-1">Vorgang läuft...</p>
{:else if isError}
<Alert class="w-full" type="error">Fehler beim Umbenennen</Alert>
{:else}
<Alert class="w-full">Umbenennen erfolgreich</Alert>
{/if}
</ModalContent>
<ModalFooter><Button disabled={inProgress} on:click={closeModal}>Ok</Button></ModalFooter>
</Modal>
<style>
ul {
min-width: 24rem;
}
</style>

View File

@@ -1,311 +0,0 @@
<style>
ul {
min-width: 24rem;
}
</style>
<script lang="ts">
import { onMount, tick } from 'svelte';
import shortenFileSize from '$lib/helper/shortenFileSize';
import { page } from '$app/stores';
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';
/** @type {import('./$types').PageData} */
export let data;
interface ListItem {
name: string;
size: number;
lastModified: string | number | Date;
show_button?: boolean;
// add other properties as needed
}
let list: ListItem[] = [];
$: list;
let open = false;
$: open;
let inProgress = false;
$: inProgress;
let err = false;
$: err;
let rename_input;
$: rename_input;
onMount(async () => {
const response = await fetch('/api/list/' + $page.params.vorgang);
const stream = response.body;
if (!stream) return;
const reader = stream.getReader();
while (true) {
const { done, value } = await reader.read();
if (done) return;
const objs = new TextDecoder()
.decode(value)
.split('\n')
.filter((i) => i.length > 0)
.map((i) => JSON.parse(i));
console.log(objs);
list = list.concat(objs);
list = list.map((item) => {
item.show_button = true;
return item;
})
}
});
function uploadSuccessful() {
console.log('reset');
open = false;
}
function defocus_element(i: number) {
let item = list[i]
let text_field_id = `label__${item.name}`
let text_field = document.getElementById(text_field_id)
if (text_field) {
text_field.setAttribute("contenteditable", "false")
text_field.textContent = item.name;
}
// reshow button
list[i].show_button = true;
return;
}
async function handle_input(ev: KeyboardEvent, i: number) {
let item = list[i]
if (ev.key == "Escape") {
let text_field_id = `label__${item.name}`
let text_field = document.getElementById(text_field_id)
if (text_field) {
text_field.setAttribute("contenteditable", "false");
text_field.textContent = item.name;
}
// reshow button
item.show_button = true
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 || '') : '';
if (new_name == '') {
alert('Bitte einen gültigen Namen eingeben.');
ev.preventDefault();
return;
}
// actual upload
// -------------
// to prevent from item being selected
ev.preventDefault();
// 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
data_obj["old_name"] = ev.currentTarget && (ev.currentTarget as HTMLElement).id ? (ev.currentTarget as HTMLElement).id.split('__')[1] : ''
open = true;
inProgress = true;
const response = await fetch(url,
{method: 'PUT', body: JSON.stringify( data_obj )
})
inProgress = false;
if (!response.ok) {
err = true;
if (response.status == 400) {
let json_res = await response.json()
// alert(json_res['msg'])
return;
}
throw new Error(`Fehlgeschlagen: ${response.status}`)
} else {
uploadSuccessful();
setTimeout(() => {window.location.reload()}, 500)
}
// --- upload finished ---
return;
}
}
</script>
<div class="-z-10 bg-white">
<div class="flex flex-col items-center justify-center w-full">
<h1 class="text-xl">Vorgang {$page.params.vorgang}</h1>
</div>
<div class="mx-auto flex justify-center max-w-7xl h-full">
<ul class="divide-y divide-gray-100">
{#each list as item, i}
<li>
<a
href="/view/{$page.params.vorgang}/{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="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="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);
}}
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 -->
{#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
}}
>
<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>
</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}`;
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)
}
}
}
}}
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>
</button>
<p class="mt-1 truncate text-xs leading-5 text-gray-500">
{shortenFileSize(item.size)}
</p>
</div>
</div>
<div class="hidden sm:flex sm:flex-col sm:items-end">
<p class="text-sm leading-6 text-gray-900">3D Tatort</p>
<p class="mt-1 text-xs leading-5 text-gray-500">
Zuletzt geändert <time datetime="2023-01-23T13:23Z"
>{timeElapsed(new Date(item.lastModified))}</time
>
</p>
</div>
</a>
</li>
{/each}
</ul>
</div>
<Modal {open}
><ModalTitle>Umbenennen</ModalTitle><ModalContent>
{#if inProgress}
<p class="py-2 mb-1">Vorgang läuft...</p>
{/if}
{#if err}
<Alert class="w-full" type="error">Fehler beim Umbenennen</Alert>
{/if}
</ModalContent>
<ModalFooter><Button disabled={inProgress} on:click={uploadSuccessful}>Ok</Button></ModalFooter>
</Modal>
</div>

View File

@@ -1,36 +0,0 @@
import { client } from '$lib/minio';
import { json } from '@sveltejs/kit';
// rename operation
export async function PUT({ request }) {
const data = await request.json();
console.log(`--- ${request.url.split('/').at(-1)} +++ ${JSON.stringify(data)}`);
// Vorgang
let vorgang = request.url.split('/').at(-1)
// prepare copy, incl. check if new name exists already
let old_name = data["old_name"]
let src_full_path = `/tatort/${vorgang}/${old_name}`
let new_name = `${vorgang}/${data["new_name"]}`
try {
let file_stats = await client.statObject('tatort', new_name)
return json({ msg: 'Die Datei existiert bereits.' }, { status: 400 })
} catch (error) {
// continue operation
console.log('continue operation')
}
// actual copy operation
await client.copyObject('tatort', new_name, src_full_path)
// delete
await client.removeObject('tatort', `${vorgang}/${old_name}`)
// return success or failure
return json({ success: 'success' }, { status: 200 });
};

View File

@@ -1,13 +0,0 @@
import { client } from '$lib/minio';
import { json } from '@sveltejs/kit';
export async function DELETE({ request }) {
let url_fragments = request.url.split('/')
let item = url_fragments.at(-1);
let vorgang = url_fragments.at(-2);
await client.removeObject('tatort', `${vorgang}/${item}`)
return new Response(null, { status: 204 });
};

View File

@@ -1,37 +0,0 @@
import { client } from '$lib/minio';
import { fail } from '@sveltejs/kit';
import caseNumberOccupied from '$lib/helper/caseNumberOccupied';
/** @type {import('./$types').Actions} */
export const actions = {
default: async ({ request }) => {
const data = await request.formData();
const caseNumber = data.get('caseNumber');
const description = data.get('description');
if (!caseNumber) {
return fail(400, {
caseNumber,
description,
error: { caseNumber: 'Es muss eine Vorgangsnummer vorhanden sein.' }
});
}
if (await caseNumberOccupied(`${caseNumber}`)) {
return fail(400, {
caseNumber,
description,
error: { caseNumber: 'Die Vorgangsnummer wurde im System bereits angelegt.' }
});
}
const config = `${JSON.stringify({ caseNumber, description, version: 1 })}\n`;
await client.putObject('tatort', `${caseNumber}/config.json`, config, {
'Content-Type': 'application/json'
});
return { success: true };
}
};

View File

@@ -1,115 +0,0 @@
<script>
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 Exclamation from '$lib/icons/Exclamation.svelte';
export let form;
let open = false;
$: open = form?.success ?? false;
</script>
<div class="mx-auto max-w-2xl">
<div class="flex flex-col items-center justify-center w-full">
<h1 class="text-xl">Neuer Vorgang</h1>
</div>
<form method="POST">
<div class="space-y-12">
<div class="border-b border-gray-900/10 pb-12">
<p class="mt-8 text-sm leading-6 text-gray-600">
This information will be displayed publicly so be careful what you share.
</p>
<div class="mt-10 grid grid-cols-1 gap-x-6 gap-y-8">
<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>
<div>
<label for="description" class="block text-sm font-medium leading-6 text-gray-900"
><span class="flex"
>{#if form?.error?.description}
<span class="inline-block mr-1"><Exclamation /></span>
{/if} Beschreibung</span
></label
>
<div class="mt-2">
<textarea
value={form?.description ?? ''}
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}
</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
type="submit"
class="rounded-md bg-indigo-600 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"
>Save</Button
>
</div>
</div>
</form>
<Modal {open}
><ModalTitle>vorgang anlegen</ModalTitle><ModalContent>
{#if form?.success}
<Alert class="w-full">Vorgang erfolgreich angelegt</Alert>
{:else}
<Alert class="w-full" type="error">Fehler beim Upload</Alert>
{/if}
</ModalContent>
<ModalFooter><Button on:click={() => (open = false)}>Ok</Button></ModalFooter>
</Modal>
</div>

View File

@@ -1,116 +0,0 @@
import path from 'path';
import { writeFile } from 'fs/promises';
import { createReadStream } from 'fs';
/** import Minio from 'minio'; */
import { Readable } from 'stream';
/** const MINIO_ACCESS_KEY = 'tMhLrfog47lMm0HZ'; */
import { client } from '$lib/minio';
import { fail } from '@sveltejs/kit';
function isRequiredFieldValid(value) {
if (value == null) return false;
if (typeof value === 'string' || value instanceof String) return value.trim() !== '';
return true;
}
/** @type {import('./$types').Actions} */
export const actions = {
url: async ({ request }) => {
const data = await request.formData();
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}`;
switch (type) {
case 'image/png':
if (!objectName.endsWith('.png')) objectName += '.png';
break;
case '':
if (fileName.endsWith('.glb') && !objectName.endsWith('.glb')) objectName += '.glb';
}
const url = await client.presignedPutObject('tatort', objectName);
// enter code
return { url };
},
validate: async ({ request }) => {
const requestData = await request.formData();
const data = Object.fromEntries(requestData);
const vorgang = data.vorgang;
const name = data.name;
const zugangscode = data.zugangscode;
let success = true;
let err = {};
if (isRequiredFieldValid(vorgang)) err.vorgang = null;
else {
err.vorgang = 'Das Feld Vorgang darf nicht leer bleiben.';
success = false;
}
if (isRequiredFieldValid(name)) err.name = null;
else {
err.name = 'Das Feld Name darf nicht leer bleiben.';
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);
},
upload: async ({ request }) => {
const requestData = await request.formData();
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 }) => {
const requestData = await request.formData();
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) {
if (err) return reject(err);
resolve(etag);
});
});
let etag = null;
let error = null;
try {
etag = await result;
console.log(etag);
} catch (err) {
error = err;
console.log('Error:', err);
}
return { etag, error };
//await writeFile(filePath, Buffer.from(await data.file.arrayBuffer()));
},
get_code: async ({ request }) => {
console.log('TO-DO');
}
};

View File

@@ -0,0 +1,107 @@
import { Readable } from 'stream';
import { BUCKET, client } from '$lib/minio';
import { fail, error } from '@sveltejs/kit';
import { getVorgangByName } from '$lib/server/vorgangService';
const isRequiredFieldValid = (value: unknown) => {
if (value == null) return false;
if (typeof value === 'string' || value instanceof String) return value.trim() !== '';
return true;
};
export const actions = {
url: async ({ request }: { request: Request }) => {
const data = await request.formData();
const vorgangName: string | null = data.get('vorgang') as string;
const crimeName: string | null = data.get('name') as string;
const type: string | null = data.get('type') as string;
const fileName: string | null = data.get('fileName') as string;
let vorgangToken;
const vorgang = getVorgangByName(vorgangName);
vorgangToken = vorgang.token;
let objectName = `${vorgangToken}/${crimeName}`;
switch (type) {
case 'image/png':
if (!objectName.endsWith('.png')) objectName += '.png';
break;
case '':
if (fileName?.toString().endsWith('.glb') && !objectName.endsWith('.glb'))
objectName += '.glb';
}
const url = await client.presignedPutObject(BUCKET, objectName);
return { url };
},
validate: async ({ request }: { request: Request }) => {
const requestData = await request.formData();
const data = Object.fromEntries(requestData);
const vorgang = data.vorgang;
const name = data.name;
let success = true;
const err = {};
if (isRequiredFieldValid(vorgang)) {
err.vorgang = null;
} else {
err.vorgang = 'Das Feld Vorgang darf nicht leer bleiben.';
success = false;
}
if (isRequiredFieldValid(name)) {
err.name = null;
} else {
err.name = 'Das Feld Name darf nicht leer bleiben.';
success = false;
}
if (success) return { success };
return fail(400, err);
},
upload: async ({ request }: { request: Request }) => {
const requestData = await request.formData();
const data = Object.fromEntries(requestData);
const vorgang = data.vorgang;
const name = data.name;
const url = await client.presignedPutObject(BUCKET, `${vorgang}/${name}`, 60);
return { url };
},
upload3: async ({ request }: { request: Request }) => {
const requestData = await request.formData();
const data = Object.fromEntries(requestData);
const name = data.name;
const stream = data.file.stream();
const metaData = { 'Content-Type': 'model-gtlf-binary', 'X-VorgangsNr': '4711' };
const result = new Promise((resolve, reject) => {
client.putObject(BUCKET, name, Readable.from(stream), metaData, function (err, etag) {
if (err) return reject(err);
resolve(etag);
});
});
let etag = null;
let error = null;
try {
etag = await result;
} catch (err) {
error = err;
console.log('Error:', err);
}
return { etag, error };
}
};
export const load: PageServerLoad = async (event) => {
if (!event.locals.user) {
error(404, 'Not found')
}
};

View File

@@ -1,46 +1,50 @@
<script>
import { deserialize, enhance } 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';
<script lang="ts">
import { deserialize } from '$app/forms';
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';
import { API_ROUTES, ROUTE_NAMES } from '../../index.js';
export let form;
let open = false;
let inProgress = false;
let vorgang = '';
const code_len = 8;
let zugangscode = ''
let zugangscode_prev = '';
const PINLength = 8;
$: zugangscode = Math.random().toString(36).slice(2, 2+code_len);
function generatePIN() {
return Math.random()
.toString(36)
.slice(2, 2 + PINLength);
}
let vorgangPIN = '';
let vorgangPINOld = '';
$: vorgangPINOld = generatePIN();
$: vorgangPIN = vorgangPINOld;
let case_existing = undefined;
$: case_existing = false;
let vorgangExists = undefined;
$: vorgangExists = false;
let name = '';
/** @type {?string}*/
let etag = null;
/** @type {?FileList} */
let files = null;
let etag: string | null = null;
let files: FileList | null = null;
$: inProgress = form === null;
/** @type {?Record<string,any>}*/
let formErrors;
let formErrors: Record<string, any> | null;
async function validateForm() {
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 });
data.append('vorgangPIN', vorgangPIN);
const response = await fetch(ROUTE_NAMES.UPLOAD_VALIDATE, { method: 'POST', body: data });
/** @type {import('@sveltejs/kit').ActionResult} */
const result = deserialize(await response.text());
@@ -52,7 +56,6 @@
success = false;
}
console.log('File', files);
if (!files?.length) {
formErrors = { file: 'Sie haben keine Datei ausgewählt.', ...formErrors };
success = false;
@@ -62,7 +65,6 @@
formErrors = { file: 'Keine gültige .GLD-Datei', ...formErrors };
success = false;
}
return success;
}
@@ -70,12 +72,12 @@
let data = new FormData();
data.append('vorgang', vorgang);
data.append('name', name);
data.append('zugangscode', zugangscode)
data.append('vorgangPIN', vorgangPIN);
if (files?.length === 1) {
data.append('type', files[0].type);
data.append('fileName', files[0].name);
}
const response = await fetch('?/url', { method: 'POST', body: data });
const response = await fetch(ROUTE_NAMES.UPLOAD_URL, { method: 'POST', body: data });
/** @type {import('@sveltejs/kit').ActionResult} */
const result = deserialize(await response.text());
if (result.type === 'success') return result.data?.url;
@@ -83,14 +85,12 @@
return null;
}
/** @param {MouseEvent} event*/
async function buttonClick(event) {
async function buttonClick(event: MouseEvent) {
if (!(await validateForm())) {
event.preventDefault();
return;
}
const url = await getUrl();
console.log('URL', url);
open = true;
inProgress = true;
@@ -98,7 +98,6 @@
.then((response) => {
inProgress = false;
etag = '123';
console.log('SUCCESS', response);
})
.catch((err) => {
inProgress = false;
@@ -108,7 +107,6 @@
}
function uploadSuccessful() {
console.log('reset');
open = false;
vorgang = '';
name = '';
@@ -119,69 +117,84 @@
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);
console.log(file_header);
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;
}
return true;
}
// return true or false
async function case_exists(case_no) {
// ping `/(angemeldet)/view` with caseNumber in POST body
let url = '/view'
let data = new FormData();
data.append('caseNumber', case_no);
const response = await fetch(url, {
method: 'POST',
body: data,
redirect: 'error'
})
const res_json = await response.json();
const status = res_json.status;
// aktualisiere Zugangscode mit
if (status == 303) {
// TO-DO: check existing code
console.log(`+ existiert`)
case_existing = true;
async function checkVorgangExists(vorgangName: string) {
if (vorgangName == '') {
vorgangPIN = vorgangPINOld;
return;
}
case_existing = false;
try {
// `HEAD` method
const url = API_ROUTES.VORGANG_NAME_EXIST(vorgangName);
const response = await fetch(url, { method: 'HEAD' });
if (response.status === 200) {
console.log('Vorgang existiert:', vorgangName);
vorgangExists = true;
const token = await getVorgangPIN(vorgangName);
vorgangPIN = token;
return true;
} else {
console.log('Vorgang existiert nicht!');
vorgangExists = false;
vorgangPIN = vorgangPINOld;
return false;
}
} catch (err) {
console.error('Fehler bei checkVorgangExists:', err);
vorgangExists = false;
vorgangPIN = vorgangPINOld;
return false;
}
}
async function getVorgangPIN(vorgangName: string) {
if (vorgangName == '') return;
let url = API_ROUTES.VORGANG_PIN(vorgangName);
const response = await fetch(url);
if (response.status == 200) {
return response.text();
} else {
return -1;
}
}
</script>
<div class="mx-auto max-w-2xl">
@@ -202,7 +215,7 @@
><span class="flex"
>{#if formErrors?.vorgang}
<span class="inline-block mr-1"><Exclamation /></span>
{/if} Vorgang</span
{/if} Vorgangsname</span
></label
>
<div class="mt-2">
@@ -216,16 +229,16 @@
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)}
on:input={() => checkVorgangExists(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) }
{#if vorgangExists && vorgang.length > 0}
<span>Datei wird zum existierenden Vorgang hinzugefügt.</span>
{:else if (vorgang.length > 0) }
{:else if vorgang.length > 0}
<span>Neuer Vorgang wird angelegt.</span>
{/if}
</div>
@@ -235,7 +248,7 @@
><span class="flex"
>{#if formErrors?.name}
<span class="inline-block mr-1"><Exclamation /></span>
{/if} Name</span
{/if} Modellname</span
></label
>
<div class="mt-2">
@@ -258,11 +271,11 @@
</div>
<div>
<label for="zugangscode" class="block text-sm font-medium leading-6 text-gray-900"
<label for="vorgang-pin" class="block text-sm font-medium leading-6 text-gray-900"
><span class="flex"
>{#if formErrors?.zugangscode}
>{#if formErrors?.vorgangPIN}
<span class="inline-block mr-1"><Exclamation /></span>
{/if} Zugangscode</span
{/if} Zugangs-PIN</span
></label
>
<div class="mt-2">
@@ -270,16 +283,28 @@
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}
bind:value={vorgangPIN}
type="text"
name="zugangscode"
id="zugangscode"
name="vorgang-pin"
id="vorgang-pin"
on:input={(ev) => {
vorgangPINOld = 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={() => {
vorgangPIN = vorgangPINOld = generatePIN();
}}
type="button"
>
Generiere Zugangs-PIN
</button>
</div>
{#if formErrors?.code}
<p class="block text-sm leading-6 text-red-900 mt-2">{formErrors.code}</p>
{#if formErrors?.vorgangPIN}
<p class="block text-sm leading-6 text-red-900 mt-2">{formErrors.vorgangPIN}</p>
{/if}
</div>
@@ -295,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

@@ -0,0 +1,8 @@
import type { PageServerLoad } from '../../(token-based)/view/$types';
import { error } from '@sveltejs/kit';
export const load: PageServerLoad = async (event) => {
if (!event.locals.user) {
error(404, 'Not Found')
}
};

View File

@@ -0,0 +1,211 @@
<script lang="ts">
import { onMount } from 'svelte';
import Button from '$lib/components/Button.svelte';
import { API_ROUTES } from '../../index.js';
const { data } = $props();
let userName = $state('');
let userPassword = $state('');
let userList: { userId: string; userName: string }[] = $state([]);
let addUserError = $state(false);
let addUserSuccess = $state(false);
const currentUser: string = data.user.id;
onMount(async () => {
try {
userList = await getUsers();
} catch (error) {
console.log(`An error occured while retrieving users: ${error}`);
}
});
async function getUsers() {
const URL = API_ROUTES.USERS;
try {
const response = await fetch(URL);
return await response.json();
} catch (error) {
console.log(`Error fetching users: ${error}`);
return null;
}
}
async function addUser() {
if (userName == '') {
alert('Der Benutzername darf nicht leer sein.');
return;
}
if (userPassword == '') {
alert('Das Passwort darf nicht leer sein.');
return;
}
const URL = API_ROUTES.USERS;
const userData = { userName: userName, userPassword: userPassword };
try {
const response = await fetch(URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(userData)
});
if (response.ok) {
const newUser = await response.json();
userList = [...userList, newUser];
addUserSuccess = true;
resetInput();
} else {
addUserError = true;
}
} catch (error) {
console.log(`Error creating user: ${error}`);
addUserError = true;
}
}
function resetInput() {
userName = '';
userPassword = '';
addUserError = false;
setInterval(() => {
addUserSuccess = false;
}, 5000);
}
async function deleteUser(userId: string) {
const URL = API_ROUTES.USER(userId);
try {
const response = await fetch(URL, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
}
});
if (response.status == 204) {
userList = await getUsers();
} else {
alert('Nutzer konnte nicht gelöscht werden');
}
} catch (error) {
console.log(`Error deleting users: ${error}`);
}
}
</script>
<h1 class="flex justify-center text-3xl md:text-4xl font-bold text-gray-800 dark:text-white tracking-tight mb-4">
Benutzerverwaltung
</h1>
<h1 class="flex justify-center text-lg md:text-xl font-medium text-gray-800 dark:text-white tracking-tight mb-2">
Benutzerliste
</h1>
<div class="w-1/4 mx-auto">
<table class="min-w-full border border-gray-300 rounded overflow-hidden">
<thead class="bg-gray-100 dark:bg-gray-700">
<tr>
<th class="text-left px-4 py-2">Benutzername</th>
<th class="text-center px-4 py-2">Entfernen</th>
</tr>
</thead>
<tbody>
{#each userList as userItem}
<tr class="border-t border-gray-200 dark:border-gray-600">
<td class="px-4 py-2 text-gray-800 dark:text-white">{userItem.userName}</td>
<td class="px-4 py-2 text-center">
<button
class="text-red-600 hover:text-red-800 focus:outline-none focus:ring-2 focus:ring-red-500 rounded-full p-1 transition"
on:click={() => deleteUser(userItem.userId)}
aria-label="Delete user"
>
{#if (userItem.userName != currentUser)}
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M6 18L18 6M6 6l12 12" />
</svg>
{/if}
</button>
</td>
</tr>
{/each}
</tbody>
</table>
</div>
<h1 style="margin-top: 50px;"
class="flex justify-center text-lg md:text-xl font-medium text-gray-800 dark:text-white tracking-tight mb-2">
Neuer Nutzer
</h1>
<div class="mx-auto flex justify-center">
<form>
<div class="form-group">
<label for="username">Benutzername</label>
<input bind:value={userName} type="text" id="username" placeholder="Namen eingeben" />
</div>
<div class="form-group">
<label for="password">Passwort</label>
<input bind:value={userPassword} type="password" id="password" placeholder="Passwort vergeben" />
</div>
</form>
</div>
<div class="mx-auto flex flex-col items-center space-y-4" style="margin-top: 20px;">
{#if addUserError}
<div class="flex items-center bg-yellow-100 border-l-4 border-yellow-500 text-yellow-700 p-4 rounded shadow-sm"
role="alert">
<svg class="h-5 w-5 mr-3 text-yellow-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M12 9v2m0 4h.01M12 5a7 7 0 100 14 7 7 0 000-14z" />
</svg>
<span class="text-sm font-medium">Der Benutzer konnte nicht hinzugefügt werden.</span>
</div>
{/if}
{#if addUserSuccess}
<div class="flex items-center bg-yellow-100 border-l-4 border-yellow-500 text-yellow-700 p-4 rounded shadow-sm"
role="alert">
<svg class="h-5 w-5 mr-3 text-yellow-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M12 9v2m0 4h.01M12 5a7 7 0 100 14 7 7 0 000-14z" />
</svg>
<span class="text-sm font-medium">Der Benutzer wurde hinzugefügt.</span>
</div>
{/if}
<Button on:click={addUser}>Benutzer hinzufügen</Button>
</div>
<style>
.form-group {
display: flex;
flex-direction: column;
margin-bottom: 15px;
}
label {
margin-bottom: 5px;
font-weight: bold;
}
input[type="text"],
input[type="password"] {
padding: 8px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 4px;
}
</style>

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 }) => {
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 (!(await caseNumberOccupied(caseNumber))) {
return fail(400, {
success: false,
caseNumber,
error: { caseNumber: 'Die Vorgangsnummer existiert in dieser Anwendung nicht.' }
});
}
redirect(303, `/list/${caseNumber}`);
}
};

View File

@@ -1,64 +0,0 @@
<script>
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 Exclamation from '$lib/icons/Exclamation.svelte';
export let form;
</script>
<div class="mx-auto max-w-2xl">
<div class="flex flex-col items-center justify-center w-full">
<h1 class="text-xl">Vorgang ansehen</h1>
</div>
<form method="POST">
<div class="space-y-12">
<div class="border-b border-gray-900/10 pb-12">
<!-- <h2 class="text-base font-semibold leading-7 text-gray-900">Profile</h2> -->
<p class="mt-8 text-sm leading-6 text-gray-600">
Anhand der Vorgangsnummer werden Sie zu den Dateien des Vorgangs weitergeleitet und können
sich den Vorgang dann ansehen.
</p>
<div class="mt-10 grid grid-cols-1 gap-x-6 gap-y-8">
<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 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={form?.caseNumber ?? ''}
type="text"
name="caseNumber"
id="caseNumber"
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?.caseNumber}
<p class="block text-sm leading-6 text-red-900 mt-2">{form.error.caseNumber}</p>
{/if}
</div>
</div>
</div>
<div class="mt-6 flex items-center justify-end gap-x-6">
<Button
type="submit"
class="rounded-md bg-indigo-600 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"
>Weiter</Button
>
</div>
</div>
</form>
</div>

View File

@@ -1,8 +0,0 @@
import { client } from '$lib/minio';
/** @type {import('./$types').PageServerLoad} */
export async function load({ params }) {
const { vorgang, tatort } = params;
const url = await client.presignedUrl('GET', 'tatort', `${vorgang}/${tatort}`);
return { url };
}

View File

@@ -0,0 +1,22 @@
import { vorgangPINValidation, vorgangExists } from '$lib/server/vorgangService';
import { redirect } from '@sveltejs/kit';
import type { LayoutServerLoad } from './$types';
import { ROUTE_NAMES } from '..';
export const load: LayoutServerLoad = async ({ params, cookies, locals }) => {
if (locals.user) {
return {
user: locals.user
};
}
const vorgangToken = params.vorgang ?? '';
const COOKIE_NAME = `token-${vorgangToken}`;
const vorgangPIN = cookies.get(COOKIE_NAME) ?? '';
const isVorgangValid = vorgangExists(vorgangToken);
const isVorgangPINValid = vorgangPINValidation(vorgangToken, vorgangPIN);
if (!isVorgangValid || !isVorgangPINValid)
throw redirect(303, ROUTE_NAMES.ANMELDUNG_VORGANG_PARAM(vorgangToken));
};

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

@@ -0,0 +1,23 @@
import { getCrimesListByToken, getVorgaenge } from '$lib/server/vorgangService.js';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ params, url }) => {
const vorgangList = getVorgaenge();
const vorgangToken = params.vorgang;
const crimesList = await getCrimesListByToken(vorgangToken);
const vorgang = vorgangList.find((v) => v.vorgangToken === vorgangToken); //vorgang sollte ein eigener Typ werden, und dann kann man es hier vernünftig typisieren
if (!vorgang || !crimesList) {
throw new Error(`Fehlgeschlagen, es wurden keine Daten zum token gefunden`);
}
//Variabeln für NameItemEditor
const crimeNames: string[] = crimesList.map((l) => l.name);
return {
vorgang,
vorgangList,
crimesList,
url,
crimeNames
};
}

View File

@@ -0,0 +1,496 @@
<script lang="ts">
import { fade } from 'svelte/transition';
import shortenFileSize from '$lib/helper/shortenFileSize';
import timeElapsed from '$lib/helper/timeElapsed';
import { deserialize } from '$app/forms';
import ExpandableForm from '$lib/components/ExpandableForm.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 { invalidateAll } from '$app/navigation';
import NameItemEditor from '$lib/components/NameItemEditor.svelte';
import EmptyList from '$lib/components/EmptyList.svelte';
import FileRect from '$lib/icons/File-rect.svelte';
import Exclamation from '$lib/icons/Exclamation.svelte';
import { API_ROUTES, ROUTE_NAMES } from '../../../index.js';
//Seite für die Tatort-Liste
let { data, form } = $props();
interface ListItem {
//sollte Typ Vorgang sein, aber der einfachheit ist es noch ListItem, damit die Komponente NameItemEditor für Vorgang und Tatort eingesetzt werden kann
name: string;
size: number;
lastModified: string | number | Date;
show_button?: boolean;
prefix?: string;
// add other properties as needed
}
let crimesList = $state<ListItem[]>(data.crimesList);
let vorgangName: string = data.vorgang.vorgangName;
const vorgangPIN: string = data.vorgang.vorgangPIN;
let vorgangToken: string = data.vorgang.vorgangToken;
let isEmptyList = $derived(crimesList.length === 0);
// File Upload Variablen
let name = $state('');
let formErrors: Record<string, any> | null = $state(null);
let etag: string | null = $state(null);
let files: FileList | null = $state(null);
// Model Variablen für Upload
let openUL = $state(false);
let inProgressUL = $state(form === null);
// Variablen für Copy-Funktion
let copied = $state(false);
async function buttonClick(event: MouseEvent) {
if (!(await validateForm())) {
event.preventDefault();
return;
}
const url = await getUrl();
openUL = true;
inProgressUL = true;
fetch(url, { method: 'PUT', body: files[0] })
.then((response) => {
inProgressUL = false;
etag = '123';
})
.catch((err) => {
inProgressUL = false;
etag = null;
console.log('ERROR', err);
});
}
async function validateForm() {
let data = new FormData();
data.append('vorgang', vorgangName);
data.append('name', name);
const response = await fetch(ROUTE_NAMES.UPLOAD_VALIDATE, { method: 'POST', body: data });
const result = deserialize(await response.text());
let success = true;
if (result.type === 'success') {
formErrors = null;
} else {
if (result.type === 'failure' && result.data) formErrors = result.data;
success = false;
}
if (!files?.length) {
formErrors = { file: 'Sie haben keine Datei ausgewählt.', ...formErrors };
success = false;
}
if (!(await check_valid_glb_file())) {
formErrors = { file: 'Keine gültige .GLD-Datei', ...formErrors };
success = false;
}
return success;
}
async function uploadSuccessful() {
openUL = false;
name = '';
files = null;
await invalidateAll();
crimesList = data.crimesList;
}
// `val` is hex string
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;
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;
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;
// big endian!
let file = files[0];
const fileHeader = file.slice(0, 4);
const buffer = await fileHeader.arrayBuffer();
console.log(fileHeader);
let headerBytes = new Uint8Array(buffer);
let fileHeaderHex = '0x' + headerBytes.toHex().toString();
if (GLD_MAGIC == swap_endian(fileHeaderHex)) {
return true;
} else {
return false;
}
}
async function getUrl() {
let data = new FormData();
data.append('vorgang', vorgangName);
data.append('name', name);
if (files?.length === 1) {
data.append('type', files[0].type);
data.append('fileName', files[0].name);
}
const response = await fetch(ROUTE_NAMES.UPLOAD_URL, { method: 'POST', body: data });
const result = deserialize(await response.text());
if (result.type === 'success') return result.data?.url;
return null;
}
//Variablen für Modal
let open = $state(false);
let inProgress = $state(false);
let isError = $state(false);
let admin = data?.user?.admin;
async function handleSave(newName: string, oldName: string) {
open = true;
inProgress = true;
isError = false;
try {
const res = await fetch(API_ROUTES.CRIME(vorgangToken, oldName), {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ vorgangToken, oldName, newName })
});
if (!res.ok) {
throw new Error('Fehler beim Speichern');
}
await invalidateAll();
crimesList = data.crimesList;
open = false;
} catch (err) {
console.error('⚠️ Netzwerkfehler beim Speichern', err);
isError = true;
} finally {
inProgress = false;
}
}
async function savePIN(newVorgangPIN: string, oldVorgangPIN: string) {
open = true;
inProgress = true;
isError = false;
try {
const res = await fetch(API_ROUTES.VORGANG(vorgangToken), {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ vorgangToken, oldVorgangPIN, newVorgangPIN,
changePIN: true})
});
if (!res.ok) {
throw new Error('Fehler beim Speichern');
}
await invalidateAll();
crimesList = data.crimesList;
open = false;
} catch (err) {
console.error('⚠️ Netzwerkfehler beim Speichern', err);
isError = true;
} finally {
inProgress = false;
}
}
async function handleDelete(tatort: string) {
open = true;
inProgress = true;
isError = false;
let path = API_ROUTES.CRIME(vorgangToken, tatort)
try {
const res = await fetch(path, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ vorgangToken, tatort })
});
if (!res.ok) {
throw new Error('Fehler beim Löschen');
}
crimesList = crimesList.filter((i) => i.name !== tatort);
await invalidateAll();
console.log('🗑️ Erfolgreich gelöscht:', path);
open = false;
} catch (err) {
console.error('⚠️ Netzwerkfehler beim Speichern', err);
isError = true;
} finally {
inProgress = false;
}
}
async function copyAndOpenMail() {
const subject = 'Link zum Tatvorgang';
const link = data.url.origin + data.url.pathname;
const body = `Hallo,
hier ist der Link zum Tatvorgang:
${link}
Der Zugangs-PIN wird zur Sicherheit über einen zweiten Kommunikationskanal übermittelt.
Mit freundlichen Grüßen,
`;
try {
await navigator.clipboard.writeText(body);
copied = true;
// Kurz warten, dann Mail öffnen
setTimeout(() => {
const mailtoLink = `mailto:?subject=${encodeURIComponent(subject)}`;
window.location.href = mailtoLink;
}, 1000);
setTimeout(() => copied = false, 2000);
} catch (err) {
console.error('Clipboard-Fehler:', err);
error = 'Konnte Text nicht kopieren. Bitte manuell markieren und kopieren.';
}
}
function closeModal() {
open = false;
isError = false;
}
</script>
{#if data.vorgang && crimesList}
<div class="-z-10 bg-white">
<div class="flex flex-col items-center justify-center w-full">
<h1 class="text-xl">{vorgangName}</h1>
{#if admin}
<div class="flex items-center gap-2">
Zugangs-PIN:
<NameItemEditor
list={[]}
currentName={vorgangPIN}
onSave={savePIN}
onDelete={null}
/>
</div>
<Button variant="secondary" on:click={copyAndOpenMail} disabled={isEmptyList}>Link kopieren und Mail verfassen</Button>
{#if copied}
<p transition:fade>✔ Kopiert! Per Ctrl+V einfügen.</p>
{/if}
{/if}
</div>
<div class="mx-auto flex justify-center max-w-7xl h-full">
<ul class="divide-y divide-gray-100">
{#if isEmptyList}
<EmptyList></EmptyList>
{:else}
{#each crimesList as item (item.name)}
<li
data-testid="test-list-item"
class="flex items-center justify-between gap-6 py-4 px-2 hover:bg-gray-50 rounded-lg transition"
>
<div class="flex items-center gap-4 flex-1">
<a
data-testid="crime-link"
href="{ROUTE_NAMES.CRIME(vorgangToken, item.name, vorgangPIN)}"
class="flex items-center justify-center w-8 h-8 text-gray-600 hover:text-blue-600 transition"
aria-label="{ROUTE_NAMES.CRIME(vorgangToken, item.name, vorgangPIN)}"
title={item.name}
>
<Cube class="w-5 h-5" />
</a>
<div class="flex flex-col flex-1 min-w-0">
{#if admin}
<NameItemEditor
list={crimesList}
currentName={item.name}
onSave={handleSave}
onDelete={handleDelete}
/>
{:else}
<p
data-testid="test-nameItem-p"
class="text-sm font-semibold leading-6 text-gray-900 truncate"
>
{item.name}
</p>
{/if}
<!-- size left, last modified right -->
<div class="flex items-center justify-between mt-1 text-xs leading-5 text-gray-500">
{#if item.size}
<span>{shortenFileSize(item.size)}</span>
{:else}
<span></span>
{/if}
{#if item.lastModified}
<span>
Zuletzt geändert
<time datetime={item.lastModified}>
{timeElapsed(new Date(item.lastModified))}
</time>
</span>
{/if}
</div>
</div>
</div>
</li>
{/each}
{/if}
</ul>
</div>
{#if admin}
<div class="flex justify-center my-4">
<ExpandableForm>
<div class="mx-auto max-w-2xl">
<div class="flex flex-col items-center space-y-6">
<!-- Name Input -->
<div class="w-full max-w-md">
<label for="name" class="block text-sm font-medium leading-6 text-gray-900">
<span class="flex">
{#if formErrors?.name}
<span class="inline-block mr-1"><Exclamation /></span>
{/if} Modellname
</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={name}
type="text"
name="name"
id="name"
autocomplete={name}
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>
</div>
{#if formErrors?.name}
<p class="block text-sm leading-6 text-red-900 mt-2">{formErrors.name}</p>
{/if}
</div>
<!-- File Upload -->
<div class="w-full max-w-md">
<label for="file" class="block text-sm font-medium leading-6 text-gray-900">
<span class="flex">
{#if formErrors?.file}
<span class="inline-block mr-1"><Exclamation /></span>
{/if} Datei
</span>
</label>
<div
class="mt-2 flex justify-center rounded-lg border border-dashed border-gray-900/25 px-6 py-10"
>
<div class="text-center">
<FileRect />
<div class="mt-4 flex text-sm leading-6 text-gray-600">
<label
for="file"
class="relative cursor-pointer rounded-md bg-white font-semibold text-indigo-600 focus-within:outline-none focus-within:ring-2 focus-within:ring-indigo-600 focus-within:ring-offset-2 hover:text-indigo-500"
>
<span>Wähle eine Datei aus</span>
<input id="file" bind:files name="file" type="file" class="sr-only" />
</label>
<p class="pl-1">oder ziehe sie ins Feld</p>
</div>
<p class="text-xs leading-5 text-gray-600">GLB Dateien bis zu 1GB</p>
{#if files?.length}
<div class="flex justify-center text-xs mt-2">
<p class="mx-2">Datei: <span class="font-bold">{files[0].name}</span></p>
<p class="mx-2">
Größe: <span class="font-bold">{shortenFileSize(files[0].size)}</span>
</p>
</div>
{/if}
</div>
</div>
{#if formErrors?.file}
<p class="block text-sm leading-6 text-red-900 mt-2">{formErrors.file}</p>
{/if}
</div>
<div class="mt-6 flex items-center justify-end gap-x-6">
<Button
on:click={buttonClick}
class="rounded-md bg-indigo-600 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"
>
Hinzufügen
</Button>
</div>
</div>
</div>
</ExpandableForm>
</div>
{/if}
<Modal {open}
><ModalTitle>Umbenennen</ModalTitle><ModalContent>
{#if inProgress}
<p class="py-2 mb-1">Vorgang läuft...</p>
{:else if isError}
<Alert class="w-full" type="error">Fehler beim Umbenennen</Alert>
{:else}
<Alert class="w-full">Umbenennen erfolgreich</Alert>
{/if}
</ModalContent>
<ModalFooter><Button disabled={inProgress} on:click={closeModal}>Ok</Button></ModalFooter>
</Modal>
<Modal open={openUL}
><ModalTitle>Upload</ModalTitle><ModalContent>
{#if inProgressUL}
<p class="py-2 mb-1">Upload läuft...</p>
{:else if etag}
<Alert class="w-full">Upload erfolgreich</Alert>
{:else}
<Alert class="w-full" type="error">Fehler beim Upload</Alert>
{/if}
</ModalContent>
<ModalFooter
><Button disabled={inProgressUL} on:click={uploadSuccessful}>Ok</Button></ModalFooter
>
</Modal>
</div>
{/if}
<style>
ul {
min-width: 24rem;
}
</style>

View File

@@ -0,0 +1,8 @@
import { BUCKET, client } from '$lib/minio';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ params }) => {
const { vorgang, tatort } = params;
const url = await client.presignedUrl('GET', BUCKET, `${vorgang}/${tatort}`);
return { url };
};

View File

@@ -1,7 +1,8 @@
<script>
import Panel from '$lib/components/ui/Panel.svelte';
<script lang="ts">
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';
import type { ModelViewerElement } from '@google/model-viewer';
export let data;
@@ -19,54 +20,29 @@
let cameraAzimuth = 0;
let cameraPolar = 0;
let frontView = cameraAzimuth === 0 && cameraPolar === 0 ? true : false;
let topView = cameraAzimuth === 0 && cameraPolar === 90 ? true : false;
let cameraZoom = 100;
let xRotation = 0;
let yRotation = 0;
let zRotation = 0;
/**
* @type {any}
*/
let modelViewer;
let modelViewer: ModelViewerElement | null = null;
$: style = `width: ${progress}%`;
/**
* @param {any} detail
*/
function onProgress({ detail }) {
const updateModelProgress = ({ detail }: { detail: { totalProgress: number } }) => {
progress = Math.ceil(detail.totalProgress * 100.0);
if (progress == 100) {
setTimeout(() => {
hideProgressScreen = true;
}, 250);
} else hideProgressScreen = false;
}
};
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')
);
if (modelViewer) {
cameraAzimuth = 0;
cameraPolar = 0;
cameraZoom = 100;
modelViewer.cameraOrbit = cameraOrbit;
modelViewer.cameraTarget = cameraTarget;
modelViewer.fieldOfView = fieldOfView;
@@ -75,21 +51,20 @@
cameraZoom = 100;
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;
}
</script>
<div class="h-full model w-full bg-neutral-200 p-4 transition-all delay-250">
<div class="h-full w-full bg-neutral-200 p-4 transition-all delay-250">
<!-- xr-environment -->
<model-viewer
class="h-full w-full"
shadow-intensity="1"
src={data.url}
bind:this={modelViewer}
touch-action="pan-y"
@@ -100,7 +75,7 @@
orientation={`${xRotation}deg ${yRotation}deg ${zRotation}deg`}
camera-target="0m 0m 0m"
camera-orbit={`${cameraAzimuth}deg ${cameraPolar}deg ${cameraZoom}%`}
on:progress={onProgress}
on:progress={updateModelProgress}
>
<!--Buttons zum Steuern-->
<div
@@ -200,22 +175,4 @@
</div>
<style>
model-viewer {
height: 100%;
width: 100%;
}
/* .vertical-slider {
writing-mode: bt-lr; /* Schreibt von unten nach oben (Vertikale Darstellung)
transform: rotate(270deg); /* Slider um 270° drehen
height: 200px;
} */
.model {
height: calc(100%-84px);
}
/* .active-border {
border: 2px blue solid;
} */
</style>

View File

@@ -1,4 +1,4 @@
<script>
<script lang="ts">
import '../app.css';
</script>

View File

@@ -1,31 +0,0 @@
import { dev } from '$app/environment';
import { fail, redirect } from '@sveltejs/kit';
import { authenticate } from '$lib/auth';
const COOKIE_NAME = 'session';
/** @type {import('./$types').Actions} */
export const actions = {
login: async ({ request, 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) => {
event.cookies.delete(COOKIE_NAME, {path: '/'});
event.locals.user = null;
return { success: true };
}
};

View File

@@ -0,0 +1,35 @@
import { dev } from '$app/environment';
import { error, fail, redirect } from '@sveltejs/kit';
import { ROUTE_NAMES } from '../index.js';
import { vorgangPINValidation } from '$lib/server/vorgangService.js';
export const actions = {
default: async ({ request, cookies }) => {
const data = await request.formData();
const vorgangToken = data.get('vorgang-token');
const vorgangPIN = data.get('vorgang-pin') as string;
if (!vorgangPIN) {
return fail(400, { message: 'Bitte einen PIN eingeben.'});
}
if (!vorgangPINValidation(vorgangToken, vorgangPIN)) {
return fail(400, { message: 'Falsche Zugangsdaten.'});
}
const COOKIE_NAME = `token-${vorgangToken}`;
cookies.set(COOKIE_NAME, vorgangPIN, {
path: '/',
httpOnly: true,
sameSite: 'strict',
secure: !dev
});
throw redirect(303, ROUTE_NAMES.VORGANG(vorgangToken));
}
} as const;
export const load: PageServerLoad = async ({ url }) => {
const vorgang = url.searchParams.get('vorgang');
if (!vorgang) error(404, "Not Found");
};

View File

@@ -1,75 +1,50 @@
<script>
import Panel from '$lib/components/ui/Panel.svelte';
import Button from '$lib/components/ui/Button.svelte';
import Alert from '$lib/components/ui/Alert.svelte';
import Login from '$lib/icons/Login.svelte';
<script lang="ts">
import BaseInputField from '$lib/components/BaseInputField.svelte';
import Button from '$lib/components/Button.svelte';
import ArrowRight from '$lib/icons/Arrow-right.svelte';
/** @type {import('./$types').ActionData} */
export let form;
let user = form?.user ?? '';
function buttonClick() {}
import { page } from '$app/state';
import { ROUTE_NAMES } from '../index.js';
const vorgangToken = page.url.searchParams.get('vorgang');
</script>
<!--
This example requires updating your template:
```
<html class="h-full bg-white">
<body class="h-full">
```
-->
{#if vorgangToken}
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
<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="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">
<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="user" class="block text-sm font-medium leading-6 text-gray-900">Kennung</label>
<div class="mt-2">
<input
id="user"
name="user"
<form method="POST">
<input type="hidden" name="vorgang-token" value={vorgangToken} />
<div class="mt-5">
<BaseInputField
id="vorgang-pin"
name="vorgang-pin"
label="Zugangs-PIN"
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"
value={form?.vorgangPIN}
error={form?.error?.message}
/>
</div>
</div>
{#if form?.message}
<p class="block text-sm leading-6 text-red-900 mt-2">{form.message}</p>
{/if}
<div>
<div class="flex items-center justify-between">
<label for="password" class="block text-sm font-medium leading-6 text-gray-900"
>Passwort</label
>
</div>
<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="flex justify-end pt-4">
<Button type="submit"><ArrowRight /></Button>
</div>
</form>
</div>
</div>
</div>
</div>
{/if}

View File

@@ -0,0 +1,9 @@
import { getVorgaenge } from '$lib/server/vorgangService';
export async function GET() {
const vorgaenge = getVorgaenge();
return new Response(JSON.stringify(vorgaenge), {
status: 200
});
}

View File

@@ -1,63 +0,0 @@
import { client } from '$lib/minio';
/** @type {import('./$types').RequestHandler} */
export async function GET({ params }) {
const prefix = params.vorgang ? `${params.vorgang}/` : '';
let 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;
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 async function DELETE({ params }) {
const vorgang = params.vorgang
const object_list = await new Promise((resolve, reject) => {
const res = []
const items_str = client.listObjects('tatort', vorgang, true)
items_str.on('data', (obj) => {
res.push(obj.name)
})
items_str.on('error', reject)
items_str.on('end', async () => {
resolve(res)
})
console.log(`+++ ${vorgang}`)
})
await client.removeObjects('tatort', object_list)
return new Response(null, { status: 204 });
};

View File

@@ -0,0 +1,88 @@
import { BUCKET, client } from '$lib/minio';
import { json } from '@sveltejs/kit';
import {
deleteVorgangByToken,
getCrimesListByToken,
vorgangNameExists,
updateVorgangAttrByToken
} from '$lib/server/vorgangService';
export async function DELETE({ params }) {
const vorgangToken = params.vorgang;
const object_list = await new Promise((resolve, reject) => {
const res = [];
const items_str = client.listObjects(BUCKET, vorgangToken, true);
items_str.on('data', (obj) => {
res.push(obj.name);
});
items_str.on('error', reject);
items_str.on('end', async () => {
resolve(res);
});
});
await client.removeObjects(BUCKET, object_list);
deleteVorgangByToken(vorgangToken);
return new Response(null, { status: 204 });
}
export async function HEAD({ params }) {
try {
const vorgangName = params.vorgang;
const existing = vorgangNameExists(vorgangName);
return new Response(null, {
status: existing ? 200 : 404
});
} catch (err) {
console.error('Fehler im HEAD-Handler:', err);
return new Response(null, { status: 500 });
}
}
export async function GET({ params }) {
try {
const vorgangToken = params.vorgang;
const crimesList = await getCrimesListByToken(vorgangToken);
return new Response(JSON.stringify(crimesList), {
status: 200
});
} catch (err) {
console.error('Fehler im GET-Handler:', err);
return new Response(null, { status: 500 });
}
}
// change Vorgang properties
export async function PUT({ request }) {
const data = await request.json();
const vorgangToken = data['vorgangToken'];
const changePIN = data['changePIN'];
let attrChanged;
let newValue;
if (changePIN) {
attrChanged = 'pin';
newValue = data['newVorgangPIN']
} else {
attrChanged = 'name';
newValue = data['newName']
}
const res = updateVorgangAttrByToken(vorgangToken, newValue, attrChanged);
if (!res) {
return json({ msg: 'Fehler beim Umbenennen' }, { status: 400 });
}
return json({ success: 'success' }, { status: 200 });
}

View File

@@ -0,0 +1,63 @@
import { BUCKET, client } from '$lib/minio';
import { json } from '@sveltejs/kit';
export async function GET() {
const stream = client.listObjectsV2(BUCKET, '', true);
const result = new ReadableStream({
start(controller) {
stream.on('data', (data) => {
controller.enqueue(`${JSON.stringify(data)}\n`);
});
stream.on('end', () => {
controller.close();
});
},
cancel() {
stream.destroy();
}
});
return new Response(result, {
headers: {
'content-type': 'text/event-stream'
}
});
}
export async function DELETE({ request }) {
const url_fragments = request.url.split('/');
const item = url_fragments.at(-1);
const vorgang = url_fragments.at(-2);
await client.removeObject(BUCKET, `${vorgang}/${item}`);
return new Response(null, { status: 204 });
}
// rename operation for crimes
export async function PUT({ params, request }) {
const data = await request.json();
const vorgangToken = params.vorgang;
// prepare copy, incl. check if new name exists already
const crimeOldName = data['oldName'];
const crimeS3FullBucketPathOld = `/${BUCKET}/${vorgangToken}/${crimeOldName}`;
const crimeNewName = `${vorgangToken}/${data['newName']}`;
if (!crimeOldName || !crimeNewName) {
return json({ msg: 'Der Name darf nicht leer sein.' }, { status: 400 });
}
try {
await client.statObject(BUCKET, crimeNewName);
return json({ msg: 'Die Datei existiert bereits.' }, { status: 400 });
} catch (error) {
console.log(error, 'continue operation');
}
await client.copyObject(BUCKET, crimeNewName, crimeS3FullBucketPathOld);
await client.removeObject(BUCKET, `${vorgangToken}/${crimeOldName}`);
return json({ success: 'success' }, { status: 200 });
}

View File

@@ -1,26 +0,0 @@
import { client } from '$lib/minio';
/** @type {import('./$types').RequestHandler} */
export async function GET() {
var stream = client.listObjectsV2('tatort', '', true);
const result = new ReadableStream({
start(controller) {
stream.on('data', (data) => {
//console.log(data);
controller.enqueue(`${JSON.stringify(data)}\n`);
});
stream.on('end', () => {
controller.close();
});
},
cancel() {
stream.destroy();
}
});
return new Response(result, {
headers: {
'content-type': 'text/event-stream'
}
});
}

View File

@@ -1,6 +0,0 @@
import { client } from '$lib/minio';
/** @type {import('./$types').RequestHandler} */
export async function GET(params) {
console.log('GET', params);
}

View File

@@ -0,0 +1,5 @@
import type { RequestHandler } from "@sveltejs/kit";
export async function GET(params: RequestHandler) {
console.log('GET', params);
}

View File

@@ -0,0 +1,10 @@
//Rollenabfrage ob Benutzer admin ist
import { json } from "@sveltejs/kit";
export async function GET({locals}) {
const isAdmin = locals.user?.admin === true;
const data = {admin: isAdmin}
return json(data)
}

View File

@@ -0,0 +1,31 @@
import { json } from '@sveltejs/kit';
import { addUser, getUsers } from '$lib/server/userService';
import bcrypt from 'bcrypt';
const saltRounds = 12;
export function GET() {
const userList = getUsers();
return new Response(JSON.stringify(userList));
}
export async function POST({ request }) {
const data = await request.json();
const userName = data.userName;
const userPassword = data.userPassword;
if (!userName || !userPassword) {
return json({ error: 'Missing input' }, { status: 400 });
}
const hashedPassword = bcrypt.hashSync(userPassword, saltRounds);
const rowInfo = addUser(userName, hashedPassword);
if (rowInfo?.changes == 1) {
return json({ userId: rowInfo.lastInsertRowid, userName: userName }, { status: 201 });
} else {
return new Response(null, { status: 400 });
}
}

View File

@@ -0,0 +1,8 @@
import { deleteUser } from '$lib/server/userService';
export async function DELETE({ params }) {
const userId = params.user;
const rowCount = deleteUser(userId);
return new Response(null, { status: rowCount == 1 ? 204 : 400 });
}

View File

@@ -0,0 +1,18 @@
import { db } from '$lib/server/dbService';
/** @type {import('./$types').RequestHandler} */
export async function GET({ params }) {
const vorgangName = params.vorgang;
const getPINSQLStatement = `SELECT pin
FROM cases
WHERE name = ?;`;
const row = db.prepare(getPINSQLStatement).get(vorgangName);
const vorgangPIN = row?.pin;
if (vorgangPIN) {
return new Response(vorgangPIN, { status: 200 });
} else {
return new Response(null, { status: 404 });
}
}

41
src/routes/index.ts Normal file
View File

@@ -0,0 +1,41 @@
export const ROUTE_NAMES = {
ROOT: '/',
// (angemeldet)
LIST: '/list',
UPLOAD: '/upload',
// UPLOAD actions
UPLOAD_URL: '/upload?/url',
UPLOAD_VALIDATE: '/upload?/validate',
USERMGMT: '/user-management',
// (token-based)
VORGANG: (vorgangToken: string) => `/list/${vorgangToken}`,
CRIME: (vorgangToken: string, tatort: string) => `/view/${vorgangToken}/${tatort}`,
// Anmeldung: actions
ANMELDUNG: '/anmeldung',
LOGIN: '/?/login',
LOGOUT: '/?/logout',
ANMELDUNG_GET_VORGANG_BY_TOKEN: '/anmeldung?/getVorgangByToken',
ANMELDUNG_VORGANG_PARAM: (vorgangToken: string) => `/anmeldung?vorgang=${vorgangToken}`
};
export const API_ROUTES = {
LIST: '/api/list',
VORGANG: (vorgangToken: string) => `/api/list/${vorgangToken}`,
// via `HEAD` method
VORGANG_NAME_EXIST: (vorgangName: string) => `/api/list/${vorgangName}`,
VORGANG_PIN: (vorgangName: string) => `/api/vorgang/${vorgangName}/vorgangPIN`,
// Tatort
CRIME: (vorgangToken: string, crimeName: string) => `/api/list/${vorgangToken}/${crimeName}`,
// Users
USERS: '/api/users',
USER: (userId: string) => `/api/users/${userId}`
};
const isProd = process.env.NODE_ENV == 'production';
export const DB_FULLPATH = !isProd ? './src/lib/data/tatort.db' : '/daten/tatort.db';

Some files were not shown because too many files have changed in this diff Show More