opencode ergebnis V0.1
This commit is contained in:
1 parent
61d86a3d83
commit
7e498ebc3f
71 files changed
+28982
-46
No files matched your search
@@ -0,0 +1,427 @@
|
||||
/* Dispatcher-View: Karte 2/3 links, Kontrollansicht 1/3 rechts */
|
||||
|
||||
body.dispatcher-page {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
height: 100vh;
|
||||
height: 100dvh;
|
||||
background: #eef1f4;
|
||||
}
|
||||
|
||||
body.dispatcher-page main.container {
|
||||
width: 100vw;
|
||||
max-width: none;
|
||||
height: 100vh;
|
||||
height: 100dvh;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.dispatcher-layout {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
height: 100dvh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.map-pane {
|
||||
position: relative;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
background: #dce3e8;
|
||||
}
|
||||
|
||||
#map {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
/* Fadenkreuz-Modus der Karte */
|
||||
.leaflet-container.crosshair,
|
||||
.leaflet-container.crosshair .leaflet-interactive {
|
||||
cursor: crosshair !important;
|
||||
}
|
||||
|
||||
.control-pane {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
background: var(--card-background-color, #fff);
|
||||
border-left: 1px solid rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
/* ---------- Header ---------- */
|
||||
|
||||
.control-header {
|
||||
flex: 0 0 auto;
|
||||
padding: 0.85rem 1rem 0.6rem;
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.clock {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.05rem;
|
||||
margin-bottom: 0.55rem;
|
||||
}
|
||||
|
||||
.clock-date {
|
||||
font-size: 0.78rem;
|
||||
color: var(--muted-color, #5b6771);
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.clock-time {
|
||||
font-size: clamp(1.8rem, 4vw, 2.7rem);
|
||||
line-height: 1.05;
|
||||
font-weight: 700;
|
||||
font-variant-numeric: tabular-nums;
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
|
||||
.header-controls {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
.map-layer-label {
|
||||
flex: 1 1 auto;
|
||||
margin: 0 !important;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.map-layer-label > span {
|
||||
display: block;
|
||||
margin-bottom: 0.15rem;
|
||||
color: var(--muted-color, #5b6771);
|
||||
}
|
||||
|
||||
.map-layer-label select {
|
||||
margin: 0;
|
||||
height: 2.35rem;
|
||||
padding-top: 0.25rem;
|
||||
padding-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.icon-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: 0 0 auto;
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-radius: 0.55rem;
|
||||
font-size: 1.2rem;
|
||||
line-height: 1;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.icon-button {
|
||||
border: 1px solid rgba(0, 0, 0, 0.18);
|
||||
background: var(--form-element-background-color, #fff);
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.icon-button.active {
|
||||
background: #2f6fdb;
|
||||
border-color: #2f6fdb;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.connection-status {
|
||||
margin-top: 0.45rem;
|
||||
font-size: 0.72rem;
|
||||
color: var(--muted-color, #5b6771);
|
||||
}
|
||||
|
||||
.connection-status.connected {
|
||||
color: #18794e;
|
||||
}
|
||||
|
||||
.connection-status.disconnected {
|
||||
color: #b42318;
|
||||
}
|
||||
|
||||
/* ---------- Accordion ---------- */
|
||||
|
||||
.group-accordion {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
padding: 0.7rem;
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
|
||||
.group-empty {
|
||||
padding: 1rem;
|
||||
color: var(--muted-color, #5b6771);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.group-item {
|
||||
margin: 0 0 0.55rem;
|
||||
border: 1px solid rgba(0, 0, 0, 0.12);
|
||||
border-radius: 0.65rem;
|
||||
background: var(--card-background-color, #fff);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.group-item > summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.55rem;
|
||||
padding: 0.65rem 0.75rem;
|
||||
cursor: pointer;
|
||||
list-style: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.group-item > summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.group-item > summary::after {
|
||||
content: "▾";
|
||||
margin-left: auto;
|
||||
font-size: 0.8rem;
|
||||
color: var(--muted-color, #5b6771);
|
||||
transition: transform 0.15s ease;
|
||||
}
|
||||
|
||||
.group-item[open] > summary::after {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.group-dot {
|
||||
flex: 0 0 auto;
|
||||
width: 0.8rem;
|
||||
height: 0.8rem;
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 0 0 3px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.group-name {
|
||||
min-width: 0;
|
||||
font-weight: 650;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.group-state {
|
||||
flex: 0 0 auto;
|
||||
margin-left: 0.35rem;
|
||||
padding: 0.1rem 0.45rem;
|
||||
border-radius: 999px;
|
||||
background: rgba(0, 0, 0, 0.07);
|
||||
font-size: 0.7rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.group-details {
|
||||
padding: 0 0.75rem 0.75rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
.group-position-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.group-position-row .icon-button {
|
||||
width: 2.25rem;
|
||||
height: 2.25rem;
|
||||
font-size: 1.05rem;
|
||||
}
|
||||
|
||||
.group-position-row progress {
|
||||
flex: 1 1 auto;
|
||||
width: auto;
|
||||
height: 0.75rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.group-position-meta {
|
||||
font-size: 0.72rem;
|
||||
color: var(--muted-color, #5b6771);
|
||||
}
|
||||
|
||||
.group-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.group-crosshair {
|
||||
width: 2.35rem;
|
||||
height: 2.35rem;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.group-message {
|
||||
margin: 0;
|
||||
cursor: pointer;
|
||||
background: rgba(0, 0, 0, 0.035);
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
.group-message:focus {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* ---------- Footer ---------- */
|
||||
|
||||
.control-footer {
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.55rem;
|
||||
padding: 0.7rem 1rem 0.85rem;
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
background: var(--card-background-color, #fff);
|
||||
}
|
||||
|
||||
.slider-control {
|
||||
margin: 0 !important;
|
||||
font-size: 0.74rem;
|
||||
}
|
||||
|
||||
.slider-control > span {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
color: var(--muted-color, #5b6771);
|
||||
}
|
||||
|
||||
.slider-control input[type="range"] {
|
||||
margin: 0.25rem 0 0;
|
||||
height: 1.15rem;
|
||||
}
|
||||
|
||||
.footer-buttons {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.5rem;
|
||||
margin-top: 0.1rem;
|
||||
}
|
||||
|
||||
/* ---------- Dialoge ---------- */
|
||||
|
||||
dialog article {
|
||||
max-height: 90dvh;
|
||||
}
|
||||
|
||||
#chatModal article,
|
||||
.chat-dialog {
|
||||
width: min(44rem, 94vw);
|
||||
max-width: 94vw;
|
||||
}
|
||||
|
||||
.chat-messages {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.55rem;
|
||||
max-height: 58dvh;
|
||||
overflow-y: auto;
|
||||
padding: 0.15rem;
|
||||
}
|
||||
|
||||
.chat-empty {
|
||||
padding: 1rem;
|
||||
text-align: center;
|
||||
color: var(--muted-color, #5b6771);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.chat-message {
|
||||
padding: 0.5rem 0.65rem;
|
||||
border-radius: 0.55rem;
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.chat-message.own {
|
||||
background: rgba(47, 111, 219, 0.12);
|
||||
}
|
||||
|
||||
.chat-message-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 0.7rem;
|
||||
margin-bottom: 0.18rem;
|
||||
font-size: 0.7rem;
|
||||
color: var(--muted-color, #5b6771);
|
||||
}
|
||||
|
||||
.chat-message-text {
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
/* ---------- Leaflet-Marker ---------- */
|
||||
|
||||
.group-marker-icon {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.group-marker-icon span {
|
||||
display: block;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 50%;
|
||||
background: var(--marker-color, #2f6fdb);
|
||||
border: 2px solid #fff;
|
||||
box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.38), 0 1px 3px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.dispatcher-layout {
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: minmax(0, 55vh) minmax(0, 45vh);
|
||||
grid-template-rows: minmax(0, 55dvh) minmax(0, 45dvh);
|
||||
}
|
||||
|
||||
.control-pane {
|
||||
border-left: 0;
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.control-header {
|
||||
padding-top: 0.55rem;
|
||||
padding-bottom: 0.45rem;
|
||||
}
|
||||
|
||||
.clock {
|
||||
flex-direction: row;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.clock-time {
|
||||
font-size: 1.55rem;
|
||||
}
|
||||
|
||||
.group-accordion {
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.control-footer {
|
||||
padding: 0.5rem 0.75rem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/* CMBNet Custom Styles */
|
||||
article.error {
|
||||
background-color: #f8d7da;
|
||||
border-color: #f5c6cb;
|
||||
color: #721c24;
|
||||
}
|
||||
|
||||
article.success {
|
||||
background-color: #d4edda;
|
||||
border-color: #c3e6cb;
|
||||
color: #155724;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,78 @@
|
||||
const tenant = window.location.pathname.split('/')[1];
|
||||
const apiBase = `/${tenant}/admin/api`;
|
||||
|
||||
function changeRole(accountId, role) {
|
||||
fetch(`${apiBase}/accounts/${accountId}/role`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({role: role})
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (data.success) alert('Rolle geändert');
|
||||
});
|
||||
}
|
||||
|
||||
function openPasswordModal(accountId) {
|
||||
document.getElementById('pwdAccountId').value = accountId;
|
||||
document.getElementById('passwordModal').showModal();
|
||||
}
|
||||
|
||||
function closePasswordModal() {
|
||||
document.getElementById('passwordModal').close();
|
||||
document.getElementById('newPassword').value = '';
|
||||
}
|
||||
|
||||
function resetPassword() {
|
||||
const accountId = document.getElementById('pwdAccountId').value;
|
||||
const password = document.getElementById('newPassword').value;
|
||||
fetch(`${apiBase}/accounts/${accountId}/password`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({password: password})
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (data.success) {
|
||||
alert('Passwort zurückgesetzt');
|
||||
closePasswordModal();
|
||||
} else {
|
||||
alert(data.error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleteAccount(accountId) {
|
||||
if (!confirm('Account wirklich löschen?')) return;
|
||||
fetch(`${apiBase}/accounts/${accountId}`, {
|
||||
method: 'DELETE'
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (data.success) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function openCreateAccountModal() {
|
||||
document.getElementById('createAccountModal').showModal();
|
||||
}
|
||||
|
||||
function closeCreateAccountModal() {
|
||||
document.getElementById('createAccountModal').close();
|
||||
document.getElementById('newAccountName').value = '';
|
||||
document.getElementById('newAccountPassword').value = '';
|
||||
}
|
||||
|
||||
function createAccount() {
|
||||
const name = document.getElementById('newAccountName').value;
|
||||
const password = document.getElementById('newAccountPassword').value;
|
||||
const role = document.getElementById('newAccountRole').value;
|
||||
fetch(`${apiBase}/accounts`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({name, password, role})
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (data.success) {
|
||||
alert('Account angelegt');
|
||||
location.reload();
|
||||
} else {
|
||||
alert(data.error);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
const tenant = window.location.pathname.split('/')[1];
|
||||
const apiBase = `/${tenant}/admin/api`;
|
||||
const GROUP_STATES = ['offen', 'unterwegs', 'online', 'pausierend', 'fertig'];
|
||||
let currentGroupId = null;
|
||||
|
||||
function hasPosition(lat, lon) {
|
||||
return lat !== null && lat !== undefined && lon !== null && lon !== undefined;
|
||||
}
|
||||
|
||||
function formatPosition(lat, lon) {
|
||||
return hasPosition(lat, lon) ? `${lat}, ${lon}` : 'unbekannt';
|
||||
}
|
||||
|
||||
function showError(data) {
|
||||
alert(data && data.error ? data.error : 'Aktion fehlgeschlagen');
|
||||
}
|
||||
|
||||
function makeButton(label, className, handler) {
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.textContent = label;
|
||||
if (className) button.className = className;
|
||||
button.addEventListener('click', handler);
|
||||
return button;
|
||||
}
|
||||
|
||||
function updateGruppe(groupId, data) {
|
||||
fetch(`${apiBase}/gruppen/${groupId}`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify(data)
|
||||
}).then(r => r.json()).then(result => {
|
||||
if (!result.success) showError(result);
|
||||
}).catch(() => alert('Server nicht erreichbar'));
|
||||
}
|
||||
|
||||
function deleteGruppe(groupId) {
|
||||
if (!confirm('Gruppe wirklich löschen?')) return;
|
||||
fetch(`${apiBase}/gruppen/${groupId}`, {
|
||||
method: 'DELETE'
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (data.success) {
|
||||
location.reload();
|
||||
} else {
|
||||
showError(data);
|
||||
}
|
||||
}).catch(() => alert('Server nicht erreichbar'));
|
||||
}
|
||||
|
||||
// === Neue Gruppe ===
|
||||
|
||||
function openCreateGruppeModal() {
|
||||
document.getElementById('gruppeAlias').value = '';
|
||||
document.getElementById('gruppeAccount').value = '';
|
||||
document.getElementById('createGruppeModal').showModal();
|
||||
}
|
||||
|
||||
function closeCreateGruppeModal() {
|
||||
document.getElementById('createGruppeModal').close();
|
||||
document.getElementById('gruppeAlias').value = '';
|
||||
document.getElementById('gruppeAccount').value = '';
|
||||
}
|
||||
|
||||
function buildStateSelect(state) {
|
||||
const select = document.createElement('select');
|
||||
GROUP_STATES.forEach(value => {
|
||||
const option = document.createElement('option');
|
||||
option.value = value;
|
||||
option.textContent = value;
|
||||
option.selected = value === state;
|
||||
select.appendChild(option);
|
||||
});
|
||||
return select;
|
||||
}
|
||||
|
||||
function buildAccountSelect(accountId) {
|
||||
const select = document.createElement('select');
|
||||
const source = document.getElementById('gruppeAccount');
|
||||
Array.from(source.options).forEach(option => {
|
||||
const copy = document.createElement('option');
|
||||
copy.value = option.value;
|
||||
copy.textContent = option.textContent;
|
||||
copy.selected = String(option.value) === String(accountId ?? '');
|
||||
select.appendChild(copy);
|
||||
});
|
||||
return select;
|
||||
}
|
||||
|
||||
function addGruppeRow(gruppe) {
|
||||
const tbody = document.querySelector('#gruppenTable tbody');
|
||||
const row = document.createElement('tr');
|
||||
row.dataset.id = gruppe.id;
|
||||
|
||||
const idCell = document.createElement('td');
|
||||
idCell.textContent = gruppe.id;
|
||||
row.appendChild(idCell);
|
||||
|
||||
const aliasCell = document.createElement('td');
|
||||
const aliasInput = document.createElement('input');
|
||||
aliasInput.type = 'text';
|
||||
aliasInput.value = gruppe.aliasname || '';
|
||||
aliasInput.addEventListener('change',
|
||||
() => updateGruppe(gruppe.id, {aliasname: aliasInput.value}));
|
||||
aliasCell.appendChild(aliasInput);
|
||||
row.appendChild(aliasCell);
|
||||
|
||||
const stateCell = document.createElement('td');
|
||||
const stateSelect = buildStateSelect(gruppe.state);
|
||||
stateSelect.addEventListener('change',
|
||||
() => updateGruppe(gruppe.id, {state: stateSelect.value}));
|
||||
stateCell.appendChild(stateSelect);
|
||||
row.appendChild(stateCell);
|
||||
|
||||
const accountCell = document.createElement('td');
|
||||
const accountSelect = buildAccountSelect(gruppe.account_id);
|
||||
accountSelect.addEventListener('change',
|
||||
() => updateGruppe(gruppe.id, {account_id: accountSelect.value}));
|
||||
accountCell.appendChild(accountSelect);
|
||||
row.appendChild(accountCell);
|
||||
|
||||
const positionCell = document.createElement('td');
|
||||
positionCell.className = 'group-position';
|
||||
positionCell.textContent = formatPosition(gruppe.last_lat, gruppe.last_lon);
|
||||
row.appendChild(positionCell);
|
||||
|
||||
const actionsCell = document.createElement('td');
|
||||
actionsCell.appendChild(makeButton('Historie', '', () => showHistory(gruppe.id)));
|
||||
|
||||
const clearPositionButton = makeButton('Position löschen', 'secondary delete-position',
|
||||
() => deleteGroupPosition(gruppe.id));
|
||||
clearPositionButton.disabled = !hasPosition(gruppe.last_lat, gruppe.last_lon);
|
||||
actionsCell.appendChild(clearPositionButton);
|
||||
|
||||
actionsCell.appendChild(makeButton('Löschen', 'secondary', () => deleteGruppe(gruppe.id)));
|
||||
row.appendChild(actionsCell);
|
||||
|
||||
tbody.appendChild(row);
|
||||
row.scrollIntoView({block: 'nearest'});
|
||||
}
|
||||
|
||||
function createGruppe() {
|
||||
const aliasname = document.getElementById('gruppeAlias').value;
|
||||
const accountId = document.getElementById('gruppeAccount').value;
|
||||
|
||||
fetch(`${apiBase}/gruppen`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({aliasname, account_id: accountId})
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (!data.success) {
|
||||
showError(data);
|
||||
return;
|
||||
}
|
||||
addGruppeRow({
|
||||
id: data.id,
|
||||
aliasname: aliasname,
|
||||
account_id: accountId || null,
|
||||
state: 'offen',
|
||||
last_lat: null,
|
||||
last_lon: null
|
||||
});
|
||||
closeCreateGruppeModal();
|
||||
}).catch(() => alert('Server nicht erreichbar'));
|
||||
}
|
||||
|
||||
// === Historie / Position ===
|
||||
|
||||
function setPositionCell(groupId, lat, lon) {
|
||||
const row = document.querySelector(`#gruppenTable tr[data-id="${groupId}"]`);
|
||||
if (!row) return;
|
||||
|
||||
const positionCell = row.querySelector('.group-position');
|
||||
if (positionCell) positionCell.textContent = formatPosition(lat, lon);
|
||||
|
||||
const clearButton = row.querySelector('.delete-position');
|
||||
if (clearButton) clearButton.disabled = !hasPosition(lat, lon);
|
||||
}
|
||||
|
||||
function showHistory(groupId) {
|
||||
currentGroupId = groupId;
|
||||
fetch(`${apiBase}/gruppen/${groupId}/history`)
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
const tbody = document.getElementById('historyBody');
|
||||
tbody.innerHTML = '';
|
||||
data.forEach(entry => {
|
||||
const row = document.createElement('tr');
|
||||
|
||||
[entry.created_at, entry.from_state || '-', entry.to_state,
|
||||
formatPosition(entry.last_lat, entry.last_lon)].forEach(value => {
|
||||
const cell = document.createElement('td');
|
||||
cell.textContent = value;
|
||||
row.appendChild(cell);
|
||||
});
|
||||
|
||||
const actionCell = document.createElement('td');
|
||||
actionCell.appendChild(makeButton('Zustand wiederherstellen', '',
|
||||
() => revertGroup(entry.id)));
|
||||
if (hasPosition(entry.last_lat, entry.last_lon)) {
|
||||
actionCell.appendChild(makeButton('Position setzen', 'secondary',
|
||||
() => setPositionFromHistory(entry.id, entry.last_lat, entry.last_lon)));
|
||||
}
|
||||
row.appendChild(actionCell);
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
document.getElementById('historyModal').showModal();
|
||||
})
|
||||
.catch(() => alert('Historie konnte nicht geladen werden'));
|
||||
}
|
||||
|
||||
function setPositionFromHistory(histId, lat, lon) {
|
||||
if (!confirm('Position aus diesem Historieneintrag übernehmen?')) return;
|
||||
fetch(`${apiBase}/gruppen/${currentGroupId}/position/history/${histId}`, {
|
||||
method: 'POST'
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (!data.success) {
|
||||
showError(data);
|
||||
return;
|
||||
}
|
||||
setPositionCell(currentGroupId, lat, lon);
|
||||
closeHistoryModal();
|
||||
}).catch(() => alert('Server nicht erreichbar'));
|
||||
}
|
||||
|
||||
function deleteGroupPosition(groupId) {
|
||||
if (!confirm('Position dieser Gruppe wirklich löschen?')) return;
|
||||
fetch(`${apiBase}/gruppen/${groupId}/position`, {
|
||||
method: 'DELETE'
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (!data.success) {
|
||||
showError(data);
|
||||
return;
|
||||
}
|
||||
setPositionCell(groupId, null, null);
|
||||
}).catch(() => alert('Server nicht erreichbar'));
|
||||
}
|
||||
|
||||
function revertGroup(histId) {
|
||||
if (!confirm('Zustand wirklich wiederherstellen?')) return;
|
||||
fetch(`${apiBase}/gruppen/${currentGroupId}/history/${histId}/revert`, {
|
||||
method: 'POST'
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (data.success) {
|
||||
location.reload();
|
||||
} else {
|
||||
showError(data);
|
||||
}
|
||||
}).catch(() => alert('Server nicht erreichbar'));
|
||||
}
|
||||
|
||||
function closeHistoryModal() {
|
||||
document.getElementById('historyModal').close();
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
const tenant = window.location.pathname.split('/')[1];
|
||||
const apiBase = `/${tenant}/admin/api`;
|
||||
let currentStreetId = null;
|
||||
let editMode = false;
|
||||
|
||||
function updateStrasse(streetId, data) {
|
||||
fetch(`${apiBase}/strassen/${streetId}`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify(data)
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (data.success) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleteStrasse(streetId) {
|
||||
if (!confirm('Straße wirklich löschen?')) return;
|
||||
fetch(`${apiBase}/strassen/${streetId}`, {
|
||||
method: 'DELETE'
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (data.success) location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
function openCreateStrasseModal() {
|
||||
editMode = false;
|
||||
document.getElementById('strasseModalTitle').innerText = 'Neue Straße';
|
||||
document.getElementById('strasseId').value = '';
|
||||
document.getElementById('strasseName').value = '';
|
||||
document.getElementById('strasseHnMin').value = '';
|
||||
document.getElementById('strasseHnMax').value = '';
|
||||
document.getElementById('strasseBbox').value = '';
|
||||
document.getElementById('strasseState').value = 'unbearbeitet';
|
||||
document.getElementById('strasseState').disabled = true;
|
||||
document.getElementById('strasseGroup').value = '';
|
||||
document.getElementById('strasseGroup').disabled = true;
|
||||
document.getElementById('strasseModal').showModal();
|
||||
}
|
||||
|
||||
function editStrasse(streetId) {
|
||||
editMode = true;
|
||||
const row = document.querySelector(`tr[data-id="${streetId}"]`);
|
||||
document.getElementById('strasseModalTitle').innerText = 'Straße bearbeiten';
|
||||
document.getElementById('strasseId').value = streetId;
|
||||
document.getElementById('strasseName').value = row.cells[1].innerText;
|
||||
document.getElementById('strasseHnMin').value = row.cells[4].innerText === '-' ? '' : row.cells[4].innerText;
|
||||
document.getElementById('strasseHnMax').value = row.cells[5].innerText === '-' ? '' : row.cells[5].innerText;
|
||||
document.getElementById('strasseBbox').value = row.cells[6].innerText === '-' ? '' : row.cells[6].innerText;
|
||||
document.getElementById('strasseState').value = row.cells[2].querySelector('select').value;
|
||||
document.getElementById('strasseState').disabled = false;
|
||||
document.getElementById('strasseGroup').value = row.cells[3].querySelector('select').value;
|
||||
document.getElementById('strasseGroup').disabled = false;
|
||||
document.getElementById('strasseModal').showModal();
|
||||
}
|
||||
|
||||
function closeStrasseModal() {
|
||||
document.getElementById('strasseModal').close();
|
||||
}
|
||||
|
||||
function saveStrasse() {
|
||||
const id = document.getElementById('strasseId').value;
|
||||
const data = {
|
||||
name: document.getElementById('strasseName').value,
|
||||
hn_min: document.getElementById('strasseHnMin').value || null,
|
||||
hn_max: document.getElementById('strasseHnMax').value || null,
|
||||
bbox: document.getElementById('strasseBbox').value || null,
|
||||
state: document.getElementById('strasseState').value,
|
||||
group_id: document.getElementById('strasseGroup').value || null
|
||||
};
|
||||
|
||||
if (!editMode) {
|
||||
fetch(`${apiBase}/strassen`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify(data)
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (data.success) {
|
||||
alert('Straße angelegt');
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fetch(`${apiBase}/strassen/${id}`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify(data)
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (data.success) {
|
||||
alert('Gespeichert');
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
closeStrasseModal();
|
||||
}
|
||||
|
||||
function importCSV(input) {
|
||||
const file = input.files[0];
|
||||
if (!file) return;
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
fetch(`${apiBase}/strassen/import`, {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (data.success) {
|
||||
alert(`${data.count} Straßen importiert`);
|
||||
location.reload();
|
||||
} else {
|
||||
alert(data.error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function showStreetHistory(streetId) {
|
||||
currentStreetId = streetId;
|
||||
fetch(`${apiBase}/strassen/${streetId}/history`)
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
const tbody = document.getElementById('streetHistoryBody');
|
||||
tbody.innerHTML = '';
|
||||
data.forEach(h => {
|
||||
const tr = document.createElement('tr');
|
||||
tr.innerHTML = `
|
||||
<td>${h.created_at}</td>
|
||||
<td>${h.from_state || '-'}</td>
|
||||
<td>${h.to_state}</td>
|
||||
<td>${h.group_id || '-'}</td>
|
||||
<td><button onclick="revertStreet(${h.id})">Wiederherstellen</button></td>
|
||||
`;
|
||||
tbody.appendChild(tr);
|
||||
});
|
||||
document.getElementById('streetHistoryModal').showModal();
|
||||
});
|
||||
}
|
||||
|
||||
function revertStreet(histId) {
|
||||
if (!confirm('Zustand wirklich wiederherstellen?')) return;
|
||||
fetch(`${apiBase}/strassen/${currentStreetId}/history/${histId}/revert`, {
|
||||
method: 'POST'
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (data.success) {
|
||||
alert('Wiederhergestellt');
|
||||
location.reload();
|
||||
} else {
|
||||
alert(data.error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function closeStreetHistoryModal() {
|
||||
document.getElementById('streetHistoryModal').close();
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user