Добавил фильтры

jwt
Sipachev Igor 2 years ago
parent 0a5dc77b97
commit 72772e6304
  1. 2
      api/schema-client.ts
  2. 1
      api/sm/requests/get-processes.ts
  3. 67
      components/elements/processes/index.tsx

@ -57,8 +57,6 @@ export class SchemaClient {
} }
} }
console.log('context', this.context, context)
let url = `${this.baseUrl}${schema.url}` let url = `${this.baseUrl}${schema.url}`
let {url: preparedUrl, data: preparedData} = this.processAttributes(url, data) let {url: preparedUrl, data: preparedData} = this.processAttributes(url, data)

@ -6,4 +6,5 @@ export enum ProcessesType
export interface GetProcessesRequest { export interface GetProcessesRequest {
type?: ProcessesType type?: ProcessesType
name?: string
} }

@ -10,12 +10,26 @@ import ErrorOutline from "@mui/icons-material/ErrorOutline"
import ReplayOutlined from "@mui/icons-material/ReplayOutlined" 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 {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 ConfirmDialog from "../confirm-dialog";
import smClient from "../../../api/sm/sm-client"; import smClient from "../../../api/sm/sm-client";
import {ProcessInterface, Status} from "../../../api/sm/responses/processes"; import {ProcessInterface, Status} from "../../../api/sm/responses/processes";
import Command from "../commands/elements/command"; import Command from "../commands/elements/command";
import {CommandInterface} from "../../../api/sm/responses/comamnds"; import {CommandInterface} from "../../../api/sm/responses/comamnds";
import Grid from '@mui/material/Grid';
enum Action { enum Action {
Run, Run,
@ -28,8 +42,11 @@ enum Action {
export default function Processes() { export default function Processes() {
const [processes, setProcesses] = useState<ProcessInterface[]>([]); const [processes, setProcesses] = useState<ProcessInterface[]>([]);
const [commands, setCommands] = useState<CommandInterface[]>([]);
const [page, setPage] = useState<number>(0); const [page, setPage] = useState<number>(0);
const [count, setCount] = 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 [loading, setLoading] = useState<boolean>(true);
const [modalLoading, setModalLoading] = useState<boolean>(true); const [modalLoading, setModalLoading] = useState<boolean>(true);
const [action, setAction] = useState<Action | null>(null); const [action, setAction] = useState<Action | null>(null);
@ -38,13 +55,33 @@ export default function Processes() {
const [optionList, setOptionList] = useState<Record<string, any>>({}); const [optionList, setOptionList] = useState<Record<string, any>>({});
const [argumentList, setArgumentList] = 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 refreshLock = false
let refreshProcesses = async () => { let refreshProcesses = async () => {
if (refreshLock) { if (refreshLock) {
return return
} }
refreshLock = true 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({ const { data: processes, headers } = await smClient.getProcesses({
...data,
page: page + 1, page: page + 1,
limit: 20, limit: 20,
}) })
@ -68,7 +105,7 @@ export default function Processes() {
useEffect(() => { useEffect(() => {
const timer = setInterval(() => refreshProcesses(), 1000) const timer = setInterval(() => refreshProcesses(), 1000)
return () => clearInterval(timer); return () => clearInterval(timer);
}, [page]); }, [page, name, type]);
useEffect(() => { useEffect(() => {
if (action === null) { if (action === null) {
@ -133,6 +170,32 @@ export default function Processes() {
return ( 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> <TableContainer>
<Table> <Table>
<TableHead> <TableHead>

Loading…
Cancel
Save