task locking
parent
4fceaad245
commit
4211a1a1ac
|
@ -20,6 +20,7 @@ import {
|
||||||
SentMessagesCommands,
|
SentMessagesCommands,
|
||||||
GetDuration,
|
GetDuration,
|
||||||
MyAvatar,
|
MyAvatar,
|
||||||
|
getUserId,
|
||||||
} from "../../utils";
|
} from "../../utils";
|
||||||
import { InfoCircleOutlined } from "@ant-design/icons";
|
import { InfoCircleOutlined } from "@ant-design/icons";
|
||||||
|
|
||||||
|
@ -326,15 +327,19 @@ export default function GroupTasksViewModal({ isOpen }) {
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
{console.log("stepLocked", groupTaskSteps[index].Locked)}
|
||||||
|
|
||||||
<Alert
|
<Alert
|
||||||
message={<b>{getAlertMessage(groupTaskSteps[index].Status)}</b>}
|
message={<b>{getAlertMessage(groupTaskSteps[index].Status)}</b>}
|
||||||
description={
|
description={
|
||||||
groupTaskSteps[index].Status ===
|
groupTaskSteps[index].Status ===
|
||||||
Constants.GROUP_TASKS_STATUS.INPUT_REQUIRED ? (
|
Constants.GROUP_TASKS_STATUS.INPUT_REQUIRED ? (
|
||||||
<InputRequiredHandler
|
<InputRequiredHandler
|
||||||
|
webSocketContext={webSocketContext}
|
||||||
currentGroupTask={currentGroupTask}
|
currentGroupTask={currentGroupTask}
|
||||||
groupTaskParameters={groupTask.parameters}
|
groupTaskParameters={groupTask.parameters}
|
||||||
notificationApi={notificationApi}
|
notificationApi={notificationApi}
|
||||||
|
step={index}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
getGroupTaskStepLog(groupTaskSteps[index].Log)
|
getGroupTaskStepLog(groupTaskSteps[index].Log)
|
||||||
|
@ -493,9 +498,11 @@ export default function GroupTasksViewModal({ isOpen }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function InputRequiredHandler({
|
function InputRequiredHandler({
|
||||||
|
webSocketContext,
|
||||||
currentGroupTask,
|
currentGroupTask,
|
||||||
groupTaskParameters,
|
groupTaskParameters,
|
||||||
notificationApi,
|
notificationApi,
|
||||||
|
step,
|
||||||
}) {
|
}) {
|
||||||
const globalInputs = JSON.parse(currentGroupTask.GlobalInputs);
|
const globalInputs = JSON.parse(currentGroupTask.GlobalInputs);
|
||||||
|
|
||||||
|
@ -508,8 +515,8 @@ function InputRequiredHandler({
|
||||||
).value;
|
).value;
|
||||||
};
|
};
|
||||||
|
|
||||||
const MyFormItem = ({ children, displayName, groupTaskParameter }) => {
|
const getLabel = (displayName, groupTaskParameter) => {
|
||||||
const label = groupTaskParameter.global ? (
|
return groupTaskParameter.global ? (
|
||||||
<>
|
<>
|
||||||
{displayName}
|
{displayName}
|
||||||
<Tag style={{ marginLeft: 6 }} color="purple">
|
<Tag style={{ marginLeft: 6 }} color="purple">
|
||||||
|
@ -519,12 +526,39 @@ function InputRequiredHandler({
|
||||||
) : (
|
) : (
|
||||||
displayName
|
displayName
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
let lastChanges = [];
|
||||||
<Form.Item label={label} required>
|
|
||||||
{children}
|
const onInputChange = (currentGroupTaskId, parameterName) => {
|
||||||
</Form.Item>
|
console.log(
|
||||||
|
"change",
|
||||||
|
|
||||||
|
currentGroupTaskId,
|
||||||
|
parameterName,
|
||||||
|
step
|
||||||
);
|
);
|
||||||
|
|
||||||
|
lastChanges = lastChanges.filter(
|
||||||
|
(lc) => Date.now() - new Date(lc.changeTime) < 3000
|
||||||
|
);
|
||||||
|
|
||||||
|
const lastChange = lastChanges.find((lC) => lC.step === step);
|
||||||
|
|
||||||
|
if (lastChange === undefined) {
|
||||||
|
lastChanges.push({
|
||||||
|
step: step,
|
||||||
|
changeTime: Date.now(),
|
||||||
|
});
|
||||||
|
|
||||||
|
console.warn("lock");
|
||||||
|
|
||||||
|
webSocketContext.SendSocketMessage(SentMessagesCommands.TaskLocking, {
|
||||||
|
lockedByUserId: getUserId(),
|
||||||
|
groupTaskId: currentGroupTaskId,
|
||||||
|
step: step,
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -533,34 +567,50 @@ function InputRequiredHandler({
|
||||||
switch (groupTaskParameter.type) {
|
switch (groupTaskParameter.type) {
|
||||||
case "text":
|
case "text":
|
||||||
return (
|
return (
|
||||||
<MyFormItem
|
<Form.Item
|
||||||
key={"fitem-" + groupTaskParameter.parameterName}
|
key={"fitem-" + groupTaskParameter.parameterName}
|
||||||
displayName={groupTaskParameter.displayName}
|
label={getLabel(
|
||||||
groupTaskParameter={groupTaskParameter}
|
groupTaskParameter.displayName,
|
||||||
children={
|
groupTaskParameter
|
||||||
|
)}
|
||||||
|
required
|
||||||
|
>
|
||||||
<Input
|
<Input
|
||||||
key={"input-" + groupTaskParameter.parameterName}
|
key={"input-" + groupTaskParameter.parameterName}
|
||||||
id={groupTaskParameter.parameterName}
|
id={groupTaskParameter.parameterName}
|
||||||
defaultValue={getDefaultValue(groupTaskParameter)}
|
defaultValue={getDefaultValue(groupTaskParameter)}
|
||||||
/>
|
onChange={() =>
|
||||||
|
onInputChange(
|
||||||
|
currentGroupTask.Id,
|
||||||
|
groupTaskParameter.parameterName
|
||||||
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
</Form.Item>
|
||||||
);
|
);
|
||||||
case "number":
|
case "number":
|
||||||
return (
|
return (
|
||||||
<MyFormItem
|
<Form.Item
|
||||||
key={"fitem-" + groupTaskParameter.parameterName}
|
key={"fitem-" + groupTaskParameter.parameterName}
|
||||||
displayName={groupTaskParameter.displayName}
|
label={getLabel(
|
||||||
groupTaskParameter={groupTaskParameter}
|
groupTaskParameter.displayName,
|
||||||
children={
|
groupTaskParameter
|
||||||
|
)}
|
||||||
|
required
|
||||||
|
>
|
||||||
<InputNumber
|
<InputNumber
|
||||||
key={"fitem-" + groupTaskParameter.parameterName}
|
key={"fitem-" + groupTaskParameter.parameterName}
|
||||||
id={groupTaskParameter.parameterName}
|
id={groupTaskParameter.parameterName}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
defaultValue={getDefaultValue(groupTaskParameter)}
|
defaultValue={getDefaultValue(groupTaskParameter)}
|
||||||
/>
|
onChange={() =>
|
||||||
|
onInputChange(
|
||||||
|
currentGroupTask.Id,
|
||||||
|
groupTaskParameter.parameterName
|
||||||
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
</Form.Item>
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
notificationApi["error"]({
|
notificationApi["error"]({
|
||||||
|
|
|
@ -193,21 +193,14 @@ function GroupGlobalInputs({
|
||||||
currentSelectedModalGroupType,
|
currentSelectedModalGroupType,
|
||||||
notificationApi,
|
notificationApi,
|
||||||
}) {
|
}) {
|
||||||
const MyFormItem = ({ children, displayName }) => {
|
const getLabel = (displayName) => {
|
||||||
return (
|
return (
|
||||||
<Form.Item
|
|
||||||
label={
|
|
||||||
<>
|
<>
|
||||||
{displayName}
|
{displayName}
|
||||||
<Tag style={{ marginLeft: 6 }} color="purple">
|
<Tag style={{ marginLeft: 6 }} color="purple">
|
||||||
Global
|
Global
|
||||||
</Tag>
|
</Tag>
|
||||||
</>
|
</>
|
||||||
}
|
|
||||||
required
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</Form.Item>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -223,31 +216,31 @@ function GroupGlobalInputs({
|
||||||
switch (globalInput.type) {
|
switch (globalInput.type) {
|
||||||
case "text":
|
case "text":
|
||||||
elements.push(
|
elements.push(
|
||||||
<MyFormItem
|
<Form.Item
|
||||||
key={"fitem-" + globalInput.parameterName}
|
key={"fitem-" + globalInput.parameterName}
|
||||||
displayName={globalInput.displayName}
|
label={getLabel(globalInput.displayName)}
|
||||||
children={
|
required
|
||||||
|
>
|
||||||
<Input
|
<Input
|
||||||
key={"input-" + globalInput.parameterName}
|
key={"input-" + globalInput.parameterName}
|
||||||
id={globalInput.parameterName}
|
id={globalInput.parameterName}
|
||||||
/>
|
/>
|
||||||
}
|
</Form.Item>
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "number":
|
case "number":
|
||||||
elements.push(
|
elements.push(
|
||||||
<MyFormItem
|
<Form.Item
|
||||||
key={"fitem-" + globalInput.parameterName}
|
key={"fitem-" + globalInput.parameterName}
|
||||||
displayName={globalInput.displayName}
|
label={getLabel(globalInput.displayName)}
|
||||||
children={
|
required
|
||||||
|
>
|
||||||
<InputNumber
|
<InputNumber
|
||||||
key={"input-" + globalInput.parameterName}
|
key={"input-" + globalInput.parameterName}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
id={globalInput.parameterName}
|
id={globalInput.parameterName}
|
||||||
/>
|
/>
|
||||||
}
|
</Form.Item>
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
13
src/utils.js
13
src/utils.js
|
@ -108,6 +108,7 @@ const ReceivedMessagesCommands = {
|
||||||
UpdateScannerUsedByUserId: 13,
|
UpdateScannerUsedByUserId: 13,
|
||||||
ScanResult: 14,
|
ScanResult: 14,
|
||||||
UpdateScannerLastUsed: 15,
|
UpdateScannerLastUsed: 15,
|
||||||
|
TaskLocked: 16,
|
||||||
};
|
};
|
||||||
|
|
||||||
// commands sent to the backend server
|
// commands sent to the backend server
|
||||||
|
@ -116,6 +117,7 @@ export const SentMessagesCommands = {
|
||||||
TaskFailedTryAgainRunTaskStep: 2,
|
TaskFailedTryAgainRunTaskStep: 2,
|
||||||
TaskContinueTaskStep: 3,
|
TaskContinueTaskStep: 3,
|
||||||
ReloadGroupTasks: 4,
|
ReloadGroupTasks: 4,
|
||||||
|
TaskLocking: 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function WebSocketProvider({
|
export function WebSocketProvider({
|
||||||
|
@ -308,6 +310,17 @@ export function WebSocketProvider({
|
||||||
return newArr;
|
return newArr;
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case ReceivedMessagesCommands.TaskLocked:
|
||||||
|
setGroupTasksSteps((arr) => {
|
||||||
|
const newArr = [...arr];
|
||||||
|
|
||||||
|
newArr[
|
||||||
|
arr.findIndex((arr1) => arr1.GroupTasksId === body.groupTaskId)
|
||||||
|
].Locked = true;
|
||||||
|
|
||||||
|
return newArr;
|
||||||
|
});
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
console.error("unknown command", cmd);
|
console.error("unknown command", cmd);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue