aboutsummaryrefslogtreecommitdiff
path: root/src/admin-tools.js
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2026-08-03 14:31:25 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2026-08-03 14:31:25 +0200
commit6839831af54cd9302119bcc3bffafe10475958d4 (patch)
tree12a1c1fbd864e9579cb9c3a09d4bf4686a280b73 /src/admin-tools.js
parentfccb70cbd876785f6833dfe6efc10ec9e445556d (diff)
downloadbycs-sol-6839831af54cd9302119bcc3bffafe10475958d4.tar.gz
bycs-sol-6839831af54cd9302119bcc3bffafe10475958d4.zip
refactor project structure
* merge sites into single project root * fix name of mass-graduation site * enable typescript support
Diffstat (limited to 'src/admin-tools.js')
-rw-r--r--src/admin-tools.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/admin-tools.js b/src/admin-tools.js
new file mode 100644
index 0000000..b0cf80d
--- /dev/null
+++ b/src/admin-tools.js
@@ -0,0 +1,57 @@
+import { DB } from "./database.js";
+import { fetchStudents } from "./student-ENV.js";
+
+let outputNode;
+function output(msg) {
+ if (outputNode.style.display === "none") {
+ outputNode.style.display = "block";
+ }
+ const line = document.createElement("div");
+ line.innerHTML = msg;
+ line.classList.add("admin-tools-output-line");
+ outputNode.appendChild(line);
+}
+
+const studentsPromise = fetchStudents();
+
+async function createGraduationDbs() {
+ const students = await studentsPromise;
+
+ for (const student of students) {
+ if (!DB.getStudentDbs(student)) {
+ }
+ }
+}
+
+async function init() {
+ outputNode = document.getElementById("admin-tools-output");
+ const students = await studentsPromise;
+
+ output("Suche nach Datenbanken ...");
+ let missing = 0;
+ for (const student of students) {
+ const dbs = await DB.getStudentDbs(student);
+ if (!dbs) {
+ output(`\t${student.name}: Datenbanken fehlen`);
+ missing += 3;
+ continue;
+ }
+ for (const type of ["shadow", "public", "submit"]) {
+ if (!dbs[type]) {
+ output(`\t${student.name} ${student.group}: ${type} Datenbank fehlt`);
+ missing++;
+ }
+ }
+ }
+ if (missing) {
+ output(`${missing} von ${students.length * 3} Datenbanken fehlen!`);
+ } else {
+ output("Alle Datenbanken vorhanden!");
+ }
+}
+
+if (document.readyState === "loading") {
+ document.addEventListener("DOMContentLoaded", init);
+} else {
+ init();
+}