ui #59

Merged
Vishnu merged 3 commits from ui into main 2025-04-11 13:17:51 +00:00
7 changed files with 68 additions and 31 deletions
Showing only changes of commit 87d73894fe - Show all commits

View File

@@ -26,8 +26,12 @@ const Templates = () => {
templateData(); templateData();
}, []); }, []);
const handleDeleteTemplate = async (id: string) => { const handleDeleteTemplate = async (
e: React.MouseEvent<HTMLButtonElement>,
id: string
) => {
try { try {
e.stopPropagation();
const email = localStorage.getItem("email") || ""; const email = localStorage.getItem("email") || "";
const organization = email?.split("@")[1]?.split(".")[0]; const organization = email?.split("@")[1]?.split(".")[0];
let deleteTemplate = { let deleteTemplate = {
@@ -108,7 +112,7 @@ const Templates = () => {
<RenameInput value={`Template ${index + 1}`} /> <RenameInput value={`Template ${index + 1}`} />
</div> </div>
<button <button
onClick={() => handleDeleteTemplate(template.id)} onClick={(e) => handleDeleteTemplate(e, template.id)}
className="delete-button" className="delete-button"
aria-label="Delete template" aria-label="Delete template"
> >

View File

@@ -33,7 +33,7 @@ const WidgetsFloating = () => {
}; };
return ( return (
<div className="floatingWidgets-wrapper"> <div className="floatingWidgets-wrapper widgets-wrapper">
{/* {widgets.map((widget) => ( {/* {widgets.map((widget) => (
<div <div
key={widget.id} key={widget.id}
@@ -48,24 +48,28 @@ const WidgetsFloating = () => {
<SimpleCard <SimpleCard
header={"Todays Earnings"} header={"Todays Earnings"}
icon={WalletIcon} icon={WalletIcon}
iconName={"WalletIcon"}
value={"$53,000"} value={"$53,000"}
per={"+55%"} per={"+55%"}
/> />
<SimpleCard <SimpleCard
header={"Todays Users"} header={"Todays Users"}
icon={GlobeIcon} icon={GlobeIcon}
iconName={"GlobeIcon"}
value={"1,200"} value={"1,200"}
per={"+30%"} per={"+30%"}
/> />
<SimpleCard <SimpleCard
header={"New Clients"} header={"New Clients"}
icon={DocumentIcon} icon={DocumentIcon}
iconName={"DocumentIcon"}
value={"250"} value={"250"}
per={"+12%"} per={"+12%"}
/> />
<SimpleCard <SimpleCard
header={"Total Sales"} header={"Total Sales"}
icon={CartIcon} icon={CartIcon}
iconName={"CartIcon"}
value={"$150,000"} value={"$150,000"}
per={"+20%"} per={"+20%"}
/>{" "} />{" "}

View File

@@ -89,16 +89,7 @@ export const DraggableWidget = ({
const chartWidget = useRef<HTMLDivElement>(null); const chartWidget = useRef<HTMLDivElement>(null);
OuterClick({
contextClassName: [
"chart-container",
"floating",
"sidebar-right-wrapper",
"card",
"dropdown-menu",
],
setMenuVisible: () => setSelectedChartId(null),
});
const deleteSelectedChart = async () => { const deleteSelectedChart = async () => {
try { try {

View File

@@ -117,6 +117,7 @@ const DroppedObjects: React.FC = () => {
const zoneEntries = Object.entries(zones); const zoneEntries = Object.entries(zones);
if (zoneEntries.length === 0) return null; if (zoneEntries.length === 0) return null;
const [zoneName, zone] = zoneEntries[0]; const [zoneName, zone] = zoneEntries[0];
console.log('zone: ', zone);
function handleDuplicate(zoneName: string, index: number) { function handleDuplicate(zoneName: string, index: number) {
setOpenKebabId(null); setOpenKebabId(null);
@@ -560,7 +561,7 @@ const DroppedObjects: React.FC = () => {
key={`${zoneName}-${index}`} key={`${zoneName}-${index}`}
className={`${obj.className} ${ className={`${obj.className} ${
selectedChartId?.id === obj.id && "activeChart" selectedChartId?.id === obj.id && "activeChart"
}`} } `}
ref={chartWidget} ref={chartWidget}
style={{ style={{
position: "absolute", position: "absolute",
@@ -569,7 +570,9 @@ const DroppedObjects: React.FC = () => {
right: rightPosition, right: rightPosition,
bottom: bottomPosition, bottom: bottomPosition,
pointerEvents: isPlaying ? "none" : "auto", pointerEvents: isPlaying ? "none" : "auto",
minHeight: `${obj.className === "warehouseThroughput" && "150px !important"} ` minHeight: `${
obj.className === "warehouseThroughput" && "150px !important"
} `,
}} }}
onPointerDown={(event) => { onPointerDown={(event) => {
setSelectedChartId(obj); setSelectedChartId(obj);

View File

@@ -7,7 +7,10 @@ import DisplayZone from "./DisplayZone";
import Scene from "../../../modules/scene/scene"; import Scene from "../../../modules/scene/scene";
import useModuleStore from "../../../store/useModuleStore"; import useModuleStore from "../../../store/useModuleStore";
import { useDroppedObjectsStore, useFloatingWidget } from "../../../store/useDroppedObjectsStore"; import {
useDroppedObjectsStore,
useFloatingWidget,
} from "../../../store/useDroppedObjectsStore";
import { import {
useAsset3dWidget, useAsset3dWidget,
useSocketStore, useSocketStore,
@@ -29,6 +32,8 @@ import {
useRightSelected, useRightSelected,
} from "../../../store/useZone3DWidgetStore"; } from "../../../store/useZone3DWidgetStore";
import Dropped3dWidgets from "./Dropped3dWidget"; import Dropped3dWidgets from "./Dropped3dWidget";
import OuterClick from "../../../utils/outerClick";
import { useWidgetStore } from "../../../store/useWidgetStore";
type Side = "top" | "bottom" | "left" | "right"; type Side = "top" | "bottom" | "left" | "right";
@@ -74,10 +79,22 @@ const RealTimeVisulization: React.FC = () => {
const [openConfirmationPopup, setOpenConfirmationPopup] = useState(false); const [openConfirmationPopup, setOpenConfirmationPopup] = useState(false);
// const [floatingWidgets, setFloatingWidgets] = useState<Record<string, { zoneName: string; zoneId: string; objects: any[] }>>({}); // const [floatingWidgets, setFloatingWidgets] = useState<Record<string, { zoneName: string; zoneId: string; objects: any[] }>>({});
const { floatingWidget, setFloatingWidget } = useFloatingWidget() const { floatingWidget, setFloatingWidget } = useFloatingWidget();
const { widgetSelect, setWidgetSelect } = useAsset3dWidget(); const { widgetSelect, setWidgetSelect } = useAsset3dWidget();
const { widgetSubOption, setWidgetSubOption } = useWidgetSubOption(); const { widgetSubOption, setWidgetSubOption } = useWidgetSubOption();
const { visualizationSocket } = useSocketStore(); const { visualizationSocket } = useSocketStore();
const { setSelectedChartId } = useWidgetStore();
OuterClick({
contextClassName: [
"chart-container",
"floating",
"sidebar-right-wrapper",
"card",
"dropdown-menu",
],
setMenuVisible: () => setSelectedChartId(null),
});
useEffect(() => { useEffect(() => {
async function GetZoneData() { async function GetZoneData() {
@@ -85,7 +102,7 @@ const RealTimeVisulization: React.FC = () => {
const organization = email?.split("@")[1]?.split(".")[0]; const organization = email?.split("@")[1]?.split(".")[0];
try { try {
const response = await getZone2dData(organization); const response = await getZone2dData(organization);
console.log('response: ', response); console.log("response: ", response);
if (!Array.isArray(response)) { if (!Array.isArray(response)) {
return; return;
@@ -107,7 +124,7 @@ const RealTimeVisulization: React.FC = () => {
{} {}
); );
setZonesData(formattedData); setZonesData(formattedData);
} catch (error) { } } catch (error) {}
} }
GetZoneData(); GetZoneData();
@@ -123,7 +140,7 @@ const RealTimeVisulization: React.FC = () => {
activeSides: selectedZone.activeSides || [], activeSides: selectedZone.activeSides || [],
panelOrder: selectedZone.panelOrder || [], panelOrder: selectedZone.panelOrder || [],
lockedPanels: selectedZone.lockedPanels || [], lockedPanels: selectedZone.lockedPanels || [],
points:selectedZone.points||[], points: selectedZone.points || [],
zoneId: selectedZone.zoneId || "", zoneId: selectedZone.zoneId || "",
zoneViewPortTarget: selectedZone.zoneViewPortTarget || [], zoneViewPortTarget: selectedZone.zoneViewPortTarget || [],
zoneViewPortPosition: selectedZone.zoneViewPortPosition || [], zoneViewPortPosition: selectedZone.zoneViewPortPosition || [],
@@ -196,7 +213,7 @@ const RealTimeVisulization: React.FC = () => {
`Objects for Zone ID: ${selectedZone.zoneId}`, `Objects for Zone ID: ${selectedZone.zoneId}`,
currentZone.objects currentZone.objects
); );
setFloatingWidget(currentZone.objects) setFloatingWidget(currentZone.objects);
} else { } else {
console.warn("Zone not found or mismatched zoneId"); console.warn("Zone not found or mismatched zoneId");
} }
@@ -211,9 +228,7 @@ const RealTimeVisulization: React.FC = () => {
// } // }
// Update floating widgets state // Update floating widgets state
} catch (error) {}
} catch (error) { }
}; };
useEffect(() => { useEffect(() => {

View File

@@ -2,7 +2,8 @@ import React from "react";
interface SimpleCardProps { interface SimpleCardProps {
header: string; header: string;
icon: React.ComponentType<React.SVGProps<SVGSVGElement>>; // React component for SVG icon icon: React.ElementType; // React component for SVG icon
iconName?: string;
value: string; value: string;
per: string; // Percentage change per: string; // Percentage change
position?: [number, number]; position?: [number, number];
@@ -11,23 +12,25 @@ interface SimpleCardProps {
const SimpleCard: React.FC<SimpleCardProps> = ({ const SimpleCard: React.FC<SimpleCardProps> = ({
header, header,
icon: Icon, icon: Icon,
iconName,
value, value,
per, per,
position = [0, 0], position = [0, 0],
}) => { }) => {
const handleDragStart = (event: React.DragEvent<HTMLDivElement>) => { const handleDragStart = (event: React.DragEvent<HTMLDivElement>) => {
const rect = event.currentTarget.getBoundingClientRect(); // Get position const rect = event.currentTarget.getBoundingClientRect(); // Get position
const cardData = JSON.stringify({ const cardData = JSON.stringify({
header, header,
value, value,
per, per,
icon: Icon, iconName: iconName || "UnknownIcon", // Use the custom iconName
className: event.currentTarget.className, className: event.currentTarget.className,
position: [rect.top, rect.left], // ✅ Store position position: [rect.top, rect.left], // ✅ Store position
}); });
event.dataTransfer.setData("text/plain", cardData); event.dataTransfer.setData("text/plain", cardData);
console.log("cardData: ", cardData);
}; };
return ( return (

View File

@@ -4,7 +4,12 @@ import useChartStore from "../../../../store/useChartStore";
import { useWidgetStore } from "../../../../store/useWidgetStore"; import { useWidgetStore } from "../../../../store/useWidgetStore";
import axios from "axios"; import axios from "axios";
import io from "socket.io-client"; import io from "socket.io-client";
import { WalletIcon } from "../../../icons/3dChartIcons"; import {
CartIcon,
DocumentIcon,
GlobeIcon,
WalletIcon,
} from "../../../icons/3dChartIcons";
const TotalCardComponent = ({ object }: any) => { const TotalCardComponent = ({ object }: any) => {
const [progress, setProgress] = useState<any>(0); const [progress, setProgress] = useState<any>(0);
@@ -77,6 +82,20 @@ const TotalCardComponent = ({ object }: any) => {
} }
}, [header, flotingDuration, flotingMeasurements]); }, [header, flotingDuration, flotingMeasurements]);
const mapIcon = (iconName: string) => {
switch (iconName) {
case "WalletIcon":
return <WalletIcon />;
case "GlobeIcon":
return <GlobeIcon />;
case "DocumentIcon":
return <DocumentIcon />;
case "CartIcon":
return <CartIcon />;
default:
return <WalletIcon />;
}
};
return ( return (
<> <>
<div className="header-wrapper"> <div className="header-wrapper">
@@ -86,9 +105,7 @@ const TotalCardComponent = ({ object }: any) => {
<div className="per">{object.per}</div> <div className="per">{object.per}</div>
</div> </div>
</div> </div>
<div className="icon"> <div className="icon">{mapIcon(object.iconName)}</div>
<WalletIcon />
</div>
</> </>
); );
}; };