From 5b8de1adf1b5a8a7ef4d1ac78cfac2b8edc74d3c Mon Sep 17 00:00:00 2001 From: Sipachev Igor Date: Fri, 27 Jan 2023 16:57:28 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3=20=D1=81=D0=B8=D0=B3=D0=BD=D0=B0=D1=82?= =?UTF-8?q?=D1=83=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/sm/responses/comamnds.ts | 12 ++++++++++-- api/sm/responses/processes.ts | 2 +- api/sm/sm-client.ts | 12 ++++++------ .../commands/elements/argument/index.tsx | 9 +-------- .../commands/elements/arguments/index.tsx | 3 ++- .../commands/elements/command/index.tsx | 11 +---------- .../elements/commands/elements/option/index.tsx | 14 +------------- .../commands/elements/options/index.tsx | 3 ++- components/elements/commands/index.tsx | 3 ++- components/elements/processes/index.tsx | 17 +++++++++-------- 10 files changed, 35 insertions(+), 51 deletions(-) diff --git a/api/sm/responses/comamnds.ts b/api/sm/responses/comamnds.ts index 578c6c3..f3ca621 100644 --- a/api/sm/responses/comamnds.ts +++ b/api/sm/responses/comamnds.ts @@ -19,10 +19,18 @@ export interface ArgumentInterface { isRequired: boolean, } -export interface CommandResponseInterface { +export interface ArgumentInterface { + name: string, + description: string|null, + default: any, + isArray: boolean, + isRequired: boolean, +} + +export interface CommandInterface { class: string, name: string, description: string, options: OptionInterface[], arguments: ArgumentInterface[], -} \ No newline at end of file +} diff --git a/api/sm/responses/processes.ts b/api/sm/responses/processes.ts index 95d989e..d08565f 100644 --- a/api/sm/responses/processes.ts +++ b/api/sm/responses/processes.ts @@ -14,7 +14,7 @@ export interface ProcessProgressInterface { percent: number } -export interface ProcessesResponseInterface { +export interface ProcessInterface { id: string lock: string | null containerUuid: string | null diff --git a/api/sm/sm-client.ts b/api/sm/sm-client.ts index 0ba4f32..c173693 100644 --- a/api/sm/sm-client.ts +++ b/api/sm/sm-client.ts @@ -1,10 +1,10 @@ import {processesSchema} from "./schemas/processes"; -import {ProcessesResponseInterface} from "./responses/processes"; +import {ProcessInterface} from "./responses/processes"; import {SchemaClient} from "../schema-client"; import {GetProcessesRequest} from "./requests/get-processes"; import {PaginationRequest} from "./requests/pagination"; import {ResponseInterface} from "./responses/response"; -import {CommandResponseInterface} from "./responses/comamnds"; +import {CommandInterface} from "./responses/comamnds"; import commandsSchema from "./schemas/commands"; import runCommandsSchema from "./schemas/run-commands"; import {RepeatProcessRequest} from "./requests/repeat-process"; @@ -20,7 +20,7 @@ import commandSchema from "./schemas/command"; export class SMClient extends SchemaClient { baseUrl = 'http://fmw.sipachev.sv' - async getCommands(): Promise> { + async getCommands(): Promise> { let { responseData, headers } = await this.send(commandsSchema, {}) return { data: responseData, @@ -28,7 +28,7 @@ export class SMClient extends SchemaClient { } } - async getCommand(name: string): Promise> { + async getCommand(name: string): Promise> { let { responseData, headers } = await this.send(commandSchema, { commandName: name }) @@ -46,7 +46,7 @@ export class SMClient extends SchemaClient { } } - async getProcesses(data: GetProcessesRequest | PaginationRequest): Promise> { + async getProcesses(data: GetProcessesRequest | PaginationRequest): Promise> { let { responseData, headers } = await this.send(processesSchema, data) return { data: responseData, @@ -57,7 +57,7 @@ export class SMClient extends SchemaClient { async repeatProcess(data: RepeatProcessRequest): Promise { let { responseData, headers } = await this.send(repeatProcessSchema, data) return { - data: responseData as ProcessesResponseInterface[], + data: responseData as ProcessInterface[], headers: headers } } diff --git a/components/elements/commands/elements/argument/index.tsx b/components/elements/commands/elements/argument/index.tsx index d5ad791..398daf0 100644 --- a/components/elements/commands/elements/argument/index.tsx +++ b/components/elements/commands/elements/argument/index.tsx @@ -2,14 +2,7 @@ import styles from './styles.module.css' import {useContext, useEffect, useState} from "react"; import Context, {ContextInterface} from "../command/context"; import {TextField} from "@mui/material"; - -export interface ArgumentInterface { - name: string, - description: string|null, - default: any, - isArray: boolean, - isRequired: boolean, -} +import {ArgumentInterface} from "../../../../../api/sm/responses/comamnds"; export default function Argument(argument: ArgumentInterface) { let {argumentList, setArgumentList} = useContext(Context) diff --git a/components/elements/commands/elements/arguments/index.tsx b/components/elements/commands/elements/arguments/index.tsx index 19c13c6..2cbf056 100644 --- a/components/elements/commands/elements/arguments/index.tsx +++ b/components/elements/commands/elements/arguments/index.tsx @@ -1,7 +1,8 @@ import styles from './styles.module.css' import {useContext, useEffect, useState} from "react"; -import Argument, {ArgumentInterface} from "../argument"; +import Argument from "../argument"; import Context, {ContextInterface} from "../command/context"; +import {ArgumentInterface} from "../../../../../api/sm/responses/comamnds"; interface ArgumentsInterface { argumentList: ArgumentInterface[] diff --git a/components/elements/commands/elements/command/index.tsx b/components/elements/commands/elements/command/index.tsx index 147bb9a..828423d 100644 --- a/components/elements/commands/elements/command/index.tsx +++ b/components/elements/commands/elements/command/index.tsx @@ -1,18 +1,9 @@ import styles from './styles.module.css' import Options from "../options"; import Arguments from "../arguments"; -import {OptionInterface} from "../option"; -import {ArgumentInterface} from "../argument"; import {Provider} from "./context"; import {useEffect, useState} from "react"; - -export interface CommandInterface { - class: string, - name: string, - description: string, - options: OptionInterface[], - arguments: ArgumentInterface[], -} +import {CommandInterface} from "../../../../../api/sm/responses/comamnds"; interface CommandComponentInterface { command: CommandInterface, diff --git a/components/elements/commands/elements/option/index.tsx b/components/elements/commands/elements/option/index.tsx index 6454ea3..4c3886b 100644 --- a/components/elements/commands/elements/option/index.tsx +++ b/components/elements/commands/elements/option/index.tsx @@ -2,19 +2,7 @@ import styles from './styles.module.css' import {useContext} from "react"; import Context, {ContextInterface} from "../command/context"; import {TextField} from "@mui/material"; - -export interface OptionInterface { - name: string, - description: string | null, - default: any, - value: any, - shortcut: string | null, - isArray: boolean, - isNegatable: boolean, - isValueOptional: boolean, - isValueRequired: boolean - acceptValue: boolean -} +import {OptionInterface} from "../../../../../api/sm/responses/comamnds"; export default function Option(option: OptionInterface) { let {optionList: ol, setOptionList} = useContext(Context) diff --git a/components/elements/commands/elements/options/index.tsx b/components/elements/commands/elements/options/index.tsx index 6ba06ac..a8d603f 100644 --- a/components/elements/commands/elements/options/index.tsx +++ b/components/elements/commands/elements/options/index.tsx @@ -1,8 +1,9 @@ import styles from './styles.module.css' -import Option, {OptionInterface} from '../option' +import Option from '../option' import {useContext, useEffect, useState} from "react"; import Context, {ContextInterface} from "../command/context"; import {Select, OutlinedInput, FormControl, MenuItem, Checkbox, ListItemText} from "@mui/material"; +import {OptionInterface} from "../../../../../api/sm/responses/comamnds"; interface OptionsInterface { optionList: OptionInterface[] diff --git a/components/elements/commands/index.tsx b/components/elements/commands/index.tsx index c387dfd..ea92228 100644 --- a/components/elements/commands/index.tsx +++ b/components/elements/commands/index.tsx @@ -1,6 +1,6 @@ import styles from './styles.module.css' import {Table, TableBody, TableCell, TableHead, TableRow, IconButton, Autocomplete, TextField} from "@mui/material"; -import Command, {CommandInterface} from "./elements/command"; +import Command from "./elements/command"; import {useContext, useEffect, useState} from "react"; import PlayCircleOutline from '@mui/icons-material/PlayCircleOutline'; import ConfirmDialog from "../confirm-dialog"; @@ -8,6 +8,7 @@ import TabContext from "../../../context/tab"; import {TabEnum} from "../../../pages"; import smClient from "../../../api/sm/sm-client"; import Send from "@mui/icons-material/Send" +import {CommandInterface} from "../../../api/sm/responses/comamnds"; export default function Commands() { const {setTab} = useContext(TabContext) diff --git a/components/elements/processes/index.tsx b/components/elements/processes/index.tsx index ddba531..9127f4a 100644 --- a/components/elements/processes/index.tsx +++ b/components/elements/processes/index.tsx @@ -13,8 +13,9 @@ import FactCheckOutlined from "@mui/icons-material/FactCheckOutlined" import {Box, CircularProgress, IconButton, LinearProgress, TableContainer, Table, TableBody, TableCell, TableHead, TableRow, TablePagination} from "@mui/material" import ConfirmDialog from "../confirm-dialog"; import smClient from "../../../api/sm/sm-client"; -import {ProcessesResponseInterface, Status} from "../../../api/sm/responses/processes"; -import Command, {CommandInterface} from "../commands/elements/command"; +import {ProcessInterface, Status} from "../../../api/sm/responses/processes"; +import Command from "../commands/elements/command"; +import {CommandInterface} from "../../../api/sm/responses/comamnds"; enum Action { Run, @@ -26,14 +27,14 @@ enum Action { } export default function Processes() { - const [processes, setProcesses] = useState([]); + const [processes, setProcesses] = useState([]); const [page, setPage] = useState(0); const [count, setCount] = useState(0); const [loading, setLoading] = useState(true); const [modalLoading, setModalLoading] = useState(true); const [action, setAction] = useState(null); const [command, setCommand] = useState(null); - const [selectedProcess, setSelectedProcess] = useState(null); + const [selectedProcess, setSelectedProcess] = useState(null); const [optionList, setOptionList] = useState>({}); const [argumentList, setArgumentList] = useState>({}); @@ -52,7 +53,7 @@ export default function Processes() { setLoading(false) refreshLock = false } - let output = async (process: ProcessesResponseInterface) => { + let output = async (process: ProcessInterface) => { const { data: output } = await smClient.getProcessOutput({ id: process.id }) @@ -76,13 +77,13 @@ export default function Processes() { } }, [action]); - let isFinished = (process: ProcessesResponseInterface) => process.cancelledAt || process.completedAt + let isFinished = (process: ProcessInterface) => process.cancelledAt || process.completedAt const handleChangePage = (event: any, page: number) => { setPage(page); } - const openDialog = (process: ProcessesResponseInterface, action: Action) => { + const openDialog = (process: ProcessInterface, action: Action) => { setSelectedProcess(process) setAction(action) } @@ -144,7 +145,7 @@ export default function Processes() { - {processes.map((process: ProcessesResponseInterface, index: number) => ( + {processes.map((process: ProcessInterface, index: number) => ( {process.name}