222 Commits

Author SHA1 Message Date
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
5927f1dacd fix SonarQube issue, mainly type annotations 2025-08-01 10:29:34 +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
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
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
ee6b9fcec1 fixed Comments of Jared 2025-06-24 18:06:59 +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
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
90 changed files with 4095 additions and 2266 deletions

3
.dockerignore Normal file
View File

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

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
test-results
node_modules
config.json
# Output
.output

18
Dockerfile.dev Normal file
View File

@@ -0,0 +1,18 @@
# --- 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
RUN npm run init-db
# --- Production stage ---
FROM node:24-alpine
COPY --from=build /app .
ENV HOST=0.0.0.0
EXPOSE 3000
CMD ["sh", "-c", "ORIGIN=https://tatort-dev.innovation-hub-niedersachsen.de node build/index.js"]

View File

@@ -6,6 +6,7 @@ WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . ./
COPY config_prod.json ./config.json
RUN npm run build
# --- Production stage ---
@@ -14,4 +15,3 @@ COPY --from=build /app .
ENV HOST=0.0.0.0
EXPOSE 3000
CMD ["sh", "-c", "ORIGIN=https://tatort.innovation-hub-niedersachsen.de node build/index.js"]

137
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,137 @@
/* 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('Test & Security Audit') {
steps {
script {
didRun = true
}
echo 'Start checking security vulnerabilities in npm packages'
sh 'npm audit --audit-level=moderate'
}
}
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

@@ -1,10 +1,10 @@
{
"minio": {
"endPoint": "api-s3.innovation-hub-niedersachsen.de",
"endPoint": "sws3.innovation-hub-niedersachsen.de",
"port": 443,
"useSSL": true,
"accessKey": "GxKhfnfkNvlDU7qzsz0D",
"secretKey": "cqSM5rIRr4MPtqzu2sNKgmB9k2OghPbyxwAWogeM"
"accessKey": "wjpKrmaqXra99rX3D61H",
"secretKey": "fTPi0u0FR6Lv9Y9IKydWv6WM0EA5XrsK008HCt9u"
},
"jwt": {
"secret": "@S2!q@@wXz$dCQ8JoVsHLpzaJ6JCfB",
@@ -14,4 +14,4 @@
"admin": { "password": "A-InnoHUB_2025!", "admin": true },
"user": { "password": "U-InnoHUB_2025!", "admin": false }
}
}
}

17
config_dev.json Normal file
View File

@@ -0,0 +1,17 @@
{
"minio": {
"endPoint": "sws3.innovation-hub-niedersachsen.de",
"port": 443,
"useSSL": true,
"accessKey": "wjpKrmaqXra99rX3D61H",
"secretKey": "fTPi0u0FR6Lv9Y9IKydWv6WM0EA5XrsK008HCt9u"
},
"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'],

3239
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -14,40 +14,46 @@
"lint": "prettier --check . && eslint .",
"test:unit": "vitest",
"test": "npm run test:unit -- --run && npm run test:e2e",
"test:e2e": "playwright test"
"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",
"@sveltejs/kit": "^2.21.3",
"@sveltejs/vite-plugin-svelte": "^5.1.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"
"@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.3"
},
"dependencies": {
"@google/model-viewer": "^4.1.0",
"@sveltejs/adapter-node": "^5.2.12",
"@tailwindcss/forms": "^0.5.10",
"autoprefixer": "^10.4.21",
"better-sqlite3": "^12.2.0",
"jsonwebtoken": "^9.0.2",
"jssha": "^3.3.1",
"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 +1,16 @@
import { decryptToken } from '$lib/auth';
import type { Handle } from '@sveltejs/kit';
/** @type {import('@sveltejs/kit').Handle} */
export async function handle({ event, resolve }) {
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 (err) {
await event.cookies.delete('session');
} catch (_) {
event.cookies.delete('session', {path: '/'});
event.locals.user = null;
}
return resolve(event);
return await resolve(event);
}

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

@@ -0,0 +1,36 @@
import Database from 'better-sqlite3';
import jsSHA from 'jssha';
const db = new Database('./src/lib/data/tatort.db');
let createSQLStmt = `CREATE TABLE IF NOT EXISTS users
(id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
pw TEXT NOT NULL)`;
db.exec(createSQLStmt);
// check if there are any users; if not add one default admin one
const userPassword = 'A-InnoHUB_2025!';
const hashedUserPassword = new jsSHA('SHA-512', 'TEXT').update(userPassword).getHash('HEX');
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 });
}

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

@@ -0,0 +1,34 @@
import jwt from 'jsonwebtoken';
import jsSHA from 'jssha';
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;
// hash user password
const hashedPW = new jsSHA('SHA-512', 'TEXT').update(password).getHash('HEX');
const getUserSQLStmt = 'SELECT name, pw FROM users WHERE name = ?';
const row = db.prepare(getUserSQLStmt).get(user);
const storedPW = row.pw;
if (hashedPW && hashedPW === storedPW) {
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

@@ -173,7 +173,7 @@
}
</style>
<script>
<script lang="ts">
export let href = null;
export let type = 'button';
export let size = 'md';

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,37 @@
<script>
import Profile from "$lib/icons/Profile.svelte";
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="/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"
>
<!--icon-->
<Profile />
{data?.user?.id}
</a>
</div>
</div>
</div>
</footer>
</div>

View File

@@ -0,0 +1,36 @@
<script lang="ts">
import Chevron from '$lib/icons/Chevron-right.svelte';
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="/" 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>
</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

@@ -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());

BIN
src/lib/data/tatort.db Normal file

Binary file not shown.

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 } 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('tatort', 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,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="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: 402 B

View File

@@ -6,3 +6,7 @@ import config from '$lib/config';
/** export const client = new Minio.Client(config.minio); */
export const client = new Client(config.minio);
export const BUCKET = 'tatort';
export const TOKENFILENAME = '__perm__';
export const CONFIGFILENAME = 'config.json';

View File

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

View File

@@ -0,0 +1,3 @@
import Database from 'better-sqlite3';
export const db = new Database('./src/lib/data/tatort.db');

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,189 @@
import { fail } from '@sveltejs/kit';
import { BUCKET, client, CONFIGFILENAME, TOKENFILENAME } from '$lib/minio';
import { checkIfExactDirectoryExists, getContentOfTextObject } from './s3ClientService';
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;
};
/**
* 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;
};

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 { redirect, type ServerLoadEvent } from '@sveltejs/kit';
import type { PageServerLoad } from '../anmeldung/$types';
export const load: PageServerLoad = (event: ServerLoadEvent) => {
if (!event.locals.user && event.url.pathname !== '/anmeldung') throw redirect(303, '/anmeldung');
return {
user: event.locals.user
};
}

View File

@@ -1,84 +1,18 @@
<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>
<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>

View File

@@ -1,10 +1,11 @@
<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';
<script>
import Panel from '$lib/components/ui/Panel.svelte';
export let data;
export let outline = true;
</script>
<div
@@ -16,20 +17,7 @@
<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
@@ -40,52 +28,12 @@
</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>
</div>
<a href="/tatorte" class="mt-6 block font-semibold text-gray-900">
Neueer Vorgang
<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>
<AddProcess class=" group-hover:text-indigo-600" />
</div>
<a href="/upload" class="mt-6 block font-semibold text-gray-900">
Hinzufügen
@@ -98,20 +46,7 @@
<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>
<FileRect class=" group-hover:text-indigo-600" {outline} />
</div>
<a href="/view" class="mt-6 block font-semibold text-gray-900">
Ansicht
@@ -121,3 +56,6 @@
</div>
</div>
</div>
<style>
</style>

View File

@@ -0,0 +1,10 @@
import { getVorgaenge } from '$lib/server/vorgangService';
import type { PageServerLoad } from '../../(token-based)/view/$types';
export const load: PageServerLoad = async () => {
const vorgangList = getVorgaenge();
return {
vorgangList
};
};

View File

@@ -1,72 +1,40 @@
<style>
ul {
min-width: 24rem;
}
</style>
<script lang="ts">
import { onMount } from 'svelte';
import { page } from '$app/stores';
import Trash from '$lib/icons/Trash.svelte';
import Folder from '$lib/icons/Folder.svelte';
import type { PageData } from '../$types';
/**
* @type any[]
*/
let list: any[] = [];
//$: list;
export let data: PageData;
onMount(async () => {
const response = await fetch('/api/list');
const stream = await 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);
}
});
const vorgangList = data.vorgangList;
async function delete_item(ev: Event) {
let delete_item = window.confirm("Bist du sicher?");
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]
const target = ev.currentTarget as HTMLElement | null;
if (!target) return;
let filename = target.id.split('del__')[1];
// delete request
// --------------
// delete request
// --------------
let url = `/api/list/${filename}`;
let url = `/api/list/${filename}`
console.log(`--- ${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);
}
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);
}
}
}
}
</script>
@@ -76,36 +44,23 @@
</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}
{#each vorgangList as vorgangItem}
<li>
<a href="/list/{item.name}" class="flex justify-between gap-x-6 py-5">
<a href="/list/{vorgangItem.vorgangToken}?pin={vorgangItem.vorgangPIN}" 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="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>
<!-- Ordner -->
<Folder />
<div class="min-w-0 flex-auto">
<span class="text-sm font-semibold leading-6 text-gray-900">{item.name}</span>
<span class="text-sm font-semibold leading-6 text-gray-900">{vorgangItem.vorgangName}</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>
style="padding: 2px"
id="del__{vorgangItem.vorgangToken}"
on:click|preventDefault={delete_item}
aria-label="Vorgang {vorgangItem.name} löschen"
>
<Trash />
</button>
</div>
</div>
<div class="hidden sm:flex sm:flex-col sm:items-end">
@@ -117,3 +72,9 @@
</ul>
</div>
</div>
<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,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

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

View File

@@ -1,10 +1,10 @@
<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';
<script lang="ts">
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 Exclamation from '$lib/icons/Exclamation.svelte';
export let form;
@@ -27,9 +27,9 @@
<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"
<label for="vorgangNumber" class="block text-sm font-medium leading-6 text-gray-900"
><span class="flex"
>{#if form?.error?.caseNumber}
>{#if form?.error?.vorgangNumber}
<span class="inline-block mr-1"><Exclamation /></span>
{/if} Vorgangs-Nr.</span
></label
@@ -39,43 +39,43 @@
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 ?? ''}
value={form?.vorgangNumber ?? ''}
type="text"
name="caseNumber"
id="caseNumber"
name="vorgangNumber"
id="vorgangNumber"
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 form?.error?.vorgangNumber}
<p class="block text-sm leading-6 text-red-900 mt-2">{form.error.vorgangNumber}</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}
>{#if form?.description}
<span class="inline-block mr-1"><Exclamation /></span>
{/if} Beschreibung</span
></label
>
<div class="mt-2">
<textarea
value={form?.description ?? ''}
value={form?.description?.toString() ?? ''}
id="description"
name="description"
rows="3"
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
></textarea>
</div>
{#if form?.error?.description}
<p class="block text-sm leading-6 text-red-900 mt-2">{form.error.description}</p>
{#if form?.error}
<p class="block text-sm leading-6 text-red-900 mt-2">{form.description}</p>
{/if}
</div>
<label for="code">
<span >Zugangscode (optional) </span>
<label for="vorgang-token">
<span >Zugangstoken (optional) </span>
</label>
<div class="mt-2">
@@ -83,7 +83,7 @@
>
<input
type="text"
id="code"
id="vorgang-token"
/>
</div>
</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,125 @@
import { Readable } from 'stream';
import { client } from '$lib/minio';
import { fail } from '@sveltejs/kit';
import { v4 as uuidv4 } from 'uuid';
import { db } from '$lib/server/dbService';
import { getVorgangByName, vorgangNameExists } 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 vorgangPIN: string | null = data.get('vorgangPIN') as string;
const fileName: string | null = data.get('fileName') as string;
const vorgangExists = vorgangNameExists(vorgangName);
let vorgangToken;
if (!vorgangExists) {
vorgangToken = uuidv4();
const insertSQLStatement = `INSERT INTO cases (token, name, pin) VALUES (?, ?, ?)`;
const statement = db.prepare(insertSQLStatement);
statement.run(vorgangToken, vorgangName, vorgangPIN);
} else {
const vorgang = getVorgangByName(vorgangName);
vorgangToken = vorgang.token;
if (vorgang && vorgang.pin != vorgangPIN) {
const updateSQLStmt = `UPDATE cases SET pin = ? WHERE token = ?`;
const statement = db.prepare(updateSQLStmt);
statement.run(vorgangPIN, vorgangToken);
}
}
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('tatort', 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;
const vorgangPIN = data.vorgangPIN;
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 (isRequiredFieldValid(vorgangPIN)) {
err.vorgangPIN = null;
} else {
err.vorgangPIN = 'Das Feld Zugangspasswort 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('tatort', `${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('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;
} catch (err) {
error = err;
console.log('Error:', err);
}
return { etag, error };
}
};

View File

@@ -1,45 +1,48 @@
<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';
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)
data.append('vorgangPIN', vorgangPIN);
const response = await fetch('?/validate', { method: 'POST', body: data });
/** @type {import('@sveltejs/kit').ActionResult} */
const result = deserialize(await response.text());
@@ -52,7 +55,6 @@
success = false;
}
console.log('File', files);
if (!files?.length) {
formErrors = { file: 'Sie haben keine Datei ausgewählt.', ...formErrors };
success = false;
@@ -62,7 +64,6 @@
formErrors = { file: 'Keine gültige .GLD-Datei', ...formErrors };
success = false;
}
return success;
}
@@ -70,7 +71,7 @@
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);
@@ -83,14 +84,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 +97,6 @@
.then((response) => {
inProgress = false;
etag = '123';
console.log('SUCCESS', response);
})
.catch((err) => {
inProgress = false;
@@ -108,7 +106,6 @@
}
function uploadSuccessful() {
console.log('reset');
open = false;
vorgang = '';
name = '';
@@ -119,69 +116,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;
// `/(angemeldet)/view` return true or false
async function checkVorgangExists(vorgangName: string) {
if (vorgangName == '') {
vorgangPIN = vorgangPINOld;
return;
}
case_existing = false;
try {
const url = `/api/list/${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/list/${vorgangName}/vorgangPIN`;
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 +214,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 +228,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 +247,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 +270,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 +282,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 +319,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

@@ -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

@@ -0,0 +1,22 @@
import {
vorgangPINValidation,
vorgangExists
} from '$lib/server/vorgangService';
import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './list/[vorgang]/$types';
export const load: PageServerLoad = async ({ params, url, locals }) => {
if (locals.user) {
return {
user: locals.user
};
}
const vorgangToken = params.vorgang;
const vorgangPIN = url.searchParams.get('pin');
const isVorgangValid = vorgangExists(vorgangToken);
const isVorgangPINValid = vorgangPINValidation(vorgangToken, vorgangPIN);
if (!isVorgangValid || !isVorgangPINValid) throw redirect(303, `/anmeldung?vorgang=${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,16 @@
import { getVorgangByToken, getCrimesListByToken } from '$lib/server/vorgangService';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ params, url }) => {
const vorgangToken = params.vorgang;
const vorgangPIN = url.searchParams.get('pin');
const crimesList = await getCrimesListByToken(vorgangToken);
const vorgang = getVorgangByToken(vorgangToken);
return {
crimesList,
vorgangPIN,
vorgang
};
};

View File

@@ -0,0 +1,284 @@
<script lang="ts">
import shortenFileSize from '$lib/helper/shortenFileSize';
import { page } from '$app/stores';
import timeElapsed from '$lib/helper/timeElapsed';
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 Edit from '$lib/icons/Edit.svelte';
import Trash from '$lib/icons/Trash.svelte';
/** export let data; */
/** @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
}
const vorgang = data.vorgang;
const crimesList: ListItem[] = data.crimesList;
const vorgangPIN: string = data.vorgangPIN;
let open = false;
$: open;
let inProgress = false;
$: inProgress;
let err = false;
$: err;
let rename_input;
$: rename_input;
function uploadSuccessful() {
open = false;
}
function defocus_element(i: number) {
let item = crimesList[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
crimesList[i].show_button = true;
return;
}
async function handle_input(ev: KeyboardEvent, i: number) {
let item = crimesList[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') {
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;
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();
return;
}
throw new Error(`Fehlgeschlagen: ${response.status}`);
} else {
uploadSuccessful();
setTimeout(() => {
window.location.reload();
}, 500);
}
// --- upload finished ---
return;
}
}
async function setClipboard(text) {
const type = "text/plain";
const clipboardItemData = {
[type]: text,
};
const clipboardItem = new ClipboardItem(clipboardItemData);
await navigator.clipboard.write([clipboardItem]);
}
</script>
<div class="-z-10 bg-white">
<div class="flex flex-col items-center justify-center w-full">
<h1 class="text-xl">Vorgang {vorgang.name}</h1>
{#if data?.user?.admin}
Zugangs-PIN: {vorgang.pin}
<Button on:click={() => setClipboard($page.url.toString().split('?')[0])}>Copy Link</Button>
{/if}
</div>
<div class="mx-auto flex justify-center max-w-7xl h-full">
<ul class="divide-y divide-gray-100">
{#each crimesList as item, i}
<li>
<a
href="/view/{$page.params.vorgang}/{item.name}?pin={vorgangPIN}"
class=" flex justify-between gap-x-6 py-5"
aria-label="zum 3D-modell"
>
<div class=" flex gap-x-4">
<Cube />
<div class="min-w-0 flex-auto">
{#if data?.user?.admin}
<span
id="label__{item.name}"
class="text-sm font-semibold leading-6 text-gray-900 inline-block min-w-1"
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
>
{#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;
}}
>
<Edit />
</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}`;
try {
const response = await fetch(`/api${url.pathname}`, { 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"
>
<Trash />
</button>
{:else}
<span class="text-sm font-semibold leading-6 text-gray-900 inline-block min-w-1"
>{item.name}</span
>
{/if}
<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>
<style>
ul {
min-width: 24rem;
}
</style>

View File

@@ -3,25 +3,24 @@ import { json } from '@sveltejs/kit';
// rename operation
export async function PUT({ request }) {
export async function PUT({ request }: {request: Request}) {
const data = await request.json();
console.log(`--- ${request.url.split('/').at(-1)} +++ ${JSON.stringify(data)}`);
// Vorgang
let vorgang = request.url.split('/').at(-1)
const 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"]}`
const old_name = data["old_name"];
const src_full_path = `/tatort/${vorgang}/${old_name}`;
const 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 })
await client.statObject('tatort', new_name);
return json({ msg: 'Die Datei existiert bereits.' }, { status: 400 });
} catch (error) {
// continue operation
console.log('continue operation')
console.log(error, 'continue operation');
}
// actual copy operation

View File

@@ -0,0 +1,11 @@
import { redirect } from '@sveltejs/kit';
export const actions = {
default: async ({request}: {request: Request}) => {
const data = await request.formData();
const vorgangId: string | null = data.get('vorgang-id') as string;
const vorgangToken: string | null = data.get('vorgang-token') as string;
if( vorgangId && vorgangToken) throw redirect(303, `/list/${vorgangId}?token=${vorgangToken}`);
}
}

View File

@@ -0,0 +1,39 @@
<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';
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>
<p class="mt-8 mb-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>
<form method="POST">
<BaseInputField
id="vorgang-id"
name="vorgang-id"
label="Vorgangskennung"
type="text"
value={form?.vorgangId}
/>
<div class="mt-5">
<BaseInputField
id="vorgang-token"
name="vorgang-token"
label="Zugangstoken"
type="text"
value={form?.vorgangToken}
error={form?.error?.message}
/>
</div>
<div class="flex justify-end pt-4">
<Button type="submit"><ArrowRight /></Button>
</div>
</form>
</div>

View File

@@ -1,7 +1,7 @@
import { client } from '$lib/minio';
import type { PageServerLoad } from './$types';
/** @type {import('./$types').PageServerLoad} */
export async function load({ params }) {
export const load: PageServerLoad = async ({ params }) => {
const { vorgang, tatort } = params;
const url = await client.presignedUrl('GET', 'tatort', `${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,77 +20,51 @@
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')
);
cameraAzimuth = 0;
cameraPolar = 0;
cameraZoom = 100;
modelViewer.cameraOrbit = cameraOrbit;
modelViewer.cameraTarget = cameraTarget;
modelViewer.fieldOfView = fieldOfView;
cameraAzimuth = 0;
cameraPolar = 0;
cameraZoom = 100;
fieldOfView = '10deg';
if (modelViewer) {
cameraAzimuth = 0;
cameraPolar = 0;
cameraZoom = 100;
modelViewer.cameraOrbit = cameraOrbit;
modelViewer.cameraTarget = cameraTarget;
modelViewer.fieldOfView = fieldOfView;
cameraAzimuth = 0;
cameraPolar = 0;
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,16 @@
import { loginUser, logoutUser } from '$lib/server/authService';
import { redirect } from '@sveltejs/kit';
export const actions = {
login: ({ request, cookies }) => loginUser({ request, cookies }),
logout: (event) => logoutUser(event),
getVorgangByToken: async ({ request }) => {
const data = await request.formData();
const vorgangToken = data.get('vorgang-token');
const vorgangPIN = data.get('vorgang-pin');
if (!vorgangToken || !vorgangPIN) return;
throw redirect(303, `/list/${vorgangToken}?pin=${vorgangPIN}`);
}
} as const;

View File

@@ -1,38 +1,67 @@
<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';
<script lang="ts">
import BaseInputField from '$lib/components/BaseInputField.svelte';
import Button from '$lib/components/Button.svelte';
import Modal from '$lib/components/Modal/Modal.svelte';
import ModalContent from '$lib/components/Modal/ModalContent.svelte';
import ModalFooter from '$lib/components/Modal/ModalFooter.svelte';
import ModalTitle from '$lib/components/Modal/ModalTitle.svelte';
import ArrowRight from '$lib/icons/Arrow-right.svelte';
import Login from '$lib/icons/Login.svelte';
/** @type {import('./$types').ActionData} */
export let form;
let user = form?.user ?? '';
export let open = false;
function buttonClick() {}
import { page } from '$app/state';
const vorgangToken = page.url.searchParams.get('vorgang');
</script>
<!--
This example requires updating your template:
```
<html class="h-full bg-white">
<body class="h-full">
```
-->
<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="mt-10 sm:mx-auto sm:w-full sm:max-w-sm">
<form class="space-y-6" action="?/login" method="POST">
<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="?/getVorgangByToken" method="POST">
<BaseInputField
id="vorgang-token"
name="vorgang-token"
label="Vorgangskennung"
type="text"
value={vorgangToken}
/>
<div class="mt-5">
<BaseInputField
id="vorgang-pin"
name="vorgang-pin"
label="Zugangs-PIN"
type="text"
value={form?.vorgangPIN}
error={form?.error?.message}
/>
</div>
<div class="flex justify-end pt-4">
<Button type="submit"><ArrowRight /></Button>
</div>
</form>
</div>
</div>
<div class="flex justify-end mt-10 px-3">
<Button on:click={() => (open = true)}><Login /></Button>
</div>
</div>
</div>
<Modal {open}>
<ModalTitle>Anmelden</ModalTitle>
<ModalContent class="flex justify-center">
<form action="?/login" method="POST">
<div>
<label for="user" class="block text-sm font-medium leading-6 text-gray-900">Kennung</label>
<label for="user" class="text-sm font-medium leading-6 text-gray-900">Kennung</label>
<div class="mt-2">
<input
id="user"
@@ -40,17 +69,15 @@
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"
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>
<div class="flex items-center justify-between">
<label for="password" class="block text-sm font-medium leading-6 text-gray-900"
>Passwort</label
>
</div>
<label for="password" class="block text-sm font-medium leading-6 text-gray-900"
>Passwort</label
>
<div class="mt-2">
<input
id="password"
@@ -63,13 +90,10 @@
</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">
<Button type="submit" class="mt-5">Anmelden</Button>
</div>
</form>
</div>
</div>
</ModalContent>
<ModalFooter><Button on:click={() => (open = false)}>Ok</Button></ModalFooter>
</Modal>

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,40 @@
import { client } from '$lib/minio';
import { deleteVorgangByToken, vorgangNameExists } 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('tatort', 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('tatort', 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 });
}
}

View File

@@ -0,0 +1,35 @@
import { BUCKET, client } from '$lib/minio';
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 }: { request: 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 });
}

View File

@@ -0,0 +1,16 @@
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 });
}
}

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);
}

14
static/1.svg Normal file
View File

@@ -0,0 +1,14 @@
<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>

After

Width:  |  Height:  |  Size: 714 B

View File

@@ -10,7 +10,9 @@
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler"
}
},
"include": ["src/**/*", "src/node_modules"],
"exclude": ["node_modules/*", "__sapper__/*", "public/*"]
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
//