Добавил фильтры
This commit is contained in:
parent
0a5dc77b97
commit
72772e6304
@ -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)
|
||||
|
||||
|
@ -6,4 +6,5 @@ export enum ProcessesType
|
||||
|
||||
export interface GetProcessesRequest {
|
||||
type?: ProcessesType
|
||||
name?: string
|
||||
}
|
||||
|
@ -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<ProcessInterface[]>([]);
|
||||
const [commands, setCommands] = useState<CommandInterface[]>([]);
|
||||
const [page, setPage] = useState<number>(0);
|
||||
const [count, setCount] = useState<number>(0);
|
||||
const [type, setType] = useState<string | null>('');
|
||||
const [name, setName] = useState<string | null>('');
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [modalLoading, setModalLoading] = useState<boolean>(true);
|
||||
const [action, setAction] = useState<Action | null>(null);
|
||||
@ -38,13 +55,33 @@ export default function Processes() {
|
||||
const [optionList, setOptionList] = useState<Record<string, any>>({});
|
||||
const [argumentList, setArgumentList] = useState<Record<string, any>>({});
|
||||
|
||||
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 (
|
||||
<>
|
||||
<br/>
|
||||
<Grid container>
|
||||
<Grid item xs={1}>
|
||||
<Autocomplete
|
||||
value={type}
|
||||
onChange={(event: any, newValue: string | null) => {
|
||||
setType(newValue);
|
||||
}}
|
||||
disablePortal
|
||||
options={['None', "Running", "History"]}
|
||||
renderInput={(params) => <TextField {...params} label="Type"/>}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={3}>
|
||||
<Autocomplete
|
||||
sx={{marginLeft: 5}}
|
||||
value={name}
|
||||
onChange={(event: any, newValue: string | null) => {
|
||||
setName(newValue || '');
|
||||
}}
|
||||
disablePortal
|
||||
options={variants}
|
||||
renderInput={(params) => <TextField {...params} label="Commands"/>}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<TableContainer>
|
||||
<Table>
|
||||
<TableHead>
|
||||
|
Loading…
Reference in New Issue
Block a user