Добавил иконку отображающую заблокирован ли процесс

Добавил возможность разблокировать
jwt
Rinsvent 2 years ago
parent 4dadbec6e8
commit 3e8f3943dc
  1. 3
      api/sm/requests/unlock-process.ts
  2. 1
      api/sm/responses/processes.ts
  3. 10
      api/sm/schemas/unlock-process.ts
  4. 10
      api/sm/sm-client.ts
  5. 27
      components/elements/processes/index.tsx

@ -0,0 +1,3 @@
export interface UnlockProcessRequest {
id: string
}

@ -38,6 +38,7 @@ export interface ProcessInterface {
canStop: boolean canStop: boolean
canKill: boolean canKill: boolean
canApprove: boolean canApprove: boolean
canUnlock: boolean
} }
export enum Status { export enum Status {

@ -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 stopProcessSchema from "./schemas/stop-process";
import killProcessSchema from "./schemas/kill-process"; import killProcessSchema from "./schemas/kill-process";
import commandSchema from "./schemas/command"; import commandSchema from "./schemas/command";
import {UnlockProcessRequest} from "./requests/unlock-process";
import unlockProcessSchema from "./schemas/unlock-process";
export class SMClient extends SchemaClient { export class SMClient extends SchemaClient {
async getCommands(): Promise<ResponseInterface<CommandInterface[]>> { 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> { async repeatProcess(data: RepeatProcessRequest): Promise<ResponseInterface> {
let { responseData, headers } = await this.send(repeatProcessSchema, data) let { responseData, headers } = await this.send(repeatProcessSchema, data)
return { return {

@ -11,6 +11,9 @@ import ReplayOutlined from "@mui/icons-material/ReplayOutlined"
import RunCircleOutlined from "@mui/icons-material/RunCircleOutlined" import RunCircleOutlined from "@mui/icons-material/RunCircleOutlined"
import FactCheckOutlined from "@mui/icons-material/FactCheckOutlined" import FactCheckOutlined from "@mui/icons-material/FactCheckOutlined"
import ThumbUpAltOutlined from '@mui/icons-material/ThumbUpAltOutlined' import ThumbUpAltOutlined from '@mui/icons-material/ThumbUpAltOutlined'
import LockOutlined from '@mui/icons-material/LockOutlined';
import LockOpenOutlined from '@mui/icons-material/LockOpenOutlined';
import { import {
Box, Box,
TextField, TextField,
@ -41,6 +44,7 @@ enum Action {
Play, Play,
Pause, Pause,
Approve, Approve,
Unlock,
} }
export default function Processes() { 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) { if (action === Action.Repeat) {
await api.repeatProcess({ await api.repeatProcess({
id: selectedProcess.id, id: selectedProcess.id,
@ -259,15 +269,21 @@ export default function Processes() {
{Status.Wait === process.status && <IconButton title={`Wait`} aria-label="Wait"> {Status.Wait === process.status && <IconButton title={`Wait`} aria-label="Wait">
<HourglassEmptyOutlined/> <HourglassEmptyOutlined/>
</IconButton>} </IconButton>}
{process.lock && <IconButton title={`Locked`} aria-label="Locked">
<LockOutlined/>
</IconButton>}
</TableCell> </TableCell>
<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"> {process.canApprove && token?.permissions.indexOf('approve_process') > -1 && <IconButton onClick={() => openDialog(process, Action.Approve)} title={`Approve`} aria-label="Approve">
<ThumbUpAltOutlined/> <ThumbUpAltOutlined/>
</IconButton>} </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/> <ReplayOutlined/>
</IconButton>} </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/> <DeleteForeverOutlined/>
</IconButton>} </IconButton>}
{process?.outputId && <IconButton title={`Output`} onClick={() => output(process)} aria-label="Output"> {process?.outputId && <IconButton title={`Output`} onClick={() => output(process)} aria-label="Output">
@ -324,6 +340,13 @@ export default function Processes() {
closeCallback={() => {setAction(null)}}> closeCallback={() => {setAction(null)}}>
Approve? Approve?
</ConfirmDialog>} </ConfirmDialog>}
{selectedProcess && <ConfirmDialog
title={selectedProcess.name}
open={Action.Unlock === action}
agreeCallback={agreeCallback}
closeCallback={() => {setAction(null)}}>
Unlock?
</ConfirmDialog>}
{selectedProcess && <ConfirmDialog {selectedProcess && <ConfirmDialog
title={`Are you sure?`} title={`Are you sure?`}
open={ !!action && ([Action.Play, Action.Pause, Action.Stop, Action.Kill].indexOf(action) > -1) } open={ !!action && ([Action.Play, Action.Pause, Action.Stop, Action.Kill].indexOf(action) > -1) }

Loading…
Cancel
Save