Refactor logging in simulation handlers to use echo for improved status reporting; update Project component to reflect successful login with success message; enhance sidebar styles with text transformation. #85

Merged
Vishnu merged 1 commits from v2-ui into main 2025-05-10 14:08:17 +00:00
13 changed files with 32 additions and 25 deletions

View File

@ -42,19 +42,21 @@ const SimulationPlayer: React.FC = () => {
if (isReset) {
setTimeout(() => {
setReset(false);
}, 0)
}, 0);
}
}, [isReset, setReset])
}, [isReset, setReset]);
// Button functions
const handleReset = () => {
setReset(true);
setIsPaused(false);
setSpeed(1);
echo.info("Simulation RESET.....");
setPlaySimulation(false); // local state reset
};
const handlePlayStop = () => {
setIsPaused(!isPaused);
echo.warn(`Simulation is ${isPaused ? "Resumed" : "Paused"}`);
setPlaySimulation(!playSimulation);
};
const handleExit = () => {
@ -62,6 +64,7 @@ const SimulationPlayer: React.FC = () => {
setIsPlaying(false);
setIsPaused(false);
setActiveTool("cursor");
echo.info("Exit Simulation");
};
// Slider functions starts
@ -282,10 +285,11 @@ const SimulationPlayer: React.FC = () => {
</div>
{index < intervals.length - 1 && (
<div
className={`line ${progress >= ((index + 1) / totalSegments) * 100
className={`line ${
progress >= ((index + 1) / totalSegments) * 100
? "filled"
: ""
}`}
}`}
></div>
)}
</React.Fragment>
@ -324,8 +328,9 @@ const SimulationPlayer: React.FC = () => {
<div className="custom-slider-wrapper">
<div className="custom-slider">
<button
className={`slider-handle ${isDragging ? "dragging" : ""
}`}
className={`slider-handle ${
isDragging ? "dragging" : ""
}`}
style={{ left: `${calculateHandlePosition()}%` }}
onMouseDown={handleMouseDown}
>

View File

@ -5,7 +5,7 @@ export function useDefaultHandler() {
const { getMaterialById } = useMaterialStore();
const defaultLogStatus = (materialUuid: string, status: string) => {
// console.log(`${materialUuid}, ${status}`);
echo.info(`${materialUuid}, ${status}`);
}
const handleDefault = useCallback((action: ConveyorAction, materialId?: string) => {

View File

@ -34,7 +34,7 @@ export function useDelayHandler() {
}, [isReset, cleanupDelay]);
const delayLogStatus = (materialUuid: string, status: string) => {
// console.log(`${materialUuid}, ${status}`);
echo.info(`${materialUuid}, ${status}`);
};
useFrame(() => {

View File

@ -5,7 +5,7 @@ export function useDespawnHandler() {
const { getMaterialById, removeMaterial } = useMaterialStore();
const deSpawnLogStatus = (materialUuid: string, status: string) => {
// console.log(`${materialUuid}, ${status}`);
echo.info(`${materialUuid}, ${status}`);
}
const handleDespawn = useCallback((action: ConveyorAction, materialId?: string) => {

View File

@ -58,7 +58,7 @@ export function useSpawnHandler() {
}, [isReset, clearAllSpawns]);
const spawnLogStatus = (materialUuid: string, status: string) => {
// console.log(`${materialUuid}, ${status}`);
echo.info(`${materialUuid}, ${status}`);
}
const createNewMaterial = useCallback((materialType: string, action: ConveyorAction) => {

View File

@ -5,7 +5,7 @@ export function useSwapHandler() {
const { getMaterialById, setMaterial } = useMaterialStore();
const swapLogStatus = (materialUuid: string, status: string) => {
// console.log(`${materialUuid}, ${status}`);
echo.info(`${materialUuid}, ${status}`);
}
const handleSwap = useCallback((action: ConveyorAction, materialId?: string) => {

View File

@ -11,7 +11,7 @@ export function useProcessHandler() {
const { selectedProduct } = useSelectedProduct();
const processLogStatus = (materialUuid: string, status: string) => {
// console.log(`${materialUuid}, ${status}`);
echo.log(`${materialUuid}, ${status}`);
}
const handleProcess = useCallback((action: MachineAction, materialId?: string) => {

View File

@ -11,7 +11,7 @@ export function usePickAndPlaceHandler() {
const { selectedProduct } = useSelectedProduct();
const pickAndPlaceLogStatus = (materialUuid: string, status: string) => {
// console.log(`${materialUuid}, ${status}`);
echo.warn(`${materialUuid}, ${status}`);
}
const handlePickAndPlace = useCallback((action: RoboticArmAction, materialId?: string) => {
@ -33,7 +33,7 @@ export function usePickAndPlaceHandler() {
pickAndPlaceLogStatus(material.materialId, `is going to be picked by armBot ${modelUuid}`);
}, [getMaterialById, getModelUuidByActionUuid, addCurrentAction]);
}, [getMaterialById, getModelUuidByActionUuid, selectedProduct.productId, addCurrentAction]);
return {
handlePickAndPlace,

View File

@ -1,5 +1,4 @@
import { useCallback, useState, useEffect, useRef } from "react";
import * as THREE from 'three';
import { useFrame } from "@react-three/fiber";
import { useMaterialStore } from "../../../../../store/simulation/useMaterialStore";
import { useProductStore } from "../../../../../store/simulation/useProductStore";
@ -26,7 +25,7 @@ export function useRetrieveHandler() {
const delayTimerRef = useRef<NodeJS.Timeout | null>(null);
const retrieveLogStatus = (materialUuid: string, status: string) => {
// console.log(`${materialUuid}, ${status}`);
echo.info(`${materialUuid}, ${status}`);
}
const createNewMaterial = useCallback((materialId: string, materialType: string, action: StorageAction) => {
@ -100,7 +99,7 @@ export function useRetrieveHandler() {
if (retrieval.isProcessing) return;
const storageUnit = getStorageUnitById(
getModelUuidByActionUuid(selectedProduct.productId, retrieval.action.actionUuid) || ''
getModelUuidByActionUuid(selectedProduct.productId, retrieval.action.actionUuid) ?? ''
);
if (!storageUnit || storageUnit.currentLoad <= 0) {
@ -124,7 +123,7 @@ export function useRetrieveHandler() {
if (triggeredModel.type === 'roboticArm') {
const armBot = getArmBotById(triggeredModel.modelUuid);
isIdle = armBot && !armBot.isActive && armBot.state === 'idle' && !armBot.currentAction || false;
isIdle = (armBot && !armBot.isActive && armBot.state === 'idle' && !armBot.currentAction) || false;
if (isIdle) {
setActiveRetrievals(prev => {
@ -148,10 +147,11 @@ export function useRetrieveHandler() {
if (material) {
addCurrentAction(
triggeredModel.modelUuid,
retrieval.action.triggers[0].triggeredAsset.triggeredAction?.actionUuid || '',
retrieval.action.triggers[0].triggeredAsset.triggeredAction?.actionUuid ?? '',
material.materialType,
material.materialId
);
retrieveLogStatus(material.materialName, `is being picked by ${armBot?.modelName}`);
}
}
@ -168,10 +168,10 @@ export function useRetrieveHandler() {
} else if (triggeredModel.type === 'vehicle') {
const vehicle = getVehicleById(triggeredModel.modelUuid);
isIdle = vehicle && !vehicle.isActive && vehicle.state === 'idle' && vehicle.isPicking || false;
isIdle = (vehicle && !vehicle.isActive && vehicle.state === 'idle' && vehicle.isPicking) || false;
if (!vehicle) return;
const loadDuration = vehicle.point.action.unLoadDuration;
// const loadDuration = vehicle.point.action.unLoadDuration;
if (isIdle) {
setActiveRetrievals(prev => {
@ -198,6 +198,7 @@ export function useRetrieveHandler() {
updateCurrentLoad(storageUnit.modelUuid, -1)
incrementVehicleLoad(vehicle.modelUuid, 1);
addCurrentMaterial(vehicle.modelUuid, material.materialType, material.materialId);
retrieveLogStatus(material.materialName, `is picked by ${vehicle.modelName}`);
}
}
}

View File

@ -11,7 +11,7 @@ export function useStoreHandler() {
const { selectedProduct } = useSelectedProduct();
const storeLogStatus = (materialUuid: string, status: string) => {
// console.log(`${materialUuid}, ${status}`);
echo.info(`${materialUuid}, ${status}`);
}
const handleStore = useCallback((action: StorageAction, materialId?: string) => {

View File

@ -11,7 +11,7 @@ export function useTravelHandler() {
const { incrementVehicleLoad, addCurrentMaterial } = useVehicleStore();
const travelLogStatus = (materialUuid: string, status: string) => {
// console.log(`${materialUuid}, ${status}`);
echo.info(`${materialUuid}, ${status}`);
}
const handleTravel = useCallback((action: VehicleAction, materialId?: string) => {
@ -29,7 +29,7 @@ export function useTravelHandler() {
travelLogStatus(material.materialId, `is triggering travel from ${modelUuid}`);
}, [getMaterialById, getModelUuidByActionUuid]);
}, [addCurrentMaterial, getMaterialById, getModelUuidByActionUuid, incrementVehicleLoad, selectedProduct.productId]);
return {
handleTravel,

View File

@ -58,7 +58,7 @@ const Project: React.FC = () => {
setOrganization(Organization);
setUserName(name);
}
echo.warn("Log in successful");
echo.success("Log in successful");
} else {
navigate("/");
}

View File

@ -789,6 +789,7 @@
@include flex-space-between;
padding: 6px 12px;
padding-right: 6px;
text-transform: capitalize;
.add-button {
@include flex-center;