Added function to hide unused reports
This commit is contained in:
@@ -23,5 +23,8 @@ RUN pip3 install --no-cache-dir -r requirements.txt --break-system-packages
|
||||
# Öffne den Port des Web-Servers
|
||||
EXPOSE 3000
|
||||
|
||||
# Setze die Umgebungsvariablen
|
||||
ENV ONLY_SHOW_AVAILABLE true
|
||||
|
||||
# Starte den Web-Server
|
||||
CMD ["node", "server.js"]
|
||||
@@ -16,6 +16,7 @@ services:
|
||||
ports:
|
||||
- 3000:3000
|
||||
environment:
|
||||
- 'ONLY_SHOW_AVAILABLE=true' # Optional, default: true (only show available reports in the UI)
|
||||
- 'CALDAV_URL=https://example.com/calendars/' # URL to the caldav server
|
||||
- 'CALDAV_USER=USERNAME' # Username for the caldav server
|
||||
- 'CALDAV_PASSWORD=PASSWORD' # Password for the caldav server
|
||||
|
||||
@@ -141,6 +141,25 @@ app.get('/newweekavailable', (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/show', (req, res) => {
|
||||
let showCalendar = true;
|
||||
let showUntis = true;
|
||||
|
||||
if (process.env.ONLY_SHOW_AVAILABLE == "true") {
|
||||
if (process.env.CALDAV_URL == undefined || process.env.CALDAV_USER == undefined || process.env.CALDAV_PASSWORD == undefined || process.env.CALDAV_CALENDAR == undefined) {
|
||||
showCalendar = false;
|
||||
}
|
||||
if (process.env.UNTIS_SCHOOLS == undefined || process.env.UNTIS_USERNAMES == undefined || process.env.UNTIS_PASSWORDS == undefined || process.env.UNTIS_SERVERS == undefined) {
|
||||
showUntis = false;
|
||||
}
|
||||
}
|
||||
|
||||
res.send({
|
||||
calendar: showCalendar,
|
||||
untis: showUntis
|
||||
});
|
||||
});
|
||||
|
||||
// Definiere eine Route für die Ausgabe der Daten
|
||||
app.get('/getreport', async (req, res) => {
|
||||
const weekDate = last50Weeks[req.query.week];
|
||||
|
||||
@@ -14,17 +14,21 @@
|
||||
</select>
|
||||
<button id="export-button" onclick="exportReport()">Exportieren</button>
|
||||
</div>
|
||||
<div class="ueberschrift">
|
||||
<h4>Kalendereinträge</h4>
|
||||
<button id="calendar-copy-button" onclick="copyToClipboard(calendarcalendarCopyButton, calendarTextarea)">Kopieren</button>
|
||||
<div id="calendar-div">
|
||||
<div class="ueberschrift">
|
||||
<h4>Kalendereinträge</h4>
|
||||
<button id="calendar-copy-button" onclick="copyToClipboard(calendarcalendarCopyButton, calendarTextarea)">Kopieren</button>
|
||||
</div>
|
||||
<textarea id="calendar-textarea"></textarea>
|
||||
</div>
|
||||
<textarea id="calendar-textarea"></textarea>
|
||||
|
||||
<div class="ueberschrift">
|
||||
<h4>Untis Einträge</h4>
|
||||
<button id="untis-copy-button" onclick="copyToClipboard(untisCopyButton, untisTextarea)">Kopieren</button>
|
||||
<div id="untis-div">
|
||||
<div class="ueberschrift">
|
||||
<h4>Untis Einträge</h4>
|
||||
<button id="untis-copy-button" onclick="copyToClipboard(untisCopyButton, untisTextarea)">Kopieren</button>
|
||||
</div>
|
||||
<textarea id="untis-textarea"></textarea>
|
||||
</div>
|
||||
<textarea id="untis-textarea"></textarea>
|
||||
|
||||
<script src="index.js"></script>
|
||||
</body>
|
||||
|
||||
@@ -7,6 +7,27 @@ const untisCopyButton = document.getElementById('untis-copy-button');
|
||||
const weekList = document.getElementById('week-list');
|
||||
const exportButton = document.getElementById('export-button');
|
||||
|
||||
const calendarDiv = document.getElementById('calendar-div');
|
||||
const untisDiv = document.getElementById('untis-div');
|
||||
|
||||
fetch('/show')
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
throw new Error('Error während des Abrufs');
|
||||
}
|
||||
}).then(json => {
|
||||
if (json.calendar == false) {
|
||||
calendarDiv.style.display = 'none';
|
||||
}
|
||||
if (json.untis == false) {
|
||||
untisDiv.style.display = 'none';
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
function loadWeeks() {
|
||||
fetch('/newweekavailable?week=' + weekList.options[0].innerHTML)
|
||||
.then(response => {
|
||||
|
||||
Reference in New Issue
Block a user