Skip to content

Commit

Permalink
Add deletion preparation for students and improve CSV file handling
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfganggreschus committed Jan 29, 2025
1 parent 1fcb577 commit b5c8b75
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
6 changes: 6 additions & 0 deletions controllers/management/managementLogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,18 @@ const mainRoute = async function (req, res, next) {
'Link',
];
const policiesBody = createPoliciesBody(consentVersions.data);

const deletionContainerHead = [
'Schüler-IDs',
'Lehrer-IDs',
];
res.render('management/management', {
title: 'Allgemeine Verwaltung',
user: res.locals.currentUser,
themeTitle: process.env.SC_NAV_TITLE || 'Schul-Cloud',
policiesHead,
policiesBody,
deletionContainerHead,
});
} catch (err) {
next(err);
Expand Down
19 changes: 11 additions & 8 deletions static/scripts/management.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ const loadPolicyFile = () => {
if (file) {
reader.readAsDataURL(file);
}
})
}
});
};

$(document).ready(() => {
console.log("Management.js geladen");
const $addConsentModal = $('.add-modal--policy');

$('.btn-add-modal--policy').on('click', (e) => {
Expand All @@ -49,20 +50,22 @@ $(document).ready(() => {
submitLabel: "Hinzufügen",
});
$addConsentModal.appendTo('body').modal('show');
})
});

document.querySelector('#policy-input').addEventListener('change', loadPolicyFile, false);
})
document.querySelector('#batchDeletionFileInput').addEventListener('change', addFile);
});



document.getElementById('batchDeletionFileInput').addEventListener('change', function(event) {
const addFile = (event) => {
const file = event.target.files[0];
if (!file) return;

const reader = new FileReader();
reader.onload = function(e) {
const content = e.target.result;
console.log("CSV Inhalt:", content);
document.getElementById('output').textContent = content;
document.getElementById('csvContent').textContent = content;
};
reader.readAsText(file);
});
};
25 changes: 23 additions & 2 deletions views/management/management.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,38 @@
</section>
</div>
{{/ifEnvNot}}
<div class="row">
<section class="section-school section-default">
<h2 class="h4">Löschvorbereitung</h2>
<div class="container-fluid">
<div class="row">
<div class="col-sm-12 no-padding">
{{> "lib/components/table" head=../deletionContainerHead}}
</div>
</div>
<div class="row">
<div class="col-sm-12 no-padding">
<button type="submit" class="btn btn-primary btn-add-modal--policy">
Hinzufügen
</button>
</div>
</div>
</div>
</section>
</div>
<div class="row">
<section class="section-school section-default">
<h2 class="h4">Sammellöschung von Schülern</h2>
<div class="container-fluid">
<div class="row">
<div class="col-sm-12 no-padding">
<input type="file" id="fileInput" accept=".csv">
<textarea id="csvContent" rows="10" cols="50" placeholder="CSV content will appear here..."></textarea>
<input type="file" id="batchDeletionFileInput" accept=".csv">
<pre id="output"></pre>
</div>
</div>
<div class="row">
<textarea id="csvContent" rows="10" cols="50" placeholder="CSV content will appear here..."></textarea>
</div>
</div>
</section>
</div>
Expand Down

0 comments on commit b5c8b75

Please sign in to comment.