feat: Webservice-Mockdaten im public-Verzeichnis hinzugefügt

- JSON-Dateien für Linienstatus, Stationsstatus, Systemdaten und Benutzerrechte unter /public/mocks/webservice/ abgelegt
- Struktur der Dateien an echte Webservice-Antworten angepasst (z. B. 'Statis' statt 'Status')
- Dienste wurden entsprechend auf Umschaltung zwischen Mock- und Echtbetrieb vorbereitet
- Ermöglicht lokale Entwicklung und Tests ohne Backend-Verbindung
This commit is contained in:
ISA
2025-06-03 13:34:38 +02:00
parent 3412d3daff
commit 5c158a0395
17 changed files with 2251 additions and 46 deletions

View File

@@ -12,8 +12,8 @@ NEXT_PUBLIC_DEBUG_LOG=true
#auf dem Entwicklungsrechner dev läuft auf Port 3000 und auf dem Server prod auf Port 80, aber der WebService ist immer auf PORT 80 #auf dem Entwicklungsrechner dev läuft auf Port 3000 und auf dem Server prod auf Port 80, aber der WebService ist immer auf PORT 80
NEXT_PUBLIC_API_PORT_MODE=prod NEXT_PUBLIC_API_PORT_MODE=dev
NEXT_PUBLIC_USE_MOCKS=false NEXT_PUBLIC_USE_MOCKS=true
# Der Unterordner talas5 gleich hinter der IP-Adresse (oder Servername) muss konfigurierbar sein. # Der Unterordner talas5 gleich hinter der IP-Adresse (oder Servername) muss konfigurierbar sein.
# Es muss auch möglich sein kein Unterorder anzugeben (z.B. nur http://talasserver/). # Es muss auch möglich sein kein Unterorder anzugeben (z.B. nur http://talasserver/).

View File

@@ -120,11 +120,11 @@ export const mockGisStationsMeasurements = {
// Optional: Funktion zum Ändern // Optional: Funktion zum Ändern
export const updateMeasurement = (id, changes) => { export const updateMeasurement = (id, changes) => {
const deviceMeasurement = mockGisStationsMeasurements.Statis.find((p) => p.IdLD === id); const deviceMeasurement = mockGisStationsMeasurements.Statis.find(p => p.IdLD === id);
if (deviceMeasurement) Object.assign(deviceMeasurement, changes); if (deviceMeasurement) Object.assign(deviceMeasurement, changes);
}; };
export const deleteMeasurement = (id) => { export const deleteMeasurement = id => {
const index = mockGisStationsMeasurements.Statis.findIndex((p) => p.IdLD === id); const index = mockGisStationsMeasurements.Statis.findIndex(p => p.IdLD === id);
if (index !== -1) mockGisStationsMeasurements.Statis.splice(index, 1); if (index !== -1) mockGisStationsMeasurements.Statis.splice(index, 1);
}; };

View File

@@ -1,4 +1,9 @@
// __mocks__/webservice/gisStationsStaticDistrict.js // __mocks__/webservice/gisStationsStaticDistrict.js
/*
Icon: 20, CPL rot
Icon: 19, Telefon rot
*/
export const mockGisStationsStaticDistrict = { export const mockGisStationsStaticDistrict = {
Name: "Liste aller Geraete einer bestimmten Karte", Name: "Liste aller Geraete einer bestimmten Karte",
@@ -163,11 +168,11 @@ export const mockGisStationsStaticDistrict = {
// Optional: Funktion zum Ändern // Optional: Funktion zum Ändern
export const updateDevice = (id, changes) => { export const updateDevice = (id, changes) => {
const device = mockGisStationsStaticDistrict.Points.find((p) => p.IdLD === id); const device = mockGisStationsStaticDistrict.Points.find(p => p.IdLD === id);
if (device) Object.assign(device, changes); if (device) Object.assign(device, changes);
}; };
export const deleteDevice = (id) => { export const deleteDevice = id => {
const index = mockGisStationsStaticDistrict.Points.findIndex((p) => p.IdLD === id); const index = mockGisStationsStaticDistrict.Points.findIndex(p => p.IdLD === id);
if (index !== -1) mockGisStationsStaticDistrict.Points.splice(index, 1); if (index !== -1) mockGisStationsStaticDistrict.Points.splice(index, 1);
}; };

View File

@@ -1,2 +1,2 @@
// /config/appVersion // /config/appVersion
export const APP_VERSION = "1.1.225"; export const APP_VERSION = "1.1.226";

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,117 @@
{
"Name": "Liste aller Messungen der Geraete",
"Zeitstempel": "2025-05-29T08:53:04.1449106+02:00",
"IdMap": "12",
"Statis": [
{
"IdLD": 50937,
"IdL": 24101,
"IdDP": 3,
"Na": "FBT",
"Val": "6",
"Unit": "°C",
"Gr": "GMA",
"Area_Name": "Rastede"
},
{
"IdLD": 50937,
"IdL": 24101,
"IdDP": 10,
"Na": "GT",
"Val": "-2.14",
"Unit": "°C",
"Gr": "GMA",
"Area_Name": "Rastede"
},
{
"IdLD": 50937,
"IdL": 24101,
"IdDP": 2,
"Na": "LT",
"Val": "0.21",
"Unit": "°C",
"Gr": "GMA",
"Area_Name": "Rastede"
},
{
"IdLD": 50937,
"IdL": 24101,
"IdDP": 6,
"Na": "RLF",
"Val": "77.54",
"Unit": "%",
"Gr": "GMA",
"Area_Name": "Rastede"
},
{
"IdLD": 50937,
"IdL": 24101,
"IdDP": 4,
"Na": "RS",
"Val": "30.33",
"Unit": "%",
"Gr": "GMA",
"Area_Name": "Rastede"
},
{
"IdLD": 50937,
"IdL": 24101,
"IdDP": 11,
"Na": "TPT",
"Val": "2.99",
"Unit": "°C",
"Gr": "GMA",
"Area_Name": "Rastede"
},
{
"IdLD": 50937,
"IdL": 24101,
"IdDP": 12,
"Na": "TT1",
"Val": "0.1245",
"Unit": "°C",
"Gr": "GMA",
"Area_Name": "Rastede"
},
{
"IdLD": 50937,
"IdL": 24101,
"IdDP": 16,
"Na": "WFD",
"Val": "0.211",
"Unit": "mm",
"Gr": "GMA",
"Area_Name": "Rastede"
},
{
"IdLD": 50937,
"IdL": 24101,
"IdDP": 8,
"Na": "WGM",
"Val": "0.5",
"Unit": "m/s",
"Gr": "GMA",
"Area_Name": "Rastede"
},
{
"IdLD": 50937,
"IdL": 24101,
"IdDP": 9,
"Na": "WGS",
"Val": "0.75",
"Unit": "m/s",
"Gr": "GMA",
"Area_Name": "Rastede"
},
{
"IdLD": 50937,
"IdL": 24101,
"IdDP": 7,
"Na": "WR",
"Val": "180",
"Unit": "°",
"Gr": "GMA",
"Area_Name": "Rastede"
}
]
}

View File

@@ -0,0 +1,160 @@
{
"Name": "Liste aller Geraete einer bestimmten Karte",
"Zeitstempel": "2025-05-29T08:08:34.2019886+02:00",
"IdMap": "12",
"Points": [
{
"LD_Name": "CPL Ismail",
"IdLD": 50922,
"Device": "CPL V3.5 mit 24 Kü",
"Link": "cpl.aspx?ver=35&kue=24&id=50922",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.242157,
"Y": 8.160353,
"Icon": 20,
"System": 1,
"Active": 1
},
{
"LD_Name": "LR 77 ISA",
"IdLD": 50935,
"Device": "LTE Modem LR77",
"Link": "lr77.aspx?ver=1&id=50935",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.242157,
"Y": 8.160353,
"Icon": 12,
"System": 5,
"Active": 1
},
{
"LD_Name": "Cisco Router 1841",
"IdLD": 50936,
"Device": "Cisco 1841",
"Link": "cisco1841.aspx?ver=1&id=50936",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.242157,
"Y": 8.160353,
"Icon": 21,
"System": 6,
"Active": 1
},
{
"LD_Name": "GMA Testgerät ISA",
"IdLD": 50937,
"Device": "Glättemeldeanlage",
"Link": "gma.aspx?ver=1&id=50937",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.242157,
"Y": 8.160353,
"Icon": 1,
"System": 11,
"Active": 1
},
{
"LD_Name": "SMS-Funkmodem",
"IdLD": 50938,
"Device": "SMS Funkmodem",
"Link": "sms_modem.aspx?ver=1&id=50938",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.242157,
"Y": 8.160353,
"Icon": 12,
"System": 111,
"Active": 1
},
{
"LD_Name": "TALAS Meldestationen ISA",
"IdLD": 50939,
"Device": "CPL V3.5 mit 16 Kü",
"Link": "cpl.aspx?ver=35&kue=16&id=50939",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.242157,
"Y": 8.160353,
"Icon": 20,
"System": 1,
"Active": 1
},
{
"LD_Name": "WAGO Klemmen ISA",
"IdLD": 50941,
"Device": "WAGO 16 DE",
"Link": "wago.aspx?ver=1&DE=16&id=50941",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.242157,
"Y": 8.160353,
"Icon": 9,
"System": 7,
"Active": 1
},
{
"LD_Name": "Cisco 1921",
"IdLD": 50942,
"Device": "Cisco 1921",
"Link": "cisco1921.aspx?ver=1&id=50942",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.242157,
"Y": 8.160353,
"Icon": 21,
"System": 6,
"Active": 1
},
{
"LD_Name": "Cisco 8200",
"IdLD": 50943,
"Device": "Cisco 8200",
"Link": "cisco8200.aspx?ver=1&id=50943",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.242157,
"Y": 8.160353,
"Icon": 21,
"System": 6,
"Active": 1
}
]
}

View File

@@ -0,0 +1,106 @@
{
"Name": "Liste aller Statis der Geraete",
"Zeitstempel": "2025-05-29T08:45:50.7257018+02:00",
"IdMap": "12",
"Statis": [
{
"IdLD": 50922,
"Na": "system",
"Le": 4,
"Co": "#FF00FF",
"Me": "Eingang DE 01 kommend",
"Feld": 4,
"Icon": 0
},
{
"IdLD": 50922,
"Na": "system",
"Le": 4,
"Co": "#FF00FF",
"Me": "Eingang DE 05 kommend",
"Feld": 4,
"Icon": 0
},
{
"IdLD": 50922,
"Na": "system",
"Le": 4,
"Co": "#FF00FF",
"Me": "Eingang DE 17 kommend",
"Feld": 4,
"Icon": 0
},
{
"IdLD": 50922,
"Na": "system",
"Le": 4,
"Co": "#FF00FF",
"Me": "Eingang DE 31 kommend",
"Feld": 4,
"Icon": 0
},
{
"IdLD": 50922,
"Na": "system",
"Le": 4,
"Co": "#FF00FF",
"Me": "Eingang DE 32 kommend",
"Feld": 4,
"Icon": 0
},
{
"IdLD": 50922,
"Na": "system",
"Le": 4,
"Co": "#FF00FF",
"Me": "Station offline",
"Feld": 4,
"Icon": 0
},
{
"IdLD": 50922,
"Na": "minor",
"Le": 3,
"Co": "#FFFF00",
"Me": "Eingang DE 02 kommend",
"Feld": 4,
"Icon": 0
},
{
"IdLD": 50922,
"Na": "minor",
"Le": 3,
"Co": "#FFFF00",
"Me": "KÜG 08: Überspannung gehend",
"Feld": 4,
"Icon": 0
},
{
"IdLD": 50922,
"Na": "major",
"Le": 2,
"Co": "#FF9900",
"Me": "Eingang DE 03 kommend",
"Feld": 4,
"Icon": 0
},
{
"IdLD": 50922,
"Na": "critical",
"Le": 1,
"Co": "#FF0000",
"Me": "KÜG 02: Aderbruch kommend",
"Feld": 4,
"Icon": 0
},
{
"IdLD": 50922,
"Na": "critical",
"Le": 1,
"Co": "#FF0000",
"Me": "KÜG 03: Aderbruch kommend",
"Feld": 4,
"Icon": 0
}
]
}

View File

@@ -0,0 +1,170 @@
{
"Name": "Liste aller angezeigten Systeme",
"Zeitstempel": "2025-05-29T08:57:47.6981898+02:00",
"IdMap": "12",
"Systems": [
{
"IdSystem": 1,
"Name": "TALAS",
"Longname": "Talas Meldestationen",
"Allow": 1,
"Icon": 1
},
{
"IdSystem": 2,
"Name": "ECI",
"Longname": "ECI Geräte",
"Allow": 1,
"Icon": 2
},
{
"IdSystem": 3,
"Name": "ULAF",
"Longname": "ULAF Geräte",
"Allow": 0,
"Icon": 3
},
{
"IdSystem": 5,
"Name": "GSM Modem",
"Longname": "LR77 GSM Modems",
"Allow": 1,
"Icon": 5
},
{
"IdSystem": 6,
"Name": "Cisco Router",
"Longname": "Cisco Router",
"Allow": 1,
"Icon": 6
},
{
"IdSystem": 7,
"Name": "WAGO",
"Longname": "WAGO I/O Systeme",
"Allow": 1,
"Icon": 7
},
{
"IdSystem": 8,
"Name": "Siemens",
"Longname": "Siemens Notrufsysteme",
"Allow": 1,
"Icon": 8
},
{
"IdSystem": 9,
"Name": "OTDR",
"Longname": "Glasfaserüberwachung OTU",
"Allow": 1,
"Icon": 9
},
{
"IdSystem": 10,
"Name": "WDM",
"Longname": " Wavelength Division Multiplexing",
"Allow": 1,
"Icon": 10
},
{
"IdSystem": 11,
"Name": "GMA",
"Longname": "Glättemeldeanlagen",
"Allow": 1,
"Icon": 11
},
{
"IdSystem": 13,
"Name": "Messstellen",
"Longname": "Messstellen",
"Allow": 1,
"Icon": 13
},
{
"IdSystem": 30,
"Name": "TK-Komponenten",
"Longname": "TK-Komponenten",
"Allow": 1,
"Icon": 30
},
{
"IdSystem": 100,
"Name": "TALAS ICL",
"Longname": "Talas ICL Unterstationen",
"Allow": 1,
"Icon": 100
},
{
"IdSystem": 110,
"Name": "DAUZ",
"Longname": "Dauerzählstellen",
"Allow": 1,
"Icon": 110
},
{
"IdSystem": 111,
"Name": "SMS Modem",
"Longname": "SMS Modem",
"Allow": 1,
"Icon": 111
},
{
"IdSystem": 200,
"Name": "Sonstige",
"Longname": "Sonstige",
"Allow": 1,
"Icon": 200
}
],
"Rights": [
{ "IdRight": 1 },
{ "IdRight": 2 },
{ "IdRight": 3 },
{ "IdRight": 5 },
{ "IdRight": 6 },
{ "IdRight": 7 },
{ "IdRight": 8 },
{ "IdRight": 10 },
{ "IdRight": 11 },
{ "IdRight": 12 },
{ "IdRight": 20 },
{ "IdRight": 22 },
{ "IdRight": 23 },
{ "IdRight": 25 },
{ "IdRight": 30 },
{ "IdRight": 40 },
{ "IdRight": 41 },
{ "IdRight": 42 },
{ "IdRight": 43 },
{ "IdRight": 44 },
{ "IdRight": 45 },
{ "IdRight": 46 },
{ "IdRight": 47 },
{ "IdRight": 48 },
{ "IdRight": 49 },
{ "IdRight": 50 },
{ "IdRight": 51 },
{ "IdRight": 52 },
{ "IdRight": 55 },
{ "IdRight": 56 },
{ "IdRight": 60 },
{ "IdRight": 61 },
{ "IdRight": 62 },
{ "IdRight": 63 },
{ "IdRight": 64 },
{ "IdRight": 65 },
{ "IdRight": 68 },
{ "IdRight": 69 },
{ "IdRight": 70 },
{ "IdRight": 71 },
{ "IdRight": 72 },
{ "IdRight": 73 },
{ "IdRight": 79 },
{ "IdRight": 80 },
{ "IdRight": 90 },
{ "IdRight": 93 },
{ "IdRight": 94 },
{ "IdRight": 95 },
{ "IdRight": 96 }
]
}

View File

@@ -0,0 +1,170 @@
{
"Name": "Liste aller angezeigten Systeme",
"Zeitstempel": "2025-05-29T08:57:47.6981898+02:00",
"IdMap": "12",
"Systems": [
{
"IdSystem": 1,
"Name": "TALAS",
"Longname": "Talas Meldestationen",
"Allow": 1,
"Icon": 1
},
{
"IdSystem": 2,
"Name": "ECI",
"Longname": "ECI Geräte",
"Allow": 1,
"Icon": 2
},
{
"IdSystem": 3,
"Name": "ULAF",
"Longname": "ULAF Geräte",
"Allow": 0,
"Icon": 3
},
{
"IdSystem": 5,
"Name": "GSM Modem",
"Longname": "LR77 GSM Modems",
"Allow": 1,
"Icon": 5
},
{
"IdSystem": 6,
"Name": "Cisco Router",
"Longname": "Cisco Router",
"Allow": 1,
"Icon": 6
},
{
"IdSystem": 7,
"Name": "WAGO",
"Longname": "WAGO I/O Systeme",
"Allow": 1,
"Icon": 7
},
{
"IdSystem": 8,
"Name": "Siemens",
"Longname": "Siemens Notrufsysteme",
"Allow": 1,
"Icon": 8
},
{
"IdSystem": 9,
"Name": "OTDR",
"Longname": "Glasfaserüberwachung OTU",
"Allow": 1,
"Icon": 9
},
{
"IdSystem": 10,
"Name": "WDM",
"Longname": " Wavelength Division Multiplexing",
"Allow": 1,
"Icon": 10
},
{
"IdSystem": 11,
"Name": "GMA",
"Longname": "Glättemeldeanlagen",
"Allow": 1,
"Icon": 11
},
{
"IdSystem": 13,
"Name": "Messstellen",
"Longname": "Messstellen",
"Allow": 1,
"Icon": 13
},
{
"IdSystem": 30,
"Name": "TK-Komponenten",
"Longname": "TK-Komponenten",
"Allow": 1,
"Icon": 30
},
{
"IdSystem": 100,
"Name": "TALAS ICL",
"Longname": "Talas ICL Unterstationen",
"Allow": 1,
"Icon": 100
},
{
"IdSystem": 110,
"Name": "DAUZ",
"Longname": "Dauerzählstellen",
"Allow": 1,
"Icon": 110
},
{
"IdSystem": 111,
"Name": "SMS Modem",
"Longname": "SMS Modem",
"Allow": 1,
"Icon": 111
},
{
"IdSystem": 200,
"Name": "Sonstige",
"Longname": "Sonstige",
"Allow": 1,
"Icon": 200
}
],
"Rights": [
{ "IdRight": 1 },
{ "IdRight": 2 },
{ "IdRight": 3 },
{ "IdRight": 5 },
{ "IdRight": 6 },
{ "IdRight": 7 },
{ "IdRight": 8 },
{ "IdRight": 10 },
{ "IdRight": 11 },
{ "IdRight": 12 },
{ "IdRight": 20 },
{ "IdRight": 22 },
{ "IdRight": 23 },
{ "IdRight": 25 },
{ "IdRight": 30 },
{ "IdRight": 40 },
{ "IdRight": 41 },
{ "IdRight": 42 },
{ "IdRight": 43 },
{ "IdRight": 44 },
{ "IdRight": 45 },
{ "IdRight": 46 },
{ "IdRight": 47 },
{ "IdRight": 48 },
{ "IdRight": 49 },
{ "IdRight": 50 },
{ "IdRight": 51 },
{ "IdRight": 52 },
{ "IdRight": 55 },
{ "IdRight": 56 },
{ "IdRight": 60 },
{ "IdRight": 61 },
{ "IdRight": 62 },
{ "IdRight": 63 },
{ "IdRight": 64 },
{ "IdRight": 65 },
{ "IdRight": 68 },
{ "IdRight": 69 },
{ "IdRight": 70 },
{ "IdRight": 71 },
{ "IdRight": 72 },
{ "IdRight": 73 },
{ "IdRight": 79 },
{ "IdRight": 80 },
{ "IdRight": 90 },
{ "IdRight": 93 },
{ "IdRight": 94 },
{ "IdRight": 95 },
{ "IdRight": 96 }
]
}

View File

@@ -1,14 +1,22 @@
// /services/webservice/fetchGisLinesStatusService.js
export const fetchGisLinesStatusService = async () => { export const fetchGisLinesStatusService = async () => {
const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true"; const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true";
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ""; const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
if (useMocks) { if (useMocks) {
console.log("🧪 Mock-Modus aktiviert: fetchGisLinesStatusService"); console.log("🧪 Mock-Modus aktiviert: fetchGisLinesStatusService");
const { mockGisLinesStatus } = await import("../../__mocks__/webservice/gisLinesStatus.js");
return mockGisLinesStatus.Statis; const response = await fetch("/mocks/webservice/gisLinesStatus.json");
if (!response.ok) {
throw new Error("Mockdaten konnten nicht geladen werden");
}
const mockData = await response.json();
if (!Array.isArray(mockData.Statis)) {
throw new Error("Ungültige Struktur: 'Status' fehlt im Mock");
}
return mockData.Statis;
} else { } else {
const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`; const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`;
@@ -19,7 +27,9 @@ export const fetchGisLinesStatusService = async () => {
console.log("📡 fetchGisLinesStatusService URL:", url); console.log("📡 fetchGisLinesStatusService URL:", url);
const response = await fetch(url); const response = await fetch(url);
if (!response.ok) throw new Error("Fehler beim Laden der Linienstatusdaten"); if (!response.ok) {
throw new Error("Fehler beim Laden der Linienstatusdaten");
}
const text = await response.text(); const text = await response.text();
@@ -31,7 +41,9 @@ export const fetchGisLinesStatusService = async () => {
throw new Error("Antwort ist kein gültiges JSON"); throw new Error("Antwort ist kein gültiges JSON");
} }
if (!Array.isArray(json.Statis)) throw new Error("Ungültige Antwortstruktur: Statis fehlt"); if (!Array.isArray(json.Statis)) {
throw new Error("Ungültige Antwortstruktur: Statis fehlt");
}
return json.Statis; return json.Statis;
} }

View File

@@ -1,14 +1,21 @@
// /services/webservice/fetchGisStationsMeasurementsService.js
export const fetchGisStationsMeasurementsService = async () => { export const fetchGisStationsMeasurementsService = async () => {
const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true"; const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true";
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ""; const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
if (useMocks) { if (useMocks) {
console.log("🧪 Mock-Modus aktiviert: fetchGisStationsMeasurementsService"); console.log("🧪 Mock-Modus aktiviert: fetchGisStationsMeasurementsService");
const { mockGisStationsMeasurements } = await import("../../__mocks__/webservice/gisStationsMeasurements.js");
return mockGisStationsMeasurements.Statis; const response = await fetch("/mocks/webservice/gisStationsMeasurements.json");
if (!response.ok) {
throw new Error("Mockdaten konnten nicht geladen werden");
}
const mockData = await response.json();
if (!Array.isArray(mockData.Statis)) {
throw new Error("Ungültige Struktur: 'Statis' fehlt im Mock");
}
return mockData.Statis;
} else { } else {
const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`; const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`;
@@ -36,7 +43,7 @@ export const fetchGisStationsMeasurementsService = async () => {
throw new Error("Antwort ist kein gültiges JSON"); throw new Error("Antwort ist kein gültiges JSON");
} }
if (!jsonResponse?.Statis) { if (!Array.isArray(jsonResponse.Statis)) {
throw new Error("Antwortstruktur ungültig 'Statis' fehlt"); throw new Error("Antwortstruktur ungültig 'Statis' fehlt");
} }

View File

@@ -1,5 +1,3 @@
// /services/webservice/fetchGisStationsStaticDistrictService.js
/** /**
* Holt statische GIS-Stationen-Daten für Bezirke. * Holt statische GIS-Stationen-Daten für Bezirke.
* Wechselt automatisch zwischen echten Daten und Mock-Daten via .env.local * Wechselt automatisch zwischen echten Daten und Mock-Daten via .env.local
@@ -9,13 +7,22 @@
*/ */
export const fetchGisStationsStaticDistrictService = async () => { export const fetchGisStationsStaticDistrictService = async () => {
const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true"; const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true";
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ""; const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
if (useMocks) { if (useMocks) {
console.log("🧪 Mock-Modus aktiviert: fetchGisStationsStaticDistrictService"); console.log("🧪 Mock-Modus aktiviert: fetchGisStationsStaticDistrictService");
const { mockGisStationsStaticDistrict } = await import("../../__mocks__/webservice/gisStationsStaticDistrict.js");
return mockGisStationsStaticDistrict.Points; const res = await fetch("/mocks/webservice/gisStationsStaticDistrict.json");
if (!res.ok) {
throw new Error("Mockdaten konnten nicht geladen werden");
}
const mockData = await res.json();
if (!Array.isArray(mockData.Points)) {
throw new Error("Mockdaten enthalten kein gültiges 'Points'-Feld");
}
return mockData.Points;
} else { } else {
const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`; const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`;
@@ -34,7 +41,7 @@ export const fetchGisStationsStaticDistrictService = async () => {
} }
const jsonResponse = await response.json(); const jsonResponse = await response.json();
if (!jsonResponse?.Points) { if (!Array.isArray(jsonResponse.Points)) {
throw new Error("Antwortstruktur ungültig 'Points' fehlt"); throw new Error("Antwortstruktur ungültig 'Points' fehlt");
} }

View File

@@ -1,5 +1,3 @@
// /services/webservice/fetchGisStationsStatusDistrictService.js
/** /**
* Holt Statusinformationen der GIS-Bezirksstationen. * Holt Statusinformationen der GIS-Bezirksstationen.
* Unterstützt dynamische Umschaltung zwischen echten und Mock-Daten. * Unterstützt dynamische Umschaltung zwischen echten und Mock-Daten.
@@ -9,13 +7,22 @@
*/ */
export const fetchGisStationsStatusDistrictService = async () => { export const fetchGisStationsStatusDistrictService = async () => {
const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true"; const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true";
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ""; const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
if (useMocks) { if (useMocks) {
console.log("🧪 Mock-Modus aktiviert: fetchGisStationsStatusDistrictService"); console.log("🧪 Mock-Modus aktiviert: fetchGisStationsStatusDistrictService");
const { mockGisStationsStatusDistrict } = await import("../../__mocks__/webservice/gisStationsStatusDistrict.js");
return mockGisStationsStatusDistrict.Statis; const response = await fetch("/mocks/webservice/gisStationsStatusDistrict.json");
if (!response.ok) {
throw new Error("Mockdaten konnten nicht geladen werden");
}
const mockData = await response.json();
if (!Array.isArray(mockData.Statis)) {
throw new Error("Ungültige Struktur: 'Statis' fehlt im Mock");
}
return mockData.Statis;
} else { } else {
const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`; const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`;
@@ -27,7 +34,6 @@ export const fetchGisStationsStatusDistrictService = async () => {
console.log("📡 fetchGisStationsStatusDistrictService URL:", url); console.log("📡 fetchGisStationsStatusDistrictService URL:", url);
const response = await fetch(url); const response = await fetch(url);
if (!response.ok) { if (!response.ok) {
const message = `❌ Fehler: ${response.status} ${response.statusText}`; const message = `❌ Fehler: ${response.status} ${response.statusText}`;
console.error(message); console.error(message);
@@ -36,7 +42,7 @@ export const fetchGisStationsStatusDistrictService = async () => {
const jsonResponse = await response.json(); const jsonResponse = await response.json();
if (!jsonResponse?.Statis) { if (!Array.isArray(jsonResponse.Statis)) {
throw new Error("Antwortstruktur ungültig 'Statis' fehlt"); throw new Error("Antwortstruktur ungültig 'Statis' fehlt");
} }

View File

@@ -1,5 +1,3 @@
// /services/webservice/fetchGisSystemStaticService.js
/** /**
* Holt GIS-Systemdaten (Systemübersicht) vom TALAS WebService oder aus Mocks. * Holt GIS-Systemdaten (Systemübersicht) vom TALAS WebService oder aus Mocks.
* *
@@ -8,13 +6,22 @@
*/ */
export const fetchGisSystemStaticService = async () => { export const fetchGisSystemStaticService = async () => {
const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true"; const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true";
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ""; const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
if (useMocks) { if (useMocks) {
console.log("🧪 Mock-Modus aktiviert: fetchGisSystemStaticService"); console.log("🧪 Mock-Modus aktiviert: fetchGisSystemStaticService");
const { mockGisSystemStatic } = await import("../../__mocks__/webservice/gisSystemStatic.js");
return mockGisSystemStatic.Systems; const response = await fetch("/mocks/webservice/gisSystemStatic.json");
if (!response.ok) {
throw new Error("Mockdaten konnten nicht geladen werden");
}
const mockData = await response.json();
if (!Array.isArray(mockData.Systems)) {
throw new Error("Ungültige Struktur: 'Systems' fehlt im Mock");
}
return mockData.Systems;
} else { } else {
const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`; const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`;

View File

@@ -1,5 +1,3 @@
// /services/webservice/fetchUserRightsService.js
/** /**
* Holt Benutzerrechte aus TALAS-Webservice oder aus Mocks. * Holt Benutzerrechte aus TALAS-Webservice oder aus Mocks.
* *
@@ -8,13 +6,18 @@
*/ */
export const fetchUserRightsService = async () => { export const fetchUserRightsService = async () => {
const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true"; const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true";
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ""; const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
if (useMocks) { if (useMocks) {
console.log("🧪 Mock-Modus aktiviert: fetchUserRightsService"); console.log("🧪 Mock-Modus aktiviert: fetchUserRightsService");
const { mockUserRights } = await import("../../__mocks__/webservice/userRights.js");
return mockUserRights.Rights || []; const response = await fetch("/mocks/webservice/userRights.json");
if (!response.ok) {
throw new Error("Mockdaten konnten nicht geladen werden");
}
const mockData = await response.json();
return mockData.Rights || [];
} else { } else {
const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`; const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`;