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:
@@ -1,14 +1,22 @@
|
||||
// /services/webservice/fetchGisLinesStatusService.js
|
||||
|
||||
export const fetchGisLinesStatusService = async () => {
|
||||
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 || "";
|
||||
|
||||
if (useMocks) {
|
||||
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 {
|
||||
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);
|
||||
|
||||
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();
|
||||
|
||||
@@ -31,7 +41,9 @@ export const fetchGisLinesStatusService = async () => {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
// /services/webservice/fetchGisStationsMeasurementsService.js
|
||||
|
||||
export const fetchGisStationsMeasurementsService = async () => {
|
||||
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 || "";
|
||||
|
||||
if (useMocks) {
|
||||
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 {
|
||||
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");
|
||||
}
|
||||
|
||||
if (!jsonResponse?.Statis) {
|
||||
if (!Array.isArray(jsonResponse.Statis)) {
|
||||
throw new Error("Antwortstruktur ungültig – 'Statis' fehlt");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// /services/webservice/fetchGisStationsStaticDistrictService.js
|
||||
|
||||
/**
|
||||
* Holt statische GIS-Stationen-Daten für Bezirke.
|
||||
* Wechselt automatisch zwischen echten Daten und Mock-Daten via .env.local
|
||||
@@ -9,13 +7,22 @@
|
||||
*/
|
||||
export const fetchGisStationsStaticDistrictService = async () => {
|
||||
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 || "";
|
||||
|
||||
if (useMocks) {
|
||||
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 {
|
||||
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();
|
||||
if (!jsonResponse?.Points) {
|
||||
if (!Array.isArray(jsonResponse.Points)) {
|
||||
throw new Error("Antwortstruktur ungültig – 'Points' fehlt");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// /services/webservice/fetchGisStationsStatusDistrictService.js
|
||||
|
||||
/**
|
||||
* Holt Statusinformationen der GIS-Bezirksstationen.
|
||||
* Unterstützt dynamische Umschaltung zwischen echten und Mock-Daten.
|
||||
@@ -9,13 +7,22 @@
|
||||
*/
|
||||
export const fetchGisStationsStatusDistrictService = async () => {
|
||||
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 || "";
|
||||
|
||||
if (useMocks) {
|
||||
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 {
|
||||
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);
|
||||
|
||||
const response = await fetch(url);
|
||||
|
||||
if (!response.ok) {
|
||||
const message = `❌ Fehler: ${response.status} ${response.statusText}`;
|
||||
console.error(message);
|
||||
@@ -36,7 +42,7 @@ export const fetchGisStationsStatusDistrictService = async () => {
|
||||
|
||||
const jsonResponse = await response.json();
|
||||
|
||||
if (!jsonResponse?.Statis) {
|
||||
if (!Array.isArray(jsonResponse.Statis)) {
|
||||
throw new Error("Antwortstruktur ungültig – 'Statis' fehlt");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// /services/webservice/fetchGisSystemStaticService.js
|
||||
|
||||
/**
|
||||
* Holt GIS-Systemdaten (Systemübersicht) vom TALAS WebService oder aus Mocks.
|
||||
*
|
||||
@@ -8,13 +6,22 @@
|
||||
*/
|
||||
export const fetchGisSystemStaticService = async () => {
|
||||
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 || "";
|
||||
|
||||
if (useMocks) {
|
||||
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 {
|
||||
const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`;
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// /services/webservice/fetchUserRightsService.js
|
||||
|
||||
/**
|
||||
* Holt Benutzerrechte aus TALAS-Webservice oder aus Mocks.
|
||||
*
|
||||
@@ -8,13 +6,18 @@
|
||||
*/
|
||||
export const fetchUserRightsService = async () => {
|
||||
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 || "";
|
||||
|
||||
if (useMocks) {
|
||||
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 {
|
||||
const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user