From f176c40a02d0710c188cb86d11c46465d1e8600b Mon Sep 17 00:00:00 2001 From: olaf Date: Fri, 27 Jun 2025 08:22:01 +0000 Subject: [PATCH] first kanban-view integration for client groups --- dashboard/package-lock.json | 340 ++++++++++-------- dashboard/package.json | 9 +- dashboard/src/App.css | 5 + dashboard/src/App.tsx | 55 ++- dashboard/src/apiClients.ts | 11 + dashboard/src/apiGroups.ts | 19 + dashboard/src/dashboard.tsx | 3 +- dashboard/src/gruppen.tsx | 8 - dashboard/src/infoscreen_groups.tsx | 203 +++++++++++ dashboard/src/main.tsx | 2 +- ...dd_client_groups_table_and_group_id_to_.py | 57 +++ server/dummy_clients.py | 45 +++ server/dummy_events.py | 228 ++---------- server/models.py | 38 +- server/wsgi.py | 108 +++++- 15 files changed, 751 insertions(+), 380 deletions(-) create mode 100644 dashboard/src/apiGroups.ts delete mode 100644 dashboard/src/gruppen.tsx create mode 100644 dashboard/src/infoscreen_groups.tsx create mode 100644 server/alembic/versions/8a45ec34f84d_add_client_groups_table_and_group_id_to_.py create mode 100644 server/dummy_clients.py diff --git a/dashboard/package-lock.json b/dashboard/package-lock.json index ec436ac..fa77e88 100644 --- a/dashboard/package-lock.json +++ b/dashboard/package-lock.json @@ -8,10 +8,11 @@ "name": "dashboard", "version": "0.0.0", "dependencies": { - "@syncfusion/ej2-react-buttons": "^29.2.5", - "@syncfusion/ej2-react-calendars": "^29.2.11", - "@syncfusion/ej2-react-grids": "^29.2.11", - "@syncfusion/ej2-react-schedule": "^29.2.10", + "@syncfusion/ej2-react-buttons": "^30.1.37", + "@syncfusion/ej2-react-calendars": "^30.1.37", + "@syncfusion/ej2-react-grids": "^30.1.37", + "@syncfusion/ej2-react-kanban": "^30.1.37", + "@syncfusion/ej2-react-schedule": "^30.1.37", "cldr-data": "^36.0.4", "lucide-react": "^0.522.0", "react": "^19.1.0", @@ -1637,264 +1638,301 @@ ] }, "node_modules/@syncfusion/ej2-base": { - "version": "29.2.11", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-base/-/ej2-base-29.2.11.tgz", - "integrity": "sha512-f1yM+6606zde7MR4q4d/q6foR3viHDA1/SkkTbLVwBME7I/0AcMG/i0eeTWJfJS8dgn91DGrsrEl0nZ9IA1CEQ==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-base/-/ej2-base-30.1.37.tgz", + "integrity": "sha512-/RXLTid6XaKEyqBttyhO6FsGHhGitOzxPv64qo4AtE+33uU2usCRuBY4QZtGq5SBMQs7tIvjdtwff989jWHgzQ==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-icons": "~29.2.4" + "@syncfusion/ej2-icons": "~30.1.37" }, "bin": { "syncfusion-license": "bin/syncfusion-license.js" } }, "node_modules/@syncfusion/ej2-buttons": { - "version": "29.2.5", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-buttons/-/ej2-buttons-29.2.5.tgz", - "integrity": "sha512-FbMi9rUi/7i8mpPA6KRaO7qW/3wIeH759u2/Ag0iMQUEdtdK7NvOCSFF29WESeBjW6GmEJ8zkW0340ymgXZruQ==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-buttons/-/ej2-buttons-30.1.37.tgz", + "integrity": "sha512-31dPIDSkraFlR8+sCz2NtM1tg9TSBN2YRHC7mBZGDWX6B26ie4zbe63S22l0ytaoMDt3XHqExsk7MLlnG3LR8g==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.4" + "@syncfusion/ej2-base": "~30.1.37" } }, "node_modules/@syncfusion/ej2-calendars": { - "version": "29.2.11", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-calendars/-/ej2-calendars-29.2.11.tgz", - "integrity": "sha512-RphIYxXwaDv59QiYjswIntNyDxOqd3oQqi2G9Z3zRD+Ez1u+ybY9koaWbj5Dq/5AsFhdNCwHhyEPX9gACZMsvA==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-calendars/-/ej2-calendars-30.1.37.tgz", + "integrity": "sha512-9g41zBRizXilbRJWHJgqRYJPpX0WJF5qJwGNpgvsBnyYdolYQy///x6c3oYo9W6YG28N0QDavdbOaxwprj4ghg==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.11", - "@syncfusion/ej2-buttons": "~29.2.5", - "@syncfusion/ej2-inputs": "~29.2.5", - "@syncfusion/ej2-lists": "~29.2.4", - "@syncfusion/ej2-popups": "~29.2.8" + "@syncfusion/ej2-base": "~30.1.37", + "@syncfusion/ej2-buttons": "~30.1.37", + "@syncfusion/ej2-inputs": "~30.1.37", + "@syncfusion/ej2-lists": "~30.1.37", + "@syncfusion/ej2-popups": "~30.1.37" } }, "node_modules/@syncfusion/ej2-compression": { - "version": "29.2.4", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-compression/-/ej2-compression-29.2.4.tgz", - "integrity": "sha512-mcgFmgtITGxoX4zV4LrFGAOHOQD8Z7is85vQE+k2Bf4OI6rZsLNIQFm6KEFg+sZMOSrABzKzg49yrktmlus4TQ==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-compression/-/ej2-compression-30.1.37.tgz", + "integrity": "sha512-QA5oAJZDaAONO12zwVCc1IqYTmiwthSoWaMoE0jgQR+mpYR8XmlMi1VOvP8Jtu+HlfQMaEGcMQ++UM5UeZW4+g==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-file-utils": "~29.2.4" + "@syncfusion/ej2-file-utils": "~30.1.37" } }, "node_modules/@syncfusion/ej2-data": { - "version": "29.2.4", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-data/-/ej2-data-29.2.4.tgz", - "integrity": "sha512-2R+N65OPq+yfwTXyBz7NdD8MHGoxUbJSEWGT0kNEGMiobiI4AL+hfMYEhXWXE+DqL5Pm0txA4gTXQprFXXbccg==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-data/-/ej2-data-30.1.37.tgz", + "integrity": "sha512-UGbF1a95BmdRcgkgekMOdJY0kcNSaOrKWLlnZxFkEl9SSvN+mxPa7ktgXHlEWRc+KY/WeNSV2kmyZ8h/htnAXQ==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.4" + "@syncfusion/ej2-base": "~30.1.37" } }, "node_modules/@syncfusion/ej2-dropdowns": { - "version": "29.2.11", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-dropdowns/-/ej2-dropdowns-29.2.11.tgz", - "integrity": "sha512-NtWQexED+1T4Ef/vPkG+C9ANkUD3QPvXelyQaS2+j+mzipOhSBGiDcJYIE1R1wtqC3BhLfMZBPJbuXGc0p+mmQ==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-dropdowns/-/ej2-dropdowns-30.1.37.tgz", + "integrity": "sha512-yk4Pous9P2Ccg/QoX+fmJatn5ypbWWTvptEd5h5p4Wb0qlvwJIPuJo/KkcyK2vUx7kRzN5dzmUX7cKP7Z1ZhPg==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.11", - "@syncfusion/ej2-data": "~29.2.4", - "@syncfusion/ej2-inputs": "~29.2.5", - "@syncfusion/ej2-lists": "~29.2.4", - "@syncfusion/ej2-navigations": "~29.2.8", - "@syncfusion/ej2-notifications": "~29.2.4", - "@syncfusion/ej2-popups": "~29.2.8" + "@syncfusion/ej2-base": "~30.1.37", + "@syncfusion/ej2-data": "~30.1.37", + "@syncfusion/ej2-inputs": "~30.1.37", + "@syncfusion/ej2-lists": "~30.1.37", + "@syncfusion/ej2-navigations": "~30.1.37", + "@syncfusion/ej2-notifications": "~30.1.37", + "@syncfusion/ej2-popups": "~30.1.37" } }, "node_modules/@syncfusion/ej2-excel-export": { - "version": "29.2.4", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-excel-export/-/ej2-excel-export-29.2.4.tgz", - "integrity": "sha512-N3VAdlhP+Wq/Uyl82ZSx6x8zL3slgtEKzWb13nrfas7cdJicYrbx02YZru5/euaeE3yGTlbKmhjjLLbkVFU/kQ==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-excel-export/-/ej2-excel-export-30.1.37.tgz", + "integrity": "sha512-AMOTpy/uzb6QzKHgQdofA2P0Ec1KLmfT9vDXPzmF3npsPbqL0a+6K73MaZZKjW8rBrwohnbJV2R+acotpW/Seg==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.4", - "@syncfusion/ej2-compression": "~29.2.4" + "@syncfusion/ej2-base": "~30.1.37", + "@syncfusion/ej2-compression": "~30.1.37" } }, "node_modules/@syncfusion/ej2-file-utils": { - "version": "29.2.4", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-file-utils/-/ej2-file-utils-29.2.4.tgz", - "integrity": "sha512-nnvZ+1xVULe418habMciZnDAoMOM+TqFaFpO9kf4Cct9RPYUr22Tsvu84CZI7yzzKj/dLfD4n5TRRCHVo+5vVA==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-file-utils/-/ej2-file-utils-30.1.37.tgz", + "integrity": "sha512-1r0rWrXEsXsRJhG0yOs8Hp2nGARLsBCD4u602R4IxLDrockIPVJv4gz0rIw4dDtFW7bpAa8J+yWXtr6fW29Bhw==", "license": "SEE LICENSE IN license" }, "node_modules/@syncfusion/ej2-grids": { - "version": "29.2.11", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-grids/-/ej2-grids-29.2.11.tgz", - "integrity": "sha512-11jI7ve/qxQVsA4kP+v0Y1bEfO7kFCCtBekag80Fy+yio88Wcr5c1Q9SxgsmZtX+Kzk6oSymS497/zNcBDsUJw==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-grids/-/ej2-grids-30.1.37.tgz", + "integrity": "sha512-EG8RzzPCML9UULAN+SZdo/G5j8AsmzKzwQvocvZoL/YOfDPWom8WaGXNbE5pssMmIEnF2YnQkMuwRWg1tLHyog==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.11", - "@syncfusion/ej2-buttons": "~29.2.5", - "@syncfusion/ej2-calendars": "~29.2.11", - "@syncfusion/ej2-compression": "~29.2.4", - "@syncfusion/ej2-data": "~29.2.4", - "@syncfusion/ej2-dropdowns": "~29.2.11", - "@syncfusion/ej2-excel-export": "~29.2.4", - "@syncfusion/ej2-file-utils": "~29.2.4", - "@syncfusion/ej2-inputs": "~29.2.5", - "@syncfusion/ej2-lists": "~29.2.4", - "@syncfusion/ej2-navigations": "~29.2.8", - "@syncfusion/ej2-notifications": "~29.2.4", - "@syncfusion/ej2-pdf-export": "~29.2.4", - "@syncfusion/ej2-popups": "~29.2.8", - "@syncfusion/ej2-splitbuttons": "~29.2.4" + "@syncfusion/ej2-base": "~30.1.37", + "@syncfusion/ej2-buttons": "~30.1.37", + "@syncfusion/ej2-calendars": "~30.1.37", + "@syncfusion/ej2-compression": "~30.1.37", + "@syncfusion/ej2-data": "~30.1.37", + "@syncfusion/ej2-dropdowns": "~30.1.37", + "@syncfusion/ej2-excel-export": "~30.1.37", + "@syncfusion/ej2-file-utils": "~30.1.37", + "@syncfusion/ej2-inputs": "~30.1.37", + "@syncfusion/ej2-lists": "~30.1.37", + "@syncfusion/ej2-navigations": "~30.1.37", + "@syncfusion/ej2-notifications": "~30.1.37", + "@syncfusion/ej2-pdf-export": "~30.1.37", + "@syncfusion/ej2-popups": "~30.1.37", + "@syncfusion/ej2-splitbuttons": "~30.1.37" } }, "node_modules/@syncfusion/ej2-icons": { - "version": "29.2.4", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-icons/-/ej2-icons-29.2.4.tgz", - "integrity": "sha512-2DYZglxLM++w0S2wB2bcr/Akk1MODdVhfFYLaLqe6mDHDRicFeTEyvnGPx2SHS2EXXlNNFm2GfNWoNNxgs5MhQ==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-icons/-/ej2-icons-30.1.37.tgz", + "integrity": "sha512-bgPklX0jiaLESbWJDNx8f8PqVexwbRJHoz4kDgOJR4VN4JoOtC7Zw47Wb+eFwj13Ped1lTfuPfmU8sI1s5INeQ==", "license": "SEE LICENSE IN license" }, "node_modules/@syncfusion/ej2-inputs": { - "version": "29.2.5", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-inputs/-/ej2-inputs-29.2.5.tgz", - "integrity": "sha512-3ZqMl005qL0tENHcKvBfKUHMYQ/S0FRYjUDQVDPRsg28tE0Lz87oyamrxLYne3zDBEJ7kxWWnaNpgrTVvxsVNw==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-inputs/-/ej2-inputs-30.1.37.tgz", + "integrity": "sha512-6gOvtZO7ygdPnec8M7cr0TNBkENMmiW4YLnJTgGl5UgogQb+f8D8giE3SKqfWdmlJMBD1lzW96Ig4gW2n4JwMQ==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.4", - "@syncfusion/ej2-buttons": "~29.2.5", - "@syncfusion/ej2-popups": "~29.2.4", - "@syncfusion/ej2-splitbuttons": "~29.2.4" + "@syncfusion/ej2-base": "~30.1.37", + "@syncfusion/ej2-buttons": "~30.1.37", + "@syncfusion/ej2-popups": "~30.1.37", + "@syncfusion/ej2-splitbuttons": "~30.1.37" + } + }, + "node_modules/@syncfusion/ej2-kanban": { + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-kanban/-/ej2-kanban-30.1.37.tgz", + "integrity": "sha512-JiR7+CrLqaji0OaPx7BsvN/pM5hwWLMnJC9TPk6MbyMmsch8NlHBw+DMPl+0MbssNg2qFAoKmeOR6uNWv+EZvw==", + "license": "SEE LICENSE IN license", + "dependencies": { + "@syncfusion/ej2-base": "~30.1.37", + "@syncfusion/ej2-buttons": "~30.1.37", + "@syncfusion/ej2-data": "~30.1.37", + "@syncfusion/ej2-dropdowns": "~30.1.37", + "@syncfusion/ej2-inputs": "~30.1.37", + "@syncfusion/ej2-layouts": "~30.1.37", + "@syncfusion/ej2-navigations": "~30.1.37", + "@syncfusion/ej2-notifications": "~30.1.37", + "@syncfusion/ej2-popups": "~30.1.37" + } + }, + "node_modules/@syncfusion/ej2-layouts": { + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-layouts/-/ej2-layouts-30.1.37.tgz", + "integrity": "sha512-EPI00OSBMuzxp8od6jTOK2LRlv5IWtN4WmpIklUe34vev0qG9HLo8yT2BKCUIo5TRm4xEUXx0mQM7ZSKw2iHig==", + "license": "SEE LICENSE IN license", + "dependencies": { + "@syncfusion/ej2-base": "~30.1.37" } }, "node_modules/@syncfusion/ej2-lists": { - "version": "29.2.4", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-lists/-/ej2-lists-29.2.4.tgz", - "integrity": "sha512-U64nGdZMjnhHG/+YCTF+WhJ3BoUxFyN2DXxv2qlC+wtayMbfioDRwqSQgxTkH8XE4TgrkRFenRtj5SbYLKliSw==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-lists/-/ej2-lists-30.1.37.tgz", + "integrity": "sha512-Tot/4yjBoBlCPr49EKPL/yDHFoPhHlgp3bK6+LG5jgThQE+guB5sSlqlNl3Noui25oMTRcXlt29SHZwstdpsNg==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.4", - "@syncfusion/ej2-buttons": "~29.2.4", - "@syncfusion/ej2-data": "~29.2.4", - "@syncfusion/ej2-popups": "~29.2.4" + "@syncfusion/ej2-base": "~30.1.37", + "@syncfusion/ej2-buttons": "~30.1.37", + "@syncfusion/ej2-data": "~30.1.37", + "@syncfusion/ej2-popups": "~30.1.37" } }, "node_modules/@syncfusion/ej2-navigations": { - "version": "29.2.8", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-navigations/-/ej2-navigations-29.2.8.tgz", - "integrity": "sha512-u14J+dEocqGIKgWCC1eiATv1nh40dgILsGPpGbYS+h9Y7y4YMBRzL2UCcuNHXgPKL7SiJ5lCaVORFco8cxyh6A==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-navigations/-/ej2-navigations-30.1.37.tgz", + "integrity": "sha512-FD3hsT4a8fMdS3S7EFu9tnu741980HRK97fDAUgUtLGqDANC6Ee2HyeZZTjVeUpVAHfdomb/n7oYvtDUXZxwYw==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.4", - "@syncfusion/ej2-buttons": "~29.2.5", - "@syncfusion/ej2-data": "~29.2.4", - "@syncfusion/ej2-inputs": "~29.2.5", - "@syncfusion/ej2-lists": "~29.2.4", - "@syncfusion/ej2-popups": "~29.2.8" + "@syncfusion/ej2-base": "~30.1.37", + "@syncfusion/ej2-buttons": "~30.1.37", + "@syncfusion/ej2-data": "~30.1.37", + "@syncfusion/ej2-inputs": "~30.1.37", + "@syncfusion/ej2-lists": "~30.1.37", + "@syncfusion/ej2-popups": "~30.1.37" } }, "node_modules/@syncfusion/ej2-notifications": { - "version": "29.2.4", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-notifications/-/ej2-notifications-29.2.4.tgz", - "integrity": "sha512-rB9OuGHWVfnl9aBno+4KRH3aESbakLKYT70V7wjTxwS7u11XbxYwLiA4/YKsTQg/zrgOtcr3Ma1sVOeMYW17gQ==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-notifications/-/ej2-notifications-30.1.37.tgz", + "integrity": "sha512-ksXk9lTf0Iw5+4EarYjxG1rKU+e9ZbCOaxvl/PN+MP1w1BAFwu4jRwpE9mbPF2FQUxcL1xNCxTnspSQaH36f4Q==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.4", - "@syncfusion/ej2-buttons": "~29.2.4", - "@syncfusion/ej2-popups": "~29.2.4" + "@syncfusion/ej2-base": "~30.1.37", + "@syncfusion/ej2-buttons": "~30.1.37", + "@syncfusion/ej2-popups": "~30.1.37" } }, "node_modules/@syncfusion/ej2-pdf-export": { - "version": "29.2.4", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-pdf-export/-/ej2-pdf-export-29.2.4.tgz", - "integrity": "sha512-Cb5QKYqhuvEb96DzqJT6/nLuan8FkA40mU4Lggg5Ujo1OdIK3Ca5GolM7HStTct4DnU02UKuXTrqoL5umGTfKQ==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-pdf-export/-/ej2-pdf-export-30.1.37.tgz", + "integrity": "sha512-4vtuyp+IhB8FUdxnizwytYFYP7Uxdr0thFCEuT3p7T7v4HzwEIk1uingaO32Z4AD72LUNuzznnRTZNyd59VU7w==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-compression": "~29.2.4" + "@syncfusion/ej2-compression": "~30.1.37" } }, "node_modules/@syncfusion/ej2-popups": { - "version": "29.2.8", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-popups/-/ej2-popups-29.2.8.tgz", - "integrity": "sha512-LsXfTiFd6dyoE8XIxFOgC24TeQCqgLdjp3VOg0tWvyuWiZ/skH2sBlF2Y1CWqNJS07OKhtcjLY1h446RTBlalQ==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-popups/-/ej2-popups-30.1.37.tgz", + "integrity": "sha512-royzgtNf2BE330yBySDvLcnMHfDq1xxFKK4YocQJt5PAdYrm5mxIAmxrbbAO0LElI4GN0yQU8Xy4ne7VjqPzJg==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.4", - "@syncfusion/ej2-buttons": "~29.2.5" + "@syncfusion/ej2-base": "~30.1.37", + "@syncfusion/ej2-buttons": "~30.1.37" } }, "node_modules/@syncfusion/ej2-react-base": { - "version": "29.2.4", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-react-base/-/ej2-react-base-29.2.4.tgz", - "integrity": "sha512-Yri3M0IU6JJyrdLi+r7Ai1cejRwvOkqTxpZ/TG6gqcf2jaisvbATq0SrrTYXeFsXmHGpjfg6aCUtkRoexYwmrg==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-react-base/-/ej2-react-base-30.1.37.tgz", + "integrity": "sha512-9Mr+gGR9fb9ywlvXLU/sROH7qcQl/rnITR9wVndKtLP0kCULIAl0QVjaBP4krVIrV5rKIqpL4dEXOJhNVXwgNQ==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.4" + "@syncfusion/ej2-base": "~30.1.37" } }, "node_modules/@syncfusion/ej2-react-buttons": { - "version": "29.2.5", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-react-buttons/-/ej2-react-buttons-29.2.5.tgz", - "integrity": "sha512-L7XH6Tr7Eyq99xTpPWdcuCOXs0f6d1EjSO+ppjOcmiskdQMxCJO+Soew4ABzRHVamulmpkzlTzRsqJjtHn75fw==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-react-buttons/-/ej2-react-buttons-30.1.37.tgz", + "integrity": "sha512-QWvVNwfDBk9bZTM1otAmjGK9b8GeA/d1+/Db6skgBDcVzyQUBh26rCJeKMKOnyg/8DratkUG1VdfuhKL5YAMvA==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.4", - "@syncfusion/ej2-buttons": "29.2.5", - "@syncfusion/ej2-react-base": "~29.2.4" + "@syncfusion/ej2-base": "~30.1.37", + "@syncfusion/ej2-buttons": "30.1.37", + "@syncfusion/ej2-react-base": "~30.1.37" } }, "node_modules/@syncfusion/ej2-react-calendars": { - "version": "29.2.11", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-react-calendars/-/ej2-react-calendars-29.2.11.tgz", - "integrity": "sha512-o6SzmhR9Cuew0y6lijOPniyyJqHzuGoVtDFxp10/x+Tm2Ab1tyXgxpC2jqZLt0SFXcBl2l01h50Xnf0MZnEJSw==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-react-calendars/-/ej2-react-calendars-30.1.37.tgz", + "integrity": "sha512-RDHxN2q1Pj+yIfZIm9qyFMvQdrpWXGXIh51o3CREKViD26R2ykh5WmI6JICvgp+Mru1VS3nEIzzsXEsIDrwoaw==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.11", - "@syncfusion/ej2-calendars": "29.2.11", - "@syncfusion/ej2-react-base": "~29.2.4" + "@syncfusion/ej2-base": "~30.1.37", + "@syncfusion/ej2-calendars": "30.1.37", + "@syncfusion/ej2-react-base": "~30.1.37" } }, "node_modules/@syncfusion/ej2-react-grids": { - "version": "29.2.11", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-react-grids/-/ej2-react-grids-29.2.11.tgz", - "integrity": "sha512-HHSEb4ZpcncY/8QV+wbsR8ZVArnsGinwv9kLi2sGwJhS3yKm83aXAMojvPYSv1h5jX8ujnR0Y/YSi6MTYL4O+g==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-react-grids/-/ej2-react-grids-30.1.37.tgz", + "integrity": "sha512-QNnvwD88GYezX9glpGUEltFmUCKZORXz7w93BS2CfgTxsjJjdaZ8xzDi98J+aAUrUh6I44pMut5Sfb9QOBFH+g==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.11", - "@syncfusion/ej2-grids": "29.2.11", - "@syncfusion/ej2-react-base": "~29.2.4" + "@syncfusion/ej2-base": "~30.1.37", + "@syncfusion/ej2-grids": "30.1.37", + "@syncfusion/ej2-react-base": "~30.1.37" + } + }, + "node_modules/@syncfusion/ej2-react-kanban": { + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-react-kanban/-/ej2-react-kanban-30.1.37.tgz", + "integrity": "sha512-lcUwtLNBodSSHYQhYlG4ZiMt4kqQQLjoDBYuFu1GhDimshonwxkXEk+ekgPSHtgJFDJX5YEca/XT5jlm6gxBKw==", + "license": "SEE LICENSE IN license", + "dependencies": { + "@syncfusion/ej2-base": "~30.1.37", + "@syncfusion/ej2-kanban": "30.1.37", + "@syncfusion/ej2-react-base": "~30.1.37" } }, "node_modules/@syncfusion/ej2-react-schedule": { - "version": "29.2.10", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-react-schedule/-/ej2-react-schedule-29.2.10.tgz", - "integrity": "sha512-Ud3c5qrjY+NT9VPg3OoQ4YxnVYNj9Xi/12VVJS6cxbs0b91oXzoBSmQpoBVvFefVH0EUaRk7D9ILBs2TZIJj/Q==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-react-schedule/-/ej2-react-schedule-30.1.37.tgz", + "integrity": "sha512-Lw+9CYk6gLobmjWtt5dmsWkAXwgDb8IrNLyfkC9sos6ym0C4skR80gW0BP1n5xTZrWjtZSW1dMUlbMcyknus8w==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.4", - "@syncfusion/ej2-react-base": "~29.2.4", - "@syncfusion/ej2-schedule": "29.2.10" + "@syncfusion/ej2-base": "~30.1.37", + "@syncfusion/ej2-react-base": "~30.1.37", + "@syncfusion/ej2-schedule": "30.1.37" } }, "node_modules/@syncfusion/ej2-schedule": { - "version": "29.2.10", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-schedule/-/ej2-schedule-29.2.10.tgz", - "integrity": "sha512-PWbxLWfVCNxuEAyZos5c7Ne8lfXhQKR9vN4CNy+yMjRoO+rejI1/sH9iOeKpjCsVmO+ucZuG4IwPCz+qypQtsw==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-schedule/-/ej2-schedule-30.1.37.tgz", + "integrity": "sha512-1VGVuTYgqPIeVwcAqcbpoT18F+gygX+PP9e+oxDzQzSzi/YVYhNRFxrwzfm4Mhx/JLKArCn7Wr8WSidX+t9xow==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.4", - "@syncfusion/ej2-buttons": "~29.2.5", - "@syncfusion/ej2-calendars": "~29.2.10", - "@syncfusion/ej2-data": "~29.2.4", - "@syncfusion/ej2-dropdowns": "~29.2.10", - "@syncfusion/ej2-excel-export": "~29.2.4", - "@syncfusion/ej2-inputs": "~29.2.5", - "@syncfusion/ej2-lists": "~29.2.4", - "@syncfusion/ej2-navigations": "~29.2.8", - "@syncfusion/ej2-popups": "~29.2.8" + "@syncfusion/ej2-base": "~30.1.37", + "@syncfusion/ej2-buttons": "~30.1.37", + "@syncfusion/ej2-calendars": "~30.1.37", + "@syncfusion/ej2-data": "~30.1.37", + "@syncfusion/ej2-dropdowns": "~30.1.37", + "@syncfusion/ej2-excel-export": "~30.1.37", + "@syncfusion/ej2-inputs": "~30.1.37", + "@syncfusion/ej2-lists": "~30.1.37", + "@syncfusion/ej2-navigations": "~30.1.37", + "@syncfusion/ej2-popups": "~30.1.37" } }, "node_modules/@syncfusion/ej2-splitbuttons": { - "version": "29.2.4", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-splitbuttons/-/ej2-splitbuttons-29.2.4.tgz", - "integrity": "sha512-sZKs0IZJ6+rDK2OLRl+m5Rs1ai84GE9NV2hpDG5CPFv5uM5WoOf33qYOyp6BSuBerpobpycoXDWH/mh1fZSCDw==", + "version": "30.1.37", + "resolved": "https://registry.npmjs.org/@syncfusion/ej2-splitbuttons/-/ej2-splitbuttons-30.1.37.tgz", + "integrity": "sha512-V4MNbw8qBNumd7B4AlbmndxXGqILcSUoCrA+wBfLt6KZArZnuK8Y2zaD7fN9xoR1c/hoxlgo9sXyIxdPfi9Lyg==", "license": "SEE LICENSE IN license", "dependencies": { - "@syncfusion/ej2-base": "~29.2.4", - "@syncfusion/ej2-popups": "~29.2.4" + "@syncfusion/ej2-base": "~30.1.37", + "@syncfusion/ej2-popups": "~30.1.37" } }, "node_modules/@tailwindcss/aspect-ratio": { diff --git a/dashboard/package.json b/dashboard/package.json index 1a589cd..2862612 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -10,10 +10,11 @@ "preview": "vite preview" }, "dependencies": { - "@syncfusion/ej2-react-buttons": "^29.2.5", - "@syncfusion/ej2-react-calendars": "^29.2.11", - "@syncfusion/ej2-react-grids": "^29.2.11", - "@syncfusion/ej2-react-schedule": "^29.2.10", + "@syncfusion/ej2-react-buttons": "^30.1.37", + "@syncfusion/ej2-react-calendars": "^30.1.37", + "@syncfusion/ej2-react-grids": "^30.1.37", + "@syncfusion/ej2-react-kanban": "^30.1.37", + "@syncfusion/ej2-react-schedule": "^30.1.37", "cldr-data": "^36.0.4", "lucide-react": "^0.522.0", "react": "^19.1.0", diff --git a/dashboard/src/App.css b/dashboard/src/App.css index f76a276..b0901e5 100644 --- a/dashboard/src/App.css +++ b/dashboard/src/App.css @@ -8,4 +8,9 @@ @import "../node_modules/@syncfusion/ej2-popups/styles/material.css"; @import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css"; @import "../node_modules/@syncfusion/ej2-react-schedule/styles/material.css"; +@import "../node_modules/@syncfusion/ej2-kanban/styles/material.css"; + +body { + font-family: Inter, 'Segoe UI', Roboto, Arial, sans-serif; +} diff --git a/dashboard/src/App.tsx b/dashboard/src/App.tsx index cd84a9a..5360a3f 100644 --- a/dashboard/src/App.tsx +++ b/dashboard/src/App.tsx @@ -12,7 +12,8 @@ import { User, Settings, Monitor, - MonitorDotIcon + MonitorDotIcon, + LogOut, } from 'lucide-react'; const sidebarItems = [ @@ -20,7 +21,7 @@ const sidebarItems = [ { name: 'Termine', path: '/termine', icon: Calendar }, { name: 'Ressourcen', path: '/ressourcen', icon: Boxes }, { name: 'Infoscreens', path: '/Infoscreens', icon: Monitor }, - { name: 'Gruppen', path: '/gruppen', icon: MonitorDotIcon }, + { name: 'Gruppen', path: '/infoscr_groups', icon: MonitorDotIcon }, { name: 'Medien', path: '/medien', icon: Image }, { name: 'Benutzer', path: '/benutzer', icon: User }, { name: 'Einstellungen', path: '/einstellungen', icon: Settings }, @@ -54,9 +55,21 @@ const Layout: React.FC = () => { /> @@ -92,6 +105,38 @@ const Layout: React.FC = () => { ); })} + {/* Abmelden-Button immer ganz unten */} +
+ +
{/* Main Content */}
@@ -134,7 +179,7 @@ const App: React.FC = () => ( } /> } /> } /> - } /> + } /> } /> } /> } /> @@ -150,7 +195,7 @@ import Dashboard from './dashboard'; import Appointments from './appointments'; import Ressourcen from './ressourcen'; import Infoscreens from './clients'; -import Gruppen from './gruppen'; +import Infoscreen_groups from './infoscreen_groups'; import Medien from './medien'; import Benutzer from './benutzer'; import Einstellungen from './einstellungen'; diff --git a/dashboard/src/apiClients.ts b/dashboard/src/apiClients.ts index 079d77e..5ebf91f 100644 --- a/dashboard/src/apiClients.ts +++ b/dashboard/src/apiClients.ts @@ -6,6 +6,7 @@ export interface Client { hardware_hash: string; ip_address: string; last_alive: string | null; + group_id: number; // <--- Dieses Feld ergänzen } export async function fetchClients(): Promise { @@ -15,3 +16,13 @@ export async function fetchClients(): Promise { } return await response.json(); } + +export async function updateClientGroup(clientIds: string[], groupName: string) { + const res = await fetch('/api/clients/group', { + method: 'PUT', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ client_ids: clientIds, group_name: groupName }), + }); + if (!res.ok) throw new Error('Fehler beim Aktualisieren der Clients'); + return await res.json(); +} diff --git a/dashboard/src/apiGroups.ts b/dashboard/src/apiGroups.ts new file mode 100644 index 0000000..6ee0673 --- /dev/null +++ b/dashboard/src/apiGroups.ts @@ -0,0 +1,19 @@ +export async function createGroup(name: string) { + const res = await fetch('/api/groups', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ name }), + }); + if (!res.ok) throw new Error('Fehler beim Erstellen der Gruppe'); + return await res.json(); +} + +export async function fetchGroups() { + const res = await fetch('/api/groups'); + if (!res.ok) throw new Error('Fehler beim Laden der Gruppen'); + return await res.json(); +} + +// Hier kannst du später weitere Funktionen ergänzen: +// export async function deleteGroup(id: number) { ... } +// export async function updateGroup(id: number, name: string) { ... } diff --git a/dashboard/src/dashboard.tsx b/dashboard/src/dashboard.tsx index 44bd69e..e665f9e 100644 --- a/dashboard/src/dashboard.tsx +++ b/dashboard/src/dashboard.tsx @@ -13,9 +13,8 @@ const Dashboard: React.FC = () => {

Dashboard

-

Willkommen im Infoscreen-Management Dashboard.

-

Clients

+

Infoscreens

{clients.map(client => (
diff --git a/dashboard/src/gruppen.tsx b/dashboard/src/gruppen.tsx deleted file mode 100644 index 91a516c..0000000 --- a/dashboard/src/gruppen.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import React from 'react'; -const Gruppen: React.FC = () => ( -
-

Gruppen

-

Willkommen im Infoscreen-Management Gruppen.

-
-); -export default Gruppen; diff --git a/dashboard/src/infoscreen_groups.tsx b/dashboard/src/infoscreen_groups.tsx new file mode 100644 index 0000000..cb9abeb --- /dev/null +++ b/dashboard/src/infoscreen_groups.tsx @@ -0,0 +1,203 @@ +import React, { useEffect, useState, useRef } from 'react'; +import { KanbanComponent, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-kanban'; +import { fetchClients, updateClientGroup } from './apiClients'; +import { fetchGroups, createGroup } from './apiGroups'; +import type { Client } from './apiClients'; +import type { KanbanComponent as KanbanComponentType } from '@syncfusion/ej2-react-kanban'; + +interface KanbanClient extends Client { + Id: string; + Status: string; // Raumgruppe (Gruppenname) + Summary: string; // Anzeigename +} + +interface Group { + id: number; + name: string; + // weitere Felder möglich +} + +interface KanbanDragEventArgs { + element: HTMLElement | HTMLElement[]; + data: KanbanClient | KanbanClient[]; + event?: { event?: MouseEvent }; + [key: string]: unknown; +} + +const Infoscreen_groups: React.FC = () => { + const [clients, setClients] = useState([]); + const [groups, setGroups] = useState<{ keyField: string; headerText: string }[]>([]); + const [showDialog, setShowDialog] = useState(false); + const [newGroupName, setNewGroupName] = useState(''); + const [draggedCard, setDraggedCard] = useState<{ id: string; fromColumn: string } | null>(null); + const kanbanRef = useRef(null); // Ref für Kanban + + // Lade Gruppen und Clients + useEffect(() => { + let groupMap: Record = {}; + fetchGroups().then((groupData: Group[]) => { + const kanbanGroups = groupData.map(g => ({ + keyField: g.name, + headerText: g.name, + id: g.id, + })); + setGroups(kanbanGroups); + + groupMap = Object.fromEntries(groupData.map(g => [g.id, g.name])); + + fetchClients().then(data => { + setClients( + data.map((c, i) => ({ + ...c, + Id: c.uuid, + Status: groupMap[c.group_id] || 'Nicht zugeordnet', + Summary: c.location || `Client ${i + 1}`, + })) + ); + }); + }); + }, []); + + // Neue Gruppe anlegen (persistiert per API) + const handleAddGroup = async () => { + if (!newGroupName.trim()) return; + try { + const newGroup = await createGroup(newGroupName); + setGroups([...groups, { keyField: newGroup.name, headerText: newGroup.name }]); + setNewGroupName(''); + setShowDialog(false); + } catch { + alert('Fehler beim Erstellen der Gruppe'); + } + }; + + const handleDragStart = (args: KanbanDragEventArgs) => { + const element = Array.isArray(args.element) ? args.element[0] : args.element; + const cardId = element.getAttribute('data-id'); + const fromColumn = element.getAttribute('data-key'); + setDraggedCard({ id: cardId || '', fromColumn: fromColumn || '' }); + }; + + const handleCardDrop = async (args: KanbanDragEventArgs) => { + if (!draggedCard) return; + + const mouseEvent = args.event?.event; + let targetGroupName = ''; + + if (mouseEvent && mouseEvent.clientX && mouseEvent.clientY) { + const targetElement = document.elementFromPoint(mouseEvent.clientX, mouseEvent.clientY); + const kanbanColumn = + targetElement?.closest('[data-key]') || targetElement?.closest('.e-content-row'); + if (kanbanColumn) { + const columnKey = kanbanColumn.getAttribute('data-key'); + if (columnKey) { + targetGroupName = columnKey; + } else { + const headerElement = kanbanColumn.querySelector('.e-header-text'); + targetGroupName = headerElement?.textContent?.trim() || ''; + } + } + } + + // Fallback + if (!targetGroupName) { + const targetElement = Array.isArray(args.element) ? args.element[0] : args.element; + const cardWrapper = targetElement.closest('.e-card-wrapper'); + const contentRow = cardWrapper?.closest('.e-content-row'); + const headerText = contentRow?.querySelector('.e-header-text'); + targetGroupName = headerText?.textContent?.trim() || ''; + } + + if (!targetGroupName || targetGroupName === draggedCard.fromColumn) { + setDraggedCard(null); + return; + } + + const dropped = Array.isArray(args.data) ? args.data : [args.data]; + const clientIds = dropped.map((card: KanbanClient) => card.Id); + + try { + await updateClientGroup(clientIds, targetGroupName); + fetchGroups().then((groupData: Group[]) => { + const groupMap = Object.fromEntries(groupData.map(g => [g.id, g.name])); + setGroups( + groupData.map(g => ({ + keyField: g.name, + headerText: g.name, + id: g.id, + })) + ); + fetchClients().then(data => { + setClients( + data.map((c, i) => ({ + ...c, + Id: c.uuid, + Status: groupMap[c.group_id] || 'Nicht zugeordnet', + Summary: c.location || `Client ${i + 1}`, + })) + ); + }); + }); + } catch { + alert('Fehler beim Aktualisieren der Clients'); + } + setDraggedCard(null); + }; + + return ( +
+

Gruppen

+ + + + {groups.map(group => ( + + ))} + + + {showDialog && ( +
+
+

Neue Raumgruppe

+ setNewGroupName(e.target.value)} + placeholder="Raumname" + /> +
+ + +
+
+
+ )} +
+ ); +}; + +export default Infoscreen_groups; diff --git a/dashboard/src/main.tsx b/dashboard/src/main.tsx index c4bfe27..a04ec1a 100644 --- a/dashboard/src/main.tsx +++ b/dashboard/src/main.tsx @@ -5,7 +5,7 @@ import App from './App.tsx'; import { registerLicense } from '@syncfusion/ej2-base'; // Setze hier deinen Lizenzschlüssel ein -registerLicense('Ngo9BigBOggjHTQxAR8/V1NNaF1cWWhPYVFxWmFZfVtgd19FaFZRQ2Y/P1ZhSXxWdkNhWX5bc3xVQWZUUkF9XUs='); +registerLicense('ORg4AjUWIQA/Gnt3VVhhQlJDfV5AQmBIYVp/TGpJfl96cVxMZVVBJAtUQF1hTH5VdENiXX1dcHxUQWNVWkd2'); createRoot(document.getElementById('root')!).render( diff --git a/server/alembic/versions/8a45ec34f84d_add_client_groups_table_and_group_id_to_.py b/server/alembic/versions/8a45ec34f84d_add_client_groups_table_and_group_id_to_.py new file mode 100644 index 0000000..48eff28 --- /dev/null +++ b/server/alembic/versions/8a45ec34f84d_add_client_groups_table_and_group_id_to_.py @@ -0,0 +1,57 @@ +"""Add client_groups table and group_id to clients + +Revision ID: 8a45ec34f84d +Revises: c1178d5fa549 +Create Date: 2025-06-26 18:40:10.988281 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = '8a45ec34f84d' +down_revision: Union[str, None] = 'c1178d5fa549' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + """Upgrade schema.""" + # 1. Neue Tabelle anlegen + op.create_table( + 'client_groups', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('name', sa.String(length=100), nullable=False), + sa.Column('created_at', sa.TIMESTAMP(timezone=True), + server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True), + sa.Column('is_active', sa.Boolean(), nullable=False), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('name') + ) + # 2. Gruppe "Nicht zugeordnet" mit id=0 anlegen + op.execute( + "INSERT INTO client_groups (id, name, is_active) VALUES (0, 'Nicht zugeordnet', true)") + + # 3. Spalte group_id mit Default 0 hinzufügen + op.add_column('clients', sa.Column('group_id', sa.Integer(), + nullable=False, server_default='0')) + + # 4. Für alle bestehenden Clients group_id auf 0 setzen (optional, falls Daten vorhanden) + op.execute("UPDATE clients SET group_id = 0 WHERE group_id IS NULL") + + # 5. Foreign Key Constraint setzen + op.create_foreign_key(None, 'clients', 'client_groups', [ + 'group_id'], ['id']) + # ### end Alembic commands ### + + +def downgrade() -> None: + """Downgrade schema.""" + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint(None, 'clients', type_='foreignkey') + op.drop_column('clients', 'group_id') + op.drop_table('client_groups') + # ### end Alembic commands ### diff --git a/server/dummy_clients.py b/server/dummy_clients.py new file mode 100644 index 0000000..9b27e2c --- /dev/null +++ b/server/dummy_clients.py @@ -0,0 +1,45 @@ +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker +from models import Client +from dotenv import load_dotenv +import os +from datetime import datetime, timedelta +import random +import uuid + +# .env laden +load_dotenv() + +DB_USER = os.getenv("DB_USER") +DB_PASSWORD = os.getenv("DB_PASSWORD") +DB_HOST = os.getenv("DB_HOST") +DB_NAME = os.getenv("DB_NAME") + +db_conn_str = f"mysql+pymysql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}/{DB_NAME}" +engine = create_engine(db_conn_str) +Session = sessionmaker(bind=engine) +session = Session() + +# Dummy-Clients erzeugen +locations = [ + "Raum 101", + "Raum 102", + "Lehrerzimmer", + "Aula", + "Bibliothek" +] + +for i in range(5): + client = Client( + uuid=str(uuid.uuid4()), + hardware_hash=f"dummyhash{i:02d}", + location=locations[i], + ip_address=f"192.168.0.{100+i}", + registration_time=datetime.now() - timedelta(days=random.randint(1, 30)), + last_alive=datetime.now(), + is_active=True + ) + session.add(client) + +session.commit() +print("5 Dummy-Clients wurden angelegt.") diff --git a/server/dummy_events.py b/server/dummy_events.py index 2eff9e5..4c24cd4 100644 --- a/server/dummy_events.py +++ b/server/dummy_events.py @@ -1,6 +1,6 @@ from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker -from models import Event, EventMedia, EventType +from models import Event, EventMedia, EventType, Client from dotenv import load_dotenv import os from datetime import datetime, timedelta @@ -19,22 +19,6 @@ engine = create_engine(db_conn_str) Session = sessionmaker(bind=engine) session = Session() -# Beispiel-Events (client_uuid und created_by müssen existieren!) -client_uuid = "36671351-7a90-44af-bfef-a192c541373b" -created_by = 1 # ID eines existierenden Users - -# --- Alte Testdaten löschen --- -# Zuerst alle EventMedia zu den Events dieses Clients löschen -event_ids = [e.id for e in session.query( - Event.id).filter_by(client_uuid=client_uuid).all()] -if event_ids: - session.query(EventMedia).filter(EventMedia.event_id.in_( - event_ids)).delete(synchronize_session=False) -# Dann alle Events dieses Clients löschen -session.query(Event).filter_by(client_uuid=client_uuid).delete() -session.commit() -# --- Ende Löschungen --- - now = datetime.now() @@ -47,189 +31,33 @@ def random_time_on_day(day_offset: int, duration_hours: int = 1): return start, end -events = [ - Event( - client_uuid=client_uuid, - title="Mathe Präsentation", - description="Präsentation zum Thema Algebra.", - start=random_time_on_day(1)[0], - end=random_time_on_day(1)[1], - event_type=EventType.presentation, - created_by=created_by, - updated_by=None, - is_active=True - ), - Event( - client_uuid=client_uuid, - title="Schulwebsite Update", - description="Neue Inhalte auf der Schulwebsite.", - start=random_time_on_day(2)[0], - end=random_time_on_day(2)[1], - event_type=EventType.website, - created_by=created_by, - updated_by=None, - is_active=True - ), - Event( - client_uuid=client_uuid, - title="Lehrvideo ansehen", - description="Video zum Thema Photosynthese.", - start=random_time_on_day(3)[0], - end=random_time_on_day(3)[1], - event_type=EventType.video, - created_by=created_by, - updated_by=None, - is_active=True - ), - Event( - client_uuid=client_uuid, - title="Nachricht vom Lehrer", - description="Wichtige Mitteilung zum Unterricht.", - start=random_time_on_day(4)[0], - end=random_time_on_day(4)[1], - event_type=EventType.message, - created_by=created_by, - updated_by=None, - is_active=True - ), - Event( - client_uuid=client_uuid, - title="Sonstiges Event", - description="Allgemeines Event ohne Kategorie.", - start=random_time_on_day(5)[0], - end=random_time_on_day(5)[1], - event_type=EventType.other, - created_by=created_by, - updated_by=None, - is_active=True - ), - Event( - client_uuid=client_uuid, - title="WebUntis Termin", - description="Termin aus WebUntis importiert.", - start=random_time_on_day(6)[0], - end=random_time_on_day(6)[1], - event_type=EventType.webuntis, - created_by=created_by, - updated_by=None, - is_active=True - ), - Event( - client_uuid=client_uuid, - title="Englisch Präsentation", - description="Präsentation zu Shakespeare.", - start=random_time_on_day(8)[0], - end=random_time_on_day(8)[1], - event_type=EventType.presentation, - created_by=created_by, - updated_by=None, - is_active=True - ), - Event( - client_uuid=client_uuid, - title="Website Relaunch", - description="Vorstellung der neuen Schulwebsite.", - start=random_time_on_day(10)[0], - end=random_time_on_day(10)[1], - event_type=EventType.website, - created_by=created_by, - updated_by=None, - is_active=True - ), - Event( - client_uuid=client_uuid, - title="Videoanalyse", - description="Analyse eines Lehrvideos.", - start=random_time_on_day(12)[0], - end=random_time_on_day(12)[1], - event_type=EventType.video, - created_by=created_by, - updated_by=None, - is_active=True - ), - Event( - client_uuid=client_uuid, - title="WebUntis Info", - description="Weitere Termine aus WebUntis.", - start=random_time_on_day(14)[0], - end=random_time_on_day(14)[1], - event_type=EventType.webuntis, - created_by=created_by, - updated_by=None, - is_active=True - ), -] +# Hole alle Clients aus der Datenbank +clients = session.query(Client).all() +created_by = 1 # Passe ggf. an -# Events anlegen und speichern -for event in events: +all_events = [] + +for client in clients: + for i in range(10): + day_offset = random.randint(0, 13) # Termine in den nächsten 14 Tagen + duration = random.choice([1, 2]) # 1 oder 2 Stunden + start, end = random_time_on_day(day_offset, duration) + event = Event( + client_uuid=client.uuid, + title=f"Termin {i+1} für {client.location or client.uuid[:8]}", + description=f"Automatisch generierter Termin {i+1} für Client {client.uuid}", + start=start, + end=end, + event_type=random.choice(list(EventType)), + created_by=created_by, + updated_by=None, + is_active=True + ) + all_events.append(event) + +# Events speichern +for event in all_events: session.add(event) -session.commit() # Jetzt haben alle Events eine ID - -# EventMedia mit den richtigen event_id-Werten anlegen -event_media = [ - EventMedia( - event_id=events[0].id, - media_type=EventType.presentation, - url="https://example.com/praesentation-mathe.pdf", - order=1 - ), - EventMedia( - event_id=events[1].id, - media_type=EventType.website, - url="https://schule.example.com/update", - order=1 - ), - EventMedia( - event_id=events[2].id, - media_type=EventType.video, - url="https://example.com/photosynthese-video.mp4", - order=1 - ), - EventMedia( - event_id=events[3].id, - media_type=EventType.message, - url="https://example.com/lehrer-nachricht", - order=1 - ), - EventMedia( - event_id=events[4].id, - media_type=EventType.other, - url="https://example.com/sonstiges-event.pdf", - order=1 - ), - EventMedia( - event_id=events[5].id, - media_type=EventType.webuntis, - url="https://webuntis.example.com/termin", - order=1 - ), - EventMedia( - event_id=events[6].id, - media_type=EventType.presentation, - url="https://example.com/praesentation-englisch.pdf", - order=1 - ), - EventMedia( - event_id=events[7].id, - media_type=EventType.website, - url="https://schule.example.com/relaunch", - order=1 - ), - EventMedia( - event_id=events[8].id, - media_type=EventType.video, - url="https://example.com/videoanalyse.mp4", - order=1 - ), - EventMedia( - event_id=events[9].id, - media_type=EventType.webuntis, - url="https://webuntis.example.com/info", - order=1 - ), -] - -for media in event_media: - session.add(media) session.commit() -print("Test-Events und EventMedia wurden angelegt.") + +print(f"{len(all_events)} Termine für {len(clients)} Clients wurden angelegt.") diff --git a/server/models.py b/server/models.py index 5c0c9b9..675d188 100644 --- a/server/models.py +++ b/server/models.py @@ -6,11 +6,13 @@ import enum Base = declarative_base() + class UserRole(enum.Enum): user = "user" admin = "admin" superadmin = "superadmin" + class User(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True, autoincrement=True) @@ -18,8 +20,20 @@ class User(Base): password_hash = Column(String(128), nullable=False) role = Column(Enum(UserRole), nullable=False, default=UserRole.user) is_active = Column(Boolean, default=True, nullable=False) - created_at = Column(TIMESTAMP(timezone=True), server_default=func.current_timestamp()) - updated_at = Column(TIMESTAMP(timezone=True), server_default=func.current_timestamp(), onupdate=func.current_timestamp()) + created_at = Column(TIMESTAMP(timezone=True), + server_default=func.current_timestamp()) + updated_at = Column(TIMESTAMP(timezone=True), server_default=func.current_timestamp( + ), onupdate=func.current_timestamp()) + + +class ClientGroup(Base): + __tablename__ = 'client_groups' + id = Column(Integer, primary_key=True, autoincrement=True) + name = Column(String(100), unique=True, nullable=False) + created_at = Column(TIMESTAMP(timezone=True), + server_default=func.current_timestamp()) + is_active = Column(Boolean, default=True, nullable=False) + class Client(Base): __tablename__ = 'clients' @@ -27,9 +41,14 @@ class Client(Base): hardware_hash = Column(String(64), nullable=False, index=True) location = Column(String(100), nullable=True) ip_address = Column(String(45), nullable=True, index=True) - registration_time = Column(TIMESTAMP(timezone=True), server_default=func.current_timestamp(), nullable=False) - last_alive = Column(TIMESTAMP(timezone=True), server_default=func.current_timestamp(), onupdate=func.current_timestamp(), nullable=False) + registration_time = Column(TIMESTAMP( + timezone=True), server_default=func.current_timestamp(), nullable=False) + last_alive = Column(TIMESTAMP(timezone=True), server_default=func.current_timestamp( + ), onupdate=func.current_timestamp(), nullable=False) is_active = Column(Boolean, default=True, nullable=False) + group_id = Column(Integer, ForeignKey( + 'client_groups.id'), nullable=False, default=1) + class EventType(enum.Enum): presentation = "presentation" @@ -39,21 +58,26 @@ class EventType(enum.Enum): other = "other" webuntis = "webuntis" + class Event(Base): __tablename__ = 'events' id = Column(Integer, primary_key=True, autoincrement=True) - client_uuid = Column(String(36), ForeignKey('clients.uuid'), nullable=False, index=True) + client_uuid = Column(String(36), ForeignKey( + 'clients.uuid'), nullable=False, index=True) title = Column(String(100), nullable=False) description = Column(Text, nullable=True) start = Column(TIMESTAMP(timezone=True), nullable=False, index=True) end = Column(TIMESTAMP(timezone=True), nullable=False, index=True) event_type = Column(Enum(EventType), nullable=False) - created_at = Column(TIMESTAMP(timezone=True), server_default=func.current_timestamp()) - updated_at = Column(TIMESTAMP(timezone=True), server_default=func.current_timestamp(), onupdate=func.current_timestamp()) + created_at = Column(TIMESTAMP(timezone=True), + server_default=func.current_timestamp()) + updated_at = Column(TIMESTAMP(timezone=True), server_default=func.current_timestamp( + ), onupdate=func.current_timestamp()) created_by = Column(Integer, ForeignKey('users.id'), nullable=False) updated_by = Column(Integer, ForeignKey('users.id'), nullable=True) is_active = Column(Boolean, default=True, nullable=False) + class EventMedia(Base): __tablename__ = 'event_media' id = Column(Integer, primary_key=True, autoincrement=True) diff --git a/server/wsgi.py b/server/wsgi.py index 515c910..ca68f81 100644 --- a/server/wsgi.py +++ b/server/wsgi.py @@ -1,10 +1,12 @@ # server/wsgi.py +from models import Client, ClientGroup +from flask import request, jsonify import glob import os from flask import Flask, jsonify, send_from_directory, request from sqlalchemy.orm import sessionmaker from sqlalchemy import create_engine, and_ -from models import Client, Base, Event +from models import Client, Base, Event, ClientGroup DB_USER = os.getenv("DB_USER") DB_PASSWORD = os.getenv("DB_PASSWORD") @@ -62,7 +64,8 @@ def get_clients(): "location": c.location, "hardware_hash": c.hardware_hash, "ip_address": c.ip_address, - "last_alive": c.last_alive.isoformat() if c.last_alive else None + "last_alive": c.last_alive.isoformat() if c.last_alive else None, + "group_id": c.group_id, } for c in clients ] @@ -96,5 +99,106 @@ def get_events(): return jsonify(result) +@app.route("/api/groups", methods=["POST"]) +def create_group(): + data = request.get_json() + name = data.get("name") + if not name or not name.strip(): + return jsonify({"error": "Gruppenname erforderlich"}), 400 + + session = Session() + # Prüfen, ob der Name schon existiert + if session.query(ClientGroup).filter_by(name=name).first(): + session.close() + return jsonify({"error": "Gruppe existiert bereits"}), 409 + + group = ClientGroup(name=name, is_active=True) + session.add(group) + session.commit() + result = { + "id": group.id, + "name": group.name, + "created_at": group.created_at.isoformat() if group.created_at else None, + "is_active": group.is_active, + } + session.close() + return jsonify(result), 201 + + +@app.route("/api/groups", methods=["GET"]) +def get_groups(): + """Liefert alle Raumgruppen als Liste zurück.""" + session = Session() + groups = session.query(ClientGroup).all() + result = [ + { + "id": g.id, + "name": g.name, + "created_at": g.created_at.isoformat() if g.created_at else None, + "is_active": g.is_active, + } + for g in groups + ] + session.close() + return jsonify(result) + + +@app.route("/api/groups/", methods=["PUT"]) +def update_group(group_id): + """Ändert den Namen oder Status einer Raumgruppe.""" + data = request.get_json() + session = Session() + group = session.query(ClientGroup).filter_by(id=group_id).first() + if not group: + session.close() + return jsonify({"error": "Gruppe nicht gefunden"}), 404 + if "name" in data: + group.name = data["name"] + if "is_active" in data: + group.is_active = bool(data["is_active"]) + session.commit() + result = { + "id": group.id, + "name": group.name, + "created_at": group.created_at.isoformat() if group.created_at else None, + "is_active": group.is_active, + } + session.close() + return jsonify(result) + + +@app.route("/api/groups/", methods=["DELETE"]) +def delete_group(group_id): + """Löscht eine Raumgruppe.""" + session = Session() + group = session.query(ClientGroup).filter_by(id=group_id).first() + if not group: + session.close() + return jsonify({"error": "Gruppe nicht gefunden"}), 404 + session.delete(group) + session.commit() + session.close() + return jsonify({"success": True}) + + +@app.route("/api/clients/group", methods=["PUT"]) +def update_clients_group(): + data = request.get_json() + client_ids = data.get("client_ids", []) + group_name = data.get("group_name") + print(f"Update Clients Group: {group_name}, IDs: {client_ids}") + session = Session() + group = session.query(ClientGroup).filter_by(name=group_name).first() + if not group: + session.close() + return jsonify({"error": "Gruppe nicht gefunden"}), 404 + session.query(Client).filter(Client.uuid.in_(client_ids)).update( + {Client.group_id: group.id}, synchronize_session=False + ) + session.commit() + session.close() + return jsonify({"success": True}) + + if __name__ == "__main__": app.run(host="0.0.0.0", port=8000, debug=True)