added new human ui

This commit is contained in:
2025-07-07 10:11:37 +05:30
parent 2feedc7dcb
commit 36421fa70a
10 changed files with 189 additions and 27 deletions

View File

@@ -14,7 +14,7 @@ type ProductsStore = {
// Event-level actions
addEvent: (productUuid: string, event: EventsSchema) => void;
removeEvent: (productUuid: string, modelUuid: string) => void;
deleteEvent: (modelUuid: string) => void;
deleteEvent: (modelUuid: string) => EventsSchema[];
updateEvent: (productUuid: string, modelUuid: string, updates: Partial<EventsSchema>) => EventsSchema | undefined;
// Point-level actions
@@ -145,11 +145,93 @@ export const createProductStore = () => {
},
deleteEvent: (modelUuid) => {
let updatedEvents: EventsSchema[] = [];
set((state) => {
const actionsToDelete = new Set<string>();
for (const product of state.products) {
product.eventDatas = product.eventDatas.filter(e => 'modelUuid' in e && e.modelUuid !== modelUuid);
const eventIndex = product.eventDatas.findIndex(e => 'modelUuid' in e && e.modelUuid === modelUuid);
if (eventIndex !== -1) {
const event = product.eventDatas[eventIndex];
if ('points' in event) {
for (const point of (event as ConveyorEventSchema).points) {
if (point.action) {
actionsToDelete.add(point.action.actionUuid);
}
}
} else if ('point' in event) {
const point = (event as any).point;
if ('action' in point && point.action) {
actionsToDelete.add(point.action.actionUuid);
} else if ('actions' in point) {
for (const action of point.actions) {
actionsToDelete.add(action.actionUuid);
}
}
}
product.eventDatas.splice(eventIndex, 1);
}
}
for (const product of state.products) {
for (const event of product.eventDatas) {
let eventModified = false;
if ('points' in event) {
for (const point of (event as ConveyorEventSchema).points) {
if (point.action?.triggers) {
const originalLength = point.action.triggers.length;
point.action.triggers = point.action.triggers.filter(trigger => {
return !(
(trigger.triggeredAsset?.triggeredModel?.modelUuid === modelUuid) ||
(actionsToDelete.has(trigger.triggeredAsset?.triggeredAction?.actionUuid || ''))
);
});
if (point.action.triggers.length !== originalLength) {
eventModified = true;
}
}
}
} else if ('point' in event) {
const point = (event as any).point;
if ('action' in point && point.action?.triggers) {
const originalLength = point.action.triggers.length;
point.action.triggers = point.action.triggers.filter((trigger: TriggerSchema) => {
return !(
(trigger.triggeredAsset?.triggeredModel?.modelUuid === modelUuid) ||
(actionsToDelete.has(trigger.triggeredAsset?.triggeredAction?.actionUuid || ''))
);
});
if (point.action.triggers.length !== originalLength) {
eventModified = true;
}
} else if ('actions' in point) {
for (const action of point.actions) {
if (action.triggers) {
const originalLength = action.triggers.length;
action.triggers = action.triggers.filter((trigger: TriggerSchema) => {
return !(
(trigger.triggeredAsset?.triggeredModel?.modelUuid === modelUuid) ||
(actionsToDelete.has(trigger.triggeredAsset?.triggeredAction?.actionUuid || ''))
);
});
if (action.triggers.length !== originalLength) {
eventModified = true;
}
}
}
}
}
if (eventModified) {
updatedEvents.push(JSON.parse(JSON.stringify(event)));
}
}
}
});
return updatedEvents;
},
updateEvent: (productUuid, modelUuid, updates) => {