add build status on node
This commit is contained in:
parent
5784940528
commit
196b4d85dc
9 changed files with 75 additions and 33 deletions
|
|
@ -7,6 +7,7 @@ import InputComponent from "../../components/inputComponent";
|
||||||
import { Button } from "../../components/ui/button";
|
import { Button } from "../../components/ui/button";
|
||||||
import { Textarea } from "../../components/ui/textarea";
|
import { Textarea } from "../../components/ui/textarea";
|
||||||
import { priorityFields } from "../../constants/constants";
|
import { priorityFields } from "../../constants/constants";
|
||||||
|
import { BuildStatus } from "../../constants/enums";
|
||||||
import NodeToolbarComponent from "../../pages/FlowPage/components/nodeToolbarComponent";
|
import NodeToolbarComponent from "../../pages/FlowPage/components/nodeToolbarComponent";
|
||||||
import useFlowStore from "../../stores/flowStore";
|
import useFlowStore from "../../stores/flowStore";
|
||||||
import useFlowsManagerStore from "../../stores/flowsManagerStore";
|
import useFlowsManagerStore from "../../stores/flowsManagerStore";
|
||||||
|
|
@ -71,7 +72,6 @@ export default function GenericNode({
|
||||||
|
|
||||||
setHandles(count);
|
setHandles(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
countHandles();
|
countHandles();
|
||||||
}, [data, data.node]);
|
}, [data, data.node]);
|
||||||
|
|
@ -164,8 +164,6 @@ export default function GenericNode({
|
||||||
numberOfHandles={handles}
|
numberOfHandles={handles}
|
||||||
showNode={showNode}
|
showNode={showNode}
|
||||||
openAdvancedModal={false}
|
openAdvancedModal={false}
|
||||||
onCloseAdvancedModal={() => {
|
|
||||||
}}
|
|
||||||
></NodeToolbarComponent>
|
></NodeToolbarComponent>
|
||||||
</NodeToolbar>
|
</NodeToolbar>
|
||||||
|
|
||||||
|
|
@ -410,6 +408,15 @@ export default function GenericNode({
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div className="generic-node-status-position flex items-center justify-center">
|
<div className="generic-node-status-position flex items-center justify-center">
|
||||||
|
{data?.build_status === BuildStatus.TO_BUILD ? (
|
||||||
|
<>
|
||||||
|
<IconComponent
|
||||||
|
name="Square"
|
||||||
|
className="red-status absolute h-5 stroke-1"
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
<IconComponent
|
<IconComponent
|
||||||
name="Play"
|
name="Play"
|
||||||
className={classNames(
|
className={classNames(
|
||||||
|
|
@ -437,6 +444,8 @@ export default function GenericNode({
|
||||||
"absolute h-5 stroke-1"
|
"absolute h-5 stroke-1"
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -6,3 +6,9 @@ export enum TypeModal {
|
||||||
TEXT = 1,
|
TEXT = 1,
|
||||||
PROMPT = 2,
|
PROMPT = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum BuildStatus {
|
||||||
|
BUILDING = "BUILDING",
|
||||||
|
TO_BUILD = "TO_BUILD",
|
||||||
|
BUILDED = "BUILDED",
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,6 @@ export default function FormModal({
|
||||||
if (Array.isArray(data) && data.length > 0) {
|
if (Array.isArray(data) && data.length > 0) {
|
||||||
//set chat history
|
//set chat history
|
||||||
setChatHistory((_) => {
|
setChatHistory((_) => {
|
||||||
console.log(data);
|
|
||||||
let newChatHistory: ChatMessageType[] = [];
|
let newChatHistory: ChatMessageType[] = [];
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
if (data[i].type === "prompt" && data[i].prompt) {
|
if (data[i].type === "prompt" && data[i].prompt) {
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import {
|
||||||
} from "reactflow";
|
} from "reactflow";
|
||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
import { INPUT_TYPES, OUTPUT_TYPES } from "../constants/constants";
|
import { INPUT_TYPES, OUTPUT_TYPES } from "../constants/constants";
|
||||||
|
import { BuildStatus } from "../constants/enums";
|
||||||
import { getFlowPool, updateFlowInDatabase } from "../controllers/API";
|
import { getFlowPool, updateFlowInDatabase } from "../controllers/API";
|
||||||
import {
|
import {
|
||||||
NodeDataType,
|
NodeDataType,
|
||||||
|
|
@ -357,6 +358,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
const setErrorData = useAlertStore.getState().setErrorData;
|
const setErrorData = useAlertStore.getState().setErrorData;
|
||||||
function handleBuildUpdate(data: any) {
|
function handleBuildUpdate(data: any) {
|
||||||
get().addDataToFlowPool(data.data[data.id], data.id);
|
get().addDataToFlowPool(data.data[data.id], data.id);
|
||||||
|
useFlowStore.getState().updateBuildStatus([data.id], BuildStatus.BUILDED);
|
||||||
}
|
}
|
||||||
await updateFlowInDatabase({
|
await updateFlowInDatabase({
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -382,6 +384,9 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
onBuildError: (title, list) => {
|
onBuildError: (title, list) => {
|
||||||
setErrorData({ list, title });
|
setErrorData({ list, title });
|
||||||
},
|
},
|
||||||
|
onBuildStart: (idList) => {
|
||||||
|
useFlowStore.getState().updateBuildStatus(idList, BuildStatus.BUILDING);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getFlow: () => {
|
getFlow: () => {
|
||||||
|
|
@ -391,6 +396,15 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
viewport: get().reactFlowInstance?.getViewport()!,
|
viewport: get().reactFlowInstance?.getViewport()!,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
updateBuildStatus: (nodeIdList: string[], status: BuildStatus) => {
|
||||||
|
nodeIdList.forEach((id) => {
|
||||||
|
const nodeToUpdate = get().nodes.find((node) => node.id === id);
|
||||||
|
if (nodeToUpdate) {
|
||||||
|
nodeToUpdate.data.build_status = status;
|
||||||
|
get().setNodes(get().nodes);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export default useFlowStore;
|
export default useFlowStore;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { Edge, Node, Viewport } from "reactflow";
|
import { Edge, Node, Viewport } from "reactflow";
|
||||||
|
import { BuildStatus } from "../../constants/enums";
|
||||||
import { FlowType } from "../flow";
|
import { FlowType } from "../flow";
|
||||||
//kind and class are just representative names to represent the actual structure of the object received by the API
|
//kind and class are just representative names to represent the actual structure of the object received by the API
|
||||||
export type APIDataType = { [key: string]: APIKindType };
|
export type APIDataType = { [key: string]: APIKindType };
|
||||||
|
|
@ -36,6 +37,7 @@ export type APIClassType = {
|
||||||
| CustomFieldsType
|
| CustomFieldsType
|
||||||
| boolean
|
| boolean
|
||||||
| undefined;
|
| undefined;
|
||||||
|
build_status?: BuildStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TemplateVariableType = {
|
export type TemplateVariableType = {
|
||||||
|
|
|
||||||
|
|
@ -625,7 +625,7 @@ export type crashComponentPropsType = {
|
||||||
|
|
||||||
export type validationStatusType = {
|
export type validationStatusType = {
|
||||||
id: string;
|
id: string;
|
||||||
data: object;
|
data: object | any;
|
||||||
params: string;
|
params: string;
|
||||||
progress: number;
|
progress: number;
|
||||||
valid: boolean;
|
valid: boolean;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { ReactFlowJsonObject, XYPosition } from "reactflow";
|
import { ReactFlowJsonObject, XYPosition } from "reactflow";
|
||||||
|
import { BuildStatus } from "../../constants/enums";
|
||||||
import { APIClassType } from "../api/index";
|
import { APIClassType } from "../api/index";
|
||||||
|
|
||||||
export type FlowType = {
|
export type FlowType = {
|
||||||
|
|
@ -26,6 +27,7 @@ export type NodeDataType = {
|
||||||
node?: APIClassType;
|
node?: APIClassType;
|
||||||
id: string;
|
id: string;
|
||||||
output_types?: string[];
|
output_types?: string[];
|
||||||
|
build_status?: BuildStatus;
|
||||||
};
|
};
|
||||||
// FlowStyleType is the type of the style object that is used to style the
|
// FlowStyleType is the type of the style object that is used to style the
|
||||||
// Flow card with an emoji and a color.
|
// Flow card with an emoji and a color.
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import {
|
||||||
ReactFlowInstance,
|
ReactFlowInstance,
|
||||||
Viewport,
|
Viewport,
|
||||||
} from "reactflow";
|
} from "reactflow";
|
||||||
|
import { BuildStatus } from "../../../constants/enums";
|
||||||
import { FlowState } from "../../tabs";
|
import { FlowState } from "../../tabs";
|
||||||
|
|
||||||
export type chatInputType = {
|
export type chatInputType = {
|
||||||
|
|
@ -84,4 +85,5 @@ export type FlowStoreType = {
|
||||||
unselectAll: () => void;
|
unselectAll: () => void;
|
||||||
buildFlow: (nodeId?: string) => Promise<void>;
|
buildFlow: (nodeId?: string) => Promise<void>;
|
||||||
getFlow: () => { nodes: Node[]; edges: Edge[]; viewport: Viewport };
|
getFlow: () => { nodes: Node[]; edges: Edge[]; viewport: Viewport };
|
||||||
|
updateBuildStatus: (nodeId: string[], status: BuildStatus) => void;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import { AxiosError } from "axios";
|
import { AxiosError } from "axios";
|
||||||
|
import { BuildStatus } from "../constants/enums";
|
||||||
import { getVerticesOrder, postBuildVertex } from "../controllers/API";
|
import { getVerticesOrder, postBuildVertex } from "../controllers/API";
|
||||||
|
import useFlowStore from "../stores/flowStore";
|
||||||
import { VertexBuildTypeAPI } from "../types/api";
|
import { VertexBuildTypeAPI } from "../types/api";
|
||||||
|
|
||||||
type BuildVerticesParams = {
|
type BuildVerticesParams = {
|
||||||
|
|
@ -9,6 +11,7 @@ type BuildVerticesParams = {
|
||||||
onBuildUpdate?: (data: any) => void; // Replace any with the actual type of data
|
onBuildUpdate?: (data: any) => void; // Replace any with the actual type of data
|
||||||
onBuildComplete?: (allNodesValid: boolean) => void;
|
onBuildComplete?: (allNodesValid: boolean) => void;
|
||||||
onBuildError?: (title, list) => void;
|
onBuildError?: (title, list) => void;
|
||||||
|
onBuildStart?: (idList: string[]) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function buildVertices({
|
export async function buildVertices({
|
||||||
|
|
@ -18,10 +21,12 @@ export async function buildVertices({
|
||||||
onBuildUpdate,
|
onBuildUpdate,
|
||||||
onBuildComplete,
|
onBuildComplete,
|
||||||
onBuildError,
|
onBuildError,
|
||||||
|
onBuildStart,
|
||||||
}: BuildVerticesParams) {
|
}: BuildVerticesParams) {
|
||||||
let orderResponse = await getVerticesOrder(flowId);
|
let orderResponse = await getVerticesOrder(flowId);
|
||||||
let verticesOrder: Array<Array<string>> = orderResponse.data.ids;
|
let verticesOrder: Array<Array<string>> = orderResponse.data.ids;
|
||||||
let vertices: Array<Array<string>> = [];
|
let vertices: Array<Array<string>> = [];
|
||||||
|
|
||||||
if (nodeId) {
|
if (nodeId) {
|
||||||
for (let i = 0; i < verticesOrder.length; i += 1) {
|
for (let i = 0; i < verticesOrder.length; i += 1) {
|
||||||
const innerArray = verticesOrder[i];
|
const innerArray = verticesOrder[i];
|
||||||
|
|
@ -40,10 +45,13 @@ export async function buildVertices({
|
||||||
vertices = verticesOrder;
|
vertices = verticesOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set each vertex state to building
|
const verticesIds = vertices.flatMap((v) => v);
|
||||||
|
useFlowStore.getState().updateBuildStatus(verticesIds, BuildStatus.TO_BUILD);
|
||||||
|
|
||||||
|
// Set each vertex state to building
|
||||||
const buildResults: Array<boolean> = [];
|
const buildResults: Array<boolean> = [];
|
||||||
for (let i = 0; i < vertices.length; i += 1) {
|
for (let i = 0; i < vertices.length; i += 1) {
|
||||||
|
if (onBuildStart) onBuildStart(vertices[i]);
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
vertices[i].map(async (id) => {
|
vertices[i].map(async (id) => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue