API für Geo Positions Update mit Testscript

This commit is contained in:
concierge committed 2026-11-04 14:42:45 +01:00
1 parent 23a9df66f4
commit d54a986c14
16 files changed
+1027 -6

No files matched your search

+8
View File
@@ -8,6 +8,14 @@ table td {
padding: 0.25rem 0.5rem;
}
.api-token-value {
display: inline-block;
max-width: 32rem;
white-space: normal;
overflow-wrap: anywhere;
font-size: 0.82rem;
}
dialog article {
max-width: 600px;
width: min(90vw, 600px);
+11 -4
View File
@@ -5,7 +5,7 @@
* damit er sowohl die mobilen Views als auch die statischen Assets
* kontrolliert. Der Cache-Name wird pro App-Wurzel gebildet.
*/
const VERSION = 'cmbnet-pwa-v13';
const VERSION = 'cmbnet-pwa-v14';
const BASE = new URL('./', self.location).href;
const SHELL_CACHE = `${VERSION}-shell`;
const TILE_CACHE = `${VERSION}-tiles`;
@@ -124,16 +124,23 @@ function isTileRequest(url) {
async function handleNavigation(request) {
const cache = await caches.open(SHELL_CACHE);
const url = new URL(request.url);
// Admin-Seiten können sensible Daten wie API-Zugriffstoken enthalten und
// werden deshalb nicht im Service-Worker-Cache abgelegt.
const cacheable = !url.pathname.includes('/admin/');
try {
const response = await fetch(request);
if (response && response.ok) {
if (cacheable && response && response.ok) {
cache.put(request, response.clone()).catch(() => {});
}
return response;
} catch (error) {
const cached = await cache.match(request, {ignoreSearch: true});
if (cached) return cached;
if (cacheable) {
const cached = await cache.match(request, {ignoreSearch: true});
if (cached) return cached;
}
return new Response(offlineHtml(), {
status: 503,
+36
View File
@@ -49,5 +49,41 @@ async function loadBrokerStatus() {
}
}
async function createApiToken() {
try {
const response = await fetch(`${apiBase}/api-tokens`, {
method: 'POST'
});
const data = await response.json();
if (!response.ok || !data.success) {
throw new Error(data.error || 'Token konnte nicht erzeugt werden');
}
window.location.reload();
} catch (error) {
alert(error.message || 'Server nicht erreichbar');
}
}
async function deleteApiToken(tokenId) {
if (!confirm('Diesen Zugriffstoken wirklich löschen?')) return;
try {
const response = await fetch(`${apiBase}/api-tokens/${tokenId}`, {
method: 'DELETE'
});
const data = await response.json();
if (!response.ok || !data.success) {
throw new Error(data.error || 'Token konnte nicht gelöscht werden');
}
window.location.reload();
} catch (error) {
alert(error.message || 'Server nicht erreichbar');
}
}
const createApiTokenBtn = document.getElementById('createApiTokenBtn');
if (createApiTokenBtn) {
createApiTokenBtn.addEventListener('click', createApiToken);
}
loadBrokerStatus();
setInterval(loadBrokerStatus, 5000);