diff --git a/api/sm/requests/unlock-process.ts b/api/sm/requests/unlock-process.ts new file mode 100644 index 0000000..30976b8 --- /dev/null +++ b/api/sm/requests/unlock-process.ts @@ -0,0 +1,3 @@ +export interface UnlockProcessRequest { + id: string +} diff --git a/api/sm/responses/processes.ts b/api/sm/responses/processes.ts index d7ad115..9108171 100644 --- a/api/sm/responses/processes.ts +++ b/api/sm/responses/processes.ts @@ -38,6 +38,7 @@ export interface ProcessInterface { canStop: boolean canKill: boolean canApprove: boolean + canUnlock: boolean } export enum Status { diff --git a/api/sm/schemas/unlock-process.ts b/api/sm/schemas/unlock-process.ts new file mode 100644 index 0000000..f15ad31 --- /dev/null +++ b/api/sm/schemas/unlock-process.ts @@ -0,0 +1,10 @@ +import {Method, SchemaInterface} from "../../schema-client"; + +class UnlockProcessSchema implements SchemaInterface { + method = Method.POST + url = '/system-monitoring/processes/{id}/unlock' + contentType = null +} + +export let unlockProcessSchema = new UnlockProcessSchema() +export default unlockProcessSchema diff --git a/api/sm/sm-client.ts b/api/sm/sm-client.ts index 4d23373..4e4263e 100644 --- a/api/sm/sm-client.ts +++ b/api/sm/sm-client.ts @@ -18,6 +18,8 @@ import pauseProcessSchema from "./schemas/pause-process"; import stopProcessSchema from "./schemas/stop-process"; import killProcessSchema from "./schemas/kill-process"; import commandSchema from "./schemas/command"; +import {UnlockProcessRequest} from "./requests/unlock-process"; +import unlockProcessSchema from "./schemas/unlock-process"; export class SMClient extends SchemaClient { async getCommands(): Promise> { @@ -62,6 +64,14 @@ export class SMClient extends SchemaClient { } } + async unlockProcess(data: UnlockProcessRequest): Promise { + let { responseData, headers } = await this.send(unlockProcessSchema, data) + return { + data: responseData as ProcessInterface[], + headers: headers + } + } + async repeatProcess(data: RepeatProcessRequest): Promise { let { responseData, headers } = await this.send(repeatProcessSchema, data) return { diff --git a/components/elements/processes/index.tsx b/components/elements/processes/index.tsx index a73999c..45ff3d8 100644 --- a/components/elements/processes/index.tsx +++ b/components/elements/processes/index.tsx @@ -11,6 +11,9 @@ import ReplayOutlined from "@mui/icons-material/ReplayOutlined" import RunCircleOutlined from "@mui/icons-material/RunCircleOutlined" import FactCheckOutlined from "@mui/icons-material/FactCheckOutlined" import ThumbUpAltOutlined from '@mui/icons-material/ThumbUpAltOutlined' +import LockOutlined from '@mui/icons-material/LockOutlined'; +import LockOpenOutlined from '@mui/icons-material/LockOpenOutlined'; + import { Box, TextField, @@ -41,6 +44,7 @@ enum Action { Play, Pause, Approve, + Unlock, } export default function Processes() { @@ -157,6 +161,12 @@ export default function Processes() { }) } + if (action === Action.Unlock) { + await api.unlockProcess({ + id: selectedProcess.id, + }) + } + if (action === Action.Repeat) { await api.repeatProcess({ id: selectedProcess.id, @@ -259,15 +269,21 @@ export default function Processes() { {Status.Wait === process.status && } + {process.lock && + + } + {process.canUnlock && token?.permissions.indexOf('unlock_process') > -1 && openDialog(process, Action.Unlock)} title={`Unlock`} aria-label="Unlock"> + + } {process.canApprove && token?.permissions.indexOf('approve_process') > -1 && openDialog(process, Action.Approve)} title={`Approve`} aria-label="Approve"> } - {process.canRepeat && openDialog(process, Action.Repeat)} title={`Repeat`} aria-label="Repeat"> + {process.canRepeat && token?.permissions.indexOf('run_command') > -1 && openDialog(process, Action.Repeat)} title={`Repeat`} aria-label="Repeat"> } - {process.canKill && openDialog(process, Action.Kill)} title={`Kill`} aria-label="Kill"> + {process.canKill && token?.permissions.indexOf('kill_process') > -1 && openDialog(process, Action.Kill)} title={`Kill`} aria-label="Kill"> } {process?.outputId && output(process)} aria-label="Output"> @@ -324,6 +340,13 @@ export default function Processes() { closeCallback={() => {setAction(null)}}> Approve? } + {selectedProcess && {setAction(null)}}> + Unlock? + } {selectedProcess && -1) }