Добавил иконку отображающую заблокирован ли процесс
Добавил возможность разблокировать
This commit is contained in:
parent
4dadbec6e8
commit
3e8f3943dc
3
api/sm/requests/unlock-process.ts
Normal file
3
api/sm/requests/unlock-process.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export interface UnlockProcessRequest {
|
||||
id: string
|
||||
}
|
@ -38,6 +38,7 @@ export interface ProcessInterface {
|
||||
canStop: boolean
|
||||
canKill: boolean
|
||||
canApprove: boolean
|
||||
canUnlock: boolean
|
||||
}
|
||||
|
||||
export enum Status {
|
||||
|
10
api/sm/schemas/unlock-process.ts
Normal file
10
api/sm/schemas/unlock-process.ts
Normal file
@ -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
|
@ -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<ResponseInterface<CommandInterface[]>> {
|
||||
@ -62,6 +64,14 @@ export class SMClient extends SchemaClient {
|
||||
}
|
||||
}
|
||||
|
||||
async unlockProcess(data: UnlockProcessRequest): Promise<ResponseInterface> {
|
||||
let { responseData, headers } = await this.send(unlockProcessSchema, data)
|
||||
return {
|
||||
data: responseData as ProcessInterface[],
|
||||
headers: headers
|
||||
}
|
||||
}
|
||||
|
||||
async repeatProcess(data: RepeatProcessRequest): Promise<ResponseInterface> {
|
||||
let { responseData, headers } = await this.send(repeatProcessSchema, data)
|
||||
return {
|
||||
|
@ -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 && <IconButton title={`Wait`} aria-label="Wait">
|
||||
<HourglassEmptyOutlined/>
|
||||
</IconButton>}
|
||||
{process.lock && <IconButton title={`Locked`} aria-label="Locked">
|
||||
<LockOutlined/>
|
||||
</IconButton>}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{process.canUnlock && token?.permissions.indexOf('unlock_process') > -1 && <IconButton onClick={() => openDialog(process, Action.Unlock)} title={`Unlock`} aria-label="Unlock">
|
||||
<LockOpenOutlined/>
|
||||
</IconButton>}
|
||||
{process.canApprove && token?.permissions.indexOf('approve_process') > -1 && <IconButton onClick={() => openDialog(process, Action.Approve)} title={`Approve`} aria-label="Approve">
|
||||
<ThumbUpAltOutlined/>
|
||||
</IconButton>}
|
||||
{process.canRepeat && <IconButton onClick={() => openDialog(process, Action.Repeat)} title={`Repeat`} aria-label="Repeat">
|
||||
{process.canRepeat && token?.permissions.indexOf('run_command') > -1 && <IconButton onClick={() => openDialog(process, Action.Repeat)} title={`Repeat`} aria-label="Repeat">
|
||||
<ReplayOutlined/>
|
||||
</IconButton>}
|
||||
{process.canKill && <IconButton onClick={() => openDialog(process, Action.Kill)} title={`Kill`} aria-label="Kill">
|
||||
{process.canKill && token?.permissions.indexOf('kill_process') > -1 && <IconButton onClick={() => openDialog(process, Action.Kill)} title={`Kill`} aria-label="Kill">
|
||||
<DeleteForeverOutlined/>
|
||||
</IconButton>}
|
||||
{process?.outputId && <IconButton title={`Output`} onClick={() => output(process)} aria-label="Output">
|
||||
@ -324,6 +340,13 @@ export default function Processes() {
|
||||
closeCallback={() => {setAction(null)}}>
|
||||
Approve?
|
||||
</ConfirmDialog>}
|
||||
{selectedProcess && <ConfirmDialog
|
||||
title={selectedProcess.name}
|
||||
open={Action.Unlock === action}
|
||||
agreeCallback={agreeCallback}
|
||||
closeCallback={() => {setAction(null)}}>
|
||||
Unlock?
|
||||
</ConfirmDialog>}
|
||||
{selectedProcess && <ConfirmDialog
|
||||
title={`Are you sure?`}
|
||||
open={ !!action && ([Action.Play, Action.Pause, Action.Stop, Action.Kill].indexOf(action) > -1) }
|
||||
|
Loading…
Reference in New Issue
Block a user