Ajout de l'interface pour selectionner des disques et modifications du coté serveur pour la sauvegarde
This commit is contained in:
1 parent
913f7a9e42
commit
7edc2a71d8
7 files changed
+153
-1
No files matched your search
@@ -10,9 +10,11 @@ import { HttpAdornment } from "@/Components/v1/Inputs/TextInput/Adornments/index
|
||||
import MonitorStatusHeader from "./Components/MonitorStatusHeader.jsx";
|
||||
import MonitorActionButtons from "./Components/MonitorActionButtons.jsx";
|
||||
import CustomAlertsSection from "./Components/CustomAlertsSection.jsx";
|
||||
import DiskSelection from "./Components/DiskSelection.jsx";
|
||||
// Utils
|
||||
import NotificationsConfig from "@/Components/v1/NotificationConfig/index.jsx";
|
||||
import { useGetNotificationsByTeamId } from "../../../../Hooks/v1/useNotifications.js";
|
||||
import NetworkService from "../../../../Utils/NetworkService";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useTheme } from "@emotion/react";
|
||||
@@ -37,6 +39,7 @@ const CreateInfrastructureMonitor = () => {
|
||||
// State
|
||||
const [https, setHttps] = useState(false);
|
||||
const [updateTrigger, setUpdateTrigger] = useState(false);
|
||||
const [availableDisks, setAvailableDisks] = useState([]);
|
||||
|
||||
// Fetch monitor details if editing
|
||||
const [monitor, isLoading] = useFetchHardwareMonitorById({
|
||||
@@ -85,6 +88,24 @@ const CreateInfrastructureMonitor = () => {
|
||||
} else if (monitor) {
|
||||
setHttps(monitor.url.startsWith("https"));
|
||||
initializeInfrastructureMonitorForUpdate(monitor);
|
||||
const fetchLastCheck = async () => {
|
||||
try {
|
||||
const params = {
|
||||
dateRange: "recent",
|
||||
limit: 1,
|
||||
sortOrder: "desc",
|
||||
};
|
||||
// On utilise NetworkService directement
|
||||
const response = await NetworkService.get(`/api/v1/checks/${monitorId}`, { params });
|
||||
const disks = response?.data?.checks?.[0]?.payload?.disks || [];
|
||||
setAvailableDisks(disks);
|
||||
} catch (error) {
|
||||
console.error("Erreur pendant la récupération des disques:", error);
|
||||
setAvailableDisks([]); // En cas d'erreur, on met un tableau vide
|
||||
}
|
||||
};
|
||||
|
||||
fetchLastCheck();
|
||||
}
|
||||
}, [
|
||||
isCreate,
|
||||
@@ -133,6 +154,15 @@ const CreateInfrastructureMonitor = () => {
|
||||
isPausing ||
|
||||
notificationsAreLoading;
|
||||
|
||||
// --- AJOUT TEMPORAIRE : Fausses données ---
|
||||
const MOCK_DISKS = [
|
||||
{ mountpoint: "C:" },
|
||||
{ mountpoint: "D:" },
|
||||
{ mountpoint: "/mnt/data" },
|
||||
{ mountpoint: "/var/lib/docker" }
|
||||
];
|
||||
// -----------------------------------------
|
||||
|
||||
return (
|
||||
<Box className="create-infrastructure-monitor">
|
||||
<Breadcrumbs list={CRUMBS} />
|
||||
@@ -327,6 +357,17 @@ const CreateInfrastructureMonitor = () => {
|
||||
infrastructureMonitor={infrastructureMonitor}
|
||||
handleCheckboxChange={handleCheckboxChange}
|
||||
/>
|
||||
|
||||
{monitorId && (
|
||||
<DiskSelection
|
||||
availableDisks={availableDisks}
|
||||
selectedDisks={infrastructureMonitor.selectedDisks}
|
||||
onChange={(newSelectedDisks) =>
|
||||
onChangeForm("selectedDisks", newSelectedDisks)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
<ConfigBox>
|
||||
<Box>
|
||||
<Typography
|
||||
|
||||
Reference in new issue
Block a user