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,2 @@
|
|||||||
|
*.pyc
|
||||||
|
/CMBNet/instance/
|
||||||
+340
@@ -0,0 +1,340 @@
|
|||||||
|
Architekturskizze: CMBNet
|
||||||
|
Dieses Dokument beschreibt den grundsätzlichen Aufbau der Webanwendung CMBNet gemäß den Anforderungen. Es werden Architekturentscheidungen, Modulzusammenhänge, Schnittstellen, Datenmodell und Ablaufdiagramme erläutert, bevor mit der Implementierung begonnen wird.
|
||||||
|
1. Ziele und Rahmenbedingungen
|
||||||
|
Anforderung Entscheidung
|
||||||
|
Server Python 3 + Flask
|
||||||
|
Frontend Reines Vanilla-JavaScript, pico.css (https://picocss.com/), Leaflet (https://leafletjs.com/)
|
||||||
|
Realtime-Synchronisation WebSocket mit eigenem Protokoll und mandantenabhängigem Routing
|
||||||
|
Mandantenfähigkeit Tenant-ID in URL, Referenz auf Tenant in jeder Entität und Account
|
||||||
|
Zugriffsschutz Login mit Rollenmodell (Gast, Beobachter, Gruppe, Dispatcher, Administrator)
|
||||||
|
Verwaltung Separate Admin-Views für Accounts, Gruppen, Straßen
|
||||||
|
Historie & Logging State-Historie für Straßen/Gruppen, reversibel; transaktionales Logfile
|
||||||
|
Performance In-Memory-Caching für Gruppen (mit Invalidierung)
|
||||||
|
Kartenanwendung Leaflet mit Polylines aus str2pl.js, dynamische Marker für Gruppen
|
||||||
|
2. Projektstruktur
|
||||||
|
Der Code soll sauber strukturiert im Projektverzeichnis CMBNet/ abgelegt werden. Folgende Gliederung wird vorgeschlagen:
|
||||||
|
CMBNet/
|
||||||
|
├── app.py # Entrypoint, Flask-App-Initialisierung
|
||||||
|
├── config.py # Konfiguration (DB, Secret, Tenant-Defaults, Limits)
|
||||||
|
├── requirements.txt # Abhängigkeiten (Flask, flask-sock/gevent/eventlet o.ä., ...)
|
||||||
|
├── wsgi.py # WSGI für Deployment
|
||||||
|
├── instance/ # SQLite-DB, Laufzeitdateien (nicht versioniert)
|
||||||
|
├── logs/ # Lesbare Transaktions-Logs
|
||||||
|
├── data/ # Importvorlagen / Hilfsdaten (z. B. CSV)
|
||||||
|
├── migrations/ # Schema-Migrationen für SQLite
|
||||||
|
├── cmbnet/ # Hauptpaket
|
||||||
|
│ ├── __init__.py # create_app(), Blueprints, Erweiterungen
|
||||||
|
│ ├── extensions.py # DB, WebSocket-Broker-Instanz, etc.
|
||||||
|
│ ├── auth/ # Authentifizierung, Sessions, Token
|
||||||
|
│ ├── core/ # Konstanten, Protokolldefinition, Fehlerklassen
|
||||||
|
│ ├── db/ # DB-Verbindung, Schema, Hilfsfunktionen
|
||||||
|
│ ├── models/ # DAO/Repository für Entitäten
|
||||||
|
│ ├── services/ # Geschäftslogik (Streets, Groups, Accounts, History, Logging)
|
||||||
|
│ ├── api/ # AJAX/REST-Handler (Initialdaten + Aktionen)
|
||||||
|
│ ├── ws/ # WebSocket-Broker, Routing, Protokoll, Heartbeat
|
||||||
|
│ ├── views/ # View-Routen für Nicht-Admin
|
||||||
|
│ ├── admin/ # Admin-Routen & Handler
|
||||||
|
│ ├── utils/ # Helfer (CSV-Parsing, Geo, Zeit)
|
||||||
|
│ └── static/ # Statische Assets
|
||||||
|
│ ├── css/ # pico.css + eigene Styles
|
||||||
|
│ ├── js/ # Vanilla-JS
|
||||||
|
│ │ ├── lib/ # leaflet.js, ggf. pico.js (falls benötigt)
|
||||||
|
│ │ ├── core/ # ws_client.js, utils.js, state.js
|
||||||
|
│ │ ├── map/ # map.js, str2pl.js Integration
|
||||||
|
│ │ ├── views/ # dispatcher.js, gruppen.js, login.js, admin-*.js
|
||||||
|
│ │ └── str2pl.js # Extern bereitgestelltes Polyline-Fragment (wie gefordert)
|
||||||
|
│ └── img/ # Icons/Symbole
|
||||||
|
├── templates/ # Jinja2-Templates
|
||||||
|
│ ├── base.html
|
||||||
|
│ ├── login.html
|
||||||
|
│ ├── dispatcher.html
|
||||||
|
│ ├── dispatcher_mobil.html
|
||||||
|
│ ├── gruppen.html
|
||||||
|
│ ├── praesentation.html
|
||||||
|
│ ├── oeffentlich.html
|
||||||
|
│ └── admin/
|
||||||
|
│ ├── accounts.html
|
||||||
|
│ ├── gruppen.html
|
||||||
|
│ └── strassen.html
|
||||||
|
└── README.md
|
||||||
|
Begründung: Trennung von Routen (views/, admin/, api/), Geschäftslogik (services/), Datenzugriff (models/), Echtzeit (ws/) und Frontend (static/js/views/) sorgt für Übersichtlichkeit und Erweiterbarkeit.
|
||||||
|
3. Mandantenfähigkeit & Routing
|
||||||
|
- Tenant in URL: Alle relevanten Zugriffe laufen über /<tenant>/.... Der Tenant wird aus der URL extrahiert, validiert und im Request-Kontext (g.tenant_id) verfügbar gemacht.
|
||||||
|
- Accounts mandantengebunden: accounts.tenant_id ist Pflicht, Login prüft (tenant_id, name) eindeutig.
|
||||||
|
- Datenisolation: Alle Queries filtern konsequent nach tenant_id (Streets, Groups, Accounts, History, Messages).
|
||||||
|
- Blueprints: auth_bp, views_bp, admin_bp, api_bp, ws_bp mit url_prefix='/<tenant>' bzw. tenant-Middleware.
|
||||||
|
4. Datenmodell (SQLite3)
|
||||||
|
Folgende Tabellen werden vorgeschlagen (Schlüsselideen). Genauere Typen/Indizes werden bei Implementierung finalisiert.
|
||||||
|
Tabelle Zweck Wesentliche Felder
|
||||||
|
tenants Mandantenstamm id (PK), code (z. B. BV/RV/SV), name, created_at
|
||||||
|
accounts Nutzer id (PK), tenant_id (FK), name, password_hash, role (ENUM/Gast/Beobachter/Gruppe/Dispatcher/Administrator), created_at, updated_at
|
||||||
|
groups Gruppen id (PK), tenant_id (FK), aliasname, state (offen/unterwegs/online/pausierend/fertig), last_lat, last_lon, last_pos_at (DATETIME), account_id (FK -> accounts, 1:1 wie gefordert), created_at, updated_at
|
||||||
|
streets Straßen id (PK), tenant_id (FK), name, state (unbearbeitet/zugewiesen/erledigt), group_id (FK -> groups, NULL wenn unbearbeitet), hn_min, hn_max, bbox (TEXT/JSON: [ [nwLon,nwLat],[seLon,seLat] ] oder Array), created_at, updated_at
|
||||||
|
street_state_history Historie Straßen id (PK), tenant_id, street_id (FK), from_state, to_state, group_id (vorher/nachher Kontext), actor_account_id (FK), reason, created_at (DATETIME)
|
||||||
|
group_state_history Historie Gruppen id (PK), tenant_id, group_id (FK), from_state, to_state, last_lat, last_lon, last_pos_at, actor_account_id, created_at
|
||||||
|
ws_tokens Zugriffstokens für WS-Auth id (PK), tenant_id, account_id, token (zufällig), session_id, expires_at, used (bool), created_at
|
||||||
|
ws_messages_store Persistenz für >=1000 (Late Entry) id (PK), tenant_id, sender_id, receiver_id (nullable für Broadcast/Gruppe), code (INT), ts (DATETIME/UNIX), msg (TEXT/JSON), delivered_to (JSON/rel), created_at
|
||||||
|
transaction_log Lesbares Transaktionslog id (PK), tenant_id, ts (DATETIME), actor_account_id, action, entity_type, entity_id, details (TEXT)
|
||||||
|
Anmerkungen:
|
||||||
|
- bbox wird als JSON-String in SQLite abgelegt, beim Ausliefern an Frontend als JS-Array geparst.
|
||||||
|
- Historieeinträge werden bei jedem State-Wechsel erzeugt. Revert setzt State zurück und schreibt neuen History-Eintrag (inkl. Kontext) gemäß "durch Anklicken alten States wieder gültig".
|
||||||
|
- Transaktionen (CRUD an Accounts/Gruppen/Straßen) werden sowohl in transaction_log als auch lesbar in Logfile geschrieben (logs/cmbnet-YYYY-MM-DD.log).
|
||||||
|
5. Authentifizierung & Sessions
|
||||||
|
- Passwortprüfung: Nur Hashvergleich (siehe Accounts-Service).
|
||||||
|
- Weiterleitung: next-Parameter wird unterstützt. Ansonsten Rollenbasiert.
|
||||||
|
- Zugriffsschutz: Decorators login_required, role_required([roles...]), tenant_required für alle geschützten Routen.
|
||||||
|
- WS-Token: Nach Login/bei Initialload liefert AJAX-Endpoint /<tenant>/api/auth/ws-token ein zufälliges Token, das serverseitig kurzzeitig gespeichert (ws_tokens) und für WS-Auth benötigt wird.
|
||||||
|
6. WebSocket-Protokoll & Broker
|
||||||
|
6.1 Protokollformat
|
||||||
|
Jede Nachricht ist JSON mit folgendem Schema:
|
||||||
|
{
|
||||||
|
"sender_id": 123,
|
||||||
|
"receiver_id": 456, // optional, je nach Code/Broadcast
|
||||||
|
"code": 100,
|
||||||
|
"ts": 1729612345678, // UNIX ms oder ISO8601; Broker setzt/validiert
|
||||||
|
"msg": "{\"name\":\"Musterstraße\",\"state\":\"zugewiesen\",\"actor\":...}"
|
||||||
|
}
|
||||||
|
- code < 100: nur intern, wird nicht in UI angezeigt
|
||||||
|
- Zeitstempel wird serverseitig normalisiert
|
||||||
|
- msg ist Freitext oder JSON (abhängig von Code)
|
||||||
|
6.2 Broker-Architektur
|
||||||
|
Der Broker verwaltet Verbindungen pro Tenant und Account.
|
||||||
|
Komponenten:
|
||||||
|
- ws/broker.py: Connection-Pool (connections[tenant_id][account_id] = ws), Auth-Flow (Code 0 + Token), Heartbeat (Code 1/2), Broadcast/Unicast
|
||||||
|
- ws/router.py: Entscheidung Empfängerkreis je Nachrichtentyp
|
||||||
|
- ws/handlers.py: Verarbeitung eingehender Codes
|
||||||
|
- ws/protocol.py: Validierung, Serialisierung
|
||||||
|
6.3 Routing nach Nachrichtentypen
|
||||||
|
Code Auslöser Empfängerkreis Inhalt msg Persistenz
|
||||||
|
0 Client nach Connect Broker-intern (Auth) Token Nein
|
||||||
|
1 Server (zyklisch 1/min) Alle verbundenen Clients Ping/Markierung Nein
|
||||||
|
2 Client (Antwort auf 1) Nur Dispatcher-Views Pong/Antwort Nein
|
||||||
|
100 State-Wechsel Straße Alle Dispatcher, Gast, Beobachter + Gruppe, die mit Straße verknüpft ist (bei Zuweisung/Änderung) JSON {name, state, actor, street_id, group_id?} Nein (Echtzeit)
|
||||||
|
200 State-Wechsel Gruppe Alle Dispatcher, Beobachter + betroffene Gruppe JSON {group_id, state, actor} Nein
|
||||||
|
300 Positionswechsel Gruppe Verbundene Dispatcher, Beobachter + betroffene Gruppe JSON {group_id, lat, lon, ts, actor} Nein
|
||||||
|
1000 Dispatcher Alle Dispatcher, Beobachter, alle Gruppen (Broadcast) Freitext Ja (>=1000)
|
||||||
|
1100 Dispatcher Alle Dispatcher, Beobachter + spezielle Gruppe (Aliasname vorangestellt) Freitext mit Präfix Ja
|
||||||
|
2000 Gruppe Alle Dispatcher, Beobachter JSON {group_id, text} Ja
|
||||||
|
Heartbeatroutine: Server sendet code=1 jede Minute. Clients antworten code=2. code=2 wird ausschließlich an angeschlossene Dispatcher-Views weitergeleitet. Verbindungen ohne rechtzeitige Antwort können nach Timeout getrennt werden.
|
||||||
|
Late Entry: Bei Anmeldung am Broker werden nur für diesen Client berechtigte Nachrichten aus ws_messages_store mit ts >= now - 8h in chronologischer Reihenfolge zugestellt. Ältere Einträge werden gelöscht. Zuständigkeit für Löschung: Broker-Routine (z. B. bei Zustellung oder periodisch).
|
||||||
|
7. Backend-Module im Detail
|
||||||
|
7.1 models/ (DAO)
|
||||||
|
Abstraktionsschicht für CRUD. Jede Methode filtert nach tenant_id.
|
||||||
|
- streets.py: get_all(), get_by_id(), create(), update(), delete(), import_from_csv_rows()
|
||||||
|
- groups.py: primär über Service (In-Memory), aber DB-Zugriff hier
|
||||||
|
- accounts.py: get_by_name_and_tenant(), get_by_id(), create(), update_role(), delete(), set_password_hash()
|
||||||
|
- history.py: Historieneinträge lesen/schreiben
|
||||||
|
- messages.py: Persistenz für Code>=1000 + Cleanup
|
||||||
|
- log.py: Transaktionslog (DB + File)
|
||||||
|
|
||||||
|
7.2 services/ (Geschäftslogik)
|
||||||
|
- streets_service.py
|
||||||
|
- handle_initial_ajax(tenant_id, ...) -> JSON aller Straßenattribute inkl. State
|
||||||
|
- update_street(street_id, changes, actor) -> DB-Update, History-Eintrag, Logging, Broker-Notify (Code 100 je nach Statewechsel)
|
||||||
|
- groups_service.py (Kernstück)
|
||||||
|
- In-Memory-Cache: groups_cache[tenant_id][group_id] = {...}
|
||||||
|
- load_from_db(tenant_id): beim Start + bei Invalidierung
|
||||||
|
- invalidate(tenant_id): erzwingen Neuladen (z. B. Admin-Änderung)
|
||||||
|
- is_account_linked(account_id, group_id)
|
||||||
|
- get_accounts_for_group(group_id)
|
||||||
|
- get_streets_for_group(group_id)
|
||||||
|
- handle_initial_ajax(...)
|
||||||
|
- update_group(...), set_position(...), change_state(...) -> DB + Cache + History + Broker (200/300)
|
||||||
|
- accounts_service.py
|
||||||
|
- verify_password(account, password) (Hashvergleich)
|
||||||
|
- has_role(account, roles)
|
||||||
|
- issue_ws_token(account, session)
|
||||||
|
- history_service.py: Revert-Funktion (lädt alten Snapshot, setzt Entität zurück, schreibt neuen History-Eintrag)
|
||||||
|
|
||||||
|
7.3 api/ (AJAX)
|
||||||
|
Endpoints für Initialload und Aktionen:
|
||||||
|
Endpoint Methode Zweck
|
||||||
|
/<tenant>/api/init/streets GET Liste Straßen (inkl. State, group_id)
|
||||||
|
/<tenant>/api/init/groups GET Liste Gruppen (inkl. State, Position, last_pos_at)
|
||||||
|
/<tenant>/api/auth/ws-token GET/POST Token für WS-Auth erzeugen
|
||||||
|
/<tenant>/api/streets/<id>/state POST State-Wechsel Straße (Dispatcher/Gruppen-Kontext)
|
||||||
|
/<tenant>/api/groups/<id>/state POST State-Wechsel Gruppe
|
||||||
|
/<tenant>/api/groups/<id>/position POST Position setzen (Gruppen-View)
|
||||||
|
Antworten sind JSON. CSRF-Schutz gemäß Flask-Konzept (oder passende Maßnahme).
|
||||||
|
|
||||||
|
7.4 admin/
|
||||||
|
Nur für Rolle Administrator. Validierung serverseitig.
|
||||||
|
- accounts: Liste, Rolle ändern (AJAX), Passwort-Reset (Modal), Anlegen (Modal), Löschen (mit Rückfrage)
|
||||||
|
- gruppen: Liste, State ändern, Account verknüpfen/ändern, Position manuell/aus Historie zurücksetzen/löschen, Anlegen, Löschen, Historie-Anzeige + Revert
|
||||||
|
- strassen: Tabelle editierbar, Modal Edit, Modal Neu, Löschdialog, CSV-Import (Upload multipart/form-data, Delimiter ;, Spalten Name, Hausnummer minimal, Hausnummer maximal, Bounding Box). Import erzeugt Einträge mit State unbearbeitet, group_id = NULL. Jede Änderung triggert Transaktionslog + bei State-Wechsel Broker-Code 100.
|
||||||
|
CSV-Import: Parsing robust (Quotes/Encoding). bbox wird validiert und als JSON für Frontend normalisiert.
|
||||||
|
7.5 ws/ Ablauf Code 0 Auth
|
||||||
|
1. Client sendet {code:0, msg: token, sender_id: account_id}
|
||||||
|
2. Broker sucht Token in ws_tokens (tenant, account, nicht genutzt, nicht abgelaufen)
|
||||||
|
3. Bei Erfolg: markiert genutzt/erstellt Session-Mapping, führt Late-Entry durch, registriert Connection in Routing-Tabellen
|
||||||
|
4. Bei Misserfolg: schließt Verbindung
|
||||||
|
|
||||||
|
8. Frontend-Architektur
|
||||||
|
8.1 Templates
|
||||||
|
- base.html: Grundgerüst, pico.css, Leaflet CSS/JS, gemeinsame Skripte
|
||||||
|
- login.html: Formular Name/Passwort + Select Mandant (BV/RV/SV, Default RV)
|
||||||
|
- View-Templates binden view-spezifisches JS ein
|
||||||
|
|
||||||
|
8.2 JS-Module
|
||||||
|
Datei Aufgabe
|
||||||
|
core/ws_client.js WebSocket-Verbindung, Reconnect, Senden/Empfangen, Heartbeat-Handling (Code 1 -> Code 2)
|
||||||
|
core/utils.js Helper, Formatierung Zeit/Datum, LocalStorage
|
||||||
|
core/state.js Gemeinsamer State (streetsDict, groupsDict, token, tenant)
|
||||||
|
map/map.js Leaflet-Initialisierung, Bounds, Tiles (OSM/Luftbild), Marker/Polylines, Events
|
||||||
|
map/str2pl_integration.js Lädt str2pl.js, baut Strasse2Polylines, rendert Polylines nach State
|
||||||
|
views/dispatcher.js Dispatcher-View Logik (Accordion, Position, Code 1000/1100, Opacity/Weight, Timer)
|
||||||
|
views/gruppen.js Gruppen-View (State-Wechsel, Position setzen, Nachrichten)
|
||||||
|
views/praesentation.js / oeffentlich.js Nur Darstellung + Suche, keine Modifikation
|
||||||
|
views/dispatcher_mobil.js Mobiloptimiert, selektive Darstellung
|
||||||
|
views/admin_*.js Admin-Interaktionen (Modals, AJAX, CSV-Upload)
|
||||||
|
views/login.js Client-seitige Validierung falls gewünscht
|
||||||
|
|
||||||
|
8.3 str2pl.js
|
||||||
|
Wird als separates JS-Fragment unter static/js/str2pl.js bereitgestellt. Erwartetes Format (konzeptionell):
|
||||||
|
// Beispielhaft
|
||||||
|
window.STRASSE2POLYLINES = {
|
||||||
|
"Musterstraße": [
|
||||||
|
[[7.1234, 50.1234],[7.1235,50.1235]],
|
||||||
|
[[7.1235,50.1235],[7.1236,50.1236]]
|
||||||
|
],
|
||||||
|
// ...
|
||||||
|
};
|
||||||
|
map/str2pl_integration.js iteriert über Einträge, erzeugt L.polyline pro Segment, speichert Referenz in Strasse2PolylinesMap[streetName] = [polyline1,...] für spätere Farbupdates bei Code 100.
|
||||||
|
|
||||||
|
8.4 Initialisierungsreihenfolge (Dispatcher-Prototyp)
|
||||||
|
|
||||||
|
8.5 Kartenlogik
|
||||||
|
- Bounds: Union aller bbox von Straßen -> L.latLngBounds
|
||||||
|
- LocalStorage: cmbnet:<tenant>:map speichert {center:[lat,lng], zoom, opacity, weight}
|
||||||
|
- Tiles: OSM + optional Luftbild (Layer-Control)
|
||||||
|
- Polylines: Farbe nach State (unbearbeitet blau, zugewiesen rot, erledigt grün), opacity, weight konfigurierbar
|
||||||
|
- Klick Polyline: Modal State-Wechsel je Übergang (wie 156-161), sendet Code 100 via API/WS-Pfad
|
||||||
|
- Gruppen-Marker: individuelle Farben, Position aus last_lat/lon oder Browser-Geolocation bei unbekannt
|
||||||
|
- Code 100: Aktualisiert Farbe aller Segmente betroffener Straße
|
||||||
|
- Code 200/300: Aktualisiert Accordion + Marker
|
||||||
|
|
||||||
|
8.6 Kontrollansicht (Dispatcher)
|
||||||
|
- Header: Wochentag/Datum (klein), Uhrzeit (groß), sekundengenau aktualisiert
|
||||||
|
- Dropdown: Kartenhintergrund
|
||||||
|
- Lautsprecher: Modal Freitext -> Code 1000
|
||||||
|
- Zentral: Accordion pro Gruppe, Kreis Farbe, State, Position-Button, Progressbar (Zeitdiff), Fadenkreuz-Modus (Klick setzt Position -> Code 300), Nachrichtenfeld (Code 2000), Chat-Dialog für >=1000
|
||||||
|
- Footer: Opacity-Slider (0-1 step 0.05), Weight-Slider (1-100), Fit-Bounds-Button, Exit -> Logout
|
||||||
|
Progressbar-Berechnung: diff = now - last_pos_at. 100% < 60s, 0% >= 3600s, linear dazwischen. >3600s -> Button inaktiv.
|
||||||
|
Fadenkreuz-Modus: Cursor-Wechsel, ESC oder erneuter Button-Abbruch, Klick -> API set_position + WS Code 300.
|
||||||
|
|
||||||
|
8.7 Views nach Anforderung
|
||||||
|
View Zielgerät Darstellung Interaktion
|
||||||
|
Login-View Alle Login-Formular Authentifizierung, Redirect
|
||||||
|
Dispatcher-View Desktop Karte 2/3 + Kontrollansicht 1/3 Voll (State-Wechsel, Nachrichten, Position)
|
||||||
|
Dispatcher-Mobil-View Smartphone Optimiert, selektiv Ähnlich reduziert
|
||||||
|
Gruppen-View Smartphone Für Gruppenaccount Nur eigene Gruppe, State-Wechsel, Position, Nachrichten
|
||||||
|
Präsentations-View Alle Alle Infos Nur Suche, keine Modifikation
|
||||||
|
Öffentlicher-View Alle Wie Präsentation, ohne Gruppen Nur Suche
|
||||||
|
|
||||||
|
9. Wichtige Abläufe (Diagramme)
|
||||||
|
9.1 State-Wechsel Straße (Dispatcher klickt Polyline)
|
||||||
|
9.2 Gruppenposition setzen (Gruppen-View / Fadenkreuz)
|
||||||
|
9.3 Admin CSV-Import
|
||||||
|
|
||||||
|
10. Logging, Historie & Revert
|
||||||
|
10.1 Transaktionslog
|
||||||
|
Jede schreibende Transaktion muss sowohl in einer maschinenlesbaren Datenbanktabelle, als auch in einem menschenlesbaren Logfile protokolliert werden.
|
||||||
|
Ziel Umsetzung
|
||||||
|
Datenbank Tabelle transaction_log mit ts, tenant_id, actor_account_id, action, entity_type, entity_id und details (als JSON-String für eine strukturierte Auswertung).
|
||||||
|
Logfile Tagesbasiert unter logs/cmbnet-YYYY-MM-DD.log. Jedes Logformat soll folgende Felder beinhalten: Timestamp, Tenant, Actor (Account-ID + Name), Aktion, Entitätstyp, Entitäts-ID, Details.
|
||||||
|
Auslöser CRUD für Accounts, Gruppen und Straßen, CSV-Import, State-Wechsel, Positionsänderungen, Rollenänderungen, Passwort-Resets sowie das Setzen/Löschen einer Gruppenposition.
|
||||||
|
Beispielhafter Logeintrag:
|
||||||
|
2026-10-22 14:32:18.542 [TENANT:RV] [ACTOR:42(DispatcherMax)] ACTION:street.state_change ENTITY:street:123 DETAILS:{"from":"unbearbeitet","to":"zugewiesen","group_id":5}
|
||||||
|
|
||||||
|
10.2 State-Historie
|
||||||
|
Für Straßen und Gruppen wird eine lückenlose Historie aller relevanten Zustandsänderungen geführt.
|
||||||
|
Tabelle Zweck Gespeicherter Snapshot
|
||||||
|
street_state_history Historie für Straßen from_state, to_state, group_id (Kontext zum Zeitpunkt des Wechsels), actor_account_id, reason, created_at
|
||||||
|
group_state_history Historie für Gruppen from_state, to_state, last_lat, last_lon, last_pos_at (vollständiger Positionssnapshot), actor_account_id, created_at
|
||||||
|
- Erzeugung: Bei jedem validierten State-Wechsel wird automatisch ein neuer Historieneintrag erzeugt, bevor oder im selben Datenbank-Commit wie das Update der Entität.
|
||||||
|
- Anzeige: In den jeweiligen Verwaltungsseiten (Gruppenverwaltung, Straßenverwaltung) ist eine Historieansicht pro Eintrag aufrufbar. Diese wird chronologisch absteigend dargestellt.
|
||||||
|
- Transparenz: Jeder Eintrag zeigt Zeitpunkt, auslösenden Account, vorherigen und neuen Zustand sowie den zum Wechsel gehörenden Kontext (z. B. verknüpfte Gruppe oder Positionssnapshot).
|
||||||
|
|
||||||
|
10.3 Revert von historischen Zuständen
|
||||||
|
Über das Anklicken eines historischen Eintrages soll der Zustand der Entität wiederhergestellt werden können. Dies ist bewusst als neuer Übergang, nicht als bloßes Überschreiben ohne Nachverfolgung, umgesetzt.
|
||||||
|
Regeln für den Revert:
|
||||||
|
- Nur Administratoren: Der Revert ist ausschließlich für Accounts mit der Rolle Administrator freigegeben und wird serverseitig validiert.
|
||||||
|
- Neuer History-Eintrag: Durch den Revert wird kein Eintrag entfernt. Es wird stattdessen ein neuer Eintrag in der Historie geschrieben, der den Übergang vom aktuellen Zustand zum wiederhergestellten Zustand abbildet.
|
||||||
|
- Positionswiederherstellung: Für Gruppen wird bei einem Revert eines Positions-Snapshots sowohl last_lat, last_lon, last_pos_at wiederhergestellt, als auch eine Code-300-Nachricht über den Broker ausgelöst, um Marker und UI aller berechtigter Clients zu synchronisieren.
|
||||||
|
- Gruppenverknüpfung: Bei Straßen wird group_id anhand des historischen Kontextes wiederhergestellt. Ist der wiederherzustellende Zustand unbearbeitet, wird group_id auf NULL gesetzt.
|
||||||
|
- Konsistenz: Nach einem Revert wird der In-Memory-Cache der Gruppen invalidiert (sofern betroffen) und das Transaktionslog entsprechend aktualisiert.
|
||||||
|
|
||||||
|
11. Sicherheit
|
||||||
|
Da die Anwendung Zugangsschutz, Mandantenfähigkeit und Echtzeitkommunikation kombiniert, werden folgende Maßnahmen konsequent umgesetzt.
|
||||||
|
Bereich Maßnahme Begründung
|
||||||
|
Authentifizierung Nur Passwort-Hash-Vergleich über einen etablierten Hash-Algorithmus (z. B. werkzeug.security mit generate_password_hash/check_password_hash) Niemals Klartextpasswörter speichern
|
||||||
|
Sessions Flask-Sessions mit HttpOnly, Secure (in Produktion), SameSite=Lax/Strict Schutz vor Session-Hijacking und CSRF-ähnlichen Angriffen
|
||||||
|
Autorisierung Serverseitige Decorators (login_required, role_required, tenant_required) für alle geschützten Routen und Aktionen Client-seitige Prüfungen sind niemals ausreichend
|
||||||
|
Mandantenisolation Filterung sämtlicher DB-Queries nach tenant_id, Prüfung beim Routing und bei jedem Broker-Zugriff Verhindert Cross-Tenant-Zugriff
|
||||||
|
WebSocket-Auth Einmalig nutzbarer, kurzlebiger Token (Code 0), Speicherung in ws_tokens mit used-Flag und optionalem expires_at Verhindert Missbrauch von Tokens
|
||||||
|
CSRF CSRF-Schutz für alle POST/PUT/PATCH/DELETE Requests (AJAX und Formulare) Schutz vor Cross-Site-Request-Forgery
|
||||||
|
Input-Validierung Serverseitige Validierung für alle Formulare, AJAX-Payloads und CSV-Import Robustheit und Integrität der Daten
|
||||||
|
Datei-Upload Nur .csv zulassen, Dateigröße begrenzen, Delimiter explizit ; erzwingen, Inhalte parsen und validieren Verhindert unerwartete Dateien und fehlerhafte Importe
|
||||||
|
SQL-Injection Ausschließlich parametrisierte Queries über den DB-Layer Vermeidung von SQL-Injection
|
||||||
|
XSS Jinja2-Autoescaping aktiv, keine Einbettung ungeprüften HTMLs im Frontend Schutz vor Cross-Site-Scripting
|
||||||
|
Logging sensibler Daten Keine Passwörter, Tokens oder sensiblen Rohdaten in Logs Vermeidung von Credential-Leaks
|
||||||
|
|
||||||
|
12. Konfiguration, Abhängigkeiten & Start
|
||||||
|
12.1 Abhängigkeiten (requirements.txt)
|
||||||
|
Folgende Pakete werden für den ersten Entwicklungsstand vorgeschlagen:
|
||||||
|
Flask>=3.0.0
|
||||||
|
Werkzeug>=3.0.0
|
||||||
|
flask-sock>=0.7.0
|
||||||
|
simple-websocket>=1.0.0
|
||||||
|
python-dateutil>=2.9.0
|
||||||
|
Hinweis: Je nach Deployment kann gevent oder eventlet für produktivere WebSocket-Verbindungen ergänzt werden. Für den Entwicklungsserver ist flask-sock in Kombination mit dem Flask-Dev-Server ausreichend.
|
||||||
|
|
||||||
|
12.2 Konfiguration (config.py)
|
||||||
|
Zentrale Konfigurationspunkte:
|
||||||
|
Variable Zweck Default (Dev)
|
||||||
|
SECRET_KEY Session-Verschlüsselung Aus Umgebungsvariable laden
|
||||||
|
DATABASE_PATH Pfad zur SQLite-DB instance/cmbnet.sqlite3
|
||||||
|
TENANTS Erlaubte Mandanten ["BV", "RV", "SV"]
|
||||||
|
DEFAULT_TENANT Vorbelegung Login "RV"
|
||||||
|
WS_HEARTBEAT_INTERVAL Intervall für Code 1 60 Sekunden
|
||||||
|
WS_HEARTBEAT_TIMEOUT Timeout für Code 2 Antwort 15 Sekunden
|
||||||
|
LATE_ENTRY_MAX_AGE_HOURS Max. Alter für gespeicherte Nachrichten 8 Stunden
|
||||||
|
LOG_DIR Verzeichnis für Transaktionslogs logs/
|
||||||
|
MAX_CSV_SIZE_BYTES Upload-Limit z. B. 5_000_000
|
||||||
|
|
||||||
|
12.3 Initialisierung & Start des Entwicklungsservers
|
||||||
|
Vor dem ersten Start müssen Verzeichnisse angelegt und das Datenbankschema initialisiert werden.
|
||||||
|
# Ins Projektverzeichnis wechseln
|
||||||
|
cd CMBNet
|
||||||
|
|
||||||
|
# Virtuelles Environment erstellen und aktivieren
|
||||||
|
python3 -m venv .venv
|
||||||
|
source .venv/bin/activate # macOS/Linux
|
||||||
|
# .\.venv\Scripts\activate # Windows
|
||||||
|
|
||||||
|
# Abhängigkeiten installieren
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
# Benötigte Verzeichnisse anlegen
|
||||||
|
mkdir -p instance logs data migrations
|
||||||
|
|
||||||
|
# Datenbank initialisieren (über CLI-Command der App)
|
||||||
|
flask --app app init-db
|
||||||
|
|
||||||
|
# Entwicklungswebserver starten
|
||||||
|
flask --app app run --debug --host 127.0.0.1 --port 5000
|
||||||
|
Anschließend ist die Anwendung unter http://127.0.0.1:5000 erreichbar. Der Zugriff erfolgt mandantenspezifisch über http://127.0.0.1:5000/<tenant>/login (z. B. /RV/login).
|
||||||
|
Hinweis: app.py bzw. das create_app() in cmbnet/__init__.py muss den CLI-Befehl init-db registrieren, um das Schema aus migrations/ bzw. cmbnet/db/schema.sql anzuwenden.
|
||||||
|
13. Implementierungsreihenfolge
|
||||||
|
Um Komplexität beherrschbar zu halten, wird eine schrittweise Umsetzung empfohlen:
|
||||||
|
Phase Fokus Ziel
|
||||||
|
Phase 0: Grundgerüst Projektstruktur, Config, DB-Verbindung, Blueprints Laufende Flask-App ohne Businesslogik
|
||||||
|
Phase 1: Datenmodell & Auth Schema für alle Tabellen, Accounts-Service, Login-View, Rollen-/Tenant-Decorators Funktionsfähiger Login mit Mandantenwahl
|
||||||
|
Phase 2: Entitätenbasis Models/Services für Streets, Groups, Accounts. In-Memory-Cache für Gruppen inkl. Invalidierung Datenzugriffsschicht steht
|
||||||
|
Phase 3: WebSocket-Broker Protokoll, Routing, Auth (Code 0), Heartbeat (1/2), Late-Entry, Persistenz für >=1000 Realtime-Grundgerüst funktionsfähig
|
||||||
|
Phase 4: Admin-Views Account-, Gruppen- und Straßenverwaltung, CSV-Import, Historie + Revert, Transactionlog Vollständige Administration
|
||||||
|
Phase 5: Karten-Views Login-Flow finalisieren, Dispatcher-Prototyp (Karte + Accordion), str2pl.js Integration, Polylines/Marker, Code 100/200/300 Erster funktionsfähiger Kartenprototyp
|
||||||
|
Phase 6: Weitere Views Dispatcher-Mobil, Gruppen-View, Präsentations-View, Öffentlicher-View Abdeckung aller geforderter Views
|
||||||
|
Phase 7: Feintuning Logging, Cleanup alter Nachrichten, LocalStorage, Responsiveness, Fehlerbehandlung Stabilisierung für den Entwicklungsstand
|
||||||
|
14. Fazit
|
||||||
|
Der hier beschriebene Aufbau trennt klar zwischen Datenzugriff, Geschäftslogik, Echtzeitkommunikation und Frontend. Durch das mandantenfähige Datenmodell, das eigene WebSocket-Protokoll mit Routing nach Account/Rolle/Gruppenverknüpfung, den In-Memory-Cache für Gruppen, die reversible State-Historie und das ausführliche Transaktionslogging wird bereits im Grundgerüst die geforderte Erweiterbarkeit für die später noch hinzuzufügende Applikationslogik geschaffen.
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# CMBNet
|
||||||
|
|
||||||
|
Webanwendung für die Verwaltung von Straßen und Gruppen mit Kartendarstellung.
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd CMBNet
|
||||||
|
python3 -m venv .venv
|
||||||
|
source .venv/bin/activate
|
||||||
|
pip install -r requirements.txt
|
||||||
|
mkdir -p instance logs data migrations
|
||||||
|
flask --app cmbnet init-db
|
||||||
|
flask --app cmbnet run --debug --host 127.0.0.1 --port 5000
|
||||||
|
```
|
||||||
|
|
||||||
|
## Zugriff
|
||||||
|
|
||||||
|
Öffne http://127.0.0.1:5000 und wähle einen Mandanten (BV, RV, SV).
|
||||||
|
|
||||||
|
## Erste Einrichtung
|
||||||
|
|
||||||
|
Nach der Initialisierung der Datenbank müssen noch Mandanten und ein Admin-Account angelegt werden.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sqlite3 instance/cmbnet.sqlite3
|
||||||
|
INSERT INTO tenants (code, name) VALUES ('BV', 'Bezirk BV'), ('RV', 'Bezirk RV'), ('SV', 'Bezirk SV');
|
||||||
|
INSERT INTO accounts (tenant_id, name, password_hash, role) VALUES (2, 'admin', '...', 'Administrator');
|
||||||
|
```
|
||||||
|
|
||||||
|
Für den Passwort-Hash kann `python3 -c "from werkzeug.security import generate_password_hash; print(generate_password_hash('admin'))"` verwendet werden.
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
from cmbnet import create_app
|
||||||
|
|
||||||
|
app = create_app()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(debug=True)
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
import os
|
||||||
|
from flask import Flask, g, session
|
||||||
|
from config import config
|
||||||
|
from cmbnet.extensions import sock
|
||||||
|
|
||||||
|
|
||||||
|
def create_app(config_name=None):
|
||||||
|
if config_name is None:
|
||||||
|
config_name = os.environ.get('FLASK_ENV', 'development')
|
||||||
|
|
||||||
|
app = Flask(__name__,
|
||||||
|
template_folder='../templates',
|
||||||
|
static_folder='../static')
|
||||||
|
app.config.from_object(config[config_name])
|
||||||
|
|
||||||
|
# Stelle sicher, dass instance Verzeichnis existiert
|
||||||
|
os.makedirs(app.instance_path, exist_ok=True)
|
||||||
|
os.makedirs(app.config['LOG_DIR'], exist_ok=True)
|
||||||
|
|
||||||
|
# Sock initialisieren
|
||||||
|
sock.init_app(app)
|
||||||
|
|
||||||
|
# Datenbank-Setup
|
||||||
|
from cmbnet.db import close_db, init_db_command
|
||||||
|
app.teardown_appcontext(close_db)
|
||||||
|
app.cli.add_command(init_db_command)
|
||||||
|
|
||||||
|
# Tenant und Account für Requests laden
|
||||||
|
@app.before_request
|
||||||
|
def load_current_account():
|
||||||
|
if 'account_id' in session:
|
||||||
|
from cmbnet.db import get_db
|
||||||
|
db = get_db()
|
||||||
|
account = db.execute('SELECT a.*, t.code as tenant_code FROM accounts a JOIN tenants t ON a.tenant_id = t.id WHERE a.id = ?', (session['account_id'],)).fetchone()
|
||||||
|
if account:
|
||||||
|
g.current_account = account
|
||||||
|
g.tenant_id = account['tenant_id']
|
||||||
|
g.tenant_code = account['tenant_code']
|
||||||
|
else:
|
||||||
|
session.clear()
|
||||||
|
|
||||||
|
# Blueprints registrieren
|
||||||
|
from cmbnet.views import auth_bp, views_bp
|
||||||
|
from cmbnet.admin.accounts import admin_accounts_bp
|
||||||
|
from cmbnet.admin.gruppen import admin_gruppen_bp
|
||||||
|
from cmbnet.admin.strassen import admin_strassen_bp
|
||||||
|
from cmbnet.admin.api import admin_api_bp
|
||||||
|
from cmbnet.api.init import api_init_bp
|
||||||
|
from cmbnet.api.auth import api_auth_bp
|
||||||
|
|
||||||
|
app.register_blueprint(auth_bp, url_prefix='/<tenant>')
|
||||||
|
app.register_blueprint(views_bp, url_prefix='/<tenant>')
|
||||||
|
# Admin-Views immer unter /<tenant>/admin/..., damit sie nicht mit den
|
||||||
|
# rollenspezifischen Views (z. B. views.gruppen unter /<tenant>/gruppen)
|
||||||
|
# kollidieren.
|
||||||
|
app.register_blueprint(admin_accounts_bp, url_prefix='/<tenant>/admin')
|
||||||
|
app.register_blueprint(admin_gruppen_bp, url_prefix='/<tenant>/admin')
|
||||||
|
app.register_blueprint(admin_strassen_bp, url_prefix='/<tenant>/admin')
|
||||||
|
app.register_blueprint(admin_api_bp, url_prefix='/<tenant>/admin/api')
|
||||||
|
app.register_blueprint(api_init_bp, url_prefix='/<tenant>/api')
|
||||||
|
app.register_blueprint(api_auth_bp, url_prefix='/<tenant>/api')
|
||||||
|
|
||||||
|
# WebSocket Routes laden
|
||||||
|
from cmbnet.ws import routes
|
||||||
|
|
||||||
|
# Heartbeat starten (Code 1 jede Minute, Aufräumen alter Nachrichten)
|
||||||
|
from cmbnet.ws.heartbeat import heartbeat_manager
|
||||||
|
heartbeat_manager.start(
|
||||||
|
app,
|
||||||
|
interval=app.config.get('WS_HEARTBEAT_INTERVAL', 60)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Root redirect
|
||||||
|
@app.route('/')
|
||||||
|
def index():
|
||||||
|
from flask import redirect, url_for
|
||||||
|
return redirect(url_for('auth.login_select'))
|
||||||
|
|
||||||
|
return app
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
from .accounts import admin_accounts_bp
|
||||||
|
from .gruppen import admin_gruppen_bp
|
||||||
|
from .strassen import admin_strassen_bp
|
||||||
|
from .api import admin_api_bp
|
||||||
|
|
||||||
|
admin_bp = admin_accounts_bp
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
"""
|
||||||
|
Accountverwaltung
|
||||||
|
"""
|
||||||
|
from flask import Blueprint, render_template, g
|
||||||
|
from cmbnet.auth import role_required
|
||||||
|
from cmbnet.db import get_db
|
||||||
|
|
||||||
|
admin_accounts_bp = Blueprint('admin', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@admin_accounts_bp.route('/accounts')
|
||||||
|
@role_required('Administrator')
|
||||||
|
def accounts(**kwargs):
|
||||||
|
"""Accountverwaltung"""
|
||||||
|
db = get_db()
|
||||||
|
accounts = db.execute(
|
||||||
|
'SELECT a.*, t.code as tenant_code FROM accounts a JOIN tenants t ON a.tenant_id = t.id WHERE a.tenant_id = ? ORDER BY a.id',
|
||||||
|
(g.tenant_id,)
|
||||||
|
).fetchall()
|
||||||
|
return render_template('admin/accounts.html', accounts=accounts)
|
||||||
@@ -0,0 +1,365 @@
|
|||||||
|
"""
|
||||||
|
Admin API Endpunkte
|
||||||
|
"""
|
||||||
|
from flask import Blueprint, request, jsonify, g, session
|
||||||
|
from cmbnet.auth import role_required
|
||||||
|
from cmbnet.db import get_db
|
||||||
|
from cmbnet.auth import hash_password
|
||||||
|
from cmbnet.models.accounts import AccountModel
|
||||||
|
from cmbnet.models.groups import GroupModel
|
||||||
|
from cmbnet.models.streets import StreetModel
|
||||||
|
from cmbnet.services.groups_service import GroupsService
|
||||||
|
from cmbnet.services.history_service import HistoryService
|
||||||
|
from cmbnet.utils.helpers import log_transaction
|
||||||
|
from cmbnet.utils.csv_utils import parse_streets_csv
|
||||||
|
from cmbnet.ws import broker
|
||||||
|
from cmbnet.ws.protocol import WSMessage
|
||||||
|
import json
|
||||||
|
|
||||||
|
admin_api_bp = Blueprint('admin_api', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
# === ACCOUNTS ===
|
||||||
|
@admin_api_bp.route('/accounts', methods=['POST'])
|
||||||
|
@role_required('Administrator')
|
||||||
|
def create_account(**kwargs):
|
||||||
|
data = request.get_json()
|
||||||
|
name = data.get('name', '').strip()
|
||||||
|
password = data.get('password', '')
|
||||||
|
role = data.get('role', 'Gast')
|
||||||
|
|
||||||
|
if not name or not password:
|
||||||
|
return jsonify({'error': 'Name und Passwort erforderlich'}), 400
|
||||||
|
|
||||||
|
existing = AccountModel.get_by_name_and_tenant(name, g.tenant_id)
|
||||||
|
if existing:
|
||||||
|
return jsonify({'error': 'Account existiert bereits'}), 400
|
||||||
|
|
||||||
|
password_hash = hash_password(password)
|
||||||
|
account_id = AccountModel.create(g.tenant_id, name, password_hash, role)
|
||||||
|
log_transaction('account.create', 'account', account_id, {'name': name, 'role': role})
|
||||||
|
|
||||||
|
return jsonify({'success': True, 'id': account_id})
|
||||||
|
|
||||||
|
|
||||||
|
@admin_api_bp.route('/accounts/<int:account_id>/role', methods=['POST'])
|
||||||
|
@role_required('Administrator')
|
||||||
|
def update_account_role(account_id, **kwargs):
|
||||||
|
data = request.get_json()
|
||||||
|
role = data.get('role')
|
||||||
|
AccountModel.update_role(account_id, g.tenant_id, role)
|
||||||
|
log_transaction('account.role_change', 'account', account_id, {'role': role})
|
||||||
|
GroupsService.invalidate(g.tenant_id)
|
||||||
|
return jsonify({'success': True})
|
||||||
|
|
||||||
|
|
||||||
|
@admin_api_bp.route('/accounts/<int:account_id>/password', methods=['POST'])
|
||||||
|
@role_required('Administrator')
|
||||||
|
def reset_password(account_id, **kwargs):
|
||||||
|
data = request.get_json()
|
||||||
|
password = data.get('password', '')
|
||||||
|
if not password:
|
||||||
|
return jsonify({'error': 'Passwort erforderlich'}), 400
|
||||||
|
password_hash = hash_password(password)
|
||||||
|
AccountModel.set_password(account_id, g.tenant_id, password_hash)
|
||||||
|
log_transaction('account.password_reset', 'account', account_id, {})
|
||||||
|
return jsonify({'success': True})
|
||||||
|
|
||||||
|
|
||||||
|
@admin_api_bp.route('/accounts/<int:account_id>', methods=['DELETE'])
|
||||||
|
@role_required('Administrator')
|
||||||
|
def delete_account(account_id, **kwargs):
|
||||||
|
AccountModel.delete(account_id, g.tenant_id)
|
||||||
|
log_transaction('account.delete', 'account', account_id, {})
|
||||||
|
GroupsService.invalidate(g.tenant_id)
|
||||||
|
return jsonify({'success': True})
|
||||||
|
|
||||||
|
|
||||||
|
# === GRUPPEN ===
|
||||||
|
@admin_api_bp.route('/gruppen', methods=['POST'])
|
||||||
|
@role_required('Administrator')
|
||||||
|
def create_group(**kwargs):
|
||||||
|
data = request.get_json() or {}
|
||||||
|
aliasname = str(data.get('aliasname') or '').strip()
|
||||||
|
account_id = data.get('account_id')
|
||||||
|
db = get_db()
|
||||||
|
|
||||||
|
if account_id == '' or account_id is None:
|
||||||
|
account_id = None
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
account_id = int(account_id)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return jsonify({'error': 'Ungültiger Account'}), 400
|
||||||
|
|
||||||
|
account = AccountModel.get_by_id(account_id, g.tenant_id)
|
||||||
|
if not account or account['role'] != 'Gruppe':
|
||||||
|
return jsonify({'error': 'Account muss die Rolle "Gruppe" haben'}), 400
|
||||||
|
|
||||||
|
linked = db.execute(
|
||||||
|
'SELECT id FROM groups WHERE tenant_id = ? AND account_id = ?',
|
||||||
|
(g.tenant_id, account_id)
|
||||||
|
).fetchone()
|
||||||
|
if linked:
|
||||||
|
return jsonify({'error': 'Dieser Account ist bereits mit einer Gruppe verknüpft'}), 400
|
||||||
|
|
||||||
|
group_id = GroupModel.create(g.tenant_id, aliasname, account_id, 'offen')
|
||||||
|
db.execute(
|
||||||
|
'INSERT INTO group_state_history (tenant_id, group_id, from_state, to_state, actor_account_id) VALUES (?, ?, ?, ?, ?)',
|
||||||
|
(g.tenant_id, group_id, None, 'offen', session['account_id'])
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
log_transaction('group.create', 'group', group_id, {'aliasname': aliasname, 'account_id': account_id})
|
||||||
|
GroupsService.invalidate(g.tenant_id)
|
||||||
|
GroupsService.load_from_db(g.tenant_id)
|
||||||
|
return jsonify({'success': True, 'id': group_id})
|
||||||
|
|
||||||
|
|
||||||
|
@admin_api_bp.route('/gruppen/<int:group_id>', methods=['POST'])
|
||||||
|
@role_required('Administrator')
|
||||||
|
def update_group(group_id, **kwargs):
|
||||||
|
data = request.get_json() or {}
|
||||||
|
db = get_db()
|
||||||
|
old = GroupModel.get_by_id(group_id, g.tenant_id)
|
||||||
|
if not old:
|
||||||
|
return jsonify({'error': 'Gruppe nicht gefunden'}), 404
|
||||||
|
|
||||||
|
updates = {}
|
||||||
|
if 'aliasname' in data:
|
||||||
|
updates['aliasname'] = data['aliasname']
|
||||||
|
|
||||||
|
if 'account_id' in data:
|
||||||
|
account_id = data['account_id']
|
||||||
|
if account_id in ('', None):
|
||||||
|
account_id = None
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
account_id = int(account_id)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return jsonify({'error': 'Ungültiger Account'}), 400
|
||||||
|
|
||||||
|
account = AccountModel.get_by_id(account_id, g.tenant_id)
|
||||||
|
if not account or account['role'] != 'Gruppe':
|
||||||
|
return jsonify({'error': 'Account muss die Rolle "Gruppe" haben'}), 400
|
||||||
|
|
||||||
|
linked = db.execute(
|
||||||
|
'SELECT id FROM groups WHERE tenant_id = ? AND account_id = ? AND id != ?',
|
||||||
|
(g.tenant_id, account_id, group_id)
|
||||||
|
).fetchone()
|
||||||
|
if linked:
|
||||||
|
return jsonify({'error': 'Dieser Account ist bereits mit einer Gruppe verknüpft'}), 400
|
||||||
|
|
||||||
|
if account_id != old['account_id']:
|
||||||
|
updates['account_id'] = account_id
|
||||||
|
|
||||||
|
allowed_states = {'offen', 'unterwegs', 'online', 'pausierend', 'fertig'}
|
||||||
|
state_changed = False
|
||||||
|
if 'state' in data:
|
||||||
|
new_state = data['state']
|
||||||
|
if new_state not in allowed_states:
|
||||||
|
return jsonify({'error': 'Ungültiger State'}), 400
|
||||||
|
if new_state != old['state']:
|
||||||
|
updates['state'] = new_state
|
||||||
|
state_changed = True
|
||||||
|
|
||||||
|
if not updates:
|
||||||
|
return jsonify({'success': True})
|
||||||
|
|
||||||
|
GroupModel.update(group_id, g.tenant_id, **updates)
|
||||||
|
|
||||||
|
if state_changed:
|
||||||
|
db.execute(
|
||||||
|
'INSERT INTO group_state_history (tenant_id, group_id, from_state, to_state, actor_account_id) VALUES (?, ?, ?, ?, ?)',
|
||||||
|
(g.tenant_id, group_id, old['state'], updates['state'], session['account_id'])
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
msg = WSMessage(sender_id=session['account_id'], code=200,
|
||||||
|
msg=json.dumps({'group_id': group_id, 'state': updates['state'], 'actor': session['account_id']}))
|
||||||
|
try:
|
||||||
|
broker.route_message(g.tenant_id, msg)
|
||||||
|
except Exception as e:
|
||||||
|
print(f'Broker error: {e}')
|
||||||
|
|
||||||
|
log_transaction('group.update', 'group', group_id, updates)
|
||||||
|
GroupsService.invalidate(g.tenant_id)
|
||||||
|
GroupsService.load_from_db(g.tenant_id)
|
||||||
|
return jsonify({'success': True})
|
||||||
|
|
||||||
|
|
||||||
|
@admin_api_bp.route('/gruppen/<int:group_id>', methods=['DELETE'])
|
||||||
|
@role_required('Administrator')
|
||||||
|
def delete_group(group_id, **kwargs):
|
||||||
|
GroupModel.delete(group_id, g.tenant_id)
|
||||||
|
log_transaction('group.delete', 'group', group_id, {})
|
||||||
|
GroupsService.invalidate(g.tenant_id)
|
||||||
|
return jsonify({'success': True})
|
||||||
|
|
||||||
|
|
||||||
|
@admin_api_bp.route('/gruppen/<int:group_id>/history')
|
||||||
|
@role_required('Administrator')
|
||||||
|
def group_history(group_id, **kwargs):
|
||||||
|
db = get_db()
|
||||||
|
history = db.execute(
|
||||||
|
'SELECT h.*, a.name as actor_name FROM group_state_history h LEFT JOIN accounts a ON h.actor_account_id = a.id WHERE h.group_id = ? AND h.tenant_id = ? ORDER BY h.created_at DESC',
|
||||||
|
(group_id, g.tenant_id)
|
||||||
|
).fetchall()
|
||||||
|
return jsonify([dict(row) for row in history])
|
||||||
|
|
||||||
|
|
||||||
|
@admin_api_bp.route('/gruppen/<int:group_id>/history/<int:hist_id>/revert', methods=['POST'])
|
||||||
|
@role_required('Administrator')
|
||||||
|
def revert_group_hist(group_id, hist_id, **kwargs):
|
||||||
|
success, msg = HistoryService.revert_group(g.tenant_id, group_id, hist_id, session['account_id'])
|
||||||
|
if not success:
|
||||||
|
return jsonify({'error': msg}), 400
|
||||||
|
return jsonify({'success': True, 'message': msg})
|
||||||
|
|
||||||
|
|
||||||
|
@admin_api_bp.route('/gruppen/<int:group_id>/position/history/<int:hist_id>', methods=['POST'])
|
||||||
|
@role_required('Administrator')
|
||||||
|
def set_group_position_from_history(group_id, hist_id, **kwargs):
|
||||||
|
success, msg = HistoryService.set_group_position_from_history(
|
||||||
|
g.tenant_id, group_id, hist_id, session['account_id']
|
||||||
|
)
|
||||||
|
if not success:
|
||||||
|
return jsonify({'error': msg}), 400
|
||||||
|
return jsonify({'success': True, 'message': msg})
|
||||||
|
|
||||||
|
|
||||||
|
@admin_api_bp.route('/gruppen/<int:group_id>/position', methods=['DELETE'])
|
||||||
|
@role_required('Administrator')
|
||||||
|
def clear_group_position(group_id, **kwargs):
|
||||||
|
success, msg = HistoryService.clear_group_position(
|
||||||
|
g.tenant_id, group_id, session['account_id']
|
||||||
|
)
|
||||||
|
if not success:
|
||||||
|
return jsonify({'error': msg}), 400
|
||||||
|
return jsonify({'success': True, 'message': msg})
|
||||||
|
|
||||||
|
|
||||||
|
# === STRASSEN ===
|
||||||
|
@admin_api_bp.route('/strassen', methods=['POST'])
|
||||||
|
@role_required('Administrator')
|
||||||
|
def create_street(**kwargs):
|
||||||
|
data = request.get_json()
|
||||||
|
name = data.get('name', '').strip()
|
||||||
|
if not name:
|
||||||
|
return jsonify({'error': 'Name erforderlich'}), 400
|
||||||
|
street_id = StreetModel.create(g.tenant_id, name,
|
||||||
|
hn_min=data.get('hn_min'),
|
||||||
|
hn_max=data.get('hn_max'),
|
||||||
|
bbox=data.get('bbox'),
|
||||||
|
state='unbearbeitet',
|
||||||
|
group_id=None)
|
||||||
|
db = get_db()
|
||||||
|
db.execute(
|
||||||
|
'INSERT INTO street_state_history (tenant_id, street_id, from_state, to_state, group_id, actor_account_id) VALUES (?, ?, ?, ?, ?, ?)',
|
||||||
|
(g.tenant_id, street_id, None, 'unbearbeitet', None, session['account_id'])
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
log_transaction('street.create', 'street', street_id, {'name': name})
|
||||||
|
return jsonify({'success': True, 'id': street_id})
|
||||||
|
|
||||||
|
|
||||||
|
@admin_api_bp.route('/strassen/<int:street_id>', methods=['POST'])
|
||||||
|
@role_required('Administrator')
|
||||||
|
def update_street(street_id, **kwargs):
|
||||||
|
data = request.get_json()
|
||||||
|
db = get_db()
|
||||||
|
old = StreetModel.get_by_id(street_id, g.tenant_id)
|
||||||
|
if not old:
|
||||||
|
return jsonify({'error': 'Straße nicht gefunden'}), 404
|
||||||
|
|
||||||
|
changes = {}
|
||||||
|
for key in ['name', 'hn_min', 'hn_max', 'bbox', 'group_id']:
|
||||||
|
if key in data:
|
||||||
|
if key == 'group_id' and (data[key] == '' or data[key] is None):
|
||||||
|
changes[key] = None
|
||||||
|
elif key in ['hn_min', 'hn_max'] and data[key] != '' and data[key] is not None:
|
||||||
|
try:
|
||||||
|
changes[key] = int(data[key])
|
||||||
|
except:
|
||||||
|
changes[key] = data[key]
|
||||||
|
else:
|
||||||
|
changes[key] = data[key]
|
||||||
|
|
||||||
|
if 'state' in data and data['state'] != old['state']:
|
||||||
|
changes['state'] = data['state']
|
||||||
|
if data['state'] == 'unbearbeitet':
|
||||||
|
changes['group_id'] = None
|
||||||
|
db.execute(
|
||||||
|
'INSERT INTO street_state_history (tenant_id, street_id, from_state, to_state, group_id, actor_account_id) VALUES (?, ?, ?, ?, ?, ?)',
|
||||||
|
(g.tenant_id, street_id, old['state'], data['state'], changes.get('group_id', old['group_id']), session['account_id'])
|
||||||
|
)
|
||||||
|
# Code 100
|
||||||
|
msg = WSMessage(sender_id=session['account_id'], code=100,
|
||||||
|
msg=json.dumps({'name': old['name'], 'state': data['state'], 'actor': session['account_id'],
|
||||||
|
'street_id': street_id, 'group_id': changes.get('group_id', old['group_id'])}))
|
||||||
|
try:
|
||||||
|
broker.route_message(g.tenant_id, msg)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if changes:
|
||||||
|
StreetModel.update(street_id, g.tenant_id, **changes)
|
||||||
|
log_transaction('street.update', 'street', street_id, changes)
|
||||||
|
|
||||||
|
db.commit()
|
||||||
|
return jsonify({'success': True})
|
||||||
|
|
||||||
|
|
||||||
|
@admin_api_bp.route('/strassen/<int:street_id>', methods=['DELETE'])
|
||||||
|
@role_required('Administrator')
|
||||||
|
def delete_street(street_id, **kwargs):
|
||||||
|
StreetModel.delete(street_id, g.tenant_id)
|
||||||
|
log_transaction('street.delete', 'street', street_id, {})
|
||||||
|
return jsonify({'success': True})
|
||||||
|
|
||||||
|
|
||||||
|
@admin_api_bp.route('/strassen/<int:street_id>/history')
|
||||||
|
@role_required('Administrator')
|
||||||
|
def street_history(street_id, **kwargs):
|
||||||
|
db = get_db()
|
||||||
|
history = db.execute(
|
||||||
|
'SELECT h.*, a.name as actor_name FROM street_state_history h LEFT JOIN accounts a ON h.actor_account_id = a.id WHERE h.street_id = ? AND h.tenant_id = ? ORDER BY h.created_at DESC',
|
||||||
|
(street_id, g.tenant_id)
|
||||||
|
).fetchall()
|
||||||
|
return jsonify([dict(row) for row in history])
|
||||||
|
|
||||||
|
|
||||||
|
@admin_api_bp.route('/strassen/<int:street_id>/history/<int:hist_id>/revert', methods=['POST'])
|
||||||
|
@role_required('Administrator')
|
||||||
|
def revert_street_hist(street_id, hist_id, **kwargs):
|
||||||
|
success, msg = HistoryService.revert_street(g.tenant_id, street_id, hist_id, session['account_id'])
|
||||||
|
if not success:
|
||||||
|
return jsonify({'error': msg}), 400
|
||||||
|
return jsonify({'success': True, 'message': msg})
|
||||||
|
|
||||||
|
|
||||||
|
@admin_api_bp.route('/strassen/import', methods=['POST'])
|
||||||
|
@role_required('Administrator')
|
||||||
|
def import_streets(**kwargs):
|
||||||
|
if 'file' not in request.files:
|
||||||
|
return jsonify({'error': 'Keine Datei'}), 400
|
||||||
|
file = request.files['file']
|
||||||
|
if file.filename == '':
|
||||||
|
return jsonify({'error': 'Keine Datei ausgewählt'}), 400
|
||||||
|
|
||||||
|
content = file.read()
|
||||||
|
if len(content) > 5_000_000:
|
||||||
|
return jsonify({'error': 'Datei zu groß'}), 400
|
||||||
|
|
||||||
|
streets_data = parse_streets_csv(content)
|
||||||
|
db = get_db()
|
||||||
|
count = 0
|
||||||
|
for s in streets_data:
|
||||||
|
street_id = StreetModel.create(g.tenant_id, s['name'], s['hn_min'], s['hn_max'], s['bbox'], 'unbearbeitet', None)
|
||||||
|
db.execute(
|
||||||
|
'INSERT INTO street_state_history (tenant_id, street_id, from_state, to_state, group_id, actor_account_id) VALUES (?, ?, ?, ?, ?, ?)',
|
||||||
|
(g.tenant_id, street_id, None, 'unbearbeitet', None, session['account_id'])
|
||||||
|
)
|
||||||
|
log_transaction('street.import', 'street', street_id, {'name': s['name']})
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
db.commit()
|
||||||
|
return jsonify({'success': True, 'count': count})
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
"""
|
||||||
|
Gruppenverwaltung
|
||||||
|
"""
|
||||||
|
from flask import Blueprint, render_template, g
|
||||||
|
from cmbnet.auth import role_required
|
||||||
|
from cmbnet.db import get_db
|
||||||
|
|
||||||
|
admin_gruppen_bp = Blueprint('admin_gruppen', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@admin_gruppen_bp.route('/gruppen')
|
||||||
|
@role_required('Administrator')
|
||||||
|
def gruppen(**kwargs):
|
||||||
|
"""Gruppenverwaltung"""
|
||||||
|
db = get_db()
|
||||||
|
gruppen = db.execute(
|
||||||
|
'SELECT g.*, a.name as account_name FROM groups g LEFT JOIN accounts a ON g.account_id = a.id WHERE g.tenant_id = ? ORDER BY g.id',
|
||||||
|
(g.tenant_id,)
|
||||||
|
).fetchall()
|
||||||
|
accounts = db.execute(
|
||||||
|
"SELECT * FROM accounts WHERE tenant_id = ? AND role = 'Gruppe'",
|
||||||
|
(g.tenant_id,)
|
||||||
|
).fetchall()
|
||||||
|
return render_template('admin/gruppen.html', gruppen=gruppen, accounts=accounts)
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
"""
|
||||||
|
Straßenverwaltung
|
||||||
|
"""
|
||||||
|
from flask import Blueprint, render_template, g
|
||||||
|
from cmbnet.auth import role_required
|
||||||
|
from cmbnet.db import get_db
|
||||||
|
|
||||||
|
admin_strassen_bp = Blueprint('admin_strassen', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@admin_strassen_bp.route('/strassen')
|
||||||
|
@role_required('Administrator')
|
||||||
|
def strassen(**kwargs):
|
||||||
|
"""Straßenverwaltung"""
|
||||||
|
db = get_db()
|
||||||
|
strassen = db.execute(
|
||||||
|
'SELECT s.*, g.aliasname as group_name FROM streets s LEFT JOIN groups g ON s.group_id = g.id WHERE s.tenant_id = ? ORDER BY s.name',
|
||||||
|
(g.tenant_id,)
|
||||||
|
).fetchall()
|
||||||
|
gruppen = db.execute(
|
||||||
|
'SELECT * FROM groups WHERE tenant_id = ? ORDER BY id',
|
||||||
|
(g.tenant_id,)
|
||||||
|
).fetchall()
|
||||||
|
return render_template('admin/strassen.html', strassen=strassen, gruppen=gruppen)
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
from .init import api_init_bp
|
||||||
|
from .auth import api_auth_bp
|
||||||
|
|
||||||
|
api_bp = api_init_bp
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
"""
|
||||||
|
API Auth Endpunkte
|
||||||
|
"""
|
||||||
|
from flask import Blueprint, jsonify, g, session
|
||||||
|
from cmbnet.auth import login_required
|
||||||
|
from cmbnet.db import get_db
|
||||||
|
import secrets
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
api_auth_bp = Blueprint('api_auth', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@api_auth_bp.route('/auth/ws-token', methods=['GET', 'POST'])
|
||||||
|
@login_required
|
||||||
|
def ws_token(**kwargs):
|
||||||
|
"""Erzeugt ein Zugriffstoken für WebSocket-Authentifizierung"""
|
||||||
|
db = get_db()
|
||||||
|
token = secrets.token_urlsafe(32)
|
||||||
|
expires_at = datetime.now() + timedelta(hours=1)
|
||||||
|
|
||||||
|
db.execute(
|
||||||
|
'INSERT INTO ws_tokens (tenant_id, account_id, token, expires_at) VALUES (?, ?, ?, ?)',
|
||||||
|
(g.tenant_id, session['account_id'], token, expires_at)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
return jsonify({'token': token})
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
"""
|
||||||
|
API Endpunkte für Initialdaten
|
||||||
|
"""
|
||||||
|
from flask import Blueprint, jsonify, g
|
||||||
|
from cmbnet.auth import login_required
|
||||||
|
from cmbnet.services.streets_service import StreetsService
|
||||||
|
from cmbnet.services.groups_service import GroupsService
|
||||||
|
|
||||||
|
api_init_bp = Blueprint('api_init', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@api_init_bp.route('/init/streets')
|
||||||
|
@login_required
|
||||||
|
def init_streets(**kwargs):
|
||||||
|
"""Liefert alle Straßen für den Initialload"""
|
||||||
|
streets = StreetsService.get_all_for_init(g.tenant_id)
|
||||||
|
return jsonify(streets)
|
||||||
|
|
||||||
|
|
||||||
|
@api_init_bp.route('/init/groups')
|
||||||
|
@login_required
|
||||||
|
def init_groups(**kwargs):
|
||||||
|
"""Liefert alle Gruppen für den Initialload (aus Cache)"""
|
||||||
|
groups_dict = GroupsService.get_all(g.tenant_id)
|
||||||
|
groups_list = list(groups_dict.values())
|
||||||
|
return jsonify(groups_list)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
from .decorators import login_required, role_required, tenant_required
|
||||||
|
from .utils import verify_password, hash_password
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
"""
|
||||||
|
Authentifizierungs-Decoratoren
|
||||||
|
"""
|
||||||
|
from functools import wraps
|
||||||
|
from flask import session, redirect, url_for, request, g, abort, flash
|
||||||
|
|
||||||
|
|
||||||
|
def _get_tenant_for_redirect():
|
||||||
|
"""Hilfsfunktion um Tenant für Redirect zu ermitteln"""
|
||||||
|
if hasattr(g, 'tenant_code') and g.tenant_code:
|
||||||
|
return g.tenant_code
|
||||||
|
if 'tenant_code' in session:
|
||||||
|
return session['tenant_code']
|
||||||
|
# Versuche aus URL
|
||||||
|
tenant = request.view_args.get('tenant') if request.view_args else None
|
||||||
|
if tenant:
|
||||||
|
return tenant
|
||||||
|
return 'RV'
|
||||||
|
|
||||||
|
|
||||||
|
def login_required(f):
|
||||||
|
"""Decorator für routes die einen eingeloggten Account erfordern"""
|
||||||
|
@wraps(f)
|
||||||
|
def decorated_function(*args, **kwargs):
|
||||||
|
if 'account_id' not in session:
|
||||||
|
return redirect(url_for('auth.login', tenant=_get_tenant_for_redirect()))
|
||||||
|
return f(*args, **kwargs)
|
||||||
|
return decorated_function
|
||||||
|
|
||||||
|
|
||||||
|
def role_required(roles):
|
||||||
|
"""Decorator für routes die bestimmte Rollen erfordern"""
|
||||||
|
if isinstance(roles, str):
|
||||||
|
roles = [roles]
|
||||||
|
|
||||||
|
def decorator(f):
|
||||||
|
@wraps(f)
|
||||||
|
def decorated_function(*args, **kwargs):
|
||||||
|
if 'account_id' not in session:
|
||||||
|
return redirect(url_for('auth.login', tenant=_get_tenant_for_redirect()))
|
||||||
|
|
||||||
|
account_role = session.get('role')
|
||||||
|
if account_role not in roles:
|
||||||
|
abort(403)
|
||||||
|
return f(*args, **kwargs)
|
||||||
|
return decorated_function
|
||||||
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
|
def tenant_required(f):
|
||||||
|
"""Decorator für tenant-spezifische Routes"""
|
||||||
|
@wraps(f)
|
||||||
|
def decorated_function(*args, **kwargs):
|
||||||
|
# Tenant wird bereits in der Route über URL extrahiert
|
||||||
|
return f(*args, **kwargs)
|
||||||
|
return decorated_function
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
"""
|
||||||
|
Authentifizierungs-Hilfsfunktionen
|
||||||
|
"""
|
||||||
|
from werkzeug.security import generate_password_hash, check_password_hash
|
||||||
|
|
||||||
|
|
||||||
|
def hash_password(password):
|
||||||
|
"""Erstellt einen Passwort-Hash"""
|
||||||
|
return generate_password_hash(password)
|
||||||
|
|
||||||
|
|
||||||
|
def verify_password(password_hash, password):
|
||||||
|
"""Überprüft ein Passwort gegen den Hash"""
|
||||||
|
return check_password_hash(password_hash, password)
|
||||||
Whitespace-only changes.
@@ -0,0 +1,41 @@
|
|||||||
|
"""
|
||||||
|
Transaktionslogging für CMBNet
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
from datetime import datetime
|
||||||
|
from pathlib import Path
|
||||||
|
from flask import current_app
|
||||||
|
|
||||||
|
|
||||||
|
def write_transaction_log(tenant_id, actor_id, actor_name, action, entity_type, entity_id, details=None):
|
||||||
|
"""
|
||||||
|
Schreibt einen lesbaren Eintrag ins tägliche Logfile
|
||||||
|
"""
|
||||||
|
log_dir = Path(current_app.config['LOG_DIR'])
|
||||||
|
log_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
date_str = datetime.now().strftime('%Y-%m-%d')
|
||||||
|
log_file = log_dir / f'cmbnet-{date_str}.log'
|
||||||
|
|
||||||
|
timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
|
||||||
|
actor_str = f"{actor_id}({actor_name})" if actor_id and actor_name else "SYSTEM"
|
||||||
|
|
||||||
|
if isinstance(details, dict):
|
||||||
|
details_str = str(details)
|
||||||
|
elif details is None:
|
||||||
|
details_str = "{}"
|
||||||
|
else:
|
||||||
|
details_str = str(details)
|
||||||
|
|
||||||
|
log_line = f"{timestamp} [TENANT:{get_tenant_code(tenant_id)}] [ACTOR:{actor_str}] ACTION:{action} ENTITY:{entity_type}:{entity_id} DETAILS:{details_str}\n"
|
||||||
|
|
||||||
|
with open(log_file, 'a', encoding='utf-8') as f:
|
||||||
|
f.write(log_line)
|
||||||
|
|
||||||
|
|
||||||
|
def get_tenant_code(tenant_id):
|
||||||
|
"""Holt den Tenant-Code für die Logausgabe"""
|
||||||
|
from cmbnet.db import get_db
|
||||||
|
db = get_db()
|
||||||
|
tenant = db.execute('SELECT code FROM tenants WHERE id = ?', (tenant_id,)).fetchone()
|
||||||
|
return tenant['code'] if tenant else str(tenant_id)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
from .database import get_db, close_db, init_db_command
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import sqlite3
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
from flask import current_app, g
|
||||||
|
import click
|
||||||
|
|
||||||
|
|
||||||
|
def get_db():
|
||||||
|
"""Stellt eine Datenbankverbindung für den aktuellen Request bereit"""
|
||||||
|
if 'db' not in g:
|
||||||
|
db_path = current_app.config['DATABASE_PATH']
|
||||||
|
# Stelle sicher, dass das instance Verzeichnis existiert
|
||||||
|
Path(db_path).parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
g.db = sqlite3.connect(db_path)
|
||||||
|
g.db.row_factory = sqlite3.Row
|
||||||
|
return g.db
|
||||||
|
|
||||||
|
|
||||||
|
def close_db(e=None):
|
||||||
|
"""Schließt die Datenbankverbindung am Ende des Requests"""
|
||||||
|
db = g.pop('db', None)
|
||||||
|
if db is not None:
|
||||||
|
db.close()
|
||||||
|
|
||||||
|
|
||||||
|
def init_db():
|
||||||
|
"""Initialisiert die Datenbank mit dem Schema"""
|
||||||
|
db = get_db()
|
||||||
|
schema_path = Path(current_app.root_path).parent / 'migrations' / 'schema.sql'
|
||||||
|
with open(schema_path, 'r', encoding='utf-8') as f:
|
||||||
|
db.executescript(f.read())
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
|
||||||
|
@click.command('init-db')
|
||||||
|
def init_db_command():
|
||||||
|
"""CLI-Befehl zum Initialisieren der Datenbank"""
|
||||||
|
init_db()
|
||||||
|
click.echo('Datenbank wurde initialisiert.')
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
"""
|
||||||
|
Erweiterungen für die CMBNet Anwendung
|
||||||
|
|
||||||
|
Hier liegen gemeinsame Instanzen, die von mehreren Modulen benötigt werden.
|
||||||
|
Wichtig ist eine einzige Sock-Instanz: Routen werden auf diesem Objekt
|
||||||
|
registriert und es muss anschließend mit der Flask-App initialisiert werden.
|
||||||
|
"""
|
||||||
|
from flask_sock import Sock
|
||||||
|
|
||||||
|
sock = Sock()
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
from .accounts import AccountModel
|
||||||
|
from .groups import GroupModel
|
||||||
|
from .streets import StreetModel
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
"""
|
||||||
|
Account Model - Abstraktionsschicht für Datenbankzugriffe
|
||||||
|
"""
|
||||||
|
from cmbnet.db import get_db
|
||||||
|
|
||||||
|
|
||||||
|
class AccountModel:
|
||||||
|
@staticmethod
|
||||||
|
def get_all_by_tenant(tenant_id):
|
||||||
|
db = get_db()
|
||||||
|
return db.execute(
|
||||||
|
'SELECT * FROM accounts WHERE tenant_id = ? ORDER BY id',
|
||||||
|
(tenant_id,)
|
||||||
|
).fetchall()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_by_id(account_id, tenant_id=None):
|
||||||
|
db = get_db()
|
||||||
|
if tenant_id:
|
||||||
|
return db.execute(
|
||||||
|
'SELECT * FROM accounts WHERE id = ? AND tenant_id = ?',
|
||||||
|
(account_id, tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
return db.execute('SELECT * FROM accounts WHERE id = ?', (account_id,)).fetchone()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_by_name_and_tenant(name, tenant_id):
|
||||||
|
db = get_db()
|
||||||
|
return db.execute(
|
||||||
|
'SELECT * FROM accounts WHERE name = ? AND tenant_id = ?',
|
||||||
|
(name, tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def create(tenant_id, name, password_hash, role):
|
||||||
|
db = get_db()
|
||||||
|
cursor = db.execute(
|
||||||
|
'INSERT INTO accounts (tenant_id, name, password_hash, role) VALUES (?, ?, ?, ?)',
|
||||||
|
(tenant_id, name, password_hash, role)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
return cursor.lastrowid
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def update_role(account_id, tenant_id, role):
|
||||||
|
db = get_db()
|
||||||
|
db.execute(
|
||||||
|
'UPDATE accounts SET role = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ? AND tenant_id = ?',
|
||||||
|
(role, account_id, tenant_id)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def set_password(account_id, tenant_id, password_hash):
|
||||||
|
db = get_db()
|
||||||
|
db.execute(
|
||||||
|
'UPDATE accounts SET password_hash = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ? AND tenant_id = ?',
|
||||||
|
(password_hash, account_id, tenant_id)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def delete(account_id, tenant_id):
|
||||||
|
db = get_db()
|
||||||
|
db.execute('DELETE FROM accounts WHERE id = ? AND tenant_id = ?', (account_id, tenant_id))
|
||||||
|
db.commit()
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
"""
|
||||||
|
Group Model - Abstraktionsschicht für Datenbankzugriffe
|
||||||
|
"""
|
||||||
|
from cmbnet.db import get_db
|
||||||
|
|
||||||
|
|
||||||
|
class GroupModel:
|
||||||
|
@staticmethod
|
||||||
|
def get_all_by_tenant(tenant_id):
|
||||||
|
db = get_db()
|
||||||
|
return db.execute(
|
||||||
|
'SELECT * FROM groups WHERE tenant_id = ? ORDER BY id',
|
||||||
|
(tenant_id,)
|
||||||
|
).fetchall()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_by_id(group_id, tenant_id):
|
||||||
|
db = get_db()
|
||||||
|
return db.execute(
|
||||||
|
'SELECT * FROM groups WHERE id = ? AND tenant_id = ?',
|
||||||
|
(group_id, tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_by_account_id(account_id, tenant_id):
|
||||||
|
db = get_db()
|
||||||
|
return db.execute(
|
||||||
|
'SELECT * FROM groups WHERE account_id = ? AND tenant_id = ?',
|
||||||
|
(account_id, tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def create(tenant_id, aliasname, account_id=None, state='offen'):
|
||||||
|
db = get_db()
|
||||||
|
cursor = db.execute(
|
||||||
|
'INSERT INTO groups (tenant_id, aliasname, account_id, state) VALUES (?, ?, ?, ?)',
|
||||||
|
(tenant_id, aliasname, account_id, state)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
return cursor.lastrowid
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def update(group_id, tenant_id, **kwargs):
|
||||||
|
db = get_db()
|
||||||
|
allowed = ['aliasname', 'state', 'account_id', 'last_lat', 'last_lon', 'last_pos_at']
|
||||||
|
updates = []
|
||||||
|
values = []
|
||||||
|
for k, v in kwargs.items():
|
||||||
|
if k in allowed:
|
||||||
|
updates.append(f'{k} = ?')
|
||||||
|
values.append(v)
|
||||||
|
if not updates:
|
||||||
|
return
|
||||||
|
updates.append('updated_at = CURRENT_TIMESTAMP')
|
||||||
|
values.extend([group_id, tenant_id])
|
||||||
|
db.execute(f'UPDATE groups SET {", ".join(updates)} WHERE id = ? AND tenant_id = ?', values)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def delete(group_id, tenant_id):
|
||||||
|
db = get_db()
|
||||||
|
db.execute('DELETE FROM groups WHERE id = ? AND tenant_id = ?', (group_id, tenant_id))
|
||||||
|
db.commit()
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
"""
|
||||||
|
Street Model - Abstraktionsschicht für Datenbankzugriffe
|
||||||
|
"""
|
||||||
|
from cmbnet.db import get_db
|
||||||
|
|
||||||
|
|
||||||
|
class StreetModel:
|
||||||
|
@staticmethod
|
||||||
|
def get_all_by_tenant(tenant_id):
|
||||||
|
db = get_db()
|
||||||
|
return db.execute(
|
||||||
|
'SELECT * FROM streets WHERE tenant_id = ? ORDER BY name',
|
||||||
|
(tenant_id,)
|
||||||
|
).fetchall()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_by_id(street_id, tenant_id):
|
||||||
|
db = get_db()
|
||||||
|
return db.execute(
|
||||||
|
'SELECT * FROM streets WHERE id = ? AND tenant_id = ?',
|
||||||
|
(street_id, tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_by_group_id(group_id, tenant_id):
|
||||||
|
db = get_db()
|
||||||
|
return db.execute(
|
||||||
|
'SELECT * FROM streets WHERE group_id = ? AND tenant_id = ?',
|
||||||
|
(group_id, tenant_id)
|
||||||
|
).fetchall()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def create(tenant_id, name, hn_min=None, hn_max=None, bbox=None, state='unbearbeitet', group_id=None):
|
||||||
|
db = get_db()
|
||||||
|
cursor = db.execute(
|
||||||
|
'INSERT INTO streets (tenant_id, name, hn_min, hn_max, bbox, state, group_id) VALUES (?, ?, ?, ?, ?, ?, ?)',
|
||||||
|
(tenant_id, name, hn_min, hn_max, bbox, state, group_id)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
return cursor.lastrowid
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def update(street_id, tenant_id, **kwargs):
|
||||||
|
db = get_db()
|
||||||
|
allowed = ['name', 'state', 'group_id', 'hn_min', 'hn_max', 'bbox']
|
||||||
|
updates = []
|
||||||
|
values = []
|
||||||
|
for k, v in kwargs.items():
|
||||||
|
if k in allowed:
|
||||||
|
updates.append(f'{k} = ?')
|
||||||
|
values.append(v)
|
||||||
|
if not updates:
|
||||||
|
return
|
||||||
|
updates.append('updated_at = CURRENT_TIMESTAMP')
|
||||||
|
values.extend([street_id, tenant_id])
|
||||||
|
db.execute(f'UPDATE streets SET {", ".join(updates)} WHERE id = ? AND tenant_id = ?', values)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def delete(street_id, tenant_id):
|
||||||
|
db = get_db()
|
||||||
|
db.execute('DELETE FROM streets WHERE id = ? AND tenant_id = ?', (street_id, tenant_id))
|
||||||
|
db.commit()
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
from .groups_service import GroupsService
|
||||||
|
from .streets_service import StreetsService
|
||||||
|
from .accounts_service import AccountsService
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
"""
|
||||||
|
Accounts Service - Geschäftslogik für Accounts
|
||||||
|
"""
|
||||||
|
from cmbnet.models.accounts import AccountModel
|
||||||
|
from cmbnet.auth import verify_password, hash_password
|
||||||
|
|
||||||
|
|
||||||
|
class AccountsService:
|
||||||
|
@staticmethod
|
||||||
|
def verify_account_password(account, password):
|
||||||
|
"""Überprüft Passwort gegen Account"""
|
||||||
|
if not account:
|
||||||
|
return False
|
||||||
|
return verify_password(account['password_hash'], password)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def has_role(account, roles):
|
||||||
|
"""Prüft, ob Account eine der angegebenen Rollen hat"""
|
||||||
|
if isinstance(roles, str):
|
||||||
|
roles = [roles]
|
||||||
|
if not account:
|
||||||
|
return False
|
||||||
|
return account['role'] in roles
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def create_account(tenant_id, name, password, role):
|
||||||
|
"""Erstellt einen neuen Account"""
|
||||||
|
password_hash = hash_password(password)
|
||||||
|
return AccountModel.create(tenant_id, name, password_hash, role)
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
"""
|
||||||
|
Groups Service - Geschäftslogik für Gruppen mit In-Memory-Caching
|
||||||
|
"""
|
||||||
|
from cmbnet.models.groups import GroupModel
|
||||||
|
from cmbnet.models.streets import StreetModel
|
||||||
|
from cmbnet.models.accounts import AccountModel
|
||||||
|
from cmbnet.db import get_db
|
||||||
|
|
||||||
|
|
||||||
|
class GroupsService:
|
||||||
|
# In-Memory Cache: groups_cache[tenant_id][group_id] = group_dict
|
||||||
|
_cache = {}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def load_from_db(cls, tenant_id):
|
||||||
|
"""Lädt alle Gruppen eines Mandanten aus der Datenbank in den Cache"""
|
||||||
|
groups = GroupModel.get_all_by_tenant(tenant_id)
|
||||||
|
if tenant_id not in cls._cache:
|
||||||
|
cls._cache[tenant_id] = {}
|
||||||
|
|
||||||
|
for group in groups:
|
||||||
|
cls._cache[tenant_id][group['id']] = {
|
||||||
|
'id': group['id'],
|
||||||
|
'tenant_id': group['tenant_id'],
|
||||||
|
'aliasname': group['aliasname'],
|
||||||
|
'state': group['state'],
|
||||||
|
'last_lat': group['last_lat'],
|
||||||
|
'last_lon': group['last_lon'],
|
||||||
|
'last_pos_at': group['last_pos_at'],
|
||||||
|
'account_id': group['account_id'],
|
||||||
|
'created_at': group['created_at'],
|
||||||
|
'updated_at': group['updated_at']
|
||||||
|
}
|
||||||
|
return cls._cache[tenant_id]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_all(cls, tenant_id, force_reload=False):
|
||||||
|
"""Gibt alle Gruppen für einen Mandanten zurück (aus Cache)"""
|
||||||
|
if force_reload or tenant_id not in cls._cache or not cls._cache[tenant_id]:
|
||||||
|
cls.load_from_db(tenant_id)
|
||||||
|
return cls._cache.get(tenant_id, {})
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_by_id(cls, tenant_id, group_id):
|
||||||
|
"""Gibt eine spezifische Gruppe aus dem Cache zurück"""
|
||||||
|
if tenant_id not in cls._cache:
|
||||||
|
cls.load_from_db(tenant_id)
|
||||||
|
return cls._cache.get(tenant_id, {}).get(group_id)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def invalidate(cls, tenant_id):
|
||||||
|
"""Invalidiert den Cache für einen Mandanten (erzwingt Neuladen)"""
|
||||||
|
if tenant_id in cls._cache:
|
||||||
|
cls._cache[tenant_id] = {}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def invalidate_all(cls):
|
||||||
|
"""Invalidiert den gesamten Cache"""
|
||||||
|
cls._cache = {}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def is_account_linked(cls, account_id, group_id, tenant_id):
|
||||||
|
"""Prüft, ob ein Account mit einer Gruppe verknüpft ist"""
|
||||||
|
group = cls.get_by_id(tenant_id, group_id)
|
||||||
|
if not group:
|
||||||
|
return False
|
||||||
|
return group.get('account_id') == account_id
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_accounts_for_group(cls, group_id, tenant_id):
|
||||||
|
"""Gibt alle mit einer Gruppe verknüpften Accounts zurück"""
|
||||||
|
group = cls.get_by_id(tenant_id, group_id)
|
||||||
|
if not group or not group.get('account_id'):
|
||||||
|
return []
|
||||||
|
account = AccountModel.get_by_id(group['account_id'], tenant_id)
|
||||||
|
return [account] if account else []
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_streets_for_group(cls, group_id, tenant_id):
|
||||||
|
"""Gibt alle mit einer Gruppe verknüpften Straßen zurück"""
|
||||||
|
return StreetModel.get_by_group_id(group_id, tenant_id)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def update_cache_entry(cls, tenant_id, group_id, data):
|
||||||
|
"""Aktualisiert einen Eintrag im Cache.
|
||||||
|
|
||||||
|
Der Cache wird vor dem Aktualisieren vollständig geladen, damit ein
|
||||||
|
gezieltes Update (z. B. nach Code 200/300) keinen Teil-Cache erzeugt,
|
||||||
|
der anschließend beim Initialload unvollständige Gruppendaten liefert.
|
||||||
|
"""
|
||||||
|
if tenant_id not in cls._cache or not cls._cache[tenant_id]:
|
||||||
|
cls.load_from_db(tenant_id)
|
||||||
|
if group_id not in cls._cache[tenant_id]:
|
||||||
|
cls._cache[tenant_id][group_id] = {}
|
||||||
|
cls._cache[tenant_id][group_id].update(data)
|
||||||
@@ -0,0 +1,276 @@
|
|||||||
|
"""
|
||||||
|
History Service für Revert von States
|
||||||
|
"""
|
||||||
|
import json
|
||||||
|
from datetime import datetime
|
||||||
|
from cmbnet.db import get_db
|
||||||
|
from cmbnet.models.streets import StreetModel
|
||||||
|
from cmbnet.models.groups import GroupModel
|
||||||
|
from cmbnet.services.groups_service import GroupsService
|
||||||
|
from cmbnet.utils.helpers import log_transaction
|
||||||
|
from cmbnet.ws import broker
|
||||||
|
from cmbnet.ws.protocol import WSMessage
|
||||||
|
|
||||||
|
|
||||||
|
class HistoryService:
|
||||||
|
@staticmethod
|
||||||
|
def revert_street(tenant_id, street_id, hist_id, actor_account_id):
|
||||||
|
db = get_db()
|
||||||
|
history = db.execute(
|
||||||
|
'SELECT * FROM street_state_history WHERE id = ? AND tenant_id = ? AND street_id = ?',
|
||||||
|
(hist_id, tenant_id, street_id)
|
||||||
|
).fetchone()
|
||||||
|
if not history:
|
||||||
|
return False, 'Historieneintrag nicht gefunden'
|
||||||
|
|
||||||
|
street = StreetModel.get_by_id(street_id, tenant_id)
|
||||||
|
if not street:
|
||||||
|
return False, 'Straße nicht gefunden'
|
||||||
|
|
||||||
|
old_state = street['state']
|
||||||
|
target_state = history['to_state']
|
||||||
|
target_group_id = history['group_id']
|
||||||
|
|
||||||
|
if target_state == 'unbearbeitet':
|
||||||
|
target_group_id = None
|
||||||
|
|
||||||
|
# Update Straße
|
||||||
|
StreetModel.update(street_id, tenant_id, state=target_state, group_id=target_group_id)
|
||||||
|
|
||||||
|
# Neuen History-Eintrag für den Revert
|
||||||
|
db.execute(
|
||||||
|
'''INSERT INTO street_state_history
|
||||||
|
(tenant_id, street_id, from_state, to_state, group_id, actor_account_id, reason)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?)''',
|
||||||
|
(tenant_id, street_id, old_state, target_state, target_group_id, actor_account_id, f'revert_from_hist_{hist_id}')
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
log_transaction('street.revert', 'street', street_id, {
|
||||||
|
'from': old_state,
|
||||||
|
'to': target_state,
|
||||||
|
'group_id': target_group_id,
|
||||||
|
'hist_id': hist_id
|
||||||
|
})
|
||||||
|
|
||||||
|
# Code 100 verschicken
|
||||||
|
msg = WSMessage(
|
||||||
|
sender_id=actor_account_id,
|
||||||
|
code=100,
|
||||||
|
msg=json.dumps({
|
||||||
|
'name': street['name'],
|
||||||
|
'state': target_state,
|
||||||
|
'actor': actor_account_id,
|
||||||
|
'street_id': street_id,
|
||||||
|
'group_id': target_group_id
|
||||||
|
})
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
broker.route_message(tenant_id, msg)
|
||||||
|
except Exception as e:
|
||||||
|
print(f'Broker error: {e}')
|
||||||
|
|
||||||
|
return True, 'Zustand wiederhergestellt'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def revert_group(tenant_id, group_id, hist_id, actor_account_id):
|
||||||
|
db = get_db()
|
||||||
|
history = db.execute(
|
||||||
|
'SELECT * FROM group_state_history WHERE id = ? AND tenant_id = ? AND group_id = ?',
|
||||||
|
(hist_id, tenant_id, group_id)
|
||||||
|
).fetchone()
|
||||||
|
if not history:
|
||||||
|
return False, 'Historieneintrag nicht gefunden'
|
||||||
|
|
||||||
|
group = GroupModel.get_by_id(group_id, tenant_id)
|
||||||
|
if not group:
|
||||||
|
return False, 'Gruppe nicht gefunden'
|
||||||
|
|
||||||
|
old_state = group['state']
|
||||||
|
target_state = history['to_state']
|
||||||
|
target_lat = history['last_lat']
|
||||||
|
target_lon = history['last_lon']
|
||||||
|
target_pos_at = history['last_pos_at']
|
||||||
|
|
||||||
|
GroupModel.update(group_id, tenant_id,
|
||||||
|
state=target_state,
|
||||||
|
last_lat=target_lat,
|
||||||
|
last_lon=target_lon,
|
||||||
|
last_pos_at=target_pos_at)
|
||||||
|
|
||||||
|
# Neuen History-Eintrag
|
||||||
|
db.execute(
|
||||||
|
'''INSERT INTO group_state_history
|
||||||
|
(tenant_id, group_id, from_state, to_state, last_lat, last_lon, last_pos_at, actor_account_id)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||||
|
(tenant_id, group_id, old_state, target_state, target_lat, target_lon, target_pos_at, actor_account_id)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
# Cache aktualisieren
|
||||||
|
GroupsService.update_cache_entry(tenant_id, group_id, {
|
||||||
|
'state': target_state,
|
||||||
|
'last_lat': target_lat,
|
||||||
|
'last_lon': target_lon,
|
||||||
|
'last_pos_at': target_pos_at
|
||||||
|
})
|
||||||
|
|
||||||
|
log_transaction('group.revert', 'group', group_id, {
|
||||||
|
'from': old_state,
|
||||||
|
'to': target_state,
|
||||||
|
'hist_id': hist_id
|
||||||
|
})
|
||||||
|
|
||||||
|
# Code 200
|
||||||
|
msg200 = WSMessage(
|
||||||
|
sender_id=actor_account_id,
|
||||||
|
code=200,
|
||||||
|
msg=json.dumps({
|
||||||
|
'group_id': group_id,
|
||||||
|
'state': target_state,
|
||||||
|
'actor': actor_account_id
|
||||||
|
})
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
broker.route_message(tenant_id, msg200)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Code 300 wenn Position vorhanden
|
||||||
|
if target_lat is not None and target_lon is not None:
|
||||||
|
msg300 = WSMessage(
|
||||||
|
sender_id=actor_account_id,
|
||||||
|
code=300,
|
||||||
|
msg=json.dumps({
|
||||||
|
'group_id': group_id,
|
||||||
|
'lat': target_lat,
|
||||||
|
'lon': target_lon,
|
||||||
|
'ts': target_pos_at,
|
||||||
|
'actor': actor_account_id
|
||||||
|
})
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
broker.route_message(tenant_id, msg300)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return True, 'Gruppe wiederhergestellt'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _send_group_position(tenant_id, group_id, lat, lon, pos_at, actor_account_id):
|
||||||
|
"""Meldet eine Positionsänderung an die berechtigten Clients (Code 300)."""
|
||||||
|
msg = WSMessage(
|
||||||
|
sender_id=actor_account_id,
|
||||||
|
code=300,
|
||||||
|
msg=json.dumps({
|
||||||
|
'group_id': group_id,
|
||||||
|
'lat': lat,
|
||||||
|
'lon': lon,
|
||||||
|
'ts': pos_at,
|
||||||
|
'actor': actor_account_id
|
||||||
|
})
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
broker.route_message(tenant_id, msg)
|
||||||
|
except Exception as e:
|
||||||
|
print(f'Broker error: {e}')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def set_group_position_from_history(tenant_id, group_id, hist_id, actor_account_id):
|
||||||
|
"""Übernimmt ausschließlich die Position eines Historieneintrags.
|
||||||
|
|
||||||
|
Der State der Gruppe bleibt unverändert; die Übernahme wird selbst als
|
||||||
|
neuer Historieneintrag festgehalten.
|
||||||
|
"""
|
||||||
|
db = get_db()
|
||||||
|
history = db.execute(
|
||||||
|
'SELECT * FROM group_state_history WHERE id = ? AND tenant_id = ? AND group_id = ?',
|
||||||
|
(hist_id, tenant_id, group_id)
|
||||||
|
).fetchone()
|
||||||
|
if not history:
|
||||||
|
return False, 'Historieneintrag nicht gefunden'
|
||||||
|
|
||||||
|
target_lat = history['last_lat']
|
||||||
|
target_lon = history['last_lon']
|
||||||
|
if target_lat is None or target_lon is None:
|
||||||
|
return False, 'Historieneintrag enthält keine Position'
|
||||||
|
|
||||||
|
group = GroupModel.get_by_id(group_id, tenant_id)
|
||||||
|
if not group:
|
||||||
|
return False, 'Gruppe nicht gefunden'
|
||||||
|
|
||||||
|
target_pos_at = history['last_pos_at']
|
||||||
|
GroupModel.update(
|
||||||
|
group_id, tenant_id,
|
||||||
|
last_lat=target_lat,
|
||||||
|
last_lon=target_lon,
|
||||||
|
last_pos_at=target_pos_at
|
||||||
|
)
|
||||||
|
|
||||||
|
db.execute(
|
||||||
|
'''INSERT INTO group_state_history
|
||||||
|
(tenant_id, group_id, from_state, to_state, last_lat, last_lon, last_pos_at, actor_account_id)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||||
|
(tenant_id, group_id, group['state'], group['state'],
|
||||||
|
target_lat, target_lon, target_pos_at, actor_account_id)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
GroupsService.update_cache_entry(tenant_id, group_id, {
|
||||||
|
'last_lat': target_lat,
|
||||||
|
'last_lon': target_lon,
|
||||||
|
'last_pos_at': target_pos_at
|
||||||
|
})
|
||||||
|
|
||||||
|
log_transaction('group.position_from_history', 'group', group_id, {
|
||||||
|
'hist_id': hist_id,
|
||||||
|
'lat': target_lat,
|
||||||
|
'lon': target_lon
|
||||||
|
})
|
||||||
|
HistoryService._send_group_position(
|
||||||
|
tenant_id, group_id, target_lat, target_lon, target_pos_at, actor_account_id
|
||||||
|
)
|
||||||
|
|
||||||
|
return True, 'Position übernommen'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def clear_group_position(tenant_id, group_id, actor_account_id):
|
||||||
|
"""Löscht die aktuelle Position einer Gruppe."""
|
||||||
|
group = GroupModel.get_by_id(group_id, tenant_id)
|
||||||
|
if not group:
|
||||||
|
return False, 'Gruppe nicht gefunden'
|
||||||
|
|
||||||
|
if group['last_lat'] is None and group['last_lon'] is None:
|
||||||
|
return True, 'Position ist bereits unbekannt'
|
||||||
|
|
||||||
|
GroupModel.update(
|
||||||
|
group_id, tenant_id,
|
||||||
|
last_lat=None,
|
||||||
|
last_lon=None,
|
||||||
|
last_pos_at=None
|
||||||
|
)
|
||||||
|
|
||||||
|
db = get_db()
|
||||||
|
db.execute(
|
||||||
|
'''INSERT INTO group_state_history
|
||||||
|
(tenant_id, group_id, from_state, to_state, last_lat, last_lon, last_pos_at, actor_account_id)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||||
|
(tenant_id, group_id, group['state'], group['state'],
|
||||||
|
None, None, None, actor_account_id)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
GroupsService.update_cache_entry(tenant_id, group_id, {
|
||||||
|
'last_lat': None,
|
||||||
|
'last_lon': None,
|
||||||
|
'last_pos_at': None
|
||||||
|
})
|
||||||
|
|
||||||
|
log_transaction('group.position_clear', 'group', group_id, {})
|
||||||
|
|
||||||
|
# Null-Koordinaten signalisieren den Clients, die Markierung zu entfernen.
|
||||||
|
HistoryService._send_group_position(
|
||||||
|
tenant_id, group_id, None, None, None, actor_account_id
|
||||||
|
)
|
||||||
|
|
||||||
|
return True, 'Position gelöscht'
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
"""
|
||||||
|
Streets Service - Geschäftslogik für Straßen
|
||||||
|
"""
|
||||||
|
from cmbnet.models.streets import StreetModel
|
||||||
|
from cmbnet.db import get_db
|
||||||
|
from cmbnet.utils.helpers import log_transaction
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
class StreetsService:
|
||||||
|
@staticmethod
|
||||||
|
def get_all_for_init(tenant_id):
|
||||||
|
"""Gibt alle Straßen für den AJAX-Initialload zurück"""
|
||||||
|
streets = StreetModel.get_all_by_tenant(tenant_id)
|
||||||
|
result = []
|
||||||
|
for street in streets:
|
||||||
|
result.append({
|
||||||
|
'id': street['id'],
|
||||||
|
'name': street['name'],
|
||||||
|
'state': street['state'],
|
||||||
|
'group_id': street['group_id'],
|
||||||
|
'hn_min': street['hn_min'],
|
||||||
|
'hn_max': street['hn_max'],
|
||||||
|
'bbox': json.loads(street['bbox']) if street['bbox'] else None
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def update_street(street_id, tenant_id, changes, actor_account_id=None):
|
||||||
|
"""Aktualisiert eine Straße und schreibt History/Log"""
|
||||||
|
db = get_db()
|
||||||
|
old_street = StreetModel.get_by_id(street_id, tenant_id)
|
||||||
|
if not old_street:
|
||||||
|
return False
|
||||||
|
|
||||||
|
StreetModel.update(street_id, tenant_id, **changes)
|
||||||
|
|
||||||
|
# History bei State-Wechsel
|
||||||
|
if 'state' in changes and changes['state'] != old_street['state']:
|
||||||
|
db.execute(
|
||||||
|
'''INSERT INTO street_state_history
|
||||||
|
(tenant_id, street_id, from_state, to_state, group_id, actor_account_id)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?)''',
|
||||||
|
(tenant_id, street_id, old_street['state'], changes['state'],
|
||||||
|
changes.get('group_id', old_street['group_id']), actor_account_id)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
log_transaction('street.state_change', 'street', street_id,
|
||||||
|
{'from': old_street['state'], 'to': changes['state']})
|
||||||
|
else:
|
||||||
|
log_transaction('street.update', 'street', street_id, changes)
|
||||||
|
|
||||||
|
return True
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
"""
|
||||||
|
CSV Import Utils für Straßen
|
||||||
|
"""
|
||||||
|
import csv
|
||||||
|
import io
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
def parse_streets_csv(file_content):
|
||||||
|
"""
|
||||||
|
Parst CSV mit Delimiter ';'
|
||||||
|
Erwartete Spalten: Name, Hausnummer minimal, Hausnummer maximal, Bounding Box
|
||||||
|
"""
|
||||||
|
streets = []
|
||||||
|
# Versuche mit verschiedenen Encodings
|
||||||
|
try:
|
||||||
|
text = file_content.decode('utf-8')
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
text = file_content.decode('latin-1')
|
||||||
|
except:
|
||||||
|
text = file_content.decode('cp1252')
|
||||||
|
|
||||||
|
f = io.StringIO(text)
|
||||||
|
reader = csv.DictReader(f, delimiter=';')
|
||||||
|
|
||||||
|
for row in reader:
|
||||||
|
name = row.get('Name') or row.get('name') or row.get('Strasse') or row.get('Straße')
|
||||||
|
hn_min = row.get('Hausnummer minimal') or row.get('hn_min') or row.get('Hausnummer_minimal')
|
||||||
|
hn_max = row.get('Hausnummer maximal') or row.get('hn_max') or row.get('Hausnummer_maximal')
|
||||||
|
bbox = row.get('Bounding Box') or row.get('bbox') or row.get('BoundingBox')
|
||||||
|
|
||||||
|
if not name:
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
hn_min_int = int(hn_min) if hn_min and hn_min.strip() else None
|
||||||
|
except:
|
||||||
|
hn_min_int = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
hn_max_int = int(hn_max) if hn_max and hn_max.strip() else None
|
||||||
|
except:
|
||||||
|
hn_max_int = None
|
||||||
|
|
||||||
|
streets.append({
|
||||||
|
'name': name.strip(),
|
||||||
|
'hn_min': hn_min_int,
|
||||||
|
'hn_max': hn_max_int,
|
||||||
|
'bbox': bbox.strip() if bbox else None
|
||||||
|
})
|
||||||
|
|
||||||
|
return streets
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
"""
|
||||||
|
Hilfsfunktionen für CMBNet
|
||||||
|
"""
|
||||||
|
from flask import g
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
def get_tenant_id():
|
||||||
|
"""Gibt die aktuelle Tenant-ID aus dem Request-Kontext zurück"""
|
||||||
|
return getattr(g, 'tenant_id', None)
|
||||||
|
|
||||||
|
|
||||||
|
def get_current_account():
|
||||||
|
"""Gibt den aktuellen Account aus dem Request-Kontext zurück"""
|
||||||
|
return getattr(g, 'current_account', None)
|
||||||
|
|
||||||
|
|
||||||
|
def log_transaction(action, entity_type, entity_id, details=None):
|
||||||
|
"""
|
||||||
|
Schreibt einen Eintrag ins Transaktionslog
|
||||||
|
"""
|
||||||
|
from cmbnet.db import get_db
|
||||||
|
from cmbnet.core.logging import write_transaction_log
|
||||||
|
|
||||||
|
db = get_db()
|
||||||
|
tenant_id = get_tenant_id()
|
||||||
|
account = get_current_account()
|
||||||
|
actor_id = account['id'] if account else None
|
||||||
|
|
||||||
|
details_json = json.dumps(details) if details else None
|
||||||
|
|
||||||
|
db.execute(
|
||||||
|
'INSERT INTO transaction_log (tenant_id, actor_account_id, action, entity_type, entity_id, details) VALUES (?, ?, ?, ?, ?, ?)',
|
||||||
|
(tenant_id, actor_id, action, entity_type, entity_id, details_json)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
# Auch ins Logfile schreiben
|
||||||
|
write_transaction_log(tenant_id, actor_id, account['name'] if account else None, action, entity_type, entity_id, details)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
from .auth import auth_bp
|
||||||
|
from .main import views_bp
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
"""
|
||||||
|
Authentifizierungs-Views
|
||||||
|
"""
|
||||||
|
from flask import Blueprint, render_template, request, redirect, url_for, session, flash, g
|
||||||
|
from cmbnet.db import get_db
|
||||||
|
from cmbnet.auth import verify_password
|
||||||
|
|
||||||
|
auth_bp = Blueprint('auth', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@auth_bp.before_request
|
||||||
|
def load_tenant():
|
||||||
|
"""Lädt Tenant aus URL"""
|
||||||
|
tenant_code = request.view_args.get('tenant')
|
||||||
|
if tenant_code:
|
||||||
|
db = get_db()
|
||||||
|
tenant = db.execute('SELECT * FROM tenants WHERE code = ?', (tenant_code,)).fetchone()
|
||||||
|
if not tenant:
|
||||||
|
flash('Ungültiger Mandant', 'error')
|
||||||
|
return redirect(url_for('auth.login_select'))
|
||||||
|
g.tenant_id = tenant['id']
|
||||||
|
g.tenant_code = tenant['code']
|
||||||
|
|
||||||
|
|
||||||
|
@auth_bp.route('/login', methods=['GET', 'POST'])
|
||||||
|
def login(**kwargs):
|
||||||
|
"""Login-View"""
|
||||||
|
tenant_code = g.tenant_code
|
||||||
|
next_url = request.args.get('next')
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
username = request.form.get('username', '').strip()
|
||||||
|
password = request.form.get('password', '')
|
||||||
|
tenant_selected = request.form.get('tenant', tenant_code)
|
||||||
|
|
||||||
|
db = get_db()
|
||||||
|
# Überprüfe Account für den Tenant
|
||||||
|
account = db.execute(
|
||||||
|
'SELECT a.*, t.code as tenant_code FROM accounts a JOIN tenants t ON a.tenant_id = t.id WHERE a.name = ? AND t.code = ?',
|
||||||
|
(username, tenant_selected)
|
||||||
|
).fetchone()
|
||||||
|
|
||||||
|
if account and verify_password(account['password_hash'], password):
|
||||||
|
# Login erfolgreich
|
||||||
|
session['account_id'] = account['id']
|
||||||
|
session['tenant_id'] = account['tenant_id']
|
||||||
|
session['tenant_code'] = account['tenant_code']
|
||||||
|
session['role'] = account['role']
|
||||||
|
session['username'] = account['name']
|
||||||
|
|
||||||
|
# Weiterleitung
|
||||||
|
if next_url:
|
||||||
|
return redirect(next_url)
|
||||||
|
|
||||||
|
# Rollenbasierte Weiterleitung
|
||||||
|
role = account['role']
|
||||||
|
if role == 'Administrator':
|
||||||
|
return redirect(url_for('admin.accounts', tenant=tenant_selected))
|
||||||
|
elif role == 'Dispatcher':
|
||||||
|
return redirect(url_for('views.dispatcher', tenant=tenant_selected))
|
||||||
|
elif role == 'Beobachter':
|
||||||
|
return redirect(url_for('views.praesentation', tenant=tenant_selected))
|
||||||
|
elif role == 'Gruppe':
|
||||||
|
return redirect(url_for('views.gruppen', tenant=tenant_selected))
|
||||||
|
else:
|
||||||
|
return redirect(url_for('views.oeffentlich', tenant=tenant_selected))
|
||||||
|
else:
|
||||||
|
flash('Ungültiger Benutzername oder Passwort', 'error')
|
||||||
|
|
||||||
|
return render_template('login.html', tenant_code=tenant_code)
|
||||||
|
|
||||||
|
|
||||||
|
@auth_bp.route('/login/select')
|
||||||
|
def login_select(**kwargs):
|
||||||
|
"""Mandantenauswahl für Login"""
|
||||||
|
return render_template('login_select.html')
|
||||||
|
|
||||||
|
|
||||||
|
@auth_bp.route('/logout')
|
||||||
|
def logout(**kwargs):
|
||||||
|
"""Logout"""
|
||||||
|
session.clear()
|
||||||
|
tenant_code = g.get('tenant_code') or request.args.get('tenant') or 'RV'
|
||||||
|
return redirect(url_for('auth.login', tenant=tenant_code))
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
"""
|
||||||
|
Haupt-Views
|
||||||
|
"""
|
||||||
|
from flask import Blueprint, render_template, g, redirect, url_for
|
||||||
|
from cmbnet.auth import login_required
|
||||||
|
|
||||||
|
views_bp = Blueprint('views', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@views_bp.route('/')
|
||||||
|
@login_required
|
||||||
|
def index(**kwargs):
|
||||||
|
"""Startseite - Weiterleitung je nach Rolle"""
|
||||||
|
role = g.current_account['role'] if hasattr(g, 'current_account') else None
|
||||||
|
tenant = g.tenant_code
|
||||||
|
|
||||||
|
if role == 'Administrator':
|
||||||
|
return redirect(url_for('admin.accounts', tenant=tenant))
|
||||||
|
elif role == 'Dispatcher':
|
||||||
|
return redirect(url_for('views.dispatcher', tenant=tenant))
|
||||||
|
elif role == 'Beobachter':
|
||||||
|
return redirect(url_for('views.praesentation', tenant=tenant))
|
||||||
|
elif role == 'Gruppe':
|
||||||
|
return redirect(url_for('views.gruppen', tenant=tenant))
|
||||||
|
else:
|
||||||
|
return redirect(url_for('views.oeffentlich', tenant=tenant))
|
||||||
|
|
||||||
|
|
||||||
|
@views_bp.route('/dispatcher')
|
||||||
|
@login_required
|
||||||
|
def dispatcher(**kwargs):
|
||||||
|
"""Dispatcher-View"""
|
||||||
|
return render_template('dispatcher.html')
|
||||||
|
|
||||||
|
|
||||||
|
@views_bp.route('/dispatcher_mobil')
|
||||||
|
@login_required
|
||||||
|
def dispatcher_mobil(**kwargs):
|
||||||
|
"""Dispatcher-Mobil-View"""
|
||||||
|
return render_template('dispatcher_mobil.html')
|
||||||
|
|
||||||
|
|
||||||
|
@views_bp.route('/gruppen')
|
||||||
|
@login_required
|
||||||
|
def gruppen(**kwargs):
|
||||||
|
"""Gruppen-View"""
|
||||||
|
return render_template('gruppen.html')
|
||||||
|
|
||||||
|
|
||||||
|
@views_bp.route('/praesentation')
|
||||||
|
@login_required
|
||||||
|
def praesentation(**kwargs):
|
||||||
|
"""Präsentations-View"""
|
||||||
|
return render_template('praesentation.html')
|
||||||
|
|
||||||
|
|
||||||
|
@views_bp.route('/oeffentlich')
|
||||||
|
def oeffentlich(**kwargs):
|
||||||
|
"""Öffentlicher-View"""
|
||||||
|
return render_template('oeffentlich.html')
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
from .broker import WebSocketBroker
|
||||||
|
from .protocol import WSMessage
|
||||||
|
|
||||||
|
broker = WebSocketBroker()
|
||||||
@@ -0,0 +1,754 @@
|
|||||||
|
"""
|
||||||
|
WebSocket Broker - Kernkomponente für Realtime-Kommunikation
|
||||||
|
|
||||||
|
Der Broker nimmt Nachrichten aus WebSocket-Verbindungen (und aus HTTP-Handlern)
|
||||||
|
entgegen, wertet den Code aus, bestimmt den erlaubten Empfängerkreis und stellt
|
||||||
|
die Nachricht zu.
|
||||||
|
|
||||||
|
Wichtige Regeln aus der Spezifikation:
|
||||||
|
- Code < 100: rein interne Nachrichten (z. B. Authentifizierung, Heartbeat).
|
||||||
|
- Code 100/200/300: State- bzw. Positionsänderungen an Dispatcher, Beobachter
|
||||||
|
und die jeweils betroffene Gruppe.
|
||||||
|
- Code 1000/1100/2000: Chat-/Broadcast-Nachrichten. Diese werden persistiert,
|
||||||
|
damit sie bei einer späteren Anmeldung als "Late Entry" nachgeliefert werden
|
||||||
|
können. Nachrichten, die älter als LATE_ENTRY_MAX_AGE_HOURS (Default 8h) sind,
|
||||||
|
werden gelöscht.
|
||||||
|
"""
|
||||||
|
import json
|
||||||
|
import time
|
||||||
|
from datetime import datetime, timedelta, timezone
|
||||||
|
from flask import current_app
|
||||||
|
from cmbnet.db import get_db
|
||||||
|
from cmbnet.services.groups_service import GroupsService
|
||||||
|
from cmbnet.ws.protocol import WSMessage
|
||||||
|
|
||||||
|
|
||||||
|
class WebSocketBroker:
|
||||||
|
def __init__(self):
|
||||||
|
# connections[tenant_id][account_id] = {
|
||||||
|
# 'ws': <WebSocket-Objekt>,
|
||||||
|
# 'role': <Rolle des Accounts>,
|
||||||
|
# 'group_id': <verknüpfte Gruppe oder None>,
|
||||||
|
# }
|
||||||
|
self.connections = {}
|
||||||
|
# authenticated[tenant_id][account_id] = True
|
||||||
|
# Erst nach erfolgreichem Code-0-Handshake darf ein Client Nachrichten
|
||||||
|
# über die Verbindung senden.
|
||||||
|
self.authenticated = {}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Verbindungen und Authentifizierung
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def register_connection(self, tenant_id, account_id, ws, role=None, group_id=None):
|
||||||
|
"""Registriert eine neue, noch nicht authentifizierte Verbindung.
|
||||||
|
|
||||||
|
Rolle und Gruppenzuordnung werden direkt mitgespeichert. Sie werden
|
||||||
|
später für die Empfängerermittlung und für das Cleanup benötigt.
|
||||||
|
"""
|
||||||
|
db = get_db()
|
||||||
|
account = db.execute(
|
||||||
|
'SELECT role FROM accounts WHERE id = ? AND tenant_id = ?',
|
||||||
|
(account_id, tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
if not account:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if role is None:
|
||||||
|
role = account['role']
|
||||||
|
|
||||||
|
# Für Gruppen-Accounts die zugehörige Gruppe ermitteln. Ein Account der
|
||||||
|
# Rolle "Gruppe" ist genau einer Gruppe zugeordnet.
|
||||||
|
if group_id is None and role == 'Gruppe':
|
||||||
|
group = db.execute(
|
||||||
|
'SELECT id FROM groups WHERE account_id = ? AND tenant_id = ?',
|
||||||
|
(account_id, tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
group_id = group['id'] if group else None
|
||||||
|
|
||||||
|
if tenant_id not in self.connections:
|
||||||
|
self.connections[tenant_id] = {}
|
||||||
|
|
||||||
|
# Eine neue Verbindung muss den Token-Handshake erneut durchlaufen.
|
||||||
|
# Ein eventuell noch gesetzter Auth-Status einer älteren Verbindung
|
||||||
|
# desselben Accounts darf nicht übernommen werden.
|
||||||
|
authenticated = self.authenticated.get(tenant_id)
|
||||||
|
if authenticated:
|
||||||
|
authenticated.pop(account_id, None)
|
||||||
|
|
||||||
|
self.connections[tenant_id][account_id] = {
|
||||||
|
'ws': ws,
|
||||||
|
'role': role,
|
||||||
|
'group_id': group_id,
|
||||||
|
'last_ping': datetime.now()
|
||||||
|
}
|
||||||
|
return True
|
||||||
|
|
||||||
|
def is_authenticated(self, tenant_id, account_id):
|
||||||
|
"""Prüft, ob eine Verbindung den Code-0-Handshake erfolgreich absolviert hat."""
|
||||||
|
return self.authenticated.get(tenant_id, {}).get(account_id, False)
|
||||||
|
|
||||||
|
def authenticate(self, tenant_id, account_id, token):
|
||||||
|
"""Authentifiziert eine Verbindung anhand des Einmal-Tokens (Code 0)."""
|
||||||
|
db = get_db()
|
||||||
|
token_row = db.execute(
|
||||||
|
'SELECT * FROM ws_tokens WHERE token = ? AND tenant_id = ? '
|
||||||
|
'AND account_id = ? AND used = 0',
|
||||||
|
(token, tenant_id, account_id)
|
||||||
|
).fetchone()
|
||||||
|
|
||||||
|
if not token_row:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Ablaufzeit prüfen (Tokens sind nur kurzzeitig gültig).
|
||||||
|
if token_row['expires_at']:
|
||||||
|
try:
|
||||||
|
expires = datetime.fromisoformat(token_row['expires_at'].replace('Z', '+00:00'))
|
||||||
|
# SQLite liefert naive Zeitstempel; ein Vergleich mit einer
|
||||||
|
# zeitzonenbehafteten Zeit wäre nicht möglich.
|
||||||
|
if expires.tzinfo is not None:
|
||||||
|
expires = expires.astimezone().replace(tzinfo=None)
|
||||||
|
if expires < datetime.now():
|
||||||
|
return False
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Token darf nur einmal verwendet werden.
|
||||||
|
db.execute('UPDATE ws_tokens SET used = 1 WHERE id = ?', (token_row['id'],))
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
if tenant_id not in self.authenticated:
|
||||||
|
self.authenticated[tenant_id] = {}
|
||||||
|
self.authenticated[tenant_id][account_id] = True
|
||||||
|
|
||||||
|
# Nach erfolgreicher Authentifizierung dürfen die gespeicherten
|
||||||
|
# Nachrichten der letzten 8 Stunden nachgeliefert werden.
|
||||||
|
self.send_late_entries(tenant_id, account_id)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def remove_connection(self, tenant_id, account_id, ws=None):
|
||||||
|
"""Entfernt eine Verbindung.
|
||||||
|
|
||||||
|
Wenn ein Account mehrere Tabs/Verbindungen öffnet, wird nur die
|
||||||
|
tatsächlich beendete Verbindung entfernt (ws-Vergleich), nicht die
|
||||||
|
zuletzt registrierte.
|
||||||
|
"""
|
||||||
|
connections = self.connections.get(tenant_id)
|
||||||
|
if connections and account_id in connections:
|
||||||
|
if ws is None or connections[account_id].get('ws') is ws:
|
||||||
|
del connections[account_id]
|
||||||
|
# Nur wenn die tatsächlich beendete Verbindung die aktuelle
|
||||||
|
# war, darf auch der Authentifizierungsstatus entfernt werden.
|
||||||
|
authenticated = self.authenticated.get(tenant_id)
|
||||||
|
if authenticated and account_id in authenticated:
|
||||||
|
del authenticated[account_id]
|
||||||
|
|
||||||
|
def _get_connection(self, tenant_id, account_id):
|
||||||
|
return self.connections.get(tenant_id, {}).get(account_id)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Late Entry
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def send_late_entries(self, tenant_id, account_id):
|
||||||
|
"""Sendet gespeicherte Nachrichten (Code >= 1000) der letzten 8 Stunden.
|
||||||
|
|
||||||
|
Es werden ausschließlich Nachrichten zugestellt, für die der Account
|
||||||
|
laut Protokoll berechtigt ist. Die Zustellung erfolgt chronologisch.
|
||||||
|
Anschließend werden abgelaufene Nachrichten gelöscht.
|
||||||
|
"""
|
||||||
|
db = get_db()
|
||||||
|
cutoff = self._late_entry_cutoff()
|
||||||
|
|
||||||
|
messages = db.execute(
|
||||||
|
'SELECT * FROM ws_messages_store WHERE tenant_id = ? AND ts >= ? '
|
||||||
|
'ORDER BY ts ASC, id ASC',
|
||||||
|
(tenant_id, cutoff)
|
||||||
|
).fetchall()
|
||||||
|
|
||||||
|
conn = self._get_connection(tenant_id, account_id)
|
||||||
|
if not conn:
|
||||||
|
return
|
||||||
|
|
||||||
|
for msg_row in messages:
|
||||||
|
if not self._is_allowed_for_client(tenant_id, account_id, msg_row):
|
||||||
|
continue
|
||||||
|
|
||||||
|
msg = WSMessage(
|
||||||
|
sender_id=msg_row['sender_id'],
|
||||||
|
receiver_id=msg_row['receiver_id'],
|
||||||
|
code=msg_row['code'],
|
||||||
|
msg=msg_row['msg'],
|
||||||
|
ts=msg_row['ts']
|
||||||
|
)
|
||||||
|
self._send(tenant_id, account_id, msg)
|
||||||
|
|
||||||
|
# Abgelaufene Nachrichten werden bei jeder Anmeldung aufgeräumt.
|
||||||
|
self.cleanup_old_messages(tenant_id)
|
||||||
|
|
||||||
|
def _late_entry_cutoff(self):
|
||||||
|
"""Zeitstempel (ms), ab dem gespeicherte Nachrichten noch zustellbar sind."""
|
||||||
|
max_age_hours = current_app.config.get('LATE_ENTRY_MAX_AGE_HOURS', 8)
|
||||||
|
return int((datetime.now() - timedelta(hours=max_age_hours)).timestamp() * 1000)
|
||||||
|
|
||||||
|
def cleanup_old_messages(self, tenant_id=None):
|
||||||
|
"""Löscht persistierte Nachrichten, die älter als die Late-Entry-Frist sind."""
|
||||||
|
db = get_db()
|
||||||
|
cutoff = self._late_entry_cutoff()
|
||||||
|
|
||||||
|
if tenant_id is None:
|
||||||
|
db.execute('DELETE FROM ws_messages_store WHERE ts < ?', (cutoff,))
|
||||||
|
else:
|
||||||
|
db.execute(
|
||||||
|
'DELETE FROM ws_messages_store WHERE tenant_id = ? AND ts < ?',
|
||||||
|
(tenant_id, cutoff)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
def _is_allowed_for_client(self, tenant_id, account_id, msg_row):
|
||||||
|
"""Prüft, ob eine persistierte Nachricht für diesen Client bestimmt ist."""
|
||||||
|
db = get_db()
|
||||||
|
account = db.execute(
|
||||||
|
'SELECT * FROM accounts WHERE id = ? AND tenant_id = ?',
|
||||||
|
(account_id, tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
if not account:
|
||||||
|
return False
|
||||||
|
|
||||||
|
role = account['role']
|
||||||
|
code = msg_row['code']
|
||||||
|
|
||||||
|
# Code 1000: Broadcast an Dispatcher, Beobachter und alle Gruppen.
|
||||||
|
if code == 1000:
|
||||||
|
return role in ('Dispatcher', 'Beobachter', 'Gruppe')
|
||||||
|
|
||||||
|
# Code 1100: Dispatcher, Beobachter und die angesprochene Gruppe.
|
||||||
|
if code == 1100:
|
||||||
|
if role in ('Dispatcher', 'Beobachter'):
|
||||||
|
return True
|
||||||
|
if role == 'Gruppe':
|
||||||
|
group = db.execute(
|
||||||
|
'SELECT id FROM groups WHERE account_id = ? AND tenant_id = ?',
|
||||||
|
(account_id, tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
return bool(group and msg_row['receiver_id'] == group['id'])
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Code 2000: nur Dispatcher und Beobachter.
|
||||||
|
if code == 2000:
|
||||||
|
return role in ('Dispatcher', 'Beobachter')
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Nachrichtenverarbeitung
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def route_message(self, tenant_id, message, apply_business=False):
|
||||||
|
"""Wertet den Code aus, persistiert ggf. und stellt die Nachricht zu.
|
||||||
|
|
||||||
|
``apply_business`` wird nur für Nachrichten verwendet, die direkt über
|
||||||
|
die WebSocket-Route eingehen. Serverintern erzeugte Nachrichten (z. B.
|
||||||
|
aus der Admin-API) haben die Datenbank bereits aktualisiert und dürfen
|
||||||
|
deshalb nicht ein zweites Mal angewendet werden.
|
||||||
|
"""
|
||||||
|
db = get_db()
|
||||||
|
|
||||||
|
# Absender muss zum Mandanten gehören. Die Absender-ID wird in der
|
||||||
|
# WebSocket-Route aus der Session gesetzt und kann nicht gefälscht
|
||||||
|
# werden.
|
||||||
|
sender = db.execute(
|
||||||
|
'SELECT * FROM accounts WHERE id = ? AND tenant_id = ?',
|
||||||
|
(message.sender_id, tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
if not sender:
|
||||||
|
return
|
||||||
|
|
||||||
|
code = message.code
|
||||||
|
|
||||||
|
# Code 0 wird ausschließlich in der WebSocket-Route (Handshake)
|
||||||
|
# verarbeitet und niemals weitergeleitet.
|
||||||
|
if code <= 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Code 1 sendet ausschließlich der Server (Heartbeat-Routine).
|
||||||
|
# Nachrichten dieses Typs von Clients werden ignoriert.
|
||||||
|
if code == 1:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Code 2 ist die Antwort eines Clients auf den Heartbeat. Sie wird nur
|
||||||
|
# an Dispatcher-Views weitergeleitet und nicht gespeichert.
|
||||||
|
if code == 2:
|
||||||
|
self._deliver(tenant_id, message, sender)
|
||||||
|
return
|
||||||
|
|
||||||
|
# Sonstige interne Codes (< 100) werden nicht an die Oberfläche gegeben.
|
||||||
|
if code < 100:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Ab hier: fachliche Nachrichten (>= 100).
|
||||||
|
# Zustandsänderungen, die ein Client per WebSocket meldet, werden vor
|
||||||
|
# der Zustellung in der Datenbank persistiert. So sind sie auch nach
|
||||||
|
# einem Neuladen der Seite wieder sichtbar.
|
||||||
|
if apply_business and code in (100, 200, 300):
|
||||||
|
if not self._apply_business_change(tenant_id, message, sender):
|
||||||
|
return
|
||||||
|
|
||||||
|
message = self._prepare_message(tenant_id, message, sender)
|
||||||
|
|
||||||
|
# Ab Code 1000 werden Nachrichten für die Late-Entry-Funktion
|
||||||
|
# gespeichert. Gespeichert wird die bereits aufbereitete Nachricht
|
||||||
|
# (bei Code 1100 inklusive Aliasname-Präfix).
|
||||||
|
if code >= 1000:
|
||||||
|
self._persist_message(tenant_id, message)
|
||||||
|
|
||||||
|
self._deliver(tenant_id, message, sender)
|
||||||
|
|
||||||
|
def _apply_business_change(self, tenant_id, message, sender):
|
||||||
|
"""Persistiert Code 100/200/300 aus einer WebSocket-Nachricht.
|
||||||
|
|
||||||
|
Gibt ``False`` zurück, wenn die Nachricht ungültig oder für den
|
||||||
|
Absender nicht erlaubt ist. In diesem Fall wird sie nicht zugestellt.
|
||||||
|
"""
|
||||||
|
payload = self._payload(message)
|
||||||
|
if not isinstance(payload, dict):
|
||||||
|
return False
|
||||||
|
|
||||||
|
if message.code == 100:
|
||||||
|
return self._apply_street_change(tenant_id, message, sender, payload)
|
||||||
|
if message.code == 200:
|
||||||
|
return self._apply_group_state_change(tenant_id, message, sender, payload)
|
||||||
|
if message.code == 300:
|
||||||
|
return self._apply_group_position_change(tenant_id, message, sender, payload)
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _apply_street_change(self, tenant_id, message, sender, payload):
|
||||||
|
"""Wendet einen Straßen-State-Wechsel aus einer Code-100-Nachricht an."""
|
||||||
|
if sender['role'] not in ('Dispatcher', 'Administrator'):
|
||||||
|
return False
|
||||||
|
|
||||||
|
db = get_db()
|
||||||
|
street = None
|
||||||
|
street_id = payload.get('street_id')
|
||||||
|
if street_id is not None:
|
||||||
|
try:
|
||||||
|
street_id = int(street_id)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return False
|
||||||
|
street = db.execute(
|
||||||
|
'SELECT * FROM streets WHERE id = ? AND tenant_id = ?',
|
||||||
|
(street_id, tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
|
||||||
|
if not street and payload.get('name'):
|
||||||
|
street = db.execute(
|
||||||
|
'SELECT * FROM streets WHERE name = ? AND tenant_id = ?',
|
||||||
|
(str(payload['name']), tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
|
||||||
|
if not street:
|
||||||
|
return False
|
||||||
|
|
||||||
|
new_state = payload.get('state')
|
||||||
|
if new_state not in ('unbearbeitet', 'zugewiesen', 'erledigt'):
|
||||||
|
return False
|
||||||
|
|
||||||
|
if 'group_id' in payload:
|
||||||
|
group_id = payload['group_id']
|
||||||
|
if group_id in ('', None):
|
||||||
|
group_id = None
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
group_id = int(group_id)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
group_id = street['group_id']
|
||||||
|
|
||||||
|
# Unbearbeitet bedeutet immer "keine Gruppe". Für "zugewiesen" ist
|
||||||
|
# dagegen eine gültige Gruppe erforderlich.
|
||||||
|
if new_state == 'unbearbeitet':
|
||||||
|
group_id = None
|
||||||
|
elif new_state == 'zugewiesen' and group_id is None:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if group_id is not None:
|
||||||
|
group = db.execute(
|
||||||
|
'SELECT id FROM groups WHERE id = ? AND tenant_id = ?',
|
||||||
|
(group_id, tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
if not group:
|
||||||
|
return False
|
||||||
|
|
||||||
|
old_state = street['state']
|
||||||
|
old_group_id = street['group_id']
|
||||||
|
changed = old_state != new_state or old_group_id != group_id
|
||||||
|
|
||||||
|
if changed:
|
||||||
|
db.execute(
|
||||||
|
'UPDATE streets SET state = ?, group_id = ?, updated_at = CURRENT_TIMESTAMP '
|
||||||
|
'WHERE id = ? AND tenant_id = ?',
|
||||||
|
(new_state, group_id, street['id'], tenant_id)
|
||||||
|
)
|
||||||
|
db.execute(
|
||||||
|
'''INSERT INTO street_state_history
|
||||||
|
(tenant_id, street_id, from_state, to_state, group_id, actor_account_id, reason)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?)''',
|
||||||
|
(tenant_id, street['id'], old_state, new_state,
|
||||||
|
group_id, sender['id'], 'ws_code_100')
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
self._log_business(tenant_id, sender['id'], 'street.state_change', 'street',
|
||||||
|
street['id'], {'from': old_state, 'to': new_state,
|
||||||
|
'group_id': group_id})
|
||||||
|
|
||||||
|
# Für die Empfängerermittlung muss die alte Gruppe bekannt bleiben:
|
||||||
|
# Bei einem Gruppenwechsel erhält sowohl die alte als auch die neue
|
||||||
|
# Gruppe die Code-100-Nachricht.
|
||||||
|
message._old_group_id = old_group_id
|
||||||
|
message.msg = json.dumps({
|
||||||
|
'name': street['name'],
|
||||||
|
'state': new_state,
|
||||||
|
'actor': sender['id'],
|
||||||
|
'street_id': street['id'],
|
||||||
|
'group_id': group_id
|
||||||
|
}, ensure_ascii=False)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def _apply_group_state_change(self, tenant_id, message, sender, payload):
|
||||||
|
"""Wendet einen Gruppen-State-Wechsel aus einer Code-200-Nachricht an."""
|
||||||
|
if sender['role'] not in ('Dispatcher', 'Administrator', 'Gruppe'):
|
||||||
|
return False
|
||||||
|
|
||||||
|
group_id = self._resolve_group_id(tenant_id, message, sender, payload)
|
||||||
|
if not group_id:
|
||||||
|
return False
|
||||||
|
|
||||||
|
db = get_db()
|
||||||
|
group = db.execute(
|
||||||
|
'SELECT * FROM groups WHERE id = ? AND tenant_id = ?',
|
||||||
|
(group_id, tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
if not group:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Ein Gruppen-Account darf nur den Zustand seiner eigenen Gruppe ändern.
|
||||||
|
if sender['role'] == 'Gruppe' and group['account_id'] != sender['id']:
|
||||||
|
return False
|
||||||
|
|
||||||
|
new_state = payload.get('state')
|
||||||
|
if new_state not in ('offen', 'unterwegs', 'online', 'pausierend', 'fertig'):
|
||||||
|
return False
|
||||||
|
|
||||||
|
if new_state != group['state']:
|
||||||
|
db.execute(
|
||||||
|
'UPDATE groups SET state = ?, updated_at = CURRENT_TIMESTAMP '
|
||||||
|
'WHERE id = ? AND tenant_id = ?',
|
||||||
|
(new_state, group_id, tenant_id)
|
||||||
|
)
|
||||||
|
db.execute(
|
||||||
|
'''INSERT INTO group_state_history
|
||||||
|
(tenant_id, group_id, from_state, to_state, last_lat, last_lon,
|
||||||
|
last_pos_at, actor_account_id)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||||
|
(tenant_id, group_id, group['state'], new_state,
|
||||||
|
group['last_lat'], group['last_lon'], group['last_pos_at'], sender['id'])
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
GroupsService.update_cache_entry(tenant_id, group_id, {'state': new_state})
|
||||||
|
self._log_business(tenant_id, sender['id'], 'group.state_change', 'group',
|
||||||
|
group_id, {'from': group['state'], 'to': new_state})
|
||||||
|
|
||||||
|
message.receiver_id = group_id
|
||||||
|
message.msg = json.dumps({
|
||||||
|
'group_id': group_id,
|
||||||
|
'state': new_state,
|
||||||
|
'actor': sender['id']
|
||||||
|
}, ensure_ascii=False)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def _apply_group_position_change(self, tenant_id, message, sender, payload):
|
||||||
|
"""Wendet eine Positionsänderung aus einer Code-300-Nachricht an."""
|
||||||
|
if sender['role'] not in ('Dispatcher', 'Administrator', 'Gruppe'):
|
||||||
|
return False
|
||||||
|
|
||||||
|
group_id = self._resolve_group_id(tenant_id, message, sender, payload)
|
||||||
|
if not group_id:
|
||||||
|
return False
|
||||||
|
|
||||||
|
db = get_db()
|
||||||
|
group = db.execute(
|
||||||
|
'SELECT * FROM groups WHERE id = ? AND tenant_id = ?',
|
||||||
|
(group_id, tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
if not group:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if sender['role'] == 'Gruppe' and group['account_id'] != sender['id']:
|
||||||
|
return False
|
||||||
|
|
||||||
|
try:
|
||||||
|
lat = float(payload.get('lat'))
|
||||||
|
lon = float(payload.get('lon'))
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not (-90 <= lat <= 90 and -180 <= lon <= 180):
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Der Server setzt den Zeitstempel, damit die Progressbar nicht durch
|
||||||
|
# manipulierbare Client-Zeitangaben verfälscht wird.
|
||||||
|
pos_at = datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
ts_ms = int(time.time() * 1000)
|
||||||
|
|
||||||
|
db.execute(
|
||||||
|
'UPDATE groups SET last_lat = ?, last_lon = ?, last_pos_at = ?, '
|
||||||
|
'updated_at = CURRENT_TIMESTAMP WHERE id = ? AND tenant_id = ?',
|
||||||
|
(lat, lon, pos_at, group_id, tenant_id)
|
||||||
|
)
|
||||||
|
db.execute(
|
||||||
|
'''INSERT INTO group_state_history
|
||||||
|
(tenant_id, group_id, from_state, to_state, last_lat, last_lon,
|
||||||
|
last_pos_at, actor_account_id)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||||
|
(tenant_id, group_id, group['state'], group['state'],
|
||||||
|
lat, lon, pos_at, sender['id'])
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
GroupsService.update_cache_entry(tenant_id, group_id, {
|
||||||
|
'last_lat': lat,
|
||||||
|
'last_lon': lon,
|
||||||
|
'last_pos_at': pos_at
|
||||||
|
})
|
||||||
|
self._log_business(tenant_id, sender['id'], 'group.position_change', 'group',
|
||||||
|
group_id, {'lat': lat, 'lon': lon})
|
||||||
|
|
||||||
|
message.receiver_id = group_id
|
||||||
|
# Auch der Nachrichten-Zeitstempel wird serverseitig gesetzt, damit
|
||||||
|
# die Progressbar nicht von einer manipulierten Client-Uhr abhängt.
|
||||||
|
message.ts = ts_ms
|
||||||
|
message.msg = json.dumps({
|
||||||
|
'group_id': group_id,
|
||||||
|
'lat': lat,
|
||||||
|
'lon': lon,
|
||||||
|
'ts': ts_ms,
|
||||||
|
'actor': sender['id']
|
||||||
|
}, ensure_ascii=False)
|
||||||
|
return True
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _log_business(tenant_id, actor_id, action, entity_type, entity_id, details):
|
||||||
|
"""Schreibt eine per WebSocket ausgelöste Änderung ins Transaktionslog."""
|
||||||
|
try:
|
||||||
|
db = get_db()
|
||||||
|
db.execute(
|
||||||
|
'INSERT INTO transaction_log '
|
||||||
|
'(tenant_id, actor_account_id, action, entity_type, entity_id, details) '
|
||||||
|
'VALUES (?, ?, ?, ?, ?, ?)',
|
||||||
|
(tenant_id, actor_id, action, entity_type, entity_id,
|
||||||
|
json.dumps(details, ensure_ascii=False))
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
from cmbnet.core.logging import write_transaction_log
|
||||||
|
actor = db.execute(
|
||||||
|
'SELECT name FROM accounts WHERE id = ? AND tenant_id = ?',
|
||||||
|
(actor_id, tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
write_transaction_log(tenant_id, actor_id, actor['name'] if actor else None,
|
||||||
|
action, entity_type, entity_id, details)
|
||||||
|
except Exception as exc:
|
||||||
|
print(f'Transaction log error: {exc}')
|
||||||
|
|
||||||
|
def _prepare_message(self, tenant_id, message, sender):
|
||||||
|
"""Ergänzt Nachrichten um serverseitig abgeleitete Informationen."""
|
||||||
|
db = get_db()
|
||||||
|
payload = self._payload(message)
|
||||||
|
|
||||||
|
if message.code == 1100:
|
||||||
|
# Empfänger ist eine spezielle Gruppe. Die Gruppen-ID wird aus dem
|
||||||
|
# Payload oder dem receiver_id-Feld gelesen.
|
||||||
|
group_id = self._resolve_group_id(tenant_id, message, sender, payload)
|
||||||
|
group = self._fetch_group(tenant_id, group_id)
|
||||||
|
message.receiver_id = group_id
|
||||||
|
|
||||||
|
# Spezifikation: Dem Freitext wird der Aliasname der Gruppe
|
||||||
|
# vorangestellt. Ein bereits vorhandenes Präfix wird nicht doppelt
|
||||||
|
# gesetzt.
|
||||||
|
if group:
|
||||||
|
alias = group['aliasname'] or str(group['id'])
|
||||||
|
prefix = f'{alias}: '
|
||||||
|
text = message.msg if isinstance(message.msg, str) else json.dumps(message.msg)
|
||||||
|
if not text.startswith(prefix):
|
||||||
|
message.msg = prefix + text
|
||||||
|
|
||||||
|
elif message.code == 2000:
|
||||||
|
# Spezifikation: Inhalt ist JSON mit Gruppen-ID und Freitext.
|
||||||
|
group_id = self._resolve_group_id(tenant_id, message, sender, payload)
|
||||||
|
message.receiver_id = group_id
|
||||||
|
if isinstance(payload, dict):
|
||||||
|
if group_id and not payload.get('group_id'):
|
||||||
|
payload['group_id'] = group_id
|
||||||
|
message.msg = json.dumps(payload, ensure_ascii=False)
|
||||||
|
elif group_id:
|
||||||
|
message.msg = json.dumps(
|
||||||
|
{'group_id': group_id, 'text': message.msg},
|
||||||
|
ensure_ascii=False
|
||||||
|
)
|
||||||
|
|
||||||
|
return message
|
||||||
|
|
||||||
|
def _deliver(self, tenant_id, message, sender):
|
||||||
|
"""Stellt eine Nachricht an alle berechtigten, verbundenen Clients zu."""
|
||||||
|
for recipient_id in self._get_recipients(tenant_id, message, sender):
|
||||||
|
self._send(tenant_id, recipient_id, message)
|
||||||
|
|
||||||
|
def _send(self, tenant_id, account_id, message):
|
||||||
|
"""Sendet eine Nachricht, falls für den Account eine Verbindung besteht."""
|
||||||
|
# Erst nach erfolgreicher Token-Authentifizierung dürfen Nachrichten
|
||||||
|
# an einen Client zugestellt werden.
|
||||||
|
if not self.is_authenticated(tenant_id, account_id):
|
||||||
|
return
|
||||||
|
conn = self._get_connection(tenant_id, account_id)
|
||||||
|
if not conn:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
conn['ws'].send(message.to_json())
|
||||||
|
except Exception:
|
||||||
|
# Eine fehlerhafte Verbindung darf den Versand an andere Clients
|
||||||
|
# nicht verhindern. Das Aufräumen übernimmt die Route beim
|
||||||
|
# Schließen der Verbindung.
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _get_recipients(self, tenant_id, message, sender):
|
||||||
|
"""Bestimmt den Empfängerkreis abhängig vom Nachrichtencode."""
|
||||||
|
db = get_db()
|
||||||
|
recipients = set()
|
||||||
|
code = message.code
|
||||||
|
payload = self._payload(message)
|
||||||
|
|
||||||
|
def add_accounts(roles):
|
||||||
|
placeholders = ','.join('?' for _ in roles)
|
||||||
|
rows = db.execute(
|
||||||
|
f'SELECT id FROM accounts WHERE tenant_id = ? AND role IN ({placeholders})',
|
||||||
|
(tenant_id, *roles)
|
||||||
|
).fetchall()
|
||||||
|
recipients.update(row['id'] for row in rows)
|
||||||
|
|
||||||
|
def add_group_account(group_id):
|
||||||
|
if not group_id:
|
||||||
|
return
|
||||||
|
group = db.execute(
|
||||||
|
'SELECT account_id FROM groups WHERE id = ? AND tenant_id = ?',
|
||||||
|
(group_id, tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
if group and group['account_id']:
|
||||||
|
recipients.add(group['account_id'])
|
||||||
|
|
||||||
|
if code == 100:
|
||||||
|
# Dispatcher, Gast, Beobachter + die mit der Straße verknüpfte
|
||||||
|
# Gruppe. Bei einem Gruppenwechsel werden sowohl die alte als auch
|
||||||
|
# die neue Gruppe benachrichtigt.
|
||||||
|
add_accounts(('Dispatcher', 'Beobachter', 'Gast'))
|
||||||
|
|
||||||
|
group_ids = set()
|
||||||
|
group_id = payload.get('group_id') if isinstance(payload, dict) else None
|
||||||
|
if group_id not in (None, ''):
|
||||||
|
group_ids.add(group_id)
|
||||||
|
old_group_id = getattr(message, '_old_group_id', None)
|
||||||
|
if old_group_id is not None:
|
||||||
|
group_ids.add(old_group_id)
|
||||||
|
|
||||||
|
street_id = payload.get('street_id') if isinstance(payload, dict) else None
|
||||||
|
# Das Payload stammt aus dem vertrauenswürdigen Server-Code. Nur
|
||||||
|
# wenn keine Gruppen-ID enthalten ist, wird die Straße aus der
|
||||||
|
# Datenbank gelesen.
|
||||||
|
if street_id and not (isinstance(payload, dict) and 'group_id' in payload):
|
||||||
|
street = db.execute(
|
||||||
|
'SELECT group_id FROM streets WHERE id = ? AND tenant_id = ?',
|
||||||
|
(street_id, tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
if street and street['group_id'] is not None:
|
||||||
|
group_ids.add(street['group_id'])
|
||||||
|
|
||||||
|
for group_id in group_ids:
|
||||||
|
add_group_account(group_id)
|
||||||
|
|
||||||
|
elif code in (200, 300):
|
||||||
|
# Dispatcher, Beobachter + die betroffene Gruppe.
|
||||||
|
add_accounts(('Dispatcher', 'Beobachter'))
|
||||||
|
group_id = self._resolve_group_id(tenant_id, message, sender, payload)
|
||||||
|
add_group_account(group_id)
|
||||||
|
|
||||||
|
elif code == 1000:
|
||||||
|
# Broadcast an Dispatcher, Beobachter und alle Gruppen.
|
||||||
|
add_accounts(('Dispatcher', 'Beobachter', 'Gruppe'))
|
||||||
|
|
||||||
|
elif code == 1100:
|
||||||
|
# Dispatcher, Beobachter + die spezielle Gruppe.
|
||||||
|
add_accounts(('Dispatcher', 'Beobachter'))
|
||||||
|
add_group_account(message.receiver_id)
|
||||||
|
|
||||||
|
elif code == 2000:
|
||||||
|
# Eine Gruppe sendet an Dispatcher und Beobachter.
|
||||||
|
add_accounts(('Dispatcher', 'Beobachter'))
|
||||||
|
|
||||||
|
elif code == 2:
|
||||||
|
# Heartbeat-Antworten werden nur an Dispatcher-Views weitergegeben.
|
||||||
|
add_accounts(('Dispatcher',))
|
||||||
|
|
||||||
|
return recipients
|
||||||
|
|
||||||
|
def _persist_message(self, tenant_id, message):
|
||||||
|
"""Speichert Nachrichten mit Code >= 1000 für die Late-Entry-Funktion."""
|
||||||
|
db = get_db()
|
||||||
|
db.execute(
|
||||||
|
'INSERT INTO ws_messages_store '
|
||||||
|
'(tenant_id, sender_id, receiver_id, code, ts, msg) '
|
||||||
|
'VALUES (?, ?, ?, ?, ?, ?)',
|
||||||
|
(tenant_id, message.sender_id, message.receiver_id,
|
||||||
|
message.code, message.ts, message.msg)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Hilfsfunktionen
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
@staticmethod
|
||||||
|
def _payload(message):
|
||||||
|
"""Liefert den JSON-Payload einer Nachricht oder None."""
|
||||||
|
if isinstance(message.msg, dict):
|
||||||
|
return message.msg
|
||||||
|
if not isinstance(message.msg, str):
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
data = json.loads(message.msg)
|
||||||
|
return data if isinstance(data, dict) else None
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _resolve_group_id(self, tenant_id, message, sender, payload):
|
||||||
|
"""Ermittelt die betroffene Gruppen-ID aus Payload, receiver_id oder Absender."""
|
||||||
|
group_id = payload.get('group_id') if isinstance(payload, dict) else None
|
||||||
|
if group_id is None:
|
||||||
|
group_id = message.receiver_id
|
||||||
|
if group_id is None and sender is not None and message.code in (200, 300, 2000):
|
||||||
|
# Bei Gruppen-Nachrichten ist der Absender die Gruppe selbst.
|
||||||
|
group = get_db().execute(
|
||||||
|
'SELECT id FROM groups WHERE account_id = ? AND tenant_id = ?',
|
||||||
|
(sender['id'], tenant_id)
|
||||||
|
).fetchone()
|
||||||
|
group_id = group['id'] if group else None
|
||||||
|
if group_id is not None:
|
||||||
|
try:
|
||||||
|
group_id = int(group_id)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
group_id = None
|
||||||
|
return group_id
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _fetch_group(tenant_id, group_id):
|
||||||
|
"""Lädt eine Gruppe mandantenspezifisch."""
|
||||||
|
if not group_id:
|
||||||
|
return None
|
||||||
|
return get_db().execute(
|
||||||
|
'SELECT id, aliasname FROM groups WHERE id = ? AND tenant_id = ?',
|
||||||
|
(group_id, tenant_id)
|
||||||
|
).fetchone()
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
"""
|
||||||
|
Heartbeat-Routine für WebSocket-Verbindungen
|
||||||
|
|
||||||
|
Der Server sendet jede Minute eine Nachricht mit Code 1 an alle
|
||||||
|
authentifizierten Clients. Die Clients antworten mit Code 2; diese Antwort
|
||||||
|
wird vom Broker ausschließlich an Dispatcher-Views weitergeleitet.
|
||||||
|
|
||||||
|
Zusätzlich räumt die Routine abgelaufene Late-Entry-Nachrichten auf, damit die
|
||||||
|
Tabelle ws_messages_store nicht unbegrenzt wächst.
|
||||||
|
"""
|
||||||
|
from threading import Timer
|
||||||
|
from cmbnet.ws import broker
|
||||||
|
from cmbnet.ws.protocol import WSMessage
|
||||||
|
|
||||||
|
|
||||||
|
class HeartbeatManager:
|
||||||
|
def __init__(self, interval=60):
|
||||||
|
self.interval = interval
|
||||||
|
self.running = False
|
||||||
|
self.app = None
|
||||||
|
self._timer = None
|
||||||
|
|
||||||
|
def start(self, app=None, interval=None):
|
||||||
|
"""Startet die zyklische Heartbeat-Routine."""
|
||||||
|
# Die App-Referenz wird benötigt, um im Hintergrund-Thread einen
|
||||||
|
# Flask-App-Kontext für Datenbankzugriffe öffnen zu können.
|
||||||
|
if app is not None:
|
||||||
|
self.app = app
|
||||||
|
if interval is not None:
|
||||||
|
self.interval = interval
|
||||||
|
|
||||||
|
if self.running:
|
||||||
|
return
|
||||||
|
self.running = True
|
||||||
|
self._send_heartbeat()
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
"""Stoppt die Heartbeat-Routine."""
|
||||||
|
self.running = False
|
||||||
|
if self._timer is not None:
|
||||||
|
self._timer.cancel()
|
||||||
|
self._timer = None
|
||||||
|
|
||||||
|
def _send_heartbeat(self):
|
||||||
|
if not self.running:
|
||||||
|
return
|
||||||
|
|
||||||
|
msg = WSMessage(sender_id=0, code=1, msg='ping')
|
||||||
|
|
||||||
|
# Nur authentifizierte Verbindungen erhalten einen Heartbeat.
|
||||||
|
for tenant_id, connections in list(broker.connections.items()):
|
||||||
|
for account_id, conn_info in list(connections.items()):
|
||||||
|
if not broker.is_authenticated(tenant_id, account_id):
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
conn_info['ws'].send(msg.to_json())
|
||||||
|
except Exception:
|
||||||
|
# Defekte Verbindungen werden beim Schließen durch die
|
||||||
|
# WebSocket-Route entfernt.
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Abgelaufene persistierte Nachrichten löschen.
|
||||||
|
if self.app is not None:
|
||||||
|
try:
|
||||||
|
with self.app.app_context():
|
||||||
|
broker.cleanup_old_messages()
|
||||||
|
except Exception as exc:
|
||||||
|
print(f'Heartbeat cleanup error: {exc}')
|
||||||
|
|
||||||
|
# Nächsten Heartbeat planen. Der Timer läuft als Daemon, damit er den
|
||||||
|
# Prozess beim Beenden nicht blockiert.
|
||||||
|
self._timer = Timer(self.interval, self._send_heartbeat)
|
||||||
|
self._timer.daemon = True
|
||||||
|
self._timer.start()
|
||||||
|
|
||||||
|
|
||||||
|
heartbeat_manager = HeartbeatManager()
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
"""
|
||||||
|
WebSocket Protokoll Definition
|
||||||
|
"""
|
||||||
|
import json
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
class WSMessage:
|
||||||
|
def __init__(self, sender_id=None, receiver_id=None, code=0, msg="", ts=None):
|
||||||
|
self.sender_id = sender_id
|
||||||
|
self.receiver_id = receiver_id
|
||||||
|
self.code = code
|
||||||
|
self.msg = msg
|
||||||
|
self.ts = ts or int(datetime.now().timestamp() * 1000)
|
||||||
|
|
||||||
|
def to_dict(self):
|
||||||
|
return {
|
||||||
|
'sender_id': self.sender_id,
|
||||||
|
'receiver_id': self.receiver_id,
|
||||||
|
'code': self.code,
|
||||||
|
'ts': self.ts,
|
||||||
|
'msg': self.msg
|
||||||
|
}
|
||||||
|
|
||||||
|
def to_json(self):
|
||||||
|
return json.dumps(self.to_dict())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, data):
|
||||||
|
return cls(
|
||||||
|
sender_id=data.get('sender_id'),
|
||||||
|
receiver_id=data.get('receiver_id'),
|
||||||
|
code=data.get('code', 0),
|
||||||
|
msg=data.get('msg', ''),
|
||||||
|
ts=data.get('ts')
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json_str):
|
||||||
|
try:
|
||||||
|
data = json.loads(json_str)
|
||||||
|
return cls.from_dict(data)
|
||||||
|
except:
|
||||||
|
return None
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
"""
|
||||||
|
WebSocket Routes
|
||||||
|
|
||||||
|
Ablauf einer Verbindung:
|
||||||
|
1. Client verbindet sich mit /<tenant>/ws.
|
||||||
|
2. Client sendet Code 0 mit dem zuvor über die API geholten Einmal-Token.
|
||||||
|
3. Erst nach erfolgreicher Prüfung dürfen fachliche Nachrichten gesendet
|
||||||
|
werden. Vorher wird die Verbindung geschlossen.
|
||||||
|
"""
|
||||||
|
from flask import session
|
||||||
|
from cmbnet.extensions import sock
|
||||||
|
from cmbnet.ws import broker
|
||||||
|
from cmbnet.ws.protocol import WSMessage
|
||||||
|
|
||||||
|
|
||||||
|
@sock.route('/<tenant>/ws')
|
||||||
|
def ws(ws, tenant):
|
||||||
|
"""WebSocket Endpoint"""
|
||||||
|
from cmbnet.db import get_db
|
||||||
|
|
||||||
|
db = get_db()
|
||||||
|
tenant_row = db.execute('SELECT * FROM tenants WHERE code = ?', (tenant,)).fetchone()
|
||||||
|
if not tenant_row:
|
||||||
|
ws.close()
|
||||||
|
return
|
||||||
|
|
||||||
|
tenant_id = tenant_row['id']
|
||||||
|
account_id = session.get('account_id')
|
||||||
|
if not account_id:
|
||||||
|
ws.close()
|
||||||
|
return
|
||||||
|
|
||||||
|
# Verbindung registrieren, aber noch nicht als authentifiziert markieren.
|
||||||
|
if not broker.register_connection(tenant_id, account_id, ws):
|
||||||
|
ws.close()
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
data = ws.receive()
|
||||||
|
if data is None:
|
||||||
|
break
|
||||||
|
|
||||||
|
msg = WSMessage.from_json(data)
|
||||||
|
if not msg:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Die Absender-ID stammt immer aus der Session und kann vom Client
|
||||||
|
# nicht gefälscht werden.
|
||||||
|
msg.sender_id = account_id
|
||||||
|
|
||||||
|
# Code 0: Authentifizierung über den Einmal-Token.
|
||||||
|
if msg.code == 0:
|
||||||
|
if not broker.authenticate(tenant_id, account_id, msg.msg):
|
||||||
|
ws.close()
|
||||||
|
break
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Fachliche Nachrichten sind erst nach erfolgreicher
|
||||||
|
# Authentifizierung erlaubt.
|
||||||
|
if not broker.is_authenticated(tenant_id, account_id):
|
||||||
|
ws.close()
|
||||||
|
break
|
||||||
|
|
||||||
|
broker.route_message(tenant_id, msg, apply_business=True)
|
||||||
|
|
||||||
|
except Exception as exc:
|
||||||
|
print(f'WebSocket error: {exc}')
|
||||||
|
finally:
|
||||||
|
broker.remove_connection(tenant_id, account_id, ws)
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
BASE_DIR = Path(__file__).parent
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
SECRET_KEY = os.environ.get('CMBNET_SECRET_KEY', 'dev-secret-key-change-in-production')
|
||||||
|
DATABASE_PATH = os.environ.get('CMBNET_DATABASE', str(BASE_DIR / 'instance' / 'cmbnet.sqlite3'))
|
||||||
|
TENANTS = ['BV', 'RV', 'SV']
|
||||||
|
DEFAULT_TENANT = 'RV'
|
||||||
|
|
||||||
|
WS_HEARTBEAT_INTERVAL = int(os.environ.get('CMBNET_WS_HEARTBEAT_INTERVAL', '60'))
|
||||||
|
WS_HEARTBEAT_TIMEOUT = 15
|
||||||
|
LATE_ENTRY_MAX_AGE_HOURS = int(os.environ.get('CMBNET_LATE_ENTRY_MAX_AGE_HOURS', '8'))
|
||||||
|
|
||||||
|
LOG_DIR = BASE_DIR / 'logs'
|
||||||
|
|
||||||
|
MAX_CSV_SIZE_BYTES = 5_000_000
|
||||||
|
|
||||||
|
SESSION_COOKIE_HTTPONLY = True
|
||||||
|
SESSION_COOKIE_SAMESITE = 'Lax'
|
||||||
|
SESSION_COOKIE_SECURE = False # Set to True in production with HTTPS
|
||||||
|
|
||||||
|
|
||||||
|
class DevelopmentConfig(Config):
|
||||||
|
DEBUG = True
|
||||||
|
|
||||||
|
|
||||||
|
class ProductionConfig(Config):
|
||||||
|
DEBUG = False
|
||||||
|
SESSION_COOKIE_SECURE = True
|
||||||
|
|
||||||
|
|
||||||
|
config = {
|
||||||
|
'development': DevelopmentConfig,
|
||||||
|
'production': ProductionConfig,
|
||||||
|
'default': DevelopmentConfig
|
||||||
|
}
|
||||||
Executable
+116
@@ -0,0 +1,116 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import sqlite3
|
||||||
|
import getpass
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# Versuche werkzeug zu importieren
|
||||||
|
try:
|
||||||
|
from werkzeug.security import generate_password_hash
|
||||||
|
except ImportError:
|
||||||
|
print("Fehler: werkzeug nicht gefunden. Installiere es mit: pip install werkzeug")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print("=== CMBNet Admin-Account erstellen ===\n")
|
||||||
|
|
||||||
|
# Datenbankpfad
|
||||||
|
db_path = Path(__file__).parent / 'instance' / 'cmbnet.sqlite3'
|
||||||
|
|
||||||
|
if not db_path.exists():
|
||||||
|
print(f"Fehler: Datenbank nicht gefunden: {db_path}")
|
||||||
|
print("Führe zuerst aus: flask --app cmbnet init-db")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
conn = sqlite3.connect(db_path)
|
||||||
|
conn.row_factory = sqlite3.Row
|
||||||
|
cur = conn.cursor()
|
||||||
|
|
||||||
|
# Mandanten anzeigen
|
||||||
|
cur.execute("SELECT id, code, name FROM tenants ORDER BY code")
|
||||||
|
tenants = cur.fetchall()
|
||||||
|
|
||||||
|
if not tenants:
|
||||||
|
print("Keine Mandanten gefunden. Erstelle sie...")
|
||||||
|
cur.execute("INSERT OR IGNORE INTO tenants (code, name) VALUES ('BV', 'Bezirk BV')")
|
||||||
|
cur.execute("INSERT OR IGNORE INTO tenants (code, name) VALUES ('RV', 'Bezirk RV')")
|
||||||
|
cur.execute("INSERT OR IGNORE INTO tenants (code, name) VALUES ('SV', 'Bezirk SV')")
|
||||||
|
conn.commit()
|
||||||
|
cur.execute("SELECT id, code, name FROM tenants ORDER BY code")
|
||||||
|
tenants = cur.fetchall()
|
||||||
|
|
||||||
|
print("Verfügbare Mandanten:")
|
||||||
|
for t in tenants:
|
||||||
|
print(f" {t['code']} - {t['name']}")
|
||||||
|
print()
|
||||||
|
|
||||||
|
# Auswahl
|
||||||
|
tenant_code = input("Mandant (BV/RV/SV): ").strip().upper()
|
||||||
|
while tenant_code not in [t['code'] for t in tenants]:
|
||||||
|
print("Ungültiger Mandant!")
|
||||||
|
tenant_code = input("Mandant (BV/RV/SV): ").strip().upper()
|
||||||
|
|
||||||
|
cur.execute("SELECT id FROM tenants WHERE code = ?", (tenant_code,))
|
||||||
|
tenant_id = cur.fetchone()['id']
|
||||||
|
|
||||||
|
# Account-Daten
|
||||||
|
username = input("Benutzername: ").strip()
|
||||||
|
while not username:
|
||||||
|
print("Benutzername darf nicht leer sein!")
|
||||||
|
username = input("Benutzername: ").strip()
|
||||||
|
|
||||||
|
# Prüfe ob Account bereits existiert
|
||||||
|
cur.execute("SELECT id FROM accounts WHERE tenant_id = ? AND name = ?", (tenant_id, username))
|
||||||
|
if cur.fetchone():
|
||||||
|
print(f"Fehler: Account '{username}' existiert bereits für Mandant {tenant_code}!")
|
||||||
|
conn.close()
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
password = getpass.getpass("Passwort: ")
|
||||||
|
password_confirm = getpass.getpass("Passwort wiederholen: ")
|
||||||
|
|
||||||
|
while password != password_confirm:
|
||||||
|
print("Passwörter stimmen nicht überein!")
|
||||||
|
password = getpass.getpass("Passwort: ")
|
||||||
|
password_confirm = getpass.getpass("Passwort wiederholen: ")
|
||||||
|
|
||||||
|
while not password:
|
||||||
|
print("Passwort darf nicht leer sein!")
|
||||||
|
password = getpass.getpass("Passwort: ")
|
||||||
|
password_confirm = getpass.getpass("Passwort wiederholen: ")
|
||||||
|
while password != password_confirm:
|
||||||
|
print("Passwörter stimmen nicht überein!")
|
||||||
|
password = getpass.getpass("Passwort: ")
|
||||||
|
password_confirm = getpass.getpass("Passwort wiederholen: ")
|
||||||
|
|
||||||
|
# Rolle
|
||||||
|
print("\nRollen: Gast, Beobachter, Gruppe, Dispatcher, Administrator")
|
||||||
|
role = input("Rolle [Administrator]: ").strip()
|
||||||
|
if not role:
|
||||||
|
role = 'Administrator'
|
||||||
|
|
||||||
|
valid_roles = ['Gast', 'Beobachter', 'Gruppe', 'Dispatcher', 'Administrator']
|
||||||
|
while role not in valid_roles:
|
||||||
|
print("Ungültige Rolle!")
|
||||||
|
role = input("Rolle [Administrator]: ").strip()
|
||||||
|
if not role:
|
||||||
|
role = 'Administrator'
|
||||||
|
|
||||||
|
# Hash erstellen und Account anlegen
|
||||||
|
password_hash = generate_password_hash(password)
|
||||||
|
|
||||||
|
cur.execute(
|
||||||
|
"INSERT INTO accounts (tenant_id, name, password_hash, role) VALUES (?, ?, ?, ?)",
|
||||||
|
(tenant_id, username, password_hash, role)
|
||||||
|
)
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
print(f"\n✅ Account erfolgreich erstellt!")
|
||||||
|
print(f" Mandant: {tenant_code}")
|
||||||
|
print(f" Benutzername: {username}")
|
||||||
|
print(f" Rolle: {role}")
|
||||||
|
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
2026-10-22 22:52:47.774 [TENANT:RV] [ACTOR:1(admin)] ACTION:account.create ENTITY:account:2 DETAILS:{'name': 'thomas', 'role': 'Dispatcher'}
|
||||||
|
2026-10-22 23:21:51.655 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.create ENTITY:group:1 DETAILS:{'aliasname': 'Alpha', 'account_id': 2}
|
||||||
|
2026-10-22 23:21:51.658 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.position_from_history ENTITY:group:1 DETAILS:{'hist_id': 2, 'lat': 50.123, 'lon': 8.456}
|
||||||
|
2026-10-22 23:21:51.661 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.position_clear ENTITY:group:1 DETAILS:{}
|
||||||
|
2026-10-22 23:21:51.664 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.update ENTITY:group:1 DETAILS:{'state': 'unterwegs'}
|
||||||
|
2026-10-22 23:21:51.665 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.update ENTITY:group:1 DETAILS:{'aliasname': 'Alpha neu'}
|
||||||
|
2026-10-22 23:21:51.666 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.update ENTITY:group:1 DETAILS:{'account_id': 3}
|
||||||
|
2026-10-22 23:21:51.668 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.create ENTITY:group:2 DETAILS:{'aliasname': 'Beta', 'account_id': 2}
|
||||||
|
2026-10-22 23:22:45.650 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.position_from_history ENTITY:group:1 DETAILS:{'hist_id': 1, 'lat': 50.1, 'lon': 8.2}
|
||||||
|
2026-10-22 23:22:54.817 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.position_from_history ENTITY:group:1 DETAILS:{'hist_id': 1, 'lat': 50.1, 'lon': 8.2}
|
||||||
|
2026-10-22 23:22:54.820 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.position_clear ENTITY:group:1 DETAILS:{}
|
||||||
|
2026-10-22 23:24:01.082 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.create ENTITY:group:1 DETAILS:{'aliasname': 'Alpha', 'account_id': 2}
|
||||||
|
2026-10-22 23:24:01.086 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.position_from_history ENTITY:group:1 DETAILS:{'hist_id': 2, 'lat': 50.123, 'lon': 8.456}
|
||||||
|
2026-10-22 23:24:01.089 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.position_clear ENTITY:group:1 DETAILS:{}
|
||||||
|
2026-10-22 23:24:01.091 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.update ENTITY:group:1 DETAILS:{'state': 'unterwegs'}
|
||||||
|
2026-10-22 23:24:01.092 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.update ENTITY:group:1 DETAILS:{'aliasname': 'Alpha neu'}
|
||||||
|
2026-10-22 23:24:01.094 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.update ENTITY:group:1 DETAILS:{'account_id': 3}
|
||||||
|
2026-10-22 23:24:01.095 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.create ENTITY:group:2 DETAILS:{'aliasname': 'Beta', 'account_id': 2}
|
||||||
|
2026-10-22 23:24:01.168 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.position_from_history ENTITY:group:1 DETAILS:{'hist_id': 1, 'lat': 50.1, 'lon': 8.2}
|
||||||
|
2026-10-22 23:24:01.171 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.position_clear ENTITY:group:1 DETAILS:{}
|
||||||
|
2026-10-22 23:25:35.444 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.create ENTITY:group:1 DETAILS:{'aliasname': 'Test1', 'account_id': None}
|
||||||
|
2026-10-22 23:26:13.833 [TENANT:RV] [ACTOR:1(admin)] ACTION:account.create ENTITY:account:3 DETAILS:{'name': 'Test1', 'role': 'Gruppe'}
|
||||||
|
2026-10-22 23:26:25.636 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.update ENTITY:group:1 DETAILS:{'account_id': 3}
|
||||||
|
2026-10-22 23:40:32.313 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'unbearbeitet', 'to': 'zugewiesen', 'group_id': 1}
|
||||||
|
2026-10-22 23:40:32.314 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'zugewiesen', 'group_id': 2}
|
||||||
|
2026-10-22 23:40:32.315 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'unbearbeitet', 'group_id': None}
|
||||||
|
2026-10-22 23:40:32.316 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'erledigt', 'group_id': 1}
|
||||||
|
2026-10-22 23:40:32.317 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:group.position_change ENTITY:group:1 DETAILS:{'lat': 50.12, 'lon': 8.34}
|
||||||
|
2026-10-22 23:40:32.318 [TENANT:RV] [ACTOR:3(Gruppe 1 Account)] ACTION:group.position_change ENTITY:group:1 DETAILS:{'lat': 50.22, 'lon': 8.44}
|
||||||
|
2026-10-22 23:40:32.319 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:group.state_change ENTITY:group:1 DETAILS:{'from': 'offen', 'to': 'unterwegs'}
|
||||||
|
2026-10-22 23:40:43.752 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'unbearbeitet', 'to': 'zugewiesen', 'group_id': 1}
|
||||||
|
2026-10-22 23:40:43.753 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'zugewiesen', 'group_id': 2}
|
||||||
|
2026-10-22 23:40:43.754 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'unbearbeitet', 'group_id': None}
|
||||||
|
2026-10-22 23:40:43.755 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'erledigt', 'group_id': 1}
|
||||||
|
2026-10-22 23:40:43.756 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:group.position_change ENTITY:group:1 DETAILS:{'lat': 50.12, 'lon': 8.34}
|
||||||
|
2026-10-22 23:40:43.757 [TENANT:RV] [ACTOR:3(Gruppe 1 Account)] ACTION:group.position_change ENTITY:group:1 DETAILS:{'lat': 50.22, 'lon': 8.44}
|
||||||
|
2026-10-22 23:40:43.758 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:group.state_change ENTITY:group:1 DETAILS:{'from': 'offen', 'to': 'unterwegs'}
|
||||||
|
2026-10-22 23:42:41.855 [TENANT:RV] [ACTOR:1(disp)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'unbearbeitet', 'to': 'zugewiesen', 'group_id': 1}
|
||||||
|
2026-10-22 23:42:42.561 [TENANT:RV] [ACTOR:1(disp)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'zugewiesen', 'group_id': 2}
|
||||||
|
2026-10-22 23:42:42.564 [TENANT:RV] [ACTOR:1(disp)] ACTION:group.position_change ENTITY:group:1 DETAILS:{'lat': 50.33, 'lon': 8.55}
|
||||||
|
2026-10-22 23:42:43.272 [TENANT:RV] [ACTOR:1(disp)] ACTION:group.state_change ENTITY:group:1 DETAILS:{'from': 'offen', 'to': 'unterwegs'}
|
||||||
|
2026-10-22 23:42:50.051 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.create ENTITY:group:1 DETAILS:{'aliasname': 'Alpha', 'account_id': 2}
|
||||||
|
2026-10-22 23:42:50.053 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.position_from_history ENTITY:group:1 DETAILS:{'hist_id': 2, 'lat': 50.123, 'lon': 8.456}
|
||||||
|
2026-10-22 23:42:50.056 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.position_clear ENTITY:group:1 DETAILS:{}
|
||||||
|
2026-10-22 23:42:50.058 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.update ENTITY:group:1 DETAILS:{'state': 'unterwegs'}
|
||||||
|
2026-10-22 23:42:50.060 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.update ENTITY:group:1 DETAILS:{'aliasname': 'Alpha neu'}
|
||||||
|
2026-10-22 23:42:50.061 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.update ENTITY:group:1 DETAILS:{'account_id': 3}
|
||||||
|
2026-10-22 23:42:50.063 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.create ENTITY:group:2 DETAILS:{'aliasname': 'Beta', 'account_id': 2}
|
||||||
|
2026-10-22 23:42:50.676 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.position_from_history ENTITY:group:1 DETAILS:{'hist_id': 1, 'lat': 50.1, 'lon': 8.2}
|
||||||
|
2026-10-22 23:42:50.679 [TENANT:RV] [ACTOR:1(admin)] ACTION:group.position_clear ENTITY:group:1 DETAILS:{}
|
||||||
|
2026-10-22 23:47:10.037 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'unbearbeitet', 'to': 'zugewiesen', 'group_id': 1}
|
||||||
|
2026-10-22 23:47:10.038 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'zugewiesen', 'group_id': 2}
|
||||||
|
2026-10-22 23:47:10.039 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'unbearbeitet', 'group_id': None}
|
||||||
|
2026-10-22 23:47:10.040 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'erledigt', 'group_id': 1}
|
||||||
|
2026-10-22 23:47:10.042 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:group.position_change ENTITY:group:1 DETAILS:{'lat': 50.12, 'lon': 8.34}
|
||||||
|
2026-10-22 23:47:10.043 [TENANT:RV] [ACTOR:3(Gruppe 1 Account)] ACTION:group.position_change ENTITY:group:1 DETAILS:{'lat': 50.22, 'lon': 8.44}
|
||||||
|
2026-10-22 23:47:10.043 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:group.state_change ENTITY:group:1 DETAILS:{'from': 'offen', 'to': 'unterwegs'}
|
||||||
|
2026-10-22 23:47:13.193 [TENANT:RV] [ACTOR:1(disp)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'unbearbeitet', 'to': 'zugewiesen', 'group_id': 1}
|
||||||
|
2026-10-22 23:47:13.904 [TENANT:RV] [ACTOR:1(disp)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'zugewiesen', 'group_id': 2}
|
||||||
|
2026-10-22 23:47:13.908 [TENANT:RV] [ACTOR:1(disp)] ACTION:group.position_change ENTITY:group:1 DETAILS:{'lat': 50.33, 'lon': 8.55}
|
||||||
|
2026-10-22 23:47:14.617 [TENANT:RV] [ACTOR:1(disp)] ACTION:group.state_change ENTITY:group:1 DETAILS:{'from': 'offen', 'to': 'unterwegs'}
|
||||||
|
2026-10-22 23:49:15.249 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'unbearbeitet', 'to': 'zugewiesen', 'group_id': 1}
|
||||||
|
2026-10-22 23:49:15.251 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'zugewiesen', 'group_id': 2}
|
||||||
|
2026-10-22 23:49:15.251 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'unbearbeitet', 'group_id': None}
|
||||||
|
2026-10-22 23:49:15.253 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'erledigt', 'group_id': 1}
|
||||||
|
2026-10-22 23:49:15.254 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:group.position_change ENTITY:group:1 DETAILS:{'lat': 50.12, 'lon': 8.34}
|
||||||
|
2026-10-22 23:49:15.255 [TENANT:RV] [ACTOR:3(Gruppe 1 Account)] ACTION:group.position_change ENTITY:group:1 DETAILS:{'lat': 50.22, 'lon': 8.44}
|
||||||
|
2026-10-22 23:49:15.255 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:group.state_change ENTITY:group:1 DETAILS:{'from': 'offen', 'to': 'unterwegs'}
|
||||||
|
2026-10-22 23:50:54.449 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'unbearbeitet', 'to': 'zugewiesen', 'group_id': 1}
|
||||||
|
2026-10-22 23:50:54.451 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'zugewiesen', 'group_id': 2}
|
||||||
|
2026-10-22 23:50:54.452 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'unbearbeitet', 'group_id': None}
|
||||||
|
2026-10-22 23:50:54.453 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'erledigt', 'group_id': 1}
|
||||||
|
2026-10-22 23:50:54.454 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:group.position_change ENTITY:group:1 DETAILS:{'lat': 50.12, 'lon': 8.34}
|
||||||
|
2026-10-22 23:50:54.455 [TENANT:RV] [ACTOR:3(Gruppe 1 Account)] ACTION:group.position_change ENTITY:group:1 DETAILS:{'lat': 50.22, 'lon': 8.44}
|
||||||
|
2026-10-22 23:50:54.456 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:group.state_change ENTITY:group:1 DETAILS:{'from': 'offen', 'to': 'unterwegs'}
|
||||||
|
2026-10-22 23:50:58.311 [TENANT:RV] [ACTOR:1(disp)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'unbearbeitet', 'to': 'zugewiesen', 'group_id': 1}
|
||||||
|
2026-10-22 23:50:59.016 [TENANT:RV] [ACTOR:1(disp)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'zugewiesen', 'group_id': 2}
|
||||||
|
2026-10-22 23:50:59.019 [TENANT:RV] [ACTOR:1(disp)] ACTION:group.position_change ENTITY:group:1 DETAILS:{'lat': 50.33, 'lon': 8.55}
|
||||||
|
2026-10-22 23:50:59.725 [TENANT:RV] [ACTOR:1(disp)] ACTION:group.state_change ENTITY:group:1 DETAILS:{'from': 'offen', 'to': 'unterwegs'}
|
||||||
|
2026-10-22 23:57:38.054 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'unbearbeitet', 'to': 'zugewiesen', 'group_id': 1}
|
||||||
|
2026-10-22 23:57:38.056 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'zugewiesen', 'group_id': 2}
|
||||||
|
2026-10-22 23:57:38.057 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'unbearbeitet', 'group_id': None}
|
||||||
|
2026-10-22 23:57:38.058 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:street.state_change ENTITY:street:1 DETAILS:{'from': 'zugewiesen', 'to': 'erledigt', 'group_id': 1}
|
||||||
|
2026-10-22 23:57:38.059 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:group.position_change ENTITY:group:1 DETAILS:{'lat': 50.12, 'lon': 8.34}
|
||||||
|
2026-10-22 23:57:38.060 [TENANT:RV] [ACTOR:3(Gruppe 1 Account)] ACTION:group.position_change ENTITY:group:1 DETAILS:{'lat': 50.22, 'lon': 8.44}
|
||||||
|
2026-10-22 23:57:38.061 [TENANT:RV] [ACTOR:1(Leitstelle)] ACTION:group.state_change ENTITY:group:1 DETAILS:{'from': 'offen', 'to': 'unterwegs'}
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
-- CMBNet Datenbankschema
|
||||||
|
-- Mandantenfähigkeit: Jede Tabelle hat tenant_id
|
||||||
|
|
||||||
|
-- Mandanten
|
||||||
|
CREATE TABLE IF NOT EXISTS tenants (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
code TEXT UNIQUE NOT NULL,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Accounts
|
||||||
|
CREATE TABLE IF NOT EXISTS accounts (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
tenant_id INTEGER NOT NULL,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
password_hash TEXT NOT NULL,
|
||||||
|
role TEXT NOT NULL CHECK(role IN ('Gast', 'Beobachter', 'Gruppe', 'Dispatcher', 'Administrator')),
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (tenant_id) REFERENCES tenants(id),
|
||||||
|
UNIQUE(tenant_id, name)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Gruppen
|
||||||
|
CREATE TABLE IF NOT EXISTS groups (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
tenant_id INTEGER NOT NULL,
|
||||||
|
aliasname TEXT,
|
||||||
|
state TEXT NOT NULL DEFAULT 'offen' CHECK(state IN ('offen', 'unterwegs', 'online', 'pausierend', 'fertig')),
|
||||||
|
last_lat REAL,
|
||||||
|
last_lon REAL,
|
||||||
|
last_pos_at TIMESTAMP,
|
||||||
|
account_id INTEGER UNIQUE,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (tenant_id) REFERENCES tenants(id),
|
||||||
|
FOREIGN KEY (account_id) REFERENCES accounts(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Straßen
|
||||||
|
CREATE TABLE IF NOT EXISTS streets (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
tenant_id INTEGER NOT NULL,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
state TEXT NOT NULL DEFAULT 'unbearbeitet' CHECK(state IN ('unbearbeitet', 'zugewiesen', 'erledigt')),
|
||||||
|
group_id INTEGER,
|
||||||
|
hn_min INTEGER,
|
||||||
|
hn_max INTEGER,
|
||||||
|
bbox TEXT,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (tenant_id) REFERENCES tenants(id),
|
||||||
|
FOREIGN KEY (group_id) REFERENCES groups(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Historie Straßen
|
||||||
|
CREATE TABLE IF NOT EXISTS street_state_history (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
tenant_id INTEGER NOT NULL,
|
||||||
|
street_id INTEGER NOT NULL,
|
||||||
|
from_state TEXT,
|
||||||
|
to_state TEXT NOT NULL,
|
||||||
|
group_id INTEGER,
|
||||||
|
actor_account_id INTEGER,
|
||||||
|
reason TEXT,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (tenant_id) REFERENCES tenants(id),
|
||||||
|
FOREIGN KEY (street_id) REFERENCES streets(id),
|
||||||
|
FOREIGN KEY (actor_account_id) REFERENCES accounts(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Historie Gruppen
|
||||||
|
CREATE TABLE IF NOT EXISTS group_state_history (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
tenant_id INTEGER NOT NULL,
|
||||||
|
group_id INTEGER NOT NULL,
|
||||||
|
from_state TEXT,
|
||||||
|
to_state TEXT NOT NULL,
|
||||||
|
last_lat REAL,
|
||||||
|
last_lon REAL,
|
||||||
|
last_pos_at TIMESTAMP,
|
||||||
|
actor_account_id INTEGER,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (tenant_id) REFERENCES tenants(id),
|
||||||
|
FOREIGN KEY (group_id) REFERENCES groups(id),
|
||||||
|
FOREIGN KEY (actor_account_id) REFERENCES accounts(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- WebSocket Tokens
|
||||||
|
CREATE TABLE IF NOT EXISTS ws_tokens (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
tenant_id INTEGER NOT NULL,
|
||||||
|
account_id INTEGER NOT NULL,
|
||||||
|
token TEXT UNIQUE NOT NULL,
|
||||||
|
session_id TEXT,
|
||||||
|
expires_at TIMESTAMP,
|
||||||
|
used BOOLEAN DEFAULT 0,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (tenant_id) REFERENCES tenants(id),
|
||||||
|
FOREIGN KEY (account_id) REFERENCES accounts(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Persistierte WebSocket Nachrichten für Code >= 1000
|
||||||
|
CREATE TABLE IF NOT EXISTS ws_messages_store (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
tenant_id INTEGER NOT NULL,
|
||||||
|
sender_id INTEGER,
|
||||||
|
receiver_id INTEGER,
|
||||||
|
code INTEGER NOT NULL,
|
||||||
|
ts INTEGER NOT NULL,
|
||||||
|
msg TEXT,
|
||||||
|
delivered_to TEXT,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (tenant_id) REFERENCES tenants(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Transaktionslog
|
||||||
|
CREATE TABLE IF NOT EXISTS transaction_log (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
tenant_id INTEGER NOT NULL,
|
||||||
|
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
actor_account_id INTEGER,
|
||||||
|
action TEXT NOT NULL,
|
||||||
|
entity_type TEXT NOT NULL,
|
||||||
|
entity_id INTEGER,
|
||||||
|
details TEXT,
|
||||||
|
FOREIGN KEY (tenant_id) REFERENCES tenants(id),
|
||||||
|
FOREIGN KEY (actor_account_id) REFERENCES accounts(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Indizes für Performance
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_accounts_tenant ON accounts(tenant_id);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_groups_tenant ON groups(tenant_id);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_streets_tenant ON streets(tenant_id);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_ws_tokens_token ON ws_tokens(token);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_ws_messages_ts ON ws_messages_store(ts);
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
Flask>=3.0.0
|
||||||
|
Werkzeug>=3.0.0
|
||||||
|
flask-sock>=0.7.0
|
||||||
|
simple-websocket>=1.0.0
|
||||||
|
python-dateutil>=2.9.0
|
||||||
@@ -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
@@ -0,0 +1,100 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Accountverwaltung - CMBNet{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Accountverwaltung</h1>
|
||||||
|
<p><a href="{{ url_for('views.dispatcher', tenant=session.tenant_code) }}">← Zurück</a> | <a href="{{ url_for('auth.logout', tenant=session.tenant_code) }}">Abmelden</a></p>
|
||||||
|
|
||||||
|
<table id="accountsTable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Rolle</th>
|
||||||
|
<th>Aktionen</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for account in accounts %}
|
||||||
|
<tr data-id="{{ account.id }}">
|
||||||
|
<td>{{ account.id }}</td>
|
||||||
|
<td>{{ account.name }}</td>
|
||||||
|
<td>
|
||||||
|
<select onchange="changeRole({{ account.id }}, this.value)">
|
||||||
|
<option value="Gast" {% if account.role == 'Gast' %}selected{% endif %}>Gast</option>
|
||||||
|
<option value="Beobachter" {% if account.role == 'Beobachter' %}selected{% endif %}>Beobachter</option>
|
||||||
|
<option value="Gruppe" {% if account.role == 'Gruppe' %}selected{% endif %}>Gruppe</option>
|
||||||
|
<option value="Dispatcher" {% if account.role == 'Dispatcher' %}selected{% endif %}>Dispatcher</option>
|
||||||
|
<option value="Administrator" {% if account.role == 'Administrator' %}selected{% endif %}>Administrator</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button onclick="openPasswordModal({{ account.id }})">Passwort zurücksetzen</button>
|
||||||
|
<button class="secondary" onclick="deleteAccount({{ account.id }})">Löschen</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<button onclick="openCreateAccountModal()">Neuer Account</button>
|
||||||
|
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<li><a href="{{ url_for('admin_gruppen.gruppen', tenant=session.tenant_code) }}">Gruppenverwaltung</a></li>
|
||||||
|
<li><a href="{{ url_for('admin_strassen.strassen', tenant=session.tenant_code) }}">Straßenverwaltung</a></li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<!-- Passwort Modal -->
|
||||||
|
<dialog id="passwordModal">
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
<a href="#close" aria-label="Close" class="close" onclick="closePasswordModal()"></a>
|
||||||
|
<h3>Passwort zurücksetzen</h3>
|
||||||
|
</header>
|
||||||
|
<input type="hidden" id="pwdAccountId">
|
||||||
|
<label>Neues Passwort
|
||||||
|
<input type="password" id="newPassword">
|
||||||
|
</label>
|
||||||
|
<footer>
|
||||||
|
<button onclick="closePasswordModal()">Abbrechen</button>
|
||||||
|
<button onclick="resetPassword()">Zurücksetzen</button>
|
||||||
|
</footer>
|
||||||
|
</article>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
|
<!-- Create Account Modal -->
|
||||||
|
<dialog id="createAccountModal">
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
<a href="#close" aria-label="Close" class="close" onclick="closeCreateAccountModal()"></a>
|
||||||
|
<h3>Neuer Account</h3>
|
||||||
|
</header>
|
||||||
|
<label>Name
|
||||||
|
<input type="text" id="newAccountName">
|
||||||
|
</label>
|
||||||
|
<label>Passwort
|
||||||
|
<input type="password" id="newAccountPassword">
|
||||||
|
</label>
|
||||||
|
<label>Rolle
|
||||||
|
<select id="newAccountRole">
|
||||||
|
<option value="Gast">Gast</option>
|
||||||
|
<option value="Beobachter">Beobachter</option>
|
||||||
|
<option value="Gruppe">Gruppe</option>
|
||||||
|
<option value="Dispatcher">Dispatcher</option>
|
||||||
|
<option value="Administrator">Administrator</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<footer>
|
||||||
|
<button onclick="closeCreateAccountModal()">Abbrechen</button>
|
||||||
|
<button onclick="createAccount()">Anlegen</button>
|
||||||
|
</footer>
|
||||||
|
</article>
|
||||||
|
</dialog>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
<script src="{{ url_for('static', filename='js/views/admin_accounts.js') }}"></script>
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Gruppenverwaltung - CMBNet{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Gruppenverwaltung</h1>
|
||||||
|
<p><a href="{{ url_for('admin.accounts', tenant=session.tenant_code) }}">← Zurück zur Accountverwaltung</a></p>
|
||||||
|
|
||||||
|
<table id="gruppenTable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Aliasname</th>
|
||||||
|
<th>State</th>
|
||||||
|
<th>Account</th>
|
||||||
|
<th>Position</th>
|
||||||
|
<th>Aktionen</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for gruppe in gruppen %}
|
||||||
|
<tr data-id="{{ gruppe.id }}">
|
||||||
|
<td>{{ gruppe.id }}</td>
|
||||||
|
<td><input type="text" value="{{ gruppe.aliasname or '' }}" onchange="updateGruppe({{ gruppe.id }}, {aliasname: this.value})"></td>
|
||||||
|
<td>
|
||||||
|
<select onchange="updateGruppe({{ gruppe.id }}, {state: this.value})">
|
||||||
|
<option value="offen" {% if gruppe.state == 'offen' %}selected{% endif %}>offen</option>
|
||||||
|
<option value="unterwegs" {% if gruppe.state == 'unterwegs' %}selected{% endif %}>unterwegs</option>
|
||||||
|
<option value="online" {% if gruppe.state == 'online' %}selected{% endif %}>online</option>
|
||||||
|
<option value="pausierend" {% if gruppe.state == 'pausierend' %}selected{% endif %}>pausierend</option>
|
||||||
|
<option value="fertig" {% if gruppe.state == 'fertig' %}selected{% endif %}>fertig</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select onchange="updateGruppe({{ gruppe.id }}, {account_id: this.value})">
|
||||||
|
<option value="">-</option>
|
||||||
|
{% for acc in accounts %}
|
||||||
|
<option value="{{ acc.id }}" {% if gruppe.account_id == acc.id %}selected{% endif %}>{{ acc.name }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td class="group-position">{% if gruppe.last_lat is not none and gruppe.last_lon is not none %}{{ gruppe.last_lat }}, {{ gruppe.last_lon }}{% else %}unbekannt{% endif %}</td>
|
||||||
|
<td>
|
||||||
|
<button onclick="showHistory({{ gruppe.id }})">Historie</button>
|
||||||
|
<button class="secondary delete-position" onclick="deleteGroupPosition({{ gruppe.id }})" {% if gruppe.last_lat is none or gruppe.last_lon is none %}disabled{% endif %}>Position löschen</button>
|
||||||
|
<button class="secondary" onclick="deleteGruppe({{ gruppe.id }})">Löschen</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<button onclick="openCreateGruppeModal()">Neue Gruppe</button>
|
||||||
|
|
||||||
|
<!-- Create Gruppe Modal -->
|
||||||
|
<dialog id="createGruppeModal">
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
<a href="#close" aria-label="Close" class="close" onclick="closeCreateGruppeModal()"></a>
|
||||||
|
<h3>Neue Gruppe</h3>
|
||||||
|
</header>
|
||||||
|
<label>Aliasname
|
||||||
|
<input type="text" id="gruppeAlias">
|
||||||
|
</label>
|
||||||
|
<label>Account (Rolle Gruppe)
|
||||||
|
<select id="gruppeAccount">
|
||||||
|
<option value="">-</option>
|
||||||
|
{% for acc in accounts %}
|
||||||
|
<option value="{{ acc.id }}">{{ acc.name }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<footer>
|
||||||
|
<button onclick="closeCreateGruppeModal()">Abbrechen</button>
|
||||||
|
<button onclick="createGruppe()">Anlegen</button>
|
||||||
|
</footer>
|
||||||
|
</article>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
|
<!-- History Modal -->
|
||||||
|
<dialog id="historyModal">
|
||||||
|
<article style="max-width: 800px;">
|
||||||
|
<header>
|
||||||
|
<a href="#close" aria-label="Close" class="close" onclick="closeHistoryModal()"></a>
|
||||||
|
<h3>Gruppen-Historie</h3>
|
||||||
|
</header>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Datum</th>
|
||||||
|
<th>Von</th>
|
||||||
|
<th>Nach</th>
|
||||||
|
<th>Position</th>
|
||||||
|
<th>Aktion</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="historyBody">
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<footer>
|
||||||
|
<button onclick="closeHistoryModal()">Schließen</button>
|
||||||
|
</footer>
|
||||||
|
</article>
|
||||||
|
</dialog>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
<script src="{{ url_for('static', filename='js/views/admin_gruppen.js') }}"></script>
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Straßenverwaltung - CMBNet{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Straßenverwaltung</h1>
|
||||||
|
<p><a href="{{ url_for('admin.accounts', tenant=session.tenant_code) }}">← Zurück zur Accountverwaltung</a></p>
|
||||||
|
|
||||||
|
<table id="strassenTable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>State</th>
|
||||||
|
<th>Gruppe</th>
|
||||||
|
<th>HN Min</th>
|
||||||
|
<th>HN Max</th>
|
||||||
|
<th>BBox</th>
|
||||||
|
<th>Aktionen</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for strasse in strassen %}
|
||||||
|
<tr data-id="{{ strasse.id }}">
|
||||||
|
<td>{{ strasse.id }}</td>
|
||||||
|
<td>{{ strasse.name }}</td>
|
||||||
|
<td>
|
||||||
|
<select onchange="updateStrasse({{ strasse.id }}, {state: this.value})">
|
||||||
|
<option value="unbearbeitet" {% if strasse.state == 'unbearbeitet' %}selected{% endif %}>unbearbeitet</option>
|
||||||
|
<option value="zugewiesen" {% if strasse.state == 'zugewiesen' %}selected{% endif %}>zugewiesen</option>
|
||||||
|
<option value="erledigt" {% if strasse.state == 'erledigt' %}selected{% endif %}>erledigt</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select onchange="updateStrasse({{ strasse.id }}, {group_id: this.value})">
|
||||||
|
<option value="">-</option>
|
||||||
|
{% for gruppe in gruppen %}
|
||||||
|
<option value="{{ gruppe.id }}" {% if strasse.group_id == gruppe.id %}selected{% endif %}>{{ gruppe.aliasname or gruppe.id }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>{{ strasse.hn_min or '-' }}</td>
|
||||||
|
<td>{{ strasse.hn_max or '-' }}</td>
|
||||||
|
<td>{{ strasse.bbox[:20] if strasse.bbox else '-' }}</td>
|
||||||
|
<td>
|
||||||
|
<button onclick="editStrasse({{ strasse.id }})">✎</button>
|
||||||
|
<button onclick="showStreetHistory({{ strasse.id }})">Historie</button>
|
||||||
|
<button class="secondary" onclick="deleteStrasse({{ strasse.id }})">🗑</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<button onclick="openCreateStrasseModal()">Neue Straße</button>
|
||||||
|
<button onclick="document.getElementById('csvFile').click()">Import CSV</button>
|
||||||
|
<input type="file" id="csvFile" accept=".csv" style="display:none" onchange="importCSV(this)">
|
||||||
|
|
||||||
|
<!-- Create/Edit Strasse Modal -->
|
||||||
|
<dialog id="strasseModal">
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
<a href="#close" aria-label="Close" class="close" onclick="closeStrasseModal()"></a>
|
||||||
|
<h3 id="strasseModalTitle">Straße</h3>
|
||||||
|
</header>
|
||||||
|
<input type="hidden" id="strasseId">
|
||||||
|
<label>Name
|
||||||
|
<input type="text" id="strasseName">
|
||||||
|
</label>
|
||||||
|
<label>Hausnummer minimal
|
||||||
|
<input type="number" id="strasseHnMin">
|
||||||
|
</label>
|
||||||
|
<label>Hausnummer maximal
|
||||||
|
<input type="number" id="strasseHnMax">
|
||||||
|
</label>
|
||||||
|
<label>Bounding Box (JSON Array)
|
||||||
|
<textarea id="strasseBbox"></textarea>
|
||||||
|
</label>
|
||||||
|
<label>State
|
||||||
|
<select id="strasseState">
|
||||||
|
<option value="unbearbeitet">unbearbeitet</option>
|
||||||
|
<option value="zugewiesen">zugewiesen</option>
|
||||||
|
<option value="erledigt">erledigt</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>Gruppe
|
||||||
|
<select id="strasseGroup">
|
||||||
|
<option value="">-</option>
|
||||||
|
{% for gruppe in gruppen %}
|
||||||
|
<option value="{{ gruppe.id }}">{{ gruppe.aliasname or gruppe.id }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<footer>
|
||||||
|
<button onclick="closeStrasseModal()">Abbrechen</button>
|
||||||
|
<button onclick="saveStrasse()">Speichern</button>
|
||||||
|
</footer>
|
||||||
|
</article>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
|
<!-- History Modal -->
|
||||||
|
<dialog id="streetHistoryModal">
|
||||||
|
<article style="max-width: 800px;">
|
||||||
|
<header>
|
||||||
|
<a href="#close" aria-label="Close" class="close" onclick="closeStreetHistoryModal()"></a>
|
||||||
|
<h3>Straßen-Historie</h3>
|
||||||
|
</header>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Datum</th>
|
||||||
|
<th>Von</th>
|
||||||
|
<th>Nach</th>
|
||||||
|
<th>Gruppe</th>
|
||||||
|
<th>Aktion</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="streetHistoryBody">
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<footer>
|
||||||
|
<button onclick="closeStreetHistoryModal()">Schließen</button>
|
||||||
|
</footer>
|
||||||
|
</article>
|
||||||
|
</dialog>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
<script src="{{ url_for('static', filename='js/views/admin_strassen.js') }}"></script>
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de" data-theme="light">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>{% block title %}CMBNet{% endblock %}</title>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@1/css/pico.min.css">
|
||||||
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
||||||
|
{% block head %}{% endblock %}
|
||||||
|
</head>
|
||||||
|
<body class="{% block body_class %}{% endblock %}">
|
||||||
|
<main class="container">
|
||||||
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||||
|
{% if messages %}
|
||||||
|
{% for category, message in messages %}
|
||||||
|
<article class="{{ category }}">{{ message }}</article>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
</main>
|
||||||
|
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
||||||
|
{% block scripts %}{% endblock %}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Dispatcher - {{ session.tenant_code }} - CMBNet{% endblock %}
|
||||||
|
|
||||||
|
{% block body_class %}dispatcher-page{% endblock %}
|
||||||
|
|
||||||
|
{% block head %}
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/dispatcher.css') }}">
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="dispatcher-layout">
|
||||||
|
<section class="map-pane" aria-label="Kartenansicht">
|
||||||
|
<div id="map"></div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<aside class="control-pane" aria-label="Kontrollansicht">
|
||||||
|
<header class="control-header">
|
||||||
|
<div class="clock" aria-live="off">
|
||||||
|
<div class="clock-date" id="clockDate"></div>
|
||||||
|
<div class="clock-time" id="clockTime">--:--:--</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="header-controls">
|
||||||
|
<label class="map-layer-label">
|
||||||
|
<span>Hintergrundkarte</span>
|
||||||
|
<select id="baseLayerSelect">
|
||||||
|
<option value="osm">OpenStreetMap</option>
|
||||||
|
<option value="aerial">Luftbild</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<button type="button" id="speakerButton" class="icon-button"
|
||||||
|
title="Nachricht an alle senden" aria-label="Nachricht an alle senden">📢</button>
|
||||||
|
</div>
|
||||||
|
<div class="connection-status" id="connectionStatus">Verbinde …</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="group-accordion" id="groupAccordion"></div>
|
||||||
|
|
||||||
|
<footer class="control-footer">
|
||||||
|
<label class="slider-control" for="opacitySlider">
|
||||||
|
<span>Opazität <output id="opacityValue">0.70</output></span>
|
||||||
|
<input id="opacitySlider" type="range" min="0" max="1" step="0.05" value="0.7">
|
||||||
|
</label>
|
||||||
|
<label class="slider-control" for="weightSlider">
|
||||||
|
<span>Markerbreite <output id="weightValue">20</output></span>
|
||||||
|
<input id="weightSlider" type="range" min="1" max="100" step="1" value="20">
|
||||||
|
</label>
|
||||||
|
<div class="footer-buttons">
|
||||||
|
<button type="button" id="fitBoundsButton" class="icon-button"
|
||||||
|
title="Gesamten Straßenbereich anzeigen" aria-label="Gesamten Straßenbereich anzeigen">🌍</button>
|
||||||
|
<a id="logoutButton" class="icon-button" href="{{ url_for('auth.logout', tenant=session.tenant_code) }}"
|
||||||
|
title="Session beenden" aria-label="Session beenden">⏻</a>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</aside>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Freitext an alle senden -->
|
||||||
|
<dialog id="speakerModal">
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
<button class="close" type="button" aria-label="Schließen" onclick="closeSpeakerModal()"></button>
|
||||||
|
<h3>Nachricht an alle</h3>
|
||||||
|
</header>
|
||||||
|
<label>Freitext
|
||||||
|
<textarea id="speakerText" rows="4" placeholder="Nachricht eingeben …"></textarea>
|
||||||
|
</label>
|
||||||
|
<footer>
|
||||||
|
<button type="button" class="secondary" onclick="closeSpeakerModal()">Abbrechen</button>
|
||||||
|
<button type="button" onclick="sendSpeakerMessage()">Senden</button>
|
||||||
|
</footer>
|
||||||
|
</article>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
|
<!-- Straßen-State ändern -->
|
||||||
|
<dialog id="streetModal">
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
<button class="close" type="button" aria-label="Schließen" onclick="closeStreetModal()"></button>
|
||||||
|
<h3 id="streetModalTitle">Straße</h3>
|
||||||
|
</header>
|
||||||
|
<label>State
|
||||||
|
<select id="streetStateSelect">
|
||||||
|
<option value="unbearbeitet">unbearbeitet</option>
|
||||||
|
<option value="zugewiesen">zugewiesen</option>
|
||||||
|
<option value="erledigt">erledigt</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label id="streetGroupLabel">Gruppe
|
||||||
|
<select id="streetGroupSelect"></select>
|
||||||
|
</label>
|
||||||
|
<footer>
|
||||||
|
<button type="button" class="secondary" onclick="closeStreetModal()">Abbrechen</button>
|
||||||
|
<button type="button" onclick="saveStreetState()">Speichern</button>
|
||||||
|
</footer>
|
||||||
|
</article>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
|
<!-- Chatverlauf einer Gruppe -->
|
||||||
|
<dialog id="chatModal">
|
||||||
|
<article class="chat-dialog">
|
||||||
|
<header>
|
||||||
|
<button class="close" type="button" aria-label="Schließen" onclick="closeChatModal()"></button>
|
||||||
|
<h3 id="chatTitle">Chat</h3>
|
||||||
|
</header>
|
||||||
|
<div class="chat-messages" id="chatMessages"></div>
|
||||||
|
<footer>
|
||||||
|
<button type="button" onclick="closeChatModal()">Schließen</button>
|
||||||
|
</footer>
|
||||||
|
</article>
|
||||||
|
</dialog>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
<script>
|
||||||
|
window.CMBNET_TENANT = {{ session.tenant_code|tojson }};
|
||||||
|
window.CMBNET_ACCOUNT_ID = {{ session.account_id|tojson }};
|
||||||
|
window.CMBNET_LOGOUT_URL = {{ url_for('auth.logout', tenant=session.tenant_code)|tojson }};
|
||||||
|
</script>
|
||||||
|
<script src="{{ url_for('static', filename='js/str2pl.js') }}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/views/dispatcher.js') }}"></script>
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Dispatcher Mobil - CMBNet{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Dispatcher Mobil View</h1>
|
||||||
|
<p>Wird später implementiert</p>
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Gruppen View - CMBNet{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Gruppen View</h1>
|
||||||
|
<p>Willkommen, {{ session.username }}</p>
|
||||||
|
<p><a href="{{ url_for('auth.logout', tenant=session.tenant_code) }}">Abmelden</a></p>
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Login - CMBNet ({{ tenant_code }}){% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
<h1>CMBNet Login</h1>
|
||||||
|
<p>Mandant: <strong>{{ tenant_code }}</strong></p>
|
||||||
|
</header>
|
||||||
|
<form method="post">
|
||||||
|
<input type="hidden" name="tenant" value="{{ tenant_code }}">
|
||||||
|
<label for="username">
|
||||||
|
Benutzername
|
||||||
|
<input type="text" id="username" name="username" required autofocus>
|
||||||
|
</label>
|
||||||
|
<label for="password">
|
||||||
|
Passwort
|
||||||
|
<input type="password" id="password" name="password" required>
|
||||||
|
</label>
|
||||||
|
<button type="submit">Anmelden</button>
|
||||||
|
</form>
|
||||||
|
<footer>
|
||||||
|
<a href="{{ url_for('auth.login_select', tenant=tenant_code) }}">← Zurück zur Mandantenauswahl</a>
|
||||||
|
</footer>
|
||||||
|
</article>
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Mandantenauswahl - CMBNet{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
<h1>CMBNet - Mandantenauswahl</h1>
|
||||||
|
</header>
|
||||||
|
<p>Bitte wählen Sie Ihren Mandanten aus:</p>
|
||||||
|
<div class="grid">
|
||||||
|
<a href="{{ url_for('auth.login', tenant='BV') }}" role="button">BV</a>
|
||||||
|
<a href="{{ url_for('auth.login', tenant='RV') }}" role="button" class="secondary">RV</a>
|
||||||
|
<a href="{{ url_for('auth.login', tenant='SV') }}" role="button" class="contrast">SV</a>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Öffentlicher View - CMBNet{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Öffentlicher View</h1>
|
||||||
|
<p><a href="{{ url_for('auth.login_select', tenant='RV') }}">Login</a></p>
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Präsentations View - CMBNet{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Präsentations View</h1>
|
||||||
|
<p>Willkommen, {{ session.username }}</p>
|
||||||
|
<p><a href="{{ url_for('auth.logout', tenant=session.tenant_code) }}">Abmelden</a></p>
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
from cmbnet import create_app
|
||||||
|
|
||||||
|
app = create_app()
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
Kurz: Du legst Mandanten und den Admin direkt in der SQLite-DB an. Am einfachsten geht das über sqlite3 + einen generierten Passwort-Hash.
|
||||||
|
1) Datenbank initialisieren
|
||||||
|
Falls noch nicht geschehen:
|
||||||
|
cd /Users/thomas/Src/Sternsinger/CMBNet
|
||||||
|
flask --app app init-db
|
||||||
|
2) Passwort-Hash erzeugen
|
||||||
|
Erzeuge dir einen Hash für dein gewünschtes Passwort. Hier beispielhaft für admin123:
|
||||||
|
cd /Users/thomas/Src/Sternsinger/CMBNet
|
||||||
|
python3 -c "from werkzeug.security import generate_password_hash; print(generate_password_hash('admin123'))"
|
||||||
|
Kopiere die komplette Ausgabe (beginnt z. B. mit pbkdf2:sha256:...).
|
||||||
|
3) Mandanten und Admin-Account anlegen
|
||||||
|
Öffne jetzt die Datenbank:
|
||||||
|
sqlite3 instance/cmbnet.sqlite3
|
||||||
|
Füge dann folgende SQL-Befehle ein. Ersetze <DEIN_HASH> mit dem eben kopierten Hash:
|
||||||
|
-- Mandanten anlegen (falls noch nicht vorhanden)
|
||||||
|
INSERT OR IGNORE INTO tenants (code, name) VALUES ('BV', 'Bezirk BV');
|
||||||
|
INSERT OR IGNORE INTO tenants (code, name) VALUES ('RV', 'Bezirk RV');
|
||||||
|
INSERT OR IGNORE INTO tenants (code, name) VALUES ('SV', 'Bezirk SV');
|
||||||
|
|
||||||
|
-- Admin für Mandant RV anlegen
|
||||||
|
INSERT INTO accounts (tenant_id, name, password_hash, role)
|
||||||
|
VALUES ((SELECT id FROM tenants WHERE code = 'RV'), 'admin', '<DEIN_HASH>', 'Administrator');
|
||||||
|
|
||||||
|
-- Prüfen
|
||||||
|
SELECT a.id, a.name, a.role, t.code AS tenant
|
||||||
|
FROM accounts a
|
||||||
|
JOIN tenants t ON a.tenant_id = t.id;
|
||||||
|
|
||||||
|
.quit
|
||||||
|
4) Einloggen
|
||||||
|
Starte den Server (falls noch nicht laufend):
|
||||||
|
flask --app app run --debug --host 127.0.0.1 --port 5000
|
||||||
|
Dann öffne im Browser:
|
||||||
|
http://127.0.0.1:5000/RV/login
|
||||||
|
Benutzername: admin, Passwort: admin123 (oder das, das du in Schritt 2 genutzt hast).
|
||||||
|
Nach dem Login wirst du direkt zur Accountverwaltung weitergeleitet, da der Account die Rolle Administrator hat.
|
||||||
@@ -0,0 +1,484 @@
|
|||||||
|
Ackerstraße
|
||||||
|
Aennchenplatz
|
||||||
|
Aennchenstraße
|
||||||
|
Aggerstraße
|
||||||
|
Ahornweg
|
||||||
|
Ahrstraße
|
||||||
|
Akazienweg
|
||||||
|
Alberichstraße
|
||||||
|
Albertus-Magnus-Straße
|
||||||
|
Alemannenstraße
|
||||||
|
Alte Bahnhofstraße
|
||||||
|
Am Arndtplatz
|
||||||
|
Am Baumgarten
|
||||||
|
Am Bismarckturm
|
||||||
|
Am Bommerich
|
||||||
|
Am Botten
|
||||||
|
Am Büchel
|
||||||
|
Am Burgfriedhof
|
||||||
|
Am Buschacker
|
||||||
|
Am Dinaswerk
|
||||||
|
Am Domblick
|
||||||
|
Am Draitschbusch
|
||||||
|
Am Finkenherd
|
||||||
|
Am Fronhof
|
||||||
|
Am Gäßchen
|
||||||
|
Am Glückshaus
|
||||||
|
Am Güsgensberg
|
||||||
|
Am Helpert
|
||||||
|
Am Klufterhof
|
||||||
|
Am Kreuter
|
||||||
|
Am Kurpark
|
||||||
|
Am Lenkert
|
||||||
|
Am Lindenbach
|
||||||
|
Am Michaelshof
|
||||||
|
Am Nippenkreuz
|
||||||
|
Am Noßbacher Weg
|
||||||
|
Am Rosenrain
|
||||||
|
Am Schaumburger Hof
|
||||||
|
Am Schörnchen
|
||||||
|
Am Schwimmbad
|
||||||
|
Am Stadtwald
|
||||||
|
Am Südfriedhof
|
||||||
|
Am Turmhof
|
||||||
|
Am Weckhasen
|
||||||
|
Am Winkel
|
||||||
|
Am Woltersweiher
|
||||||
|
Am Ziegenbaum
|
||||||
|
Amalienhöhe
|
||||||
|
Amselhang
|
||||||
|
An Brenigs Ziegelei
|
||||||
|
An der Arndtruhe
|
||||||
|
An der Kelter
|
||||||
|
An der Kommende
|
||||||
|
An der Marienkapelle
|
||||||
|
An der Nesselburg
|
||||||
|
Andreas-Hermes-Straße
|
||||||
|
Andreasstraße
|
||||||
|
Anhalter Straße
|
||||||
|
Annaberger Straße
|
||||||
|
Annettenstraße
|
||||||
|
Antoniterstraße
|
||||||
|
Arndtplatz
|
||||||
|
Auerhofstraße
|
||||||
|
Auf dem Brand
|
||||||
|
Auf dem Domhof
|
||||||
|
Auf dem Godesberg
|
||||||
|
Auf dem Oelsfeld
|
||||||
|
Auf dem Rotkopf
|
||||||
|
Auf der Hostert
|
||||||
|
Auf der Ley
|
||||||
|
August-Bebel-Allee
|
||||||
|
Augustastraße
|
||||||
|
Austraße
|
||||||
|
Axenfeldstraße
|
||||||
|
Bachaue
|
||||||
|
Bachemer Straße
|
||||||
|
Bahnstraße
|
||||||
|
Basteistraße
|
||||||
|
Beckers Garten
|
||||||
|
Beethovenallee
|
||||||
|
Behringstraße
|
||||||
|
Belderbuschstraße
|
||||||
|
Benngasse
|
||||||
|
Berliner Ring
|
||||||
|
Bernkasteler Straße
|
||||||
|
Birzentalstraße
|
||||||
|
Bismarckallee
|
||||||
|
Blumenaustraße
|
||||||
|
Bodelschwinghstraße
|
||||||
|
Bodenstaffstraße
|
||||||
|
Bonner Straße
|
||||||
|
Brandenburger Straße
|
||||||
|
Breiter Weg
|
||||||
|
Breslauer Straße
|
||||||
|
Brunhildstraße
|
||||||
|
Brunnenallee
|
||||||
|
Burgblick
|
||||||
|
Bürgerstraße
|
||||||
|
Burgstraße
|
||||||
|
Bürvigstraße
|
||||||
|
Camphausenallee
|
||||||
|
Cäsariusstraße
|
||||||
|
Charlotte-von-Stein-Straße
|
||||||
|
Cheruskerstraße
|
||||||
|
Clara-Wieck-Straße
|
||||||
|
Dankwardstraße
|
||||||
|
Danziger Straße
|
||||||
|
De-Brezé-Straße
|
||||||
|
Dechant-Heimbach-Straße
|
||||||
|
Deichmanns Aue
|
||||||
|
Denglerstraße
|
||||||
|
Deutschherrenstraße
|
||||||
|
Dietrichstraße
|
||||||
|
Dollendorfer Straße
|
||||||
|
Domhofstraße
|
||||||
|
Donatusstraße
|
||||||
|
Drachenburgstraße
|
||||||
|
Drachenfelsstraße
|
||||||
|
Dreholzstraße
|
||||||
|
Dreizehnmorgenweg
|
||||||
|
Dromersheimer Straße
|
||||||
|
Dürenstraße
|
||||||
|
Elfstraße
|
||||||
|
Elisabeth-Mayer-Straße
|
||||||
|
Elisabeth-Selbert-Allee
|
||||||
|
Elisabethstraße
|
||||||
|
Ellesdorfer Straße
|
||||||
|
Elliger Höhe
|
||||||
|
Elsässer Straße
|
||||||
|
Elsternweg
|
||||||
|
Eltviller Straße
|
||||||
|
Embavenhof
|
||||||
|
Erftstraße
|
||||||
|
Eschenweg
|
||||||
|
Etzelstraße
|
||||||
|
Europastraße
|
||||||
|
Fährstraße
|
||||||
|
Fasanenstraße
|
||||||
|
Father-Bill-Straße
|
||||||
|
Ferdinand-Lassalle-Straße
|
||||||
|
Fichtestraße
|
||||||
|
Fliederstraße
|
||||||
|
Floßweg
|
||||||
|
Fontanestraße
|
||||||
|
Frankengraben
|
||||||
|
Frankenstraße
|
||||||
|
Franz-Linz-Straße
|
||||||
|
Frascatistraße
|
||||||
|
Freier Weg
|
||||||
|
Friedrich-Bleek-Straße
|
||||||
|
Friedrich-Ebert-Straße
|
||||||
|
Friedrichallee
|
||||||
|
Friesdorfer Straße
|
||||||
|
Friesenstraße
|
||||||
|
Fröbelstraße
|
||||||
|
Fuderbachsweg
|
||||||
|
Fürstenbergstraße
|
||||||
|
Galileistraße
|
||||||
|
Gerhard-Rohlfs-Straße
|
||||||
|
Germanenstraße
|
||||||
|
Gernotstraße
|
||||||
|
Giselherstraße
|
||||||
|
Gneisenaustraße
|
||||||
|
Godesberger Allee
|
||||||
|
Godesberger Hof
|
||||||
|
Godesberger Straße
|
||||||
|
Goldbergweg
|
||||||
|
Görresstraße
|
||||||
|
Gotenstraße
|
||||||
|
Graf-von-Lehndorff-Straße
|
||||||
|
Gringsstraße
|
||||||
|
Grubenstraße
|
||||||
|
Grüner Weg
|
||||||
|
Gunterstraße
|
||||||
|
Gutenbergallee
|
||||||
|
Habsburgerstraße
|
||||||
|
Hagenstraße
|
||||||
|
Hainbuchenweg
|
||||||
|
Hannah-Arendt-Straße
|
||||||
|
Hans-Böckler-Allee
|
||||||
|
Hans-Rosenberg-Straße
|
||||||
|
Hardtstraße
|
||||||
|
Haselnußweg
|
||||||
|
Hegelstraße
|
||||||
|
Heiderhofring
|
||||||
|
Heinemannstraße
|
||||||
|
Heinrich-Hertz-Straße
|
||||||
|
Heinrich-von-Stephan-Straße
|
||||||
|
Heinrichstraße
|
||||||
|
Heisterbachstraße
|
||||||
|
Hensstraße
|
||||||
|
Herderstraße
|
||||||
|
Hermann-Löns-Straße
|
||||||
|
Hildebrandstraße
|
||||||
|
Hochkreuzallee
|
||||||
|
Hofstraße
|
||||||
|
Hohenzollernplatz
|
||||||
|
Hohenzollernstraße
|
||||||
|
Hohle Gasse
|
||||||
|
Holbeinstraße
|
||||||
|
Honnefer Straße
|
||||||
|
Hopmannstraße
|
||||||
|
Horionstraße
|
||||||
|
Hoverstraße
|
||||||
|
Hubert-Peter-Straße
|
||||||
|
Im Apfelgarten
|
||||||
|
Im Äuelchen
|
||||||
|
Im Bachele
|
||||||
|
Im Bachfeld
|
||||||
|
Im Bendel
|
||||||
|
Im Buchengrund
|
||||||
|
Im Erlengrund
|
||||||
|
Im Etzental
|
||||||
|
Im Frankenkeller
|
||||||
|
Im Gries
|
||||||
|
Im Hag
|
||||||
|
Im Hohn
|
||||||
|
Im Meisengarten
|
||||||
|
Im Pfirsichgarten
|
||||||
|
Im Rosenberg
|
||||||
|
Im Vogelsang
|
||||||
|
Im Weingarten
|
||||||
|
Im Wiesengrund
|
||||||
|
Im Wiesfeld
|
||||||
|
In der Kumme
|
||||||
|
In der Maar
|
||||||
|
Ittenbacher Straße
|
||||||
|
Jägerweg
|
||||||
|
Jahnallee
|
||||||
|
Jean-Paul-Straße
|
||||||
|
Johanna-Kinkel-Straße
|
||||||
|
Joseph-Roth-Straße
|
||||||
|
Junkerstraße
|
||||||
|
Kanalstraße
|
||||||
|
Kantstraße
|
||||||
|
Kapellenweg
|
||||||
|
Kardinal-Galen-Weg
|
||||||
|
Karl-Finkelnburg-Straße
|
||||||
|
Kastanienweg
|
||||||
|
Kelzenbergstraße
|
||||||
|
Kennedyallee
|
||||||
|
Keplerstraße
|
||||||
|
Kirchberg
|
||||||
|
Kirchweingarten
|
||||||
|
Klosterbergstraße
|
||||||
|
Klufterbachtal
|
||||||
|
Klufterstraße
|
||||||
|
Koblenzer Straße
|
||||||
|
Kolberger Straße
|
||||||
|
Kolfhausstraße
|
||||||
|
Kollgasse
|
||||||
|
Kolumbusring
|
||||||
|
Komtureistraße
|
||||||
|
Königsplatz
|
||||||
|
Konstantinstraße
|
||||||
|
Kopernikusstraße
|
||||||
|
Körnerstraße
|
||||||
|
Kortrijker Straße
|
||||||
|
Kottenstraße
|
||||||
|
Kraterstraße
|
||||||
|
Kreisauer Straße
|
||||||
|
Kriemhildstraße
|
||||||
|
Kronprinzenstraße
|
||||||
|
Kunigundenstraße
|
||||||
|
Kurfürstenallee
|
||||||
|
Kurt-Georg-Kiesinger-Allee
|
||||||
|
Lahnstraße
|
||||||
|
Langenbergsweg
|
||||||
|
Langer Grabenweg
|
||||||
|
Lannesdorfer Straße
|
||||||
|
Laufenbergstraße
|
||||||
|
Lehnpütz
|
||||||
|
Leibnizstraße
|
||||||
|
Leonardusstraße
|
||||||
|
Levyweg
|
||||||
|
Ließemer Straße
|
||||||
|
Lindenallee
|
||||||
|
Lindstraße
|
||||||
|
Löbestraße
|
||||||
|
Lohrbergstraße
|
||||||
|
Lortzingstraße
|
||||||
|
Lucas-Cranach-Straße
|
||||||
|
Ludwig-Erhard-Allee
|
||||||
|
Ludwig-Erhard-Platz
|
||||||
|
Lützowstraße
|
||||||
|
Lyngsbergstraße
|
||||||
|
Magnolienweg
|
||||||
|
Maidenheadstraße
|
||||||
|
Mainzer Straße
|
||||||
|
Mallwitzstraße
|
||||||
|
Mandelbaumweg
|
||||||
|
Margaretenstraße
|
||||||
|
Marienforster Promenade
|
||||||
|
Marienforster Steinweg
|
||||||
|
Marienforster Straße
|
||||||
|
Marta-Worringer-Straße
|
||||||
|
Martin-Luther-Allee
|
||||||
|
Martin-Luther-King-Straße
|
||||||
|
Martinstraße
|
||||||
|
Mathonetstraße
|
||||||
|
Matthias-Grünewald-Straße
|
||||||
|
Max-Franz-Straße
|
||||||
|
Max-Löbner-Straße
|
||||||
|
Max-Planck-Straße
|
||||||
|
Meckenheimer Straße
|
||||||
|
Mecklenburger Straße
|
||||||
|
Meersburgstraße
|
||||||
|
Mehlemer Straße
|
||||||
|
Meitnerstraße
|
||||||
|
Mendelssohnstraße
|
||||||
|
Merianstraße
|
||||||
|
Michaelplatz
|
||||||
|
Mildred-Scheel-Straße
|
||||||
|
Mirbachstraße
|
||||||
|
Mittelstraße
|
||||||
|
Mohrenstraße
|
||||||
|
Moltkeplatz
|
||||||
|
Moltkestraße
|
||||||
|
Moselstraße
|
||||||
|
Muffendorfer Hauptstraße
|
||||||
|
Muffendorfer Straße
|
||||||
|
Mühlenpfad
|
||||||
|
Mühlenstraße
|
||||||
|
Nachtigallenstraße
|
||||||
|
Nahestraße
|
||||||
|
Neckarstraße
|
||||||
|
Neuer Weg
|
||||||
|
Nibelungenstraße
|
||||||
|
Niersteiner Straße
|
||||||
|
Nietzschestraße
|
||||||
|
Nikolaus-Becker-Straße
|
||||||
|
Oberaustraße
|
||||||
|
Oberstraße
|
||||||
|
Offenbachstraße
|
||||||
|
Ölbergstraße
|
||||||
|
Ortwinstraße
|
||||||
|
Ostseestraße
|
||||||
|
Oststraße
|
||||||
|
Otto-Kühne-Platz
|
||||||
|
Pappelweg
|
||||||
|
Paracelsusstraße
|
||||||
|
Parkweg
|
||||||
|
Paul-Kemp-Straße
|
||||||
|
Paul-Magar-Straße
|
||||||
|
Pecher Straße
|
||||||
|
Pennefeldsweg
|
||||||
|
Peter-Hensen-Straße
|
||||||
|
Peter-Schwingen-Straße
|
||||||
|
Petersbergstraße
|
||||||
|
Pfarrer-Merck-Straße
|
||||||
|
Pfarrer-Minartz-Straße
|
||||||
|
Philosophenring
|
||||||
|
Pionierstraße
|
||||||
|
Pirolweg
|
||||||
|
Plittersdorfer Straße
|
||||||
|
Prinz-Löwenstein-Straße
|
||||||
|
Prinzenstraße
|
||||||
|
Professor-Dennert-Straße
|
||||||
|
Promenadenweg
|
||||||
|
Pützfelder Weg
|
||||||
|
Quellenstraße
|
||||||
|
Redoutenweg
|
||||||
|
Rheinallee
|
||||||
|
Rheingoldstraße
|
||||||
|
Rheinstraße
|
||||||
|
Rhodosstraße
|
||||||
|
Rhöndorfer Straße
|
||||||
|
Ria-Maternus-Platz
|
||||||
|
Riemenschneiderstraße
|
||||||
|
Robert-Schuman-Platz
|
||||||
|
Robinienweg
|
||||||
|
Rodderbergstraße
|
||||||
|
Roderichstraße
|
||||||
|
Rolandstraße
|
||||||
|
Rolandswerther Straße
|
||||||
|
Römerplatz
|
||||||
|
Röntgenstraße
|
||||||
|
Roonstraße
|
||||||
|
Rotdornweg
|
||||||
|
Rotweingarten
|
||||||
|
Rubensstraße
|
||||||
|
Rude-Krüzche-Weg
|
||||||
|
Rüdesheimer Straße
|
||||||
|
Rüdigerstraße
|
||||||
|
Rüngsdorfer Straße
|
||||||
|
Saarstraße
|
||||||
|
Sachsenstraße
|
||||||
|
Saint-Cloud-Straße
|
||||||
|
Sankt-Augustinus-Straße
|
||||||
|
Scharnhorststraße
|
||||||
|
Schenkendorfstraße
|
||||||
|
Schlehenweg
|
||||||
|
Schloßallee
|
||||||
|
Schopenhauerstraße
|
||||||
|
Schulplatz
|
||||||
|
Schultheißgasse
|
||||||
|
Schützengraben
|
||||||
|
Schwalbengarten
|
||||||
|
Schwannstraße
|
||||||
|
Schwarzbirkenweg
|
||||||
|
Schweinheimer Weg
|
||||||
|
Schwertberger Straße
|
||||||
|
Sebastianusweg
|
||||||
|
Sedanstraße
|
||||||
|
Servatiusstraße
|
||||||
|
Seufertstraße
|
||||||
|
Severinsweg
|
||||||
|
Sibyllenstraße
|
||||||
|
Siegfriedstraße
|
||||||
|
Siegstraße
|
||||||
|
Simrockallee
|
||||||
|
Sommerbergweg
|
||||||
|
Sonnenhag
|
||||||
|
Sonnenscheinstraße
|
||||||
|
Spatzenweg
|
||||||
|
Spechtweg
|
||||||
|
Spichernstraße
|
||||||
|
Spiegelhofstraße
|
||||||
|
Splickgasse
|
||||||
|
Steglitzer Straße
|
||||||
|
Steingasse
|
||||||
|
Steinstraße
|
||||||
|
Stephan-Lochner-Straße
|
||||||
|
Steubenring
|
||||||
|
Stirzenhofstraße
|
||||||
|
Stümpchensweg
|
||||||
|
Südstraße
|
||||||
|
Suebenstraße
|
||||||
|
Talstraße
|
||||||
|
Tannenallee
|
||||||
|
Telemannstraße
|
||||||
|
Teutonenstraße
|
||||||
|
Theaterplatz
|
||||||
|
Theodor-Heuss-Straße
|
||||||
|
Thüringer Straße
|
||||||
|
Truchseßstraße
|
||||||
|
Tulpenbaumweg
|
||||||
|
Turmstraße
|
||||||
|
Ubierstraße
|
||||||
|
Uhlandstraße
|
||||||
|
Ürziger Straße
|
||||||
|
Utestraße
|
||||||
|
Venner Kirchweg
|
||||||
|
Venner Straße
|
||||||
|
Vikariegasse
|
||||||
|
Viktor-Schnitzler-Straße
|
||||||
|
Viktoriaplatz
|
||||||
|
Viktoriastraße
|
||||||
|
Villichgasse
|
||||||
|
Volkerstraße
|
||||||
|
Von-der-Heydt-Straße
|
||||||
|
Von-Groote-Platz
|
||||||
|
Von-Müllenark-Straße
|
||||||
|
Von-Sandt-Ufer
|
||||||
|
Vulkanstraße
|
||||||
|
Waasemstraße
|
||||||
|
Waldburgstraße
|
||||||
|
Waldstraße
|
||||||
|
Walramstraße
|
||||||
|
Weinbergstraße
|
||||||
|
Weinrosenweg
|
||||||
|
Weißdornweg
|
||||||
|
Weißenburgstraße
|
||||||
|
Welfenstraße
|
||||||
|
Wendelstadtallee
|
||||||
|
Weststraße
|
||||||
|
Wichterichstraße
|
||||||
|
Wiedemannstraße
|
||||||
|
Wiedstraße
|
||||||
|
Wielandstraße
|
||||||
|
Winkelsweg
|
||||||
|
Winterstraße
|
||||||
|
Wittelsbacherstraße
|
||||||
|
Wolkenburgstraße
|
||||||
|
Wörthstraße
|
||||||
|
Wupperstraße
|
||||||
|
Wurzerstraße
|
||||||
|
Yalovastraße
|
||||||
|
Yorckstraße
|
||||||
|
Zanderstraße
|
||||||
|
Zeller Straße
|
||||||
|
Zeppelinstraße
|
||||||
|
Zietenstraße
|
||||||
|
Zum Kempenberg
|
||||||
@@ -0,0 +1,485 @@
|
|||||||
|
#Name;Hausnummer minimal;Hausnummer maximal;Bounding Box
|
||||||
|
Ackerstraße;1;24;[50.662251,7.188907], [50.662089,7.190370]
|
||||||
|
Aennchenplatz;1;13;[50.685995,7.152657], [50.685349,7.153062]
|
||||||
|
Aennchenstraße;1;61;[50.687726,7.147876], [50.685894,7.151963]
|
||||||
|
Aggerstraße;1;12;[50.701450,7.152388], [50.700848,7.153290]
|
||||||
|
Ahornweg;1;89;[50.661526,7.148197], [50.657965,7.150190]
|
||||||
|
Ahrstraße;1;64;[50.700406,7.149548], [50.698688,7.154599]
|
||||||
|
Akazienweg;1;35;[50.665780,7.152703], [50.663069,7.155104]
|
||||||
|
Alemannenstraße;1;10;[50.696578,7.143003], [50.696002,7.143771]
|
||||||
|
Amalienhöhe;1;26;[50.685489,7.141391], [50.684713,7.142489]
|
||||||
|
Am Bommerich;1;23;[50.693878,7.121401], [50.693285,7.121981]
|
||||||
|
Am Botten;1;24;[50.657151,7.188396], [50.655696,7.190017]
|
||||||
|
Im Buchengrund;1;17;[50.692647,7.132876], [50.691508,7.133890]
|
||||||
|
Am Burgfriedhof;1;29;[50.685322,7.145704], [50.684591,7.148488]
|
||||||
|
Am Buschacker;1;27;[50.692236,7.133906], [50.691037,7.135187]
|
||||||
|
Am Domblick;1;27;[50.667454,7.158761], [50.666659,7.161568]
|
||||||
|
Am Finkenherd;1;14;[50.675877,7.177173], [50.675280,7.178747]
|
||||||
|
Am Fronhof;1;19;[50.683274,7.151230], [50.682245,7.152763]
|
||||||
|
Am Glückshaus;1;20;[50.661284,7.194692], [50.660309,7.196809]
|
||||||
|
Am Helpert;1;36;[50.671798,7.157887], [50.670995,7.159719]
|
||||||
|
Am Kreuter;1;22;[50.677751,7.152372], [50.676219,7.153844]
|
||||||
|
Am Lenkert;1;62;[50.682336,7.142547], [50.681054,7.147105]
|
||||||
|
Am Rosenrain;1;31;[50.657977,7.190173], [50.657086,7.191469]
|
||||||
|
Am Schörnchen;1;18;[50.684827,7.145736], [50.683898,7.146613]
|
||||||
|
Am Schwimmbad;1;8;[50.681046,7.175713], [50.680833,7.177707]
|
||||||
|
Amselhang;1;6;[50.652981,7.191072], [50.652304,7.191831]
|
||||||
|
Am Stadtwald;1;119;[50.680600,7.137404], [50.674417,7.142906]
|
||||||
|
Am Turmhof;1;14;[50.699689,7.161692], [50.699361,7.162614]
|
||||||
|
Am Winkel;1;22;[50.663680,7.170845], [50.662997,7.171583]
|
||||||
|
An der Arndtruhe;1;20;[50.691396,7.130801], [50.690391,7.132875]
|
||||||
|
An der Nesselburg;1;116;[50.662505,7.179349], [50.657866,7.186388]
|
||||||
|
Andreasstraße;1;56;[50.683726,7.170729], [50.680022,7.173929]
|
||||||
|
Anhalter Straße;1;26;[50.702510,7.144845], [50.701590,7.146781]
|
||||||
|
Am Dinaswerk;1;6;[50.666698,7.180597], [50.665730,7.181873]
|
||||||
|
Annaberger Straße;1;417;[50.700904,7.113172], [50.689167,7.136330]
|
||||||
|
Annettenstraße;1;29;[50.699057,7.160267], [50.698190,7.162795]
|
||||||
|
Antoniterstraße;1;79;[50.663235,7.179838], [50.662241,7.185383]
|
||||||
|
Arndtplatz;1;8;[50.693236,7.161293], [50.692844,7.161423]
|
||||||
|
Am Arndtplatz;1;22;[50.693239,7.160927], [50.692077,7.162856]
|
||||||
|
Auerhofstraße;1;11;[50.701519,7.164635], [50.700811,7.165738]
|
||||||
|
Auf dem Brand;1;16;[50.681380,7.138504], [50.680581,7.140173]
|
||||||
|
Auf dem Godesberg;1;5;[50.685712,7.149102], [50.684400,7.150505]
|
||||||
|
Auf dem Oelsfeld;1;51;[50.658510,7.181562], [50.656437,7.183726]
|
||||||
|
Auf dem Rotkopf;1;9;[50.680627,7.136629], [50.679817,7.137518]
|
||||||
|
Auf der Ley;1;6;[50.681711,7.139274], [50.681549,7.139380]
|
||||||
|
Auf der Hostert;1;11;[50.697366,7.166741], [50.696415,7.168067]
|
||||||
|
Augustastraße;1;99;[50.691912,7.150117], [50.687340,7.157784]
|
||||||
|
Austraße;1;50;[50.670943,7.184037], [50.669086,7.187869]
|
||||||
|
Axenfeldstraße;1;28;[50.681001,7.137397], [50.678506,7.140800]
|
||||||
|
Bachemer Straße;1;50;[50.657704,7.184185], [50.655947,7.186694]
|
||||||
|
Paul-Kemp-Straße;1;36;[50.687873,7.154346], [50.686488,7.156898]
|
||||||
|
Alte Bahnhofstraße;1;36;[50.685139,7.155331], [50.684207,7.157446]
|
||||||
|
Bahnstraße;1;22;[50.698105,7.138121], [50.697696,7.138778]
|
||||||
|
Beethovenallee;1;125;[50.694623,7.157008], [50.685984,7.161086]
|
||||||
|
Behringstraße;1;48;[50.675406,7.161815], [50.673190,7.165734]
|
||||||
|
Belderbuschstraße;1;24;[50.684049,7.129817], [50.683161,7.133257]
|
||||||
|
Benngasse;1;26;[50.669742,7.163044], [50.669376,7.165069]
|
||||||
|
Burgblick;1;25;[50.685462,7.143280], [50.684086,7.145530]
|
||||||
|
Berliner Ring;1;81;[50.704177,7.143259], [50.702291,7.146840]
|
||||||
|
Bernkasteler Straße;1;67;[50.697887,7.128397], [50.692745,7.136203]
|
||||||
|
Schwarzbirkenweg;1;21;[50.664364,7.146856], [50.661992,7.147669]
|
||||||
|
Birzentalstraße;1;39;[50.667372,7.166057], [50.665674,7.168024]
|
||||||
|
Bismarckallee;1;35;[50.684320,7.164847], [50.681227,7.167903]
|
||||||
|
Fontanestraße;1;14;[50.688238,7.168759], [50.687807,7.169585]
|
||||||
|
Blumenaustraße;1;22;[50.679724,7.174573], [50.678373,7.175785]
|
||||||
|
Bodelschwinghstraße;1;20;[50.696080,7.127038], [50.695288,7.128719]
|
||||||
|
Bodenstaffstraße;1;17;[50.661035,7.192583], [50.660102,7.194536]
|
||||||
|
Bonner Straße;1;139;[50.691029,7.147778], [50.686002,7.153479]
|
||||||
|
Brandenburger Straße;1;26;[50.702929,7.142454], [50.702152,7.143887]
|
||||||
|
Breiter Weg;1;1;[50.654129,7.146257], [50.654129,7.146257]
|
||||||
|
Breslauer Straße;1;39;[50.700102,7.157148], [50.698729,7.158892]
|
||||||
|
Im Äuelchen;1;45;[50.681852,7.148616], [50.681297,7.150453]
|
||||||
|
Brunhildstraße;1;36;[50.669526,7.185691], [50.667111,7.187950]
|
||||||
|
Brunnenallee;1;31;[50.681938,7.149533], [50.680643,7.152101]
|
||||||
|
Hainbuchenweg;1;50;[50.660145,7.145789], [50.659084,7.146659]
|
||||||
|
Am Büchel;1;114;[50.696874,7.165562], [50.689978,7.169559]
|
||||||
|
Bürgerstraße;1;27;[50.686339,7.154671], [50.685131,7.156756]
|
||||||
|
Bürvigstraße;1;54;[50.673607,7.154732], [50.671177,7.157766]
|
||||||
|
Burgstraße;1;160;[50.684249,7.146844], [50.680069,7.151562]
|
||||||
|
Cäsariusstraße;1;26;[50.685365,7.169542], [50.684810,7.171324]
|
||||||
|
Camphausenallee;1;11;[50.686556,7.171964], [50.686055,7.173166]
|
||||||
|
Am Woltersweiher;1;38;[50.694536,7.128083], [50.692815,7.130812]
|
||||||
|
Cheruskerstraße;1;42;[50.701372,7.146049], [50.699958,7.147893]
|
||||||
|
Am Baumgarten;1;9;[50.696634,7.161679], [50.696258,7.162603]
|
||||||
|
Kirchweingarten;1;11;[50.669225,7.160730], [50.668333,7.162006]
|
||||||
|
Danziger Straße;1;38;[50.701192,7.155890], [50.699692,7.157700]
|
||||||
|
Dechant-Heimbach-Straße;1;75;[50.684112,7.143391], [50.678107,7.148960]
|
||||||
|
Deichmanns Aue;1;76;[50.673251,7.179990], [50.670264,7.186083]
|
||||||
|
Denglerstraße;1;82;[50.693110,7.159902], [50.688450,7.167646]
|
||||||
|
Deutschherrenstraße;1;208;[50.676816,7.158706], [50.664825,7.171302]
|
||||||
|
Dietrichstraße;1;121;[50.689619,7.137400], [50.687618,7.144294]
|
||||||
|
Dollendorfer Straße;1;15;[50.696527,7.167135], [50.695286,7.168665]
|
||||||
|
Domhofstraße;1;49;[50.661971,7.185671], [50.659753,7.189382]
|
||||||
|
Im Bachele;1;85;[50.699750,7.120398], [50.695272,7.123219]
|
||||||
|
Drachenfelsstraße;1;86;[50.679454,7.142367], [50.672096,7.150023]
|
||||||
|
Franz-Linz-Straße;1;43;[50.700233,7.122069], [50.699310,7.123615]
|
||||||
|
Dreholzstraße;1;23;[50.663060,7.188516], [50.662386,7.189969]
|
||||||
|
Dreizehnmorgenweg;1;54;[50.704528,7.131101], [50.700887,7.135477]
|
||||||
|
Dromersheimer Straße;1;23;[50.695724,7.133493], [50.695099,7.135564]
|
||||||
|
Pirolweg;1;10;[50.652099,7.191906], [50.651563,7.192930]
|
||||||
|
Dürenstraße;1;64;[50.686604,7.158785], [50.685333,7.164450]
|
||||||
|
Schlehenweg;1;96;[50.668648,7.147594], [50.666191,7.151823]
|
||||||
|
Elfstraße;1;41;[50.670303,7.154618], [50.669076,7.159190]
|
||||||
|
Elisabethstraße;1;25;[50.681709,7.148625], [50.676397,7.151726]
|
||||||
|
Ellesdorfer Straße;1;56;[50.665602,7.174708], [50.662431,7.179518]
|
||||||
|
Elliger Höhe;1;37;[50.670579,7.153229], [50.667063,7.154525]
|
||||||
|
Welfenstraße;1;18;[50.691000,7.153772], [50.689780,7.155050]
|
||||||
|
Elsässer Straße;1;41;[50.691271,7.144904], [50.689593,7.147585]
|
||||||
|
Elsternweg;1;10;[50.653253,7.189346], [50.652371,7.190900]
|
||||||
|
Eltviller Straße;1;22;[50.697996,7.134499], [50.696367,7.136845]
|
||||||
|
An der Kommende;1;24;[50.671916,7.160945], [50.671113,7.163579]
|
||||||
|
Professor-Dennert-Straße;1;8;[50.684050,7.161240], [50.683743,7.161721]
|
||||||
|
Erftstraße;1;12;[50.701721,7.151835], [50.701310,7.152679]
|
||||||
|
Eschenweg;1;37;[50.664055,7.147604], [50.662395,7.148692]
|
||||||
|
Europastraße;1;32;[50.707374,7.153682], [50.703529,7.156079]
|
||||||
|
Fährstraße;1;26;[50.667372,7.187987], [50.665253,7.190731]
|
||||||
|
Fasanenstraße;1;37;[50.678415,7.177253], [50.675335,7.182311]
|
||||||
|
Fichtestraße;1;47;[50.660895,7.161039], [50.660147,7.162794]
|
||||||
|
Floßweg;1;101;[50.665731,7.172988], [50.663474,7.180813]
|
||||||
|
Frankenstraße;1;15;[50.702228,7.147596], [50.701003,7.148853]
|
||||||
|
Frascatistraße;1;22;[50.673656,7.169221], [50.672273,7.171160]
|
||||||
|
Freier Weg;1;29;[50.680999,7.138032], [50.679020,7.141085]
|
||||||
|
Friedrich-Ebert-Straße;1;83;[50.682349,7.152015], [50.676899,7.160537]
|
||||||
|
Friedrichallee;1;45;[50.686355,7.162350], [50.682769,7.164657]
|
||||||
|
Friesdorfer Straße;1;292;[50.693465,7.132888], [50.685820,7.152608]
|
||||||
|
Friesenstraße;1;33;[50.694649,7.150872], [50.693950,7.153035]
|
||||||
|
Fröbelstraße;1;10;[50.659677,7.191337], [50.659004,7.192316]
|
||||||
|
Fuderbachsweg;1;5;[50.662601,7.133331], [50.662601,7.133331]
|
||||||
|
Fürstenbergstraße;1;20;[50.669278,7.163455], [50.668457,7.165099]
|
||||||
|
Galileistraße;1;236;[50.675652,7.170143], [50.670606,7.178425]
|
||||||
|
Am Noßbacher Weg;1;19;[50.659093,7.169179], [50.658371,7.170562]
|
||||||
|
Gerhard-Rohlfs-Straße;1;30;[50.684678,7.160965], [50.683833,7.162887]
|
||||||
|
Germanenstraße;1;76;[50.694970,7.145697], [50.693285,7.153898]
|
||||||
|
Gernotstraße;1;22;[50.664825,7.190388], [50.663975,7.191902]
|
||||||
|
Giselherstraße;1;49;[50.656922,7.190984], [50.655027,7.193398]
|
||||||
|
Gneisenaustraße;1;16;[50.692314,7.155733], [50.691559,7.156885]
|
||||||
|
Godesberger Straße;1;80;[50.695795,7.139342], [50.691297,7.147345]
|
||||||
|
Hensstraße;1;20;[50.688352,7.159845], [50.687399,7.161644]
|
||||||
|
Görresstraße;1;30;[50.658112,7.187634], [50.657176,7.190543]
|
||||||
|
Herderstraße;1;65;[50.692504,7.161910], [50.689024,7.165909]
|
||||||
|
Goldbergweg;1;30;[50.669801,7.152473], [50.668493,7.153218]
|
||||||
|
Gotenstraße;1;164;[50.698248,7.142829], [50.695180,7.161115]
|
||||||
|
Am Klufterhof;1;20;[50.693698,7.130280], [50.692284,7.131925]
|
||||||
|
Schwalbengarten;1;81;[50.700459,7.122224], [50.698171,7.125666]
|
||||||
|
Kardinal-Galen-Weg;1;12;[50.694269,7.127868], [50.693734,7.128788]
|
||||||
|
Gringsstraße;1;48;[50.674319,7.159674], [50.672274,7.161084]
|
||||||
|
Grubenstraße;1;82;[50.662998,7.165395], [50.657997,7.170302]
|
||||||
|
Grüner Weg;1;46;[50.699225,7.132315], [50.696450,7.134963]
|
||||||
|
Gunterstraße;1;16;[50.658305,7.195644], [50.657184,7.198015]
|
||||||
|
Gutenbergallee;1;24;[50.680322,7.173119], [50.679760,7.175515]
|
||||||
|
Martin-Luther-Allee;1;42;[50.699000,7.136912], [50.699000,7.136912]
|
||||||
|
Habsburgerstraße;1;16;[50.688179,7.161286], [50.687733,7.162701]
|
||||||
|
Hagenstraße;1;25;[50.656953,7.189730], [50.656166,7.193768]
|
||||||
|
Hans-Böckler-Allee;1;17;[50.678296,7.162790], [50.676384,7.166213]
|
||||||
|
Hardtstraße;1;16;[50.700806,7.164925], [50.700108,7.166550]
|
||||||
|
Haselnußweg;1;5;[50.666198,7.154224], [50.666124,7.155008]
|
||||||
|
Muffendorfer Hauptstraße;1;89;[50.673997,7.157873], [50.669444,7.162502]
|
||||||
|
Offenbachstraße;1;66;[50.683320,7.167549], [50.679592,7.169826]
|
||||||
|
Konstantinstraße;1;155;[50.684096,7.168996], [50.671480,7.179652]
|
||||||
|
Hegelstraße;1;38;[50.663096,7.161918], [50.661271,7.163157]
|
||||||
|
Heiderhofring;1;20;[50.666084,7.151188], [50.666039,7.151593]
|
||||||
|
Heinrich-Hertz-Straße;1;24;[50.676677,7.168157], [50.675804,7.169094]
|
||||||
|
Levyweg;1;5;[50.655651,7.190152], [50.655481,7.190915]
|
||||||
|
Heinrichstraße;1;15;[50.658113,7.187179], [50.657691,7.188820]
|
||||||
|
Heisterbachstraße;1;40;[50.685246,7.170023], [50.684443,7.173826]
|
||||||
|
Hermann-Löns-Straße;1;22;[50.664847,7.167080], [50.663548,7.168535]
|
||||||
|
Hochkreuzallee;1;246;[50.697054,7.129406], [50.690467,7.140533]
|
||||||
|
Hofstraße;1;9;[50.699001,7.166147], [50.698659,7.167537]
|
||||||
|
Hohenzollernplatz;1;7;[50.690605,7.155283], [50.690443,7.155652]
|
||||||
|
Hohenzollernstraße;1;89;[50.693968,7.150474], [50.689546,7.158894]
|
||||||
|
Heinrich-von-Stephan-Straße;1;9;[50.707884,7.138510], [50.705380,7.142311]
|
||||||
|
Hohle Gasse;1;106;[50.668936,7.153717], [50.666385,7.161133]
|
||||||
|
Holbeinstraße;1;17;[50.702030,7.138033], [50.700912,7.140016]
|
||||||
|
Honnefer Straße;1;48;[50.664156,7.178028], [50.663299,7.183768]
|
||||||
|
Hopmannstraße;1;30;[50.674575,7.153861], [50.672261,7.158143]
|
||||||
|
Horionstraße;1;60;[50.685029,7.139442], [50.682934,7.144316]
|
||||||
|
Hoverstraße;1;35;[50.663340,7.169973], [50.662753,7.172312]
|
||||||
|
Fliederstraße;1;22;[50.662683,7.170781], [50.662212,7.172386]
|
||||||
|
Im Apfelgarten;1;40;[50.668732,7.164767], [50.667146,7.166884]
|
||||||
|
Im Bachfeld;1;46;[50.662293,7.181844], [50.661055,7.184540]
|
||||||
|
Wiedstraße;1;6;[50.681161,7.143886], [50.680844,7.144355]
|
||||||
|
Im Erlengrund;1;48;[50.691807,7.131397], [50.689444,7.135187]
|
||||||
|
Im Etzental;1;25;[50.677734,7.154409], [50.675314,7.156535]
|
||||||
|
Im Frankenkeller;1;51;[50.657978,7.198343], [50.653757,7.202752]
|
||||||
|
Im Gries;1;50;[50.665449,7.178880], [50.663075,7.185941]
|
||||||
|
Im Hag;1;24;[50.654788,7.188672], [50.652325,7.190688]
|
||||||
|
Im Hohn;1;31;[50.678076,7.137455], [50.675739,7.140284]
|
||||||
|
Im Meisengarten;1;136;[50.674708,7.178838], [50.669252,7.183830]
|
||||||
|
Im Pfirsichgarten;1;33;[50.668212,7.164285], [50.666692,7.166050]
|
||||||
|
Im Rosenberg;1;16;[50.650289,7.195798], [50.648566,7.198365]
|
||||||
|
Im Vogelsang;1;40;[50.657202,7.196705], [50.653846,7.199105]
|
||||||
|
Im Weingarten;1;17;[50.695227,7.131551], [50.694702,7.132219]
|
||||||
|
Im Wiesengrund;1;40;[50.698286,7.118515], [50.696744,7.121377]
|
||||||
|
Im Wiesfeld;1;23;[50.666043,7.176788], [50.665282,7.177921]
|
||||||
|
In der Kumme;1;138;[50.695673,7.124210], [50.691753,7.130832]
|
||||||
|
In der Maar;1;44;[50.695527,7.126796], [50.694009,7.129440]
|
||||||
|
Magnolienweg;1;24;[50.665305,7.148345], [50.664426,7.149377]
|
||||||
|
Ittenbacher Straße;1;17;[50.666247,7.177485], [50.665700,7.178235]
|
||||||
|
Jägerweg;1;33;[50.680220,7.142383], [50.678281,7.143995]
|
||||||
|
Jahnallee;1;61;[50.692810,7.150587], [50.689964,7.156671]
|
||||||
|
Am Lindenbach;1;23;[50.662824,7.170551], [50.661918,7.171153]
|
||||||
|
Joseph-Roth-Straße;1;142;[50.698808,7.131575], [50.695544,7.133389]
|
||||||
|
Junkerstraße;1;21;[50.682627,7.149933], [50.681912,7.150829]
|
||||||
|
Am Kurpark;1;8;[50.683359,7.152444], [50.681737,7.155516]
|
||||||
|
Kanalstraße;1;27;[50.701790,7.161816], [50.700666,7.163275]
|
||||||
|
Kantstraße;1;30;[50.663127,7.159708], [50.662251,7.161063]
|
||||||
|
Kapellenweg;1;59;[50.682237,7.170493], [50.677532,7.173679]
|
||||||
|
Karl-Finkelnburg-Straße;1;53;[50.684260,7.163298], [50.681979,7.168962]
|
||||||
|
Kastanienweg;1;87;[50.661528,7.149756], [50.658643,7.151941]
|
||||||
|
Kennedyallee;1;150;[50.704094,7.142745], [50.697229,7.161227]
|
||||||
|
Keplerstraße;1;20;[50.669209,7.166902], [50.668095,7.168762]
|
||||||
|
Am Güsgensberg;1;31;[50.694687,7.122419], [50.693753,7.125478]
|
||||||
|
Kelzenbergstraße;1;34;[50.696555,7.125548], [50.695185,7.127474]
|
||||||
|
Kirchberg;1;65;[50.664485,7.167291], [50.660529,7.170881]
|
||||||
|
Frankengraben;1;80;[50.700510,7.123617], [50.697951,7.127076]
|
||||||
|
Embavenhof;1;1;[50.682061,7.149671], [50.682061,7.149671]
|
||||||
|
Klosterbergstraße;1;119;[50.671515,7.152206], [50.669764,7.160745]
|
||||||
|
Klufterbachtal;1;6;[50.689526,7.128025], [50.687894,7.128053]
|
||||||
|
Klufterstraße;1;113;[50.697388,7.127145], [50.693686,7.132791]
|
||||||
|
Koblenzer Straße;1;201;[50.685924,7.153315], [50.675951,7.171536]
|
||||||
|
Godesberger Allee;1;185;[50.704590,7.132992], [50.691927,7.147903]
|
||||||
|
Donatusstraße;1;111;[50.702653,7.154097], [50.697315,7.160354]
|
||||||
|
Königsplatz;1;27;[50.687120,7.158198], [50.685176,7.160446]
|
||||||
|
Drachenburgstraße;1;87;[50.668348,7.171283], [50.664534,7.181898]
|
||||||
|
Körnerstraße;1;31;[50.695151,7.157319], [50.692450,7.160396]
|
||||||
|
Kolberger Straße;1;58;[50.702118,7.158234], [50.700502,7.160589]
|
||||||
|
Kollgasse;1;5;[50.662165,7.192270], [50.661517,7.194230]
|
||||||
|
Kolumbusring;1;21;[50.706206,7.152593], [50.703414,7.154664]
|
||||||
|
Komtureistraße;1;33;[50.669387,7.155037], [50.667898,7.156013]
|
||||||
|
Kopernikusstraße;1;31;[50.674444,7.170748], [50.673619,7.172946]
|
||||||
|
Kottenstraße;1;36;[50.665148,7.172649], [50.663340,7.174828]
|
||||||
|
Kraterstraße;1;19;[50.654271,7.187987], [50.652369,7.189972]
|
||||||
|
Am Gäßchen;1;46;[50.672574,7.156137], [50.671231,7.159019]
|
||||||
|
Kriemhildstraße;1;18;[50.662874,7.191999], [50.661746,7.193240]
|
||||||
|
Kronprinzenstraße;1;86;[50.690946,7.160538], [50.684987,7.166948]
|
||||||
|
Kunigundenstraße;1;42;[50.659547,7.185594], [50.658401,7.186876]
|
||||||
|
Kurfürstenallee;1;78;[50.681577,7.153153], [50.676461,7.158123]
|
||||||
|
Lahnstraße;1;59;[50.699366,7.152944], [50.698222,7.155948]
|
||||||
|
Langenbergsweg;1;109;[50.662148,7.180190], [50.656626,7.185358]
|
||||||
|
Langer Grabenweg;1;68;[50.703662,7.140759], [50.699204,7.146299]
|
||||||
|
Lannesdorfer Straße;1;44;[50.664313,7.171057], [50.662158,7.173121]
|
||||||
|
Lehnpütz;1;41;[50.667904,7.155856], [50.667047,7.158163]
|
||||||
|
Leibnizstraße;1;94;[50.663758,7.157438], [50.662007,7.159312]
|
||||||
|
Wielandstraße;1;23;[50.687301,7.166934], [50.685622,7.167844]
|
||||||
|
Ließemer Straße;1;74;[50.662070,7.168400], [50.658781,7.172789]
|
||||||
|
Lindenallee;1;15;[50.684693,7.163424], [50.683798,7.166235]
|
||||||
|
Lindstraße;1;44;[50.665383,7.167738], [50.664084,7.170216]
|
||||||
|
Am Draitschbusch;1;28;[50.678940,7.145388], [50.677442,7.147273]
|
||||||
|
Lohrbergstraße;1;20;[50.673976,7.143442], [50.672214,7.144344]
|
||||||
|
Lützowstraße;1;16;[50.692503,7.150993], [50.691706,7.152221]
|
||||||
|
Basteistraße;1;94;[50.689381,7.168362], [50.684175,7.173282]
|
||||||
|
Lucas-Cranach-Straße;1;30;[50.701665,7.144488], [50.700826,7.146431]
|
||||||
|
Lyngsbergstraße;1;118;[50.669112,7.162367], [50.663588,7.169847]
|
||||||
|
Maidenheadstraße;1;27;[50.672476,7.169924], [50.671001,7.172258]
|
||||||
|
Mainzer Straße;1;350;[50.671987,7.178413], [50.649554,7.200103]
|
||||||
|
Margaretenstraße;1;89;[50.698097,7.122689], [50.696050,7.126333]
|
||||||
|
Kreisauer Straße;1;18;[50.700933,7.158842], [50.699934,7.161058]
|
||||||
|
Marienforster Promenade;1;1;[50.677724,7.144790], [50.677254,7.144813]
|
||||||
|
Marienforster Steinweg;1;83;[50.671914,7.139079], [50.670652,7.146655]
|
||||||
|
Marienforster Straße;1;52;[50.679792,7.136092], [50.672001,7.146703]
|
||||||
|
Schwertberger Straße;1;19;[50.682866,7.150396], [50.682102,7.151709]
|
||||||
|
Martinstraße;1;80;[50.670016,7.156184], [50.667952,7.162039]
|
||||||
|
Martin-Luther-King-Straße;1;40;[50.711002,7.147657], [50.703268,7.161750]
|
||||||
|
Matthias-Grünewald-Straße;1;27;[50.699808,7.142047], [50.698396,7.145147]
|
||||||
|
Max-Franz-Straße;1;25;[50.681288,7.147727], [50.680680,7.149170]
|
||||||
|
Max-Löbner-Straße;1;34;[50.702899,7.137653], [50.701783,7.140064]
|
||||||
|
Max-Planck-Straße;1;137;[50.674373,7.167218], [50.666898,7.173072]
|
||||||
|
Meckenheimer Straße;1;137;[50.660775,7.184390], [50.652172,7.191831]
|
||||||
|
Mecklenburger Straße;1;12;[50.703093,7.146806], [50.702107,7.147830]
|
||||||
|
Meersburgstraße;1;17;[50.698173,7.160661], [50.697324,7.162109]
|
||||||
|
Mehlemer Straße;1;58;[50.663954,7.172996], [50.662021,7.176514]
|
||||||
|
Michaelplatz;1;5;[50.684529,7.151980], [50.684133,7.152231]
|
||||||
|
Am Michaelshof;1;10;[50.684010,7.152327], [50.682802,7.153861]
|
||||||
|
Mirbachstraße;1;24;[50.687733,7.165309], [50.686653,7.167860]
|
||||||
|
Mittelstraße;1;94;[50.702086,7.153048], [50.695606,7.161353]
|
||||||
|
Mohrenstraße;1;10;[50.696194,7.167076], [50.695813,7.167803]
|
||||||
|
Moltkeplatz;1;4;[50.685703,7.155008], [50.685447,7.155399]
|
||||||
|
Moltkestraße;1;95;[50.686727,7.153573], [50.681872,7.161862]
|
||||||
|
Moselstraße;1;21;[50.701458,7.151411], [50.700011,7.153394]
|
||||||
|
Telemannstraße;1;35;[50.682236,7.165102], [50.680665,7.168524]
|
||||||
|
Mühlenpfad;1;20;[50.659872,7.186626], [50.659378,7.187043]
|
||||||
|
Mühlenstraße;1;47;[50.696250,7.164193], [50.694799,7.166761]
|
||||||
|
Muffendorfer Straße;1;32;[50.676630,7.154994], [50.674711,7.158644]
|
||||||
|
Nachtigallenstraße;1;24;[50.677596,7.175937], [50.675725,7.177745]
|
||||||
|
Nahestraße;1;15;[50.699897,7.154373], [50.699157,7.155317]
|
||||||
|
Neckarstraße;1;86;[50.698534,7.155302], [50.696661,7.158078]
|
||||||
|
Neuer Weg;1;16;[50.663347,7.175179], [50.662700,7.175666]
|
||||||
|
Nibelungenstraße;1;33;[50.660844,7.196489], [50.658209,7.198533]
|
||||||
|
Niersteiner Straße;1;13;[50.697508,7.131008], [50.696991,7.133011]
|
||||||
|
Nietzschestraße;1;67;[50.662361,7.155161], [50.660182,7.158899]
|
||||||
|
Nikolaus-Becker-Straße;1;10;[50.680509,7.147282], [50.680081,7.147838]
|
||||||
|
Laufenbergstraße;1;40;[50.688849,7.148588], [50.688070,7.150308]
|
||||||
|
Oberaustraße;1;149;[50.658648,7.188140], [50.650501,7.198181]
|
||||||
|
Oberstraße;1;13;[50.661799,7.170293], [50.661357,7.171526]
|
||||||
|
Ölbergstraße;1;9;[50.673707,7.142533], [50.672801,7.142900]
|
||||||
|
Oststraße;1;18;[50.685842,7.154045], [50.685507,7.154843]
|
||||||
|
Otto-Kühne-Platz;1;12;[50.689010,7.166445], [50.687982,7.168541]
|
||||||
|
Pappelweg;1;152;[50.661078,7.146163], [50.656820,7.154855]
|
||||||
|
Paracelsusstraße;1;120;[50.670020,7.166140], [50.666152,7.173437]
|
||||||
|
Parkweg;1;7;[50.660405,7.193767], [50.660164,7.194267]
|
||||||
|
Pecher Straße;1;25;[50.661860,7.123511], [50.657011,7.125128]
|
||||||
|
Pennefeldsweg;1;15;[50.671504,7.173677], [50.670229,7.176776]
|
||||||
|
Petersbergstraße;1;123;[50.679139,7.144320], [50.672212,7.150364]
|
||||||
|
Peter-Schwingen-Straße;1;49;[50.673714,7.153155], [50.671734,7.155656]
|
||||||
|
Pfarrer-Merck-Straße;1;22;[50.690643,7.130663], [50.689967,7.132787]
|
||||||
|
Pionierstraße;1;36;[50.690080,7.140118], [50.688092,7.141797]
|
||||||
|
Philosophenring;1;124;[50.663541,7.156189], [50.660406,7.161824]
|
||||||
|
Plittersdorfer Straße;1;236;[50.697865,7.153203], [50.686738,7.166654]
|
||||||
|
Löbestraße;1;5;[50.683824,7.157408], [50.683561,7.158103]
|
||||||
|
Prinzenstraße;1;217;[50.700647,7.126796], [50.699168,7.131466]
|
||||||
|
Promenadenweg;1;148;[50.690344,7.134851], [50.686607,7.145451]
|
||||||
|
Pützfelder Weg;1;26;[50.665115,7.165661], [50.663767,7.167161]
|
||||||
|
Am Schaumburger Hof;1;12;[50.698346,7.166822], [50.697599,7.167813]
|
||||||
|
Quellenstraße;1;53;[50.680981,7.141405], [50.679928,7.146384]
|
||||||
|
Mandelbaumweg;1;5;[50.664682,7.156039], [50.664473,7.156140]
|
||||||
|
Rheinallee;1;78;[50.690941,7.157812], [50.685345,7.170616]
|
||||||
|
Mathonetstraße;1;12;[50.689107,7.137875], [50.688644,7.139185]
|
||||||
|
Rheinstraße;1;96;[50.684436,7.169591], [50.679500,7.179771]
|
||||||
|
Rhodosstraße;1;27;[50.670665,7.168777], [50.669492,7.169667]
|
||||||
|
Rhöndorfer Straße;1;25;[50.665901,7.175864], [50.665221,7.177050]
|
||||||
|
Riemenschneiderstraße;1;11;[50.702447,7.139303], [50.701396,7.140911]
|
||||||
|
Lortzingstraße;1;9;[50.681333,7.169412], [50.680794,7.170813]
|
||||||
|
Am Bismarckturm;1;17;[50.675884,7.152947], [50.675202,7.154329]
|
||||||
|
Albertus-Magnus-Straße;1;67;[50.675920,7.163934], [50.671894,7.169670]
|
||||||
|
Rodderbergstraße;1;126;[50.657320,7.187173], [50.649558,7.197632]
|
||||||
|
Römerplatz;1;10;[50.684733,7.168821], [50.684184,7.169590]
|
||||||
|
Robert-Schuman-Platz;1;3;[50.706360,7.138647], [50.705479,7.139182]
|
||||||
|
Röntgenstraße;1;31;[50.678328,7.159728], [50.674664,7.161926]
|
||||||
|
Rolandstraße;1;70;[50.683798,7.172133], [50.678669,7.177614]
|
||||||
|
Rolandswerther Straße;1;148;[50.659637,7.189714], [50.649010,7.199501]
|
||||||
|
Roonstraße;1;50;[50.691342,7.149257], [50.688513,7.153417]
|
||||||
|
Rotdornweg;1;87;[50.664571,7.147945], [50.661940,7.150137]
|
||||||
|
Rubensstraße;1;35;[50.702393,7.143183], [50.701434,7.144968]
|
||||||
|
Rüdesheimer Straße;1;64;[50.699394,7.133284], [50.695890,7.137990]
|
||||||
|
Rüdigerstraße;1;147;[50.669812,7.186944], [50.661137,7.196510]
|
||||||
|
Rüngsdorfer Straße;1;59;[50.685128,7.159749], [50.684283,7.168565]
|
||||||
|
Saarstraße;1;18;[50.696985,7.156718], [50.695997,7.158973]
|
||||||
|
Sachsenstraße;1;13;[50.704854,7.143576], [50.704081,7.145157]
|
||||||
|
Saint-Cloud-Straße;1;33;[50.672582,7.165980], [50.670993,7.168439]
|
||||||
|
Scharnhorststraße;1;9;[50.689798,7.151823], [50.689158,7.152886]
|
||||||
|
Schenkendorfstraße;1;14;[50.694406,7.156880], [50.693676,7.157812]
|
||||||
|
Jean-Paul-Straße;1;12;[50.688174,7.165305], [50.687481,7.166190]
|
||||||
|
Schloßallee;1;19;[50.664275,7.191226], [50.662812,7.193676]
|
||||||
|
Schopenhauerstraße;1;21;[50.661275,7.159172], [50.660525,7.159786]
|
||||||
|
Mendelssohnstraße;1;36;[50.678808,7.171392], [50.677294,7.174230]
|
||||||
|
Schützengraben;1;11;[50.660175,7.191176], [50.659859,7.192321]
|
||||||
|
Schulplatz;1;7;[50.696466,7.123994], [50.696308,7.124284]
|
||||||
|
Schultheißgasse;1;6;[50.684752,7.153464], [50.684628,7.153941]
|
||||||
|
Clara-Wieck-Straße;1;17;[50.677038,7.173225], [50.675735,7.174242]
|
||||||
|
Schwannstraße;1;17;[50.683228,7.171616], [50.682921,7.172318]
|
||||||
|
Sebastianusweg;1;32;[50.682356,7.139347], [50.681474,7.141090]
|
||||||
|
Sedanstraße;1;26;[50.686297,7.167160], [50.685233,7.170812]
|
||||||
|
Steglitzer Straße;1;18;[50.676091,7.162570], [50.675118,7.164566]
|
||||||
|
Servatiusstraße;1;138;[50.701878,7.124125], [50.698419,7.128286]
|
||||||
|
Severinsweg;1;12;[50.664283,7.187084], [50.663014,7.188715]
|
||||||
|
Sibyllenstraße;1;79;[50.699641,7.161118], [50.696622,7.163996]
|
||||||
|
Seufertstraße;1;81;[50.681834,7.163326], [50.675922,7.172497]
|
||||||
|
Siegfriedstraße;1;28;[50.662294,7.192685], [50.661028,7.195762]
|
||||||
|
Siegstraße;1;12;[50.700867,7.153019], [50.700390,7.153899]
|
||||||
|
Simrockallee;1;35;[50.694432,7.163361], [50.693191,7.167810]
|
||||||
|
Sommerbergweg;1;38;[50.658698,7.155723], [50.658380,7.161620]
|
||||||
|
Sonnenhag;1;10;[50.650783,7.195103], [50.650315,7.195722]
|
||||||
|
Sonnenscheinstraße;1;18;[50.695628,7.126412], [50.694792,7.127543]
|
||||||
|
Spechtweg;1;4;[50.651216,7.194353], [50.651064,7.194461]
|
||||||
|
Spichernstraße;1;11;[50.688835,7.139497], [50.688146,7.139791]
|
||||||
|
Spiegelhofstraße;1;23;[50.695338,7.163760], [50.694703,7.165227]
|
||||||
|
Splickgasse;1;33;[50.666337,7.167252], [50.665651,7.169146]
|
||||||
|
Rude-Krüzche-Weg;1;2;[50.654062,7.185967], [50.654062,7.185967]
|
||||||
|
Spatzenweg;1;4;[50.651652,7.193420], [50.651490,7.193868]
|
||||||
|
Sankt-Augustinus-Straße;1;88;[50.691653,7.144488], [50.688455,7.148899]
|
||||||
|
Steingasse;1;16;[50.669015,7.156949], [50.668336,7.157872]
|
||||||
|
Steinstraße;1;62;[50.701413,7.160972], [50.697168,7.165072]
|
||||||
|
Redoutenweg;1;8;[50.681624,7.151632], [50.681429,7.152007]
|
||||||
|
Stephan-Lochner-Straße;1;3;[50.698305,7.141879], [50.698029,7.142816]
|
||||||
|
Am Nippenkreuz;1;30;[50.667377,7.184461], [50.666403,7.185567]
|
||||||
|
Ostseestraße;1;21;[50.702067,7.154363], [50.700688,7.155910]
|
||||||
|
Steubenring;1;19;[50.706239,7.156502], [50.703624,7.158616]
|
||||||
|
Ludwig-Erhard-Allee;1;20;[50.710807,7.140817], [50.703985,7.150683]
|
||||||
|
Stirzenhofstraße;1;28;[50.695461,7.162776], [50.694026,7.164190]
|
||||||
|
Heinemannstraße;1;38;[50.706503,7.136175], [50.702138,7.143736]
|
||||||
|
Stümpchensweg;1;8;[50.683761,7.138849], [50.683761,7.138849]
|
||||||
|
Suebenstraße;1;6;[50.695226,7.144486], [50.694589,7.144881]
|
||||||
|
Südstraße;1;140;[50.695184,7.136995], [50.692345,7.143285]
|
||||||
|
Talstraße;1;18;[50.674664,7.156277], [50.673753,7.157444]
|
||||||
|
Tannenallee;1;19;[50.675247,7.177286], [50.674673,7.179439]
|
||||||
|
Teutonenstraße;1;90;[50.696243,7.143967], [50.692299,7.149354]
|
||||||
|
Theaterplatz;1;30;[50.684248,7.152572], [50.682952,7.154558]
|
||||||
|
Yalovastraße;1;10;[50.681148,7.159962], [50.680588,7.160682]
|
||||||
|
Theodor-Heuss-Straße;1;26;[50.680889,7.158361], [50.676938,7.161464]
|
||||||
|
Thüringer Straße;1;22;[50.704096,7.142004], [50.703070,7.143448]
|
||||||
|
Truchseßstraße;1;103;[50.689909,7.140195], [50.686629,7.147464]
|
||||||
|
Tulpenbaumweg;1;42;[50.663138,7.152398], [50.660596,7.154639]
|
||||||
|
Turmstraße;1;51;[50.702430,7.160982], [50.697871,7.167155]
|
||||||
|
Ubierstraße;1;169;[50.695304,7.161618], [50.684889,7.169456]
|
||||||
|
Ürziger Straße;1;26;[50.696829,7.131261], [50.695429,7.136592]
|
||||||
|
Uhlandstraße;1;48;[50.691817,7.161042], [50.688662,7.165108]
|
||||||
|
Utestraße;1;57;[50.668052,7.187444], [50.663661,7.191585]
|
||||||
|
Venner Kirchweg;1;2;[50.672815,7.134497], [50.672815,7.134497]
|
||||||
|
Venner Straße;1;55;[50.682922,7.131870], [50.679312,7.141846]
|
||||||
|
Vikariegasse;1;13;[50.699547,7.163736], [50.699209,7.164698]
|
||||||
|
Viktoriaplatz;1;5;[50.693302,7.155689], [50.692896,7.156179]
|
||||||
|
Viktoriastraße;1;71;[50.695332,7.153443], [50.691041,7.159923]
|
||||||
|
Viktor-Schnitzler-Straße;1;30;[50.659733,7.194108], [50.658908,7.196915]
|
||||||
|
Hubert-Peter-Straße;1;44;[50.701031,7.129817], [50.699507,7.132014]
|
||||||
|
Villichgasse;1;20;[50.685398,7.152729], [50.683755,7.154192]
|
||||||
|
Volkerstraße;1;16;[50.669406,7.185139], [50.668524,7.186137]
|
||||||
|
Von-der-Heydt-Straße;1;9;[50.680340,7.158878], [50.679581,7.159900]
|
||||||
|
Von-Groote-Platz;1;25;[50.684761,7.159519], [50.682619,7.162043]
|
||||||
|
Von-Sandt-Ufer;1;1;[50.691098,7.171213], [50.690621,7.171375]
|
||||||
|
Vulkanstraße;1;83;[50.655040,7.185322], [50.651828,7.188387]
|
||||||
|
Waasemstraße;1;15;[50.674983,7.157145], [50.673824,7.157941]
|
||||||
|
Waldburgstraße;1;64;[50.683431,7.140730], [50.681063,7.144528]
|
||||||
|
Waldstraße;1;124;[50.685467,7.126947], [50.682117,7.137374]
|
||||||
|
Walramstraße;1;11;[50.697799,7.139166], [50.697518,7.139879]
|
||||||
|
Leonardusstraße;1;88;[50.700665,7.159598], [50.699156,7.163577]
|
||||||
|
Von-Müllenark-Straße;1;21;[50.658111,7.184997], [50.657555,7.185431]
|
||||||
|
Weinbergstraße;1;15;[50.667997,7.160351], [50.667271,7.162087]
|
||||||
|
Weißdornweg;1;139;[50.665868,7.149583], [50.661918,7.152334]
|
||||||
|
Weißenburgstraße;1;80;[50.690421,7.143686], [50.687134,7.148619]
|
||||||
|
Wendelstadtallee;1;21;[50.678551,7.174625], [50.677665,7.177042]
|
||||||
|
Weststraße;1;32;[50.692334,7.141625], [50.690685,7.144756]
|
||||||
|
Wichterichstraße;1;39;[50.685757,7.142432], [50.684617,7.144773]
|
||||||
|
Wiedemannstraße;1;75;[50.682328,7.164700], [50.678550,7.169996]
|
||||||
|
Kolfhausstraße;1;18;[50.687809,7.155403], [50.687253,7.156370]
|
||||||
|
Winkelsweg;1;82;[50.701246,7.127720], [50.699210,7.131254]
|
||||||
|
Winterstraße;1;65;[50.684423,7.144872], [50.682934,7.150334]
|
||||||
|
Wittelsbacherstraße;1;16;[50.688994,7.161006], [50.688082,7.161805]
|
||||||
|
Wörthstraße;1;67;[50.688940,7.145141], [50.686733,7.148035]
|
||||||
|
Wolkenburgstraße;1;34;[50.673539,7.145926], [50.671757,7.146406]
|
||||||
|
Wupperstraße;1;15;[50.699781,7.153845], [50.698890,7.154811]
|
||||||
|
Wurzerstraße;1;198;[50.698597,7.148425], [50.691364,7.165616]
|
||||||
|
Yorckstraße;1;12;[50.695312,7.159015], [50.694729,7.159735]
|
||||||
|
Zanderstraße;1;70;[50.679191,7.160484], [50.674416,7.167143]
|
||||||
|
Zeller Straße;1;52;[50.697500,7.128279], [50.695630,7.130972]
|
||||||
|
Zeppelinstraße;1;93;[50.679971,7.161313], [50.675323,7.168396]
|
||||||
|
Zietenstraße;1;57;[50.693778,7.151500], [50.691220,7.155936]
|
||||||
|
Zum Kempenberg;1;8;[50.669396,7.158583], [50.668961,7.159331]
|
||||||
|
Mallwitzstraße;1;71;[50.673881,7.172405], [50.666179,7.176449]
|
||||||
|
Kortrijker Straße;1;1;[50.670767,7.171810], [50.670767,7.171810]
|
||||||
|
Alberichstraße;1;55;[50.654951,7.192784], [50.654018,7.194400]
|
||||||
|
Etzelstraße;1;39;[50.654224,7.193602], [50.653404,7.195054]
|
||||||
|
Hildebrandstraße;1;13;[50.653541,7.194915], [50.652945,7.195554]
|
||||||
|
Ortwinstraße;1;32;[50.652421,7.196156], [50.651560,7.197059]
|
||||||
|
Dankwardstraße;1;14;[50.651765,7.196953], [50.651140,7.197611]
|
||||||
|
Am Weckhasen;1;15;[50.699908,7.126078], [50.699020,7.126652]
|
||||||
|
Pfarrer-Minartz-Straße;1;11;[50.683699,7.150955], [50.683439,7.152264]
|
||||||
|
Roderichstraße;1;24;[50.658759,7.192305], [50.657567,7.193445]
|
||||||
|
Am Südfriedhof;1;35;[50.702611,7.126134], [50.700822,7.127738]
|
||||||
|
Kurt-Georg-Kiesinger-Allee;1;3;[50.706098,7.135237], [50.704747,7.137748]
|
||||||
|
Mildred-Scheel-Straße;1;6;[50.705734,7.144041], [50.705091,7.144815]
|
||||||
|
Ferdinand-Lassalle-Straße;1;50;[50.705026,7.145235], [50.703362,7.148147]
|
||||||
|
Johanna-Kinkel-Straße;1;16;[50.703786,7.147925], [50.702445,7.149006]
|
||||||
|
Andreas-Hermes-Straße;1;9;[50.705353,7.146432], [50.704331,7.148210]
|
||||||
|
Elisabeth-Mayer-Straße;1;18;[50.672873,7.161171], [50.671979,7.162005]
|
||||||
|
An der Kelter;1;17;[50.673330,7.161366], [50.672137,7.162860]
|
||||||
|
August-Bebel-Allee;1;12;[50.701469,7.132978], [50.700769,7.133932]
|
||||||
|
Peter-Hensen-Straße;1;8;[50.703036,7.131119], [50.702324,7.132518]
|
||||||
|
An der Marienkapelle;1;15;[50.683384,7.173807], [50.682528,7.175310]
|
||||||
|
Ludwig-Erhard-Platz;1;3;[50.674488,7.176484], [50.674127,7.176760]
|
||||||
|
Weinrosenweg;1;12;[50.653371,7.185337], [50.652693,7.186215]
|
||||||
|
Am Ziegenbaum;1;28;[50.662630,7.173447], [50.661542,7.175227]
|
||||||
|
Rotweingarten;1;34;[50.661340,7.171484], [50.660012,7.173271]
|
||||||
|
Im Bendel;1;4;[50.691016,7.136310], [50.689958,7.137215]
|
||||||
|
Schweinheimer Weg;1;39;[50.684855,7.139456], [50.683734,7.141280]
|
||||||
|
Robinienweg;1;51;[50.668792,7.148735], [50.667574,7.150335]
|
||||||
|
Hans-Rosenberg-Straße;1;18;[50.698452,7.130815], [50.697823,7.131915]
|
||||||
|
De-Brezé-Straße;1;10;[50.662265,7.191611], [50.661952,7.192148]
|
||||||
|
Merianstraße;1;101;[50.674059,7.171290], [50.671893,7.173123]
|
||||||
|
Meitnerstraße;1;6;[50.673088,7.172302], [50.672885,7.172679]
|
||||||
|
Ria-Maternus-Platz;1;1;[50.683282,7.158779], [50.683282,7.158779]
|
||||||
|
Auf dem Domhof;1;15;[50.660522,7.186871], [50.659950,7.188388]
|
||||||
|
Graf-von-Lehndorff-Straße;1;14;[50.703937,7.146454], [50.703202,7.147721]
|
||||||
|
Paul-Magar-Straße;1;14;[50.704753,7.145023], [50.704063,7.146223]
|
||||||
|
Rheingoldstraße;1;24;[50.655355,7.192768], [50.654718,7.193966]
|
||||||
|
An Brenigs Ziegelei;1;82;[50.692100,7.134419], [50.690745,7.135928]
|
||||||
|
Godesberger Hof;1;14;[50.688716,7.170145], [50.688120,7.171957]
|
||||||
|
Father-Bill-Straße;1;20;[50.702740,7.155897], [50.702422,7.156514]
|
||||||
|
Hannah-Arendt-Straße;1;56;[50.703067,7.156372], [50.701371,7.158043]
|
||||||
|
Prinz-Löwenstein-Straße;1;53;[50.703027,7.157887], [50.701933,7.159692]
|
||||||
|
Friedrich-Bleek-Straße;1;5;[50.660785,7.185309], [50.660438,7.185736]
|
||||||
|
Bachaue;1;7;[50.700759,7.124431], [50.700439,7.124755]
|
||||||
|
Marta-Worringer-Straße;1;13;[50.671495,7.165094], [50.670703,7.166285]
|
||||||
|
Charlotte-von-Stein-Straße;1;19;[50.670771,7.165393], [50.669802,7.167011]
|
||||||
|
Beckers Garten;1;21;[50.685037,7.172467], [50.684160,7.174225]
|
||||||
|
Elisabeth-Selbert-Allee;1;50;[50.695935,7.146047], [50.692875,7.150805]
|
||||||
|
@@ -0,0 +1,554 @@
|
|||||||
|
Ackerstraße
|
||||||
|
Aennchenplatz
|
||||||
|
Aennchenstraße
|
||||||
|
Aggerstraße
|
||||||
|
Ahornweg
|
||||||
|
Ahrstraße
|
||||||
|
Akazienweg
|
||||||
|
Alberichstraße
|
||||||
|
Albert-Cahn-Weg
|
||||||
|
Albertus-Magnus-Straße
|
||||||
|
Alemannenstraße
|
||||||
|
Alte Bahnhofstraße
|
||||||
|
Alter Viehweg
|
||||||
|
Am Arndtplatz
|
||||||
|
Am Baumgarten
|
||||||
|
Am Bismarckturm
|
||||||
|
Am Bommerich
|
||||||
|
Am Botten
|
||||||
|
Am Büchel
|
||||||
|
Am Burgfriedhof
|
||||||
|
Am Buschacker
|
||||||
|
Am Dinaswerk
|
||||||
|
Am Domblick
|
||||||
|
Am Draitschbusch
|
||||||
|
Am Erdbeerfeld
|
||||||
|
Am Finkenherd
|
||||||
|
Am Fronhof
|
||||||
|
Am Gäßchen
|
||||||
|
Am Glückshaus
|
||||||
|
Am Güsgensberg
|
||||||
|
Am Helpert
|
||||||
|
Am Klufterhof
|
||||||
|
Am Kreuter
|
||||||
|
Am Kurpark
|
||||||
|
Am Lenkert
|
||||||
|
Am Lindenbach
|
||||||
|
Am Michaelshof
|
||||||
|
Am Nippenkreuz
|
||||||
|
Am Noßbacher Weg
|
||||||
|
Am Rheinblick
|
||||||
|
Am Rosenrain
|
||||||
|
Am Schaumburger Hof
|
||||||
|
Am Schörnchen
|
||||||
|
Am Schwimmbad
|
||||||
|
Am Stadtwald
|
||||||
|
Am Südfriedhof
|
||||||
|
Am Turmhof
|
||||||
|
Am Weckhasen
|
||||||
|
Am Winkel
|
||||||
|
Am Woltersweiher
|
||||||
|
Am Ziegenbaum
|
||||||
|
Amalienhöhe
|
||||||
|
Amselhang
|
||||||
|
An Brenigs Ziegelei
|
||||||
|
An der Arndtruhe
|
||||||
|
An der Kelter
|
||||||
|
An der Kommende
|
||||||
|
An der Marienkapelle
|
||||||
|
An der Nesselburg
|
||||||
|
Andreas-Hermes-Straße
|
||||||
|
Andreasstraße
|
||||||
|
Anhalter Straße
|
||||||
|
Annaberger Straße
|
||||||
|
Annettenstraße
|
||||||
|
Antoniterstraße
|
||||||
|
Arcadia-Passage
|
||||||
|
Arndtplatz
|
||||||
|
Auerhofstraße
|
||||||
|
Auf dem Brand
|
||||||
|
Auf dem Domhof
|
||||||
|
Auf dem Godesberg
|
||||||
|
Auf dem Oelsfeld
|
||||||
|
Auf dem Rotkopf
|
||||||
|
Auf der Hostert
|
||||||
|
Auf der Ley
|
||||||
|
August-Bebel-Allee
|
||||||
|
Augustastraße
|
||||||
|
Austraße
|
||||||
|
Axenfeldstraße
|
||||||
|
Bachaue
|
||||||
|
Bachemer Straße
|
||||||
|
Bad Godesberger Tunnel
|
||||||
|
Bahnstraße
|
||||||
|
Basteistraße
|
||||||
|
Baumgäßchen
|
||||||
|
Beckers Garten
|
||||||
|
Beethovenallee
|
||||||
|
Behringstraße
|
||||||
|
Belderbuschstraße
|
||||||
|
Bellerbuschallee
|
||||||
|
Benngasse
|
||||||
|
Bergmannspfad
|
||||||
|
Berliner Ring
|
||||||
|
Bernkasteler Straße
|
||||||
|
Birzentalstraße
|
||||||
|
Bismarckallee
|
||||||
|
Blumenaustraße
|
||||||
|
Bodelschwinghstraße
|
||||||
|
Bodenstaffstraße
|
||||||
|
Bonner Straße
|
||||||
|
Brandenburger Straße
|
||||||
|
Breiter Weg
|
||||||
|
Breslauer Straße
|
||||||
|
Brunhildstraße
|
||||||
|
Brunnenallee
|
||||||
|
Buchholzer Weg
|
||||||
|
Burgblick
|
||||||
|
Bürgerstraße
|
||||||
|
Burgstraße
|
||||||
|
Bürvigstraße
|
||||||
|
Cäcilienheidchensweg
|
||||||
|
Camphausenallee
|
||||||
|
Carlo-Schmid-Straße
|
||||||
|
Cäsariusstraße
|
||||||
|
Charlotte-von-Stein-Straße
|
||||||
|
Cheruskerstraße
|
||||||
|
Clara-Wieck-Straße
|
||||||
|
Dankwardstraße
|
||||||
|
Danziger Straße
|
||||||
|
De-Brezé-Straße
|
||||||
|
Dechant-Heimbach-Straße
|
||||||
|
Deichmanns Aue
|
||||||
|
Denglerstraße
|
||||||
|
Deutschherrenstraße
|
||||||
|
Dietrich-Glauner-Straße
|
||||||
|
Dietrichstraße
|
||||||
|
Dollendorfer Straße
|
||||||
|
Domhofstraße
|
||||||
|
Donatusstraße
|
||||||
|
Drachenburgstraße
|
||||||
|
Drachenfelsstraße
|
||||||
|
Dreholzstraße
|
||||||
|
Dreizehnmorgenweg
|
||||||
|
Dromersheimer Straße
|
||||||
|
Dürenstraße
|
||||||
|
Elfstraße
|
||||||
|
Elisabeth-Mayer-Straße
|
||||||
|
Elisabeth-Selbert-Allee
|
||||||
|
Elisabethstraße
|
||||||
|
Ellesdorfer Straße
|
||||||
|
Elliger Höhe
|
||||||
|
Elsässer Straße
|
||||||
|
Elsternweg
|
||||||
|
Eltviller Straße
|
||||||
|
Embavenhof
|
||||||
|
Erftstraße
|
||||||
|
Eschenweg
|
||||||
|
Etzelstraße
|
||||||
|
Europastraße
|
||||||
|
Fächelweg
|
||||||
|
Fährstraße
|
||||||
|
Fasanenstraße
|
||||||
|
Father-Bill-Straße
|
||||||
|
Ferdinand-Lassalle-Straße
|
||||||
|
Fichtestraße
|
||||||
|
Fliederstraße
|
||||||
|
Floßweg
|
||||||
|
Fontanestraße
|
||||||
|
Fourthweg
|
||||||
|
Frankengraben
|
||||||
|
Frankenstraße
|
||||||
|
Franz-Linz-Straße
|
||||||
|
Frascatistraße
|
||||||
|
Freier Weg
|
||||||
|
Friedrich-Bleek-Straße
|
||||||
|
Friedrich-Ebert-Straße
|
||||||
|
Friedrichallee
|
||||||
|
Friesdorfer Straße
|
||||||
|
Friesenstraße
|
||||||
|
Fröbelstraße
|
||||||
|
Fuderbachsweg
|
||||||
|
Fürstenbergstraße
|
||||||
|
Galileistraße
|
||||||
|
Gerd-Höllige-Weg
|
||||||
|
Gerhard-Rohlfs-Straße
|
||||||
|
Germanenstraße
|
||||||
|
Gernotstraße
|
||||||
|
Gimmersdorfer Weg
|
||||||
|
Giselherstraße
|
||||||
|
Gneisenaustraße
|
||||||
|
Godesberger Allee
|
||||||
|
Godesberger Hof
|
||||||
|
Godesberger Straße
|
||||||
|
Goldbergweg
|
||||||
|
Görresstraße
|
||||||
|
Gotenstraße
|
||||||
|
Graf-von-Lehndorff-Straße
|
||||||
|
Gräfgeshülle
|
||||||
|
Gringsstraße
|
||||||
|
Grubenstraße
|
||||||
|
Grüner Weg
|
||||||
|
Gunterstraße
|
||||||
|
Gutenbergallee
|
||||||
|
Habsburgerstraße
|
||||||
|
Hagenstraße
|
||||||
|
Hainbuchenweg
|
||||||
|
Hannah-Arendt-Straße
|
||||||
|
Hans-Böckler-Allee
|
||||||
|
Hans-Rosenberg-Straße
|
||||||
|
Hardtstraße
|
||||||
|
Haselingsweg
|
||||||
|
Haselnußweg
|
||||||
|
Hegelstraße
|
||||||
|
Heiderhofring
|
||||||
|
Heimkehrerweg
|
||||||
|
Heinemannstraße
|
||||||
|
Heinrich-Hertz-Straße
|
||||||
|
Heinrich-von-Stephan-Straße
|
||||||
|
Heinrichstraße
|
||||||
|
Heisterbachstraße
|
||||||
|
Hensstraße
|
||||||
|
Herbert-Wehner-Platz
|
||||||
|
Herderstraße
|
||||||
|
Hermann-Löns-Straße
|
||||||
|
Hildebrandstraße
|
||||||
|
Hochkreuzallee
|
||||||
|
Hofstraße
|
||||||
|
Hohenzollernplatz
|
||||||
|
Hohenzollernstraße
|
||||||
|
Hohle Gasse
|
||||||
|
Holbeinstraße
|
||||||
|
Honnefer Straße
|
||||||
|
Hopmannstraße
|
||||||
|
Horionstraße
|
||||||
|
Hoverstraße
|
||||||
|
Hubert-Peter-Straße
|
||||||
|
Hubertinumshof
|
||||||
|
Hummerichsweg
|
||||||
|
Im Apfelgarten
|
||||||
|
Im Äuelchen
|
||||||
|
Im Bachele
|
||||||
|
Im Bachfeld
|
||||||
|
Im Bendel
|
||||||
|
Im Buchengrund
|
||||||
|
Im Erlengrund
|
||||||
|
Im Etzental
|
||||||
|
Im Frankenkeller
|
||||||
|
Im Gries
|
||||||
|
Im Hag
|
||||||
|
Im Hohn
|
||||||
|
Im Meisengarten
|
||||||
|
Im Pfirsichgarten
|
||||||
|
Im Rosenberg
|
||||||
|
Im Vogelsang
|
||||||
|
Im Weingarten
|
||||||
|
Im Wiesengrund
|
||||||
|
Im Wiesfeld
|
||||||
|
In den Schleiden
|
||||||
|
In der Kumme
|
||||||
|
In der Maar
|
||||||
|
Ittenbacher Straße
|
||||||
|
Jägerweg
|
||||||
|
Jahnallee
|
||||||
|
Jean-Monnet-Straße
|
||||||
|
Jean-Paul-Straße
|
||||||
|
Jenienhülle
|
||||||
|
Johanna-Kinkel-Straße
|
||||||
|
John-J.-McCloy-Ufer
|
||||||
|
Joseph-Roth-Straße
|
||||||
|
Junkerstraße
|
||||||
|
Juppi-Schaefer-Weg
|
||||||
|
Kanalstraße
|
||||||
|
Kantstraße
|
||||||
|
Kapellenweg
|
||||||
|
Kardinal-Galen-Weg
|
||||||
|
Karl-Finkelnburg-Straße
|
||||||
|
Kastanienweg
|
||||||
|
Kelzenbergstraße
|
||||||
|
Kennedyallee
|
||||||
|
Keplerstraße
|
||||||
|
Kessenicher Straße
|
||||||
|
Kirchberg
|
||||||
|
Kirchweingarten
|
||||||
|
Kleinefeldsweg
|
||||||
|
Klosterbergstraße
|
||||||
|
Klufterbachtal
|
||||||
|
Klufterstraße
|
||||||
|
Kluttenweg
|
||||||
|
Koblenzer Straße
|
||||||
|
Kolberger Straße
|
||||||
|
Kolfhausstraße
|
||||||
|
Kollgasse
|
||||||
|
Köln-Düsseldorfer
|
||||||
|
Kolumbusring
|
||||||
|
Komtureistraße
|
||||||
|
Königsplatz
|
||||||
|
Konstantinstraße
|
||||||
|
Kopernikusstraße
|
||||||
|
Körnerstraße
|
||||||
|
Kortrijker Straße
|
||||||
|
Kottenstraße
|
||||||
|
Kraterstraße
|
||||||
|
Kreisauer Straße
|
||||||
|
Kriemhildstraße
|
||||||
|
Kronprinzenstraße
|
||||||
|
Kunigundenstraße
|
||||||
|
Kurfürstenallee
|
||||||
|
Kurt-Georg-Kiesinger-Allee
|
||||||
|
Lahnstraße
|
||||||
|
Langenbergsweg
|
||||||
|
Langer Grabenweg
|
||||||
|
Lannesdorfer Straße
|
||||||
|
Laufenbergstraße
|
||||||
|
Lehnpütz
|
||||||
|
Leibnizstraße
|
||||||
|
Leonardusstraße
|
||||||
|
Levyweg
|
||||||
|
Ließemer Straße
|
||||||
|
Ließemer Weg
|
||||||
|
Lindenallee
|
||||||
|
Lindstraße
|
||||||
|
Löbestraße
|
||||||
|
Lohrbergstraße
|
||||||
|
Lortzingstraße
|
||||||
|
Lucas-Cranach-Straße
|
||||||
|
Ludwig-Erhard-Allee
|
||||||
|
Ludwig-Erhard-Platz
|
||||||
|
Lützowstraße
|
||||||
|
Lyngsbergstraße
|
||||||
|
Magnolienweg
|
||||||
|
Maidenheadstraße
|
||||||
|
Mainzer Straße
|
||||||
|
Mallwitzstraße
|
||||||
|
Mandelbaumweg
|
||||||
|
Margaretenstraße
|
||||||
|
Marie-Schlei-Allee
|
||||||
|
Marienforster Allee
|
||||||
|
Marienforster Kirchweg
|
||||||
|
Marienforster Promenade
|
||||||
|
Marienforster Steinweg
|
||||||
|
Marienforster Straße
|
||||||
|
Marta-Worringer-Straße
|
||||||
|
Martin-Luther-Allee
|
||||||
|
Martin-Luther-King-Straße
|
||||||
|
Martinstraße
|
||||||
|
Mathonetstraße
|
||||||
|
Matthias-Grünewald-Straße
|
||||||
|
Max-Franz-Straße
|
||||||
|
Max-Löbner-Straße
|
||||||
|
Max-Planck-Straße
|
||||||
|
Meckenheimer Straße
|
||||||
|
Mecklenburger Straße
|
||||||
|
Meersburgstraße
|
||||||
|
Mehlemer Dorfplatz
|
||||||
|
Mehlemer Straße
|
||||||
|
Meitnerstraße
|
||||||
|
Mendelssohnstraße
|
||||||
|
Merianstraße
|
||||||
|
Michael-Passage
|
||||||
|
Michaelplatz
|
||||||
|
Milchgäßchen
|
||||||
|
Mildred-Scheel-Straße
|
||||||
|
Mirbachstraße
|
||||||
|
Mittelstraße
|
||||||
|
Mittelweg
|
||||||
|
Mohrenstraße
|
||||||
|
Moltkestraße
|
||||||
|
Moselstraße
|
||||||
|
Muffendorfer Hauptstraße
|
||||||
|
Muffendorfer Straße
|
||||||
|
Mühlenpfad
|
||||||
|
Mühlenstraße
|
||||||
|
Mühlenweg
|
||||||
|
Nachtigallenstraße
|
||||||
|
Nahestraße
|
||||||
|
Nahum-Goldmann-Allee
|
||||||
|
Neckarstraße
|
||||||
|
Neuer Weg
|
||||||
|
Nibelungenstraße
|
||||||
|
Niersteiner Straße
|
||||||
|
Nietzschestraße
|
||||||
|
Nikolaus-Becker-Straße
|
||||||
|
Oberaustraße
|
||||||
|
Oberer Lindweg
|
||||||
|
Oberstraße
|
||||||
|
Offenbachstraße
|
||||||
|
Ölbergstraße
|
||||||
|
Ortwinstraße
|
||||||
|
Ostseestraße
|
||||||
|
Oststraße
|
||||||
|
Otto-Kühne-Platz
|
||||||
|
Panoramaplatz
|
||||||
|
Pappelweg
|
||||||
|
Paracelsusstraße
|
||||||
|
Parkweg
|
||||||
|
Paul-Kemp-Straße
|
||||||
|
Paul-Magar-Straße
|
||||||
|
Paula-Modersohn-Becker-Weg
|
||||||
|
Pecher Straße
|
||||||
|
Pennefeldsweg
|
||||||
|
Peter-Hensen-Straße
|
||||||
|
Peter-Schwingen-Straße
|
||||||
|
Petersbergstraße
|
||||||
|
Petra-Kelly-Allee
|
||||||
|
Pfarrer-Merck-Straße
|
||||||
|
Pfarrer-Minartz-Straße
|
||||||
|
Philosophenring
|
||||||
|
Pionierstraße
|
||||||
|
Pionierweg
|
||||||
|
Pirolweg
|
||||||
|
Plittersdorfer Straße
|
||||||
|
Prinz-Löwenstein-Straße
|
||||||
|
Prinzenstraße
|
||||||
|
Professor-Dennert-Straße
|
||||||
|
Promenadenweg
|
||||||
|
Pürschweg
|
||||||
|
Pützfelder Weg
|
||||||
|
Pützgäßchen
|
||||||
|
Quellenstraße
|
||||||
|
Redoutenweg
|
||||||
|
Remagener Straße
|
||||||
|
Remi-Baert-Platz
|
||||||
|
Rheinallee
|
||||||
|
Rheinaue Hauptzugang
|
||||||
|
Rheinaue Süd
|
||||||
|
Rheingoldstraße
|
||||||
|
Rheinhöhenweg
|
||||||
|
Rheinstraße
|
||||||
|
Rheinufer
|
||||||
|
Rhodosstraße
|
||||||
|
Rhöndorfer Straße
|
||||||
|
Ria-Maternus-Platz
|
||||||
|
Riemenschneiderstraße
|
||||||
|
Robert-Schuman-Platz
|
||||||
|
Robinienweg
|
||||||
|
Rockenmaarspfad
|
||||||
|
Rodderbergstraße
|
||||||
|
Roderichstraße
|
||||||
|
Rolandstraße
|
||||||
|
Rolandswerther Straße
|
||||||
|
Römerplatz
|
||||||
|
Röntgenstraße
|
||||||
|
Roonstraße
|
||||||
|
Rotdornweg
|
||||||
|
Röttgener Weg
|
||||||
|
Rotweingarten
|
||||||
|
Rubensstraße
|
||||||
|
Rude-Krüzche-Weg
|
||||||
|
Rüdesheimer Straße
|
||||||
|
Rüdigerstraße
|
||||||
|
Rüngsdorfer Straße
|
||||||
|
Saarstraße
|
||||||
|
Sachsenstraße
|
||||||
|
Saint-Cloud-Straße
|
||||||
|
Sankt-Augustinus-Straße
|
||||||
|
Scharnhorststraße
|
||||||
|
Scheerenbergweg
|
||||||
|
Schenkendorfstraße
|
||||||
|
Schenkpfädchen
|
||||||
|
Schlangenpfad
|
||||||
|
Schlangenweg
|
||||||
|
Schlehenweg
|
||||||
|
Schloßallee
|
||||||
|
Schmales Alleechen
|
||||||
|
Schopenhauerstraße
|
||||||
|
Schulplatz
|
||||||
|
Schultheißgasse
|
||||||
|
Schützengraben
|
||||||
|
Schwalbengarten
|
||||||
|
Schwannstraße
|
||||||
|
Schwarzbirkenweg
|
||||||
|
Schweinheimer Weg
|
||||||
|
Schwertberger Straße
|
||||||
|
Sebastianusweg
|
||||||
|
Sedanstraße
|
||||||
|
Servatiusstraße
|
||||||
|
Seufertstraße
|
||||||
|
Severinsweg
|
||||||
|
Sibyllenstraße
|
||||||
|
Siegfriedstraße
|
||||||
|
Siegstraße
|
||||||
|
Simrockallee
|
||||||
|
Sommerbergweg
|
||||||
|
Sonnenhag
|
||||||
|
Sonnenscheinstraße
|
||||||
|
Spatzenweg
|
||||||
|
Spechtweg
|
||||||
|
Spichernstraße
|
||||||
|
Spiegelhofstraße
|
||||||
|
Splickgasse
|
||||||
|
Stadthalle
|
||||||
|
Steglitzer Straße
|
||||||
|
Steingasse
|
||||||
|
Steinstraße
|
||||||
|
Stephan-Lochner-Straße
|
||||||
|
Steubenring
|
||||||
|
Stirzenhofstraße
|
||||||
|
Stümpchensweg
|
||||||
|
Südstraße
|
||||||
|
Suebenstraße
|
||||||
|
Talstraße
|
||||||
|
Tannenallee
|
||||||
|
Telemannstraße
|
||||||
|
Teutonenstraße
|
||||||
|
Theaterpassage
|
||||||
|
Theaterplatz
|
||||||
|
Theodor-Heuss-Straße
|
||||||
|
Thüringer Straße
|
||||||
|
Truchseßstraße
|
||||||
|
Tulpenbaumweg
|
||||||
|
Turmstraße
|
||||||
|
Ubierstraße
|
||||||
|
Uhlandstraße
|
||||||
|
Ursula-Lehr-Straße
|
||||||
|
Ürziger Straße
|
||||||
|
Utestraße
|
||||||
|
Venner Kirchweg
|
||||||
|
Venner Straße
|
||||||
|
Vikariegasse
|
||||||
|
Viktor-Schnitzler-Straße
|
||||||
|
Viktoriaplatz
|
||||||
|
Viktoriastraße
|
||||||
|
Villichgasse
|
||||||
|
Vogelskaulerweg
|
||||||
|
Volkerstraße
|
||||||
|
Von-der-Heydt-Straße
|
||||||
|
Von-Groote-Platz
|
||||||
|
Von-Müllenark-Straße
|
||||||
|
Von-Sandt-Ufer
|
||||||
|
Vulkanstraße
|
||||||
|
Waasemstraße
|
||||||
|
Waldburgstraße
|
||||||
|
Waldstraße
|
||||||
|
Waldweg
|
||||||
|
Walramstraße
|
||||||
|
Wattendorfer Allee
|
||||||
|
Weckhasenpfad
|
||||||
|
Weinbergstraße
|
||||||
|
Weingärtenstraße
|
||||||
|
Weinrosenweg
|
||||||
|
Weißdornweg
|
||||||
|
Weiße Hülle
|
||||||
|
Weißenburgstraße
|
||||||
|
Welfenstraße
|
||||||
|
Wendelstadtallee
|
||||||
|
Weststraße
|
||||||
|
Wichterichstraße
|
||||||
|
Wiedemannstraße
|
||||||
|
Wiedstraße
|
||||||
|
Wielandstraße
|
||||||
|
Winkelsweg
|
||||||
|
Winterstraße
|
||||||
|
Wittelsbacherstraße
|
||||||
|
Wolkenburgstraße
|
||||||
|
Wörthstraße
|
||||||
|
Wupperstraße
|
||||||
|
Wurzerstraße
|
||||||
|
Yalovastraße
|
||||||
|
Yorckstraße
|
||||||
|
Zanderstraße
|
||||||
|
Zeller Straße
|
||||||
|
Zeppelinstraße
|
||||||
|
Zietenstraße
|
||||||
|
Zum Kempenberg
|
||||||
@@ -34,38 +34,41 @@ lonE = {}
|
|||||||
with open('bonn-opendata/BonnHausnummern.csv', newline='') as csvfile:
|
with open('bonn-opendata/BonnHausnummern.csv', newline='') as csvfile:
|
||||||
a_reader = csv.DictReader(csvfile, delimiter=';', quotechar='#')
|
a_reader = csv.DictReader(csvfile, delimiter=';', quotechar='#')
|
||||||
for row in a_reader:
|
for row in a_reader:
|
||||||
x = row['rechtswert_25832']
|
|
||||||
y = row['hochwert_25832']
|
|
||||||
lat, lon = to_latlon.transform(x, y)
|
|
||||||
s = row['stassen_langname']
|
|
||||||
if not s in streets:
|
|
||||||
streets.append(s)
|
|
||||||
hnr = int(row['hnr_ohne_zusatz'].split('-')[-1:][0])
|
|
||||||
max_hnr[s] = hnr
|
|
||||||
latN[s] = lat
|
|
||||||
latS[s] = lat
|
|
||||||
lonW[s] = lon
|
|
||||||
lonE[s] = lon
|
|
||||||
else:
|
|
||||||
hnr = int(row['hnr_ohne_zusatz'].split('-')[-1:][0])
|
|
||||||
if max_hnr[s] < hnr:
|
|
||||||
max_hnr[s] = hnr
|
|
||||||
if latN[s] < lat:
|
|
||||||
latN[s] = lat
|
|
||||||
if latS[s] > lat:
|
|
||||||
latS[s] = lat
|
|
||||||
if lonW[s] > lon:
|
|
||||||
lonW[s] = lon
|
|
||||||
if lonE[s] < lon:
|
|
||||||
lonE[s] = lon
|
|
||||||
if row['ortsteil_name'] in godesberg:
|
if row['ortsteil_name'] in godesberg:
|
||||||
print("%s: %s %d - %d %s (%f, %f)" %
|
x = row['rechtswert_25832']
|
||||||
(row['ortsteil_name'], s, hnr,
|
y = row['hochwert_25832']
|
||||||
int(row['hnr_ohne_zusatz'].split('-')[-1:][0]),
|
lat, lon = to_latlon.transform(x, y)
|
||||||
row['hnr_zusatz'],
|
s = row['stassen_langname']
|
||||||
lat, lon)
|
if not s in streets:
|
||||||
)
|
streets.append(s)
|
||||||
for s in streets:
|
hnr = int(row['hnr_ohne_zusatz'].split('-')[-1:][0])
|
||||||
print("%s: max=%d, (%f,%f) - (%f,%f)" %
|
max_hnr[s] = hnr
|
||||||
(s, max_hnr[s], latN[s], lonW[s], latS[s], lonE[s]))
|
latN[s] = lat
|
||||||
|
latS[s] = lat
|
||||||
|
lonW[s] = lon
|
||||||
|
lonE[s] = lon
|
||||||
|
else:
|
||||||
|
hnr = int(row['hnr_ohne_zusatz'].split('-')[-1:][0])
|
||||||
|
if max_hnr[s] < hnr:
|
||||||
|
max_hnr[s] = hnr
|
||||||
|
if latN[s] < lat:
|
||||||
|
latN[s] = lat
|
||||||
|
if latS[s] > lat:
|
||||||
|
latS[s] = lat
|
||||||
|
if lonW[s] > lon:
|
||||||
|
lonW[s] = lon
|
||||||
|
if lonE[s] < lon:
|
||||||
|
lonE[s] = lon
|
||||||
|
#print("%s: %s %d - %d %s (%f, %f)" %
|
||||||
|
## (row['ortsteil_name'], s, hnr,
|
||||||
|
# int(row['hnr_ohne_zusatz'].split('-')[-1:][0]),
|
||||||
|
# row['hnr_zusatz'],
|
||||||
|
# lat, lon)
|
||||||
|
# )
|
||||||
|
|
||||||
|
print("#Name;Hausnummer minimal;Hausnummer maximal;Bounding Box")
|
||||||
|
for s in streets:
|
||||||
|
print("%s;1;%d;[%f,%f], [%f,%f]" % (s, max_hnr[s], latN[s], lonW[s], latS[s], lonE[s]))
|
||||||
|
# print("%s: max=%d, (%f,%f) - (%f,%f)" %
|
||||||
|
# (s, max_hnr[s], latN[s], lonW[s], latS[s], lonE[s]))
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ def str2latlong(s):
|
|||||||
return latlon
|
return latlon
|
||||||
|
|
||||||
def wkt2polylines(street, wkt_lines):
|
def wkt2polylines(street, wkt_lines):
|
||||||
print(" %s : [" % (street, ))
|
print(" '%s' : [" % (street, ))
|
||||||
for line in wkt_lines:
|
for line in wkt_lines:
|
||||||
latlon = str2latlong(line)
|
latlon = str2latlong(line)
|
||||||
print(" [")
|
print(" [")
|
||||||
@@ -35,7 +35,7 @@ if __name__ == "__main__":
|
|||||||
streets = {}
|
streets = {}
|
||||||
for idx, row in enumerate(read_osm_data(STREETS_CSV)):
|
for idx, row in enumerate(read_osm_data(STREETS_CSV)):
|
||||||
if row['name'] != "":
|
if row['name'] != "":
|
||||||
print("ID %(full_id)s : %(name)s = %(WKT)s" % row)
|
# print("ID %(full_id)s : %(name)s = %(WKT)s" % row)
|
||||||
# !!! TOO SIMPLE, more than 1 row !!!!
|
# !!! TOO SIMPLE, more than 1 row !!!!
|
||||||
#streets[row['full_id']] = {row['name']: row['WKT'][12:-1]}
|
#streets[row['full_id']] = {row['name']: row['WKT'][12:-1]}
|
||||||
streets.setdefault(row['name'], [])
|
streets.setdefault(row['name'], [])
|
||||||
@@ -44,14 +44,9 @@ if __name__ == "__main__":
|
|||||||
# 0 12 -1
|
# 0 12 -1
|
||||||
wkt_line = row['WKT'][12:-1]
|
wkt_line = row['WKT'][12:-1]
|
||||||
streets[row['name']].append(wkt_line)
|
streets[row['name']].append(wkt_line)
|
||||||
print("")
|
print("window.STRASSE2POLYLINES = {")
|
||||||
print("--------------------------------")
|
for k in streets.keys():
|
||||||
print("KENNEDYALLEE")
|
# wkt2polylines(k, streets[k])
|
||||||
#print(streets['Kennedyallee'])
|
print("%s" % k)
|
||||||
wkt2polylines("Kennedyallee", streets['Kennedyallee'])
|
print("};")
|
||||||
print("")
|
|
||||||
print("--------------------------------")
|
|
||||||
print("AUSTRASSE")
|
|
||||||
#print(streets['Austraße'])
|
|
||||||
wkt2polylines("Austraße", streets['Austraße'])
|
|
||||||
|
|
||||||
Reference in new issue
Block a user