diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx index e5debde..8e2d4f1 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx @@ -21,14 +21,17 @@ const BarChartInput = (props: Props) => { const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL; const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0] + const [isLoading, setLoading] = useState(true); useEffect(() => { const fetchZoneData = async () => { try { + setLoading(true) const response = await axios.get(`http://${iotApiUrl}/floatinput`); if (response.status === 200) { // console.log("dropdown data:", response.data); setDropDownData(response.data); + setLoading(false); } else { console.log("Unexpected response:", response); } @@ -148,6 +151,7 @@ const BarChartInput = (props: Props) => { onSelect={(selectedData) => handleSelect(inputKey, selectedData)} onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand + isLoading={isLoading} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx index 55ae422..af6f735 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx @@ -21,14 +21,17 @@ const FleetEfficiencyInputComponent = (props: Props) => { const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL; const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0] + const [isLoading, setLoading] = useState(true); useEffect(() => { const fetchZoneData = async () => { try { const response = await axios.get(`http://${iotApiUrl}/floatinput`); + setLoading(true) if (response.status === 200) { // console.log("dropdown data:", response.data); setDropDownData(response.data); + setLoading(false) } else { console.log("Unexpected response:", response); } @@ -149,6 +152,7 @@ const FleetEfficiencyInputComponent = (props: Props) => { onSelect={(selectedData) => handleSelect(inputKey, selectedData)} onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand + isLoading={isLoading} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx index 1164a84..53ddbcc 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx @@ -21,14 +21,17 @@ const FlotingWidgetInput = (props: Props) => { const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL; const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0] + const [isLoading, setLoading] = useState(true); useEffect(() => { const fetchZoneData = async () => { try { + setLoading(true) const response = await axios.get(`http://${iotApiUrl}/floatinput`); if (response.status === 200) { // console.log("dropdown data:", response.data); setDropDownData(response.data); + setLoading(false); } else { console.log("Unexpected response:", response); } @@ -149,6 +152,7 @@ const FlotingWidgetInput = (props: Props) => { onSelect={(selectedData) => handleSelect(inputKey, selectedData)} onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand + isLoading={isLoading} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx index 6ab5ec3..3cf647e 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx @@ -140,14 +140,17 @@ const LineGrapInput = (props: Props) => { const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL; const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0] + const [isLoading, setLoading] = useState(true); useEffect(() => { const fetchZoneData = async () => { try { + setLoading(true) const response = await axios.get(`http://${iotApiUrl}/floatinput`); if (response.status === 200) { // console.log("dropdown data:", response.data); setDropDownData(response.data); + setLoading(false) } else { console.log("Unexpected response:", response); } @@ -267,6 +270,7 @@ const LineGrapInput = (props: Props) => { onSelect={(selectedData) => handleSelect(inputKey, selectedData)} onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand + isLoading={isLoading} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx index 56ef990..1d16358 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx @@ -21,14 +21,17 @@ const PieChartInput = (props: Props) => { const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL; const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0] + const [isLoading, setLoading] = useState(true); useEffect(() => { const fetchZoneData = async () => { try { + setLoading(true) const response = await axios.get(`http://${iotApiUrl}/floatinput`); if (response.status === 200) { // console.log("dropdown data:", response.data); setDropDownData(response.data); + setLoading(false) } else { console.log("Unexpected response:", response); } @@ -148,6 +151,7 @@ const PieChartInput = (props: Props) => { onSelect={(selectedData) => handleSelect(inputKey, selectedData)} onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand + isLoading={isLoading} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx index cd347b3..5d9dd58 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx @@ -21,14 +21,17 @@ const Progress1Input = (props: Props) => { const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL; const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0] + const [isLoading, setLoading] = useState(true); useEffect(() => { const fetchZoneData = async () => { try { + setLoading(true) const response = await axios.get(`http://${iotApiUrl}/floatinput`); if (response.status === 200) { // console.log("dropdown data:", response.data); setDropDownData(response.data); + setLoading(false) } else { console.log("Unexpected response:", response); } @@ -142,6 +145,7 @@ const Progress1Input = (props: Props) => { onSelect={(selectedData) => handleSelect(inputKey, selectedData)} onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand + isLoading={isLoading} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx index ba56e27..bc6059c 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx @@ -21,14 +21,17 @@ const Progress2Input = (props: Props) => { const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL; const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0] + const [isLoading, setLoading] = useState(true); useEffect(() => { const fetchZoneData = async () => { try { + setLoading(true) const response = await axios.get(`http://${iotApiUrl}/floatinput`); if (response.status === 200) { // console.log("dropdown data:", response.data); setDropDownData(response.data); + setLoading(false) } else { console.log("Unexpected response:", response); } @@ -142,6 +145,7 @@ const Progress2Input = (props: Props) => { onSelect={(selectedData) => handleSelect(inputKey, selectedData)} onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand + isLoading={isLoading} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx index d3ed377..8d5e717 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx @@ -21,14 +21,17 @@ const WarehouseThroughputInputComponent = (props: Props) => { const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL; const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0] + const [isLoading, setLoading] = useState(true); useEffect(() => { const fetchZoneData = async () => { try { + setLoading(true) const response = await axios.get(`http://${iotApiUrl}/floatinput`); if (response.status === 200) { // console.log("dropdown data:", response.data); setDropDownData(response.data); + setLoading(false) } else { console.log("Unexpected response:", response); } @@ -149,6 +152,7 @@ const WarehouseThroughputInputComponent = (props: Props) => { onSelect={(selectedData) => handleSelect(inputKey, selectedData)} onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand + isLoading={isLoading} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx index a32d227..a1b4360 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx @@ -21,14 +21,17 @@ const Widget2InputCard3D = (props: Props) => { const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL; const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0] + const [isLoading, setLoading] = useState(true); useEffect(() => { const fetchZoneData = async () => { try { + setLoading(true) const response = await axios.get(`http://${iotApiUrl}/floatinput`); if (response.status === 200) { // console.log("dropdown data:", response.data); setDropDownData(response.data); + setLoading(false) } else { console.log("Unexpected response:", response); } @@ -147,6 +150,7 @@ const Widget2InputCard3D = (props: Props) => { onSelect={(selectedData) => handleSelect(inputKey, selectedData)} onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand + isLoading={isLoading} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx index 95fdc33..43f8e55 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx @@ -19,14 +19,17 @@ const Widget3InputCard3D = () => { const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL; const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0] + const [isLoading, setLoading] = useState(true); useEffect(() => { const fetchZoneData = async () => { try { + setLoading(true) const response = await axios.get(`http://${iotApiUrl}/getinput`); if (response.status === 200) { // console.log("dropdown data:", response.data); setDropDownData(response.data); + setLoading(false) } else { console.log("Unexpected response:", response); } @@ -140,6 +143,7 @@ const Widget3InputCard3D = () => { onSelect={(selectedData) => handleSelect(inputKey, selectedData)} onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand + isLoading={isLoading} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx index bfd2edd..4aa9855 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx @@ -21,14 +21,17 @@ const Widget4InputCard3D = (props: Props) => { const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL; const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0] + const [isLoading, setLoading] = useState(true); useEffect(() => { const fetchZoneData = async () => { try { + setLoading(true) const response = await axios.get(`http://${iotApiUrl}/floatinput`); if (response.status === 200) { // console.log("dropdown data:", response.data); setDropDownData(response.data); + setLoading(false) } else { console.log("Unexpected response:", response); } @@ -147,6 +150,7 @@ const Widget4InputCard3D = (props: Props) => { onSelect={(selectedData) => handleSelect(inputKey, selectedData)} onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand + isLoading={isLoading} />
diff --git a/app/src/components/ui/inputs/MultiLevelDropDown.tsx b/app/src/components/ui/inputs/MultiLevelDropDown.tsx index f2be121..1293e4a 100644 --- a/app/src/components/ui/inputs/MultiLevelDropDown.tsx +++ b/app/src/components/ui/inputs/MultiLevelDropDown.tsx @@ -203,6 +203,7 @@ interface MultiLevelDropdownProps { onSelect: (selectedData: { name: string; fields: string }) => void; onUnselect: () => void; selectedValue?: { name: string; fields: string }; + isLoading?: boolean; } // Main Multi-Level Dropdown Component @@ -211,6 +212,7 @@ const MultiLevelDropdown = ({ onSelect, onUnselect, selectedValue, + isLoading = false, }: MultiLevelDropdownProps) => { const [open, setOpen] = useState(false); const dropdownRef = useRef(null); @@ -261,19 +263,22 @@ const MultiLevelDropdown = ({
{/* loading list */} - {/*
*/} + {/* Unselect Option */} {/* Nested Dropdown Items */} - {Object.entries(data).map(([key, value]) => ( - - ))} + { + isLoading ?
: + Object.entries(data).map(([key, value]) => ( + + )) + }
)} diff --git a/app/src/modules/visualization/widgets/2d/DraggableWidget.tsx b/app/src/modules/visualization/widgets/2d/DraggableWidget.tsx index 7e6ad6d..f865719 100644 --- a/app/src/modules/visualization/widgets/2d/DraggableWidget.tsx +++ b/app/src/modules/visualization/widgets/2d/DraggableWidget.tsx @@ -100,6 +100,8 @@ export const DraggableWidget = ({ const deleteSelectedChart = async () => { try { + console.log("delete"); + const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0]; let deleteWidget = { @@ -109,7 +111,9 @@ export const DraggableWidget = ({ }; if (visualizationSocket) { + setSelectedChartId(null) visualizationSocket.emit("v2:viz-widget:delete", deleteWidget); + console.log("delete widget",selectedChartId); } const updatedWidgets = selectedZone.widgets.filter( (w: Widget) => w.id !== widget.id @@ -120,7 +124,6 @@ export const DraggableWidget = ({ widgets: updatedWidgets, })); setOpenKebabId(null); - // const response = await deleteWidgetApi(widget.id, organization); // if (response?.message === "Widget deleted successfully") { // const updatedWidgets = selectedZone.widgets.filter( @@ -175,6 +178,7 @@ export const DraggableWidget = ({ const duplicatedWidget: Widget = { ...widget, + title: name === '' ? widget.title : name, Data: { duration: duration, measurements: { ...measurements }, @@ -187,6 +191,7 @@ export const DraggableWidget = ({ zoneId: selectedZone.zoneId, widget: duplicatedWidget, }; + if (visualizationSocket) { visualizationSocket.emit("v2:viz-widget:add", duplicateWidget); } @@ -306,7 +311,10 @@ export const DraggableWidget = ({ : undefined, }} ref={chartWidget} - onClick={() => setSelectedChartId(widget)} + onClick={() => {setSelectedChartId(widget) + console.log('click'); + + }} > {/* Kebab Icon */}
@@ -327,7 +335,10 @@ export const DraggableWidget = ({
Duplicate
-
+
{ + e.stopPropagation() + deleteSelectedChart(); + }}>
diff --git a/app/src/store/useDroppedObjectsStore.ts b/app/src/store/useDroppedObjectsStore.ts index ca39d9f..0c03eec 100644 --- a/app/src/store/useDroppedObjectsStore.ts +++ b/app/src/store/useDroppedObjectsStore.ts @@ -101,6 +101,7 @@ export const useDroppedObjectsStore = create((set) => ({ let visualizationSocket = socketState.visualizationSocket; let iotMeasurements = iotData.flotingMeasurements; let iotDuration = iotData.flotingDuration; + let iotHeader = iotData.header if (!zone) return; @@ -117,6 +118,7 @@ export const useDroppedObjectsStore = create((set) => ({ measurements: iotMeasurements, duration: iotDuration, }, + header: iotHeader, id: `${originalObject.id}-copy-${Date.now()}`, // Unique ID position: { ...originalObject.position,