diff --git a/api/schema-client.ts b/api/schema-client.ts index 2886527..1c3a8bb 100644 --- a/api/schema-client.ts +++ b/api/schema-client.ts @@ -57,8 +57,6 @@ export class SchemaClient { } } - console.log('context', this.context, context) - let url = `${this.baseUrl}${schema.url}` let {url: preparedUrl, data: preparedData} = this.processAttributes(url, data) diff --git a/api/sm/requests/get-processes.ts b/api/sm/requests/get-processes.ts index 440bcc1..a20b36a 100644 --- a/api/sm/requests/get-processes.ts +++ b/api/sm/requests/get-processes.ts @@ -6,4 +6,5 @@ export enum ProcessesType export interface GetProcessesRequest { type?: ProcessesType + name?: string } diff --git a/components/elements/processes/index.tsx b/components/elements/processes/index.tsx index 9127f4a..1f552c2 100644 --- a/components/elements/processes/index.tsx +++ b/components/elements/processes/index.tsx @@ -10,12 +10,26 @@ import ErrorOutline from "@mui/icons-material/ErrorOutline" import ReplayOutlined from "@mui/icons-material/ReplayOutlined" import RunCircleOutlined from "@mui/icons-material/RunCircleOutlined" import FactCheckOutlined from "@mui/icons-material/FactCheckOutlined" -import {Box, CircularProgress, IconButton, LinearProgress, TableContainer, Table, TableBody, TableCell, TableHead, TableRow, TablePagination} from "@mui/material" +import { + Box, + TextField, + CircularProgress, + IconButton, + LinearProgress, + TableContainer, + Table, + TableBody, + TableCell, + TableHead, + TableRow, + TablePagination, Autocomplete +} from "@mui/material" import ConfirmDialog from "../confirm-dialog"; import smClient from "../../../api/sm/sm-client"; import {ProcessInterface, Status} from "../../../api/sm/responses/processes"; import Command from "../commands/elements/command"; import {CommandInterface} from "../../../api/sm/responses/comamnds"; +import Grid from '@mui/material/Grid'; enum Action { Run, @@ -28,8 +42,11 @@ enum Action { export default function Processes() { const [processes, setProcesses] = useState([]); + const [commands, setCommands] = useState([]); const [page, setPage] = useState(0); const [count, setCount] = useState(0); + const [type, setType] = useState(''); + const [name, setName] = useState(''); const [loading, setLoading] = useState(true); const [modalLoading, setModalLoading] = useState(true); const [action, setAction] = useState(null); @@ -38,13 +55,33 @@ export default function Processes() { const [optionList, setOptionList] = useState>({}); const [argumentList, setArgumentList] = useState>({}); + let variants = commands.map((command: CommandInterface, index: number) => command.name); + + let refreshCommands = async () => { + const { data: commands } = await smClient.useMemory().getCommands() + setCommands(commands) + } + + useEffect(() => { + refreshCommands() + }, []) + let refreshLock = false let refreshProcesses = async () => { if (refreshLock) { return } refreshLock = true + + let data: any = {} + if (type && type !== 'None') { + data['type'] = type.toLowerCase() + } + if (!!name) { + data['name'] = name + } const { data: processes, headers } = await smClient.getProcesses({ + ...data, page: page + 1, limit: 20, }) @@ -68,7 +105,7 @@ export default function Processes() { useEffect(() => { const timer = setInterval(() => refreshProcesses(), 1000) return () => clearInterval(timer); - }, [page]); + }, [page, name, type]); useEffect(() => { if (action === null) { @@ -133,6 +170,32 @@ export default function Processes() { return ( <> +
+ + + { + setType(newValue); + }} + disablePortal + options={['None', "Running", "History"]} + renderInput={(params) => } + /> + + + { + setName(newValue || ''); + }} + disablePortal + options={variants} + renderInput={(params) => } + /> + +