vor ähnlichkeitsprüfung
This commit is contained in:
@@ -96,6 +96,18 @@
|
||||
let sse = null;
|
||||
let relativeTimer = null;
|
||||
|
||||
function handleUnauthorized(response) {
|
||||
if (response && response.status === 401) {
|
||||
if (typeof redirectToLogin === 'function') {
|
||||
redirectToLogin();
|
||||
} else {
|
||||
window.location.href = 'login.html';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function toDateTimeLocal(value) {
|
||||
if (!value) return '';
|
||||
const date = value instanceof Date ? value : new Date(value);
|
||||
@@ -120,6 +132,9 @@
|
||||
...(options.headers || {})
|
||||
};
|
||||
const response = await fetch(`${API_URL}${path}`, opts);
|
||||
if (handleUnauthorized(response)) {
|
||||
throw new Error('Nicht angemeldet');
|
||||
}
|
||||
if (!response.ok) {
|
||||
let message = 'Unbekannter Fehler';
|
||||
try {
|
||||
@@ -1335,4 +1350,9 @@
|
||||
activate,
|
||||
deactivate: cleanup
|
||||
};
|
||||
|
||||
const automationSection = document.querySelector('[data-view="automation"]');
|
||||
if (automationSection && automationSection.classList.contains('app-view--active')) {
|
||||
activate();
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user