User Berechtigung zu Poi bearbeiten
This commit is contained in:
@@ -68,11 +68,11 @@ function DataSheet() {
|
||||
const isUnique = !seenSystemNames.has(formattedName) && item.Allow === 1;
|
||||
if (isUnique) {
|
||||
seenSystemNames.add(formattedName); // Füge den formatierten Namen hinzu
|
||||
console.log("Unique system in DataSheet:", formattedName); // Zeige den formatierten Namen in der Konsole
|
||||
//console.log("Unique system in DataSheet:", formattedName); // Zeige den formatierten Namen in der Konsole
|
||||
}
|
||||
return isUnique;
|
||||
});
|
||||
console.log("filteredSystems:", filteredSystems); // Logge die gefilterten Systeme
|
||||
//console.log("filteredSystems:", filteredSystems); // Logge die gefilterten Systeme
|
||||
|
||||
setSystemListing(
|
||||
filteredSystems.map((system, index) => ({
|
||||
|
||||
@@ -35,8 +35,9 @@ const plusRoundIcon = L.icon({
|
||||
});
|
||||
|
||||
const MapComponent = ({ locations, onLocationUpdate }) => {
|
||||
const [showAddStationPopup, setShowAddStationPopup] = useState(false);
|
||||
const [userRights, setUserRights] = useState(null);
|
||||
const setSelectedPoi = useSetRecoilState(selectedPoiState);
|
||||
|
||||
const openPoiUpdateModal = () => setShowPoiUpdateModal(true);
|
||||
const closePoiUpdateModal = () => setShowPoiUpdateModal(false);
|
||||
const [showPoiUpdateModal, setShowPoiUpdateModal] = useState(false);
|
||||
@@ -49,6 +50,12 @@ const MapComponent = ({ locations, onLocationUpdate }) => {
|
||||
};
|
||||
|
||||
const handleEditPoi = (marker) => {
|
||||
// Prüfung, ob der Benutzer die notwendigen Rechte hat
|
||||
if (!userRights || !userRights.includes(56)) {
|
||||
console.log("Benutzer hat keine Berechtigung zum Bearbeiten.");
|
||||
return; // Beendet die Funktion frühzeitig, wenn keine Berechtigung vorliegt
|
||||
}
|
||||
|
||||
console.log("Selected Marker ID (idPoi):", marker.options.idPoi);
|
||||
console.log("Selected Marker Description:", marker.options.description);
|
||||
|
||||
@@ -115,6 +122,7 @@ const MapComponent = ({ locations, onLocationUpdate }) => {
|
||||
const handleAddStation = (stationData) => {
|
||||
// Station-Daten speichern oder API-Aufruf durchführen
|
||||
console.log("Neue Station:", stationData);
|
||||
setShowAddStationPopup(false);
|
||||
closePopup(); // Schließt das Popup nach dem Hinzufügen
|
||||
};
|
||||
// Beispiel zum Öffnen des Popups mit bestimmten Koordinaten
|
||||
@@ -600,6 +608,45 @@ const MapComponent = ({ locations, onLocationUpdate }) => {
|
||||
};
|
||||
// In der Marker-Erstellungsfunktion
|
||||
//---------------------------------------------------------
|
||||
//-----------------------------------------------------------
|
||||
// Funktion um die Benutzerrechte zu überprüfen
|
||||
// serverIP 10.10.0.13 idMap=10 idUser=485
|
||||
const serverURL = "http://10.10.0.13";
|
||||
const c = 10; // Beispielwert für idMap
|
||||
const user = 483; // Beispielwert für idUser
|
||||
|
||||
const fetchUserRights = async () => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${c}&idUser=${user}`
|
||||
);
|
||||
const data = await response.json();
|
||||
const rightsArray = data.Rights; // Nehmen an, dass 'Rights' das Array von Rechten ist
|
||||
|
||||
// Speichert die IDs der Rechte in einem Array
|
||||
const userRightsIds = rightsArray.map((right) => right.IdRight);
|
||||
setUserRights(userRightsIds); // Speichert die Rechte in den Zustand
|
||||
|
||||
console.log("Benutzerrechte:", rightsArray);
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Abrufen der Benutzerrechte", error);
|
||||
}
|
||||
};
|
||||
|
||||
// Überprüfen der Benutzerrechte beim Initialisieren der Komponente
|
||||
useEffect(() => {
|
||||
fetchUserRights();
|
||||
}, []);
|
||||
|
||||
// Anzeigen von Modals basierend auf Benutzerrechten
|
||||
useEffect(() => {
|
||||
if (userRights !== 56) {
|
||||
setShowPoiUpdateModal(false);
|
||||
setShowAddStationPopup(false);
|
||||
}
|
||||
}, [userRights]);
|
||||
//-----------------------------------------------------------
|
||||
//---------------------------------------------------------
|
||||
useEffect(() => {
|
||||
//console.log("useEffect current Data:", currentPoiData);
|
||||
}, [currentPoiData]);
|
||||
|
||||
Reference in New Issue
Block a user