Рефакторинг сигнатур

jwt
Sipachev Igor 2 years ago
parent 7ca897f7b0
commit 5b8de1adf1
  1. 12
      api/sm/responses/comamnds.ts
  2. 2
      api/sm/responses/processes.ts
  3. 12
      api/sm/sm-client.ts
  4. 9
      components/elements/commands/elements/argument/index.tsx
  5. 3
      components/elements/commands/elements/arguments/index.tsx
  6. 11
      components/elements/commands/elements/command/index.tsx
  7. 14
      components/elements/commands/elements/option/index.tsx
  8. 3
      components/elements/commands/elements/options/index.tsx
  9. 3
      components/elements/commands/index.tsx
  10. 17
      components/elements/processes/index.tsx

@ -19,10 +19,18 @@ export interface ArgumentInterface {
isRequired: boolean, isRequired: boolean,
} }
export interface CommandResponseInterface { export interface ArgumentInterface {
name: string,
description: string|null,
default: any,
isArray: boolean,
isRequired: boolean,
}
export interface CommandInterface {
class: string, class: string,
name: string, name: string,
description: string, description: string,
options: OptionInterface[], options: OptionInterface[],
arguments: ArgumentInterface[], arguments: ArgumentInterface[],
} }

@ -14,7 +14,7 @@ export interface ProcessProgressInterface {
percent: number percent: number
} }
export interface ProcessesResponseInterface { export interface ProcessInterface {
id: string id: string
lock: string | null lock: string | null
containerUuid: string | null containerUuid: string | null

@ -1,10 +1,10 @@
import {processesSchema} from "./schemas/processes"; import {processesSchema} from "./schemas/processes";
import {ProcessesResponseInterface} from "./responses/processes"; import {ProcessInterface} from "./responses/processes";
import {SchemaClient} from "../schema-client"; import {SchemaClient} from "../schema-client";
import {GetProcessesRequest} from "./requests/get-processes"; import {GetProcessesRequest} from "./requests/get-processes";
import {PaginationRequest} from "./requests/pagination"; import {PaginationRequest} from "./requests/pagination";
import {ResponseInterface} from "./responses/response"; import {ResponseInterface} from "./responses/response";
import {CommandResponseInterface} from "./responses/comamnds"; import {CommandInterface} from "./responses/comamnds";
import commandsSchema from "./schemas/commands"; import commandsSchema from "./schemas/commands";
import runCommandsSchema from "./schemas/run-commands"; import runCommandsSchema from "./schemas/run-commands";
import {RepeatProcessRequest} from "./requests/repeat-process"; import {RepeatProcessRequest} from "./requests/repeat-process";
@ -20,7 +20,7 @@ import commandSchema from "./schemas/command";
export class SMClient extends SchemaClient { export class SMClient extends SchemaClient {
baseUrl = 'http://fmw.sipachev.sv' baseUrl = 'http://fmw.sipachev.sv'
async getCommands(): Promise<ResponseInterface<CommandResponseInterface[]>> { async getCommands(): Promise<ResponseInterface<CommandInterface[]>> {
let { responseData, headers } = await this.send(commandsSchema, {}) let { responseData, headers } = await this.send(commandsSchema, {})
return { return {
data: responseData, data: responseData,
@ -28,7 +28,7 @@ export class SMClient extends SchemaClient {
} }
} }
async getCommand(name: string): Promise<ResponseInterface<CommandResponseInterface>> { async getCommand(name: string): Promise<ResponseInterface<CommandInterface>> {
let { responseData, headers } = await this.send(commandSchema, { let { responseData, headers } = await this.send(commandSchema, {
commandName: name commandName: name
}) })
@ -46,7 +46,7 @@ export class SMClient extends SchemaClient {
} }
} }
async getProcesses(data: GetProcessesRequest | PaginationRequest): Promise<ResponseInterface<ProcessesResponseInterface[]>> { async getProcesses(data: GetProcessesRequest | PaginationRequest): Promise<ResponseInterface<ProcessInterface[]>> {
let { responseData, headers } = await this.send(processesSchema, data) let { responseData, headers } = await this.send(processesSchema, data)
return { return {
data: responseData, data: responseData,
@ -57,7 +57,7 @@ export class SMClient extends SchemaClient {
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 {
data: responseData as ProcessesResponseInterface[], data: responseData as ProcessInterface[],
headers: headers headers: headers
} }
} }

@ -2,14 +2,7 @@ import styles from './styles.module.css'
import {useContext, useEffect, useState} from "react"; import {useContext, useEffect, useState} from "react";
import Context, {ContextInterface} from "../command/context"; import Context, {ContextInterface} from "../command/context";
import {TextField} from "@mui/material"; import {TextField} from "@mui/material";
import {ArgumentInterface} from "../../../../../api/sm/responses/comamnds";
export interface ArgumentInterface {
name: string,
description: string|null,
default: any,
isArray: boolean,
isRequired: boolean,
}
export default function Argument(argument: ArgumentInterface) { export default function Argument(argument: ArgumentInterface) {
let {argumentList, setArgumentList} = useContext<ContextInterface>(Context) let {argumentList, setArgumentList} = useContext<ContextInterface>(Context)

@ -1,7 +1,8 @@
import styles from './styles.module.css' import styles from './styles.module.css'
import {useContext, useEffect, useState} from "react"; import {useContext, useEffect, useState} from "react";
import Argument, {ArgumentInterface} from "../argument"; import Argument from "../argument";
import Context, {ContextInterface} from "../command/context"; import Context, {ContextInterface} from "../command/context";
import {ArgumentInterface} from "../../../../../api/sm/responses/comamnds";
interface ArgumentsInterface { interface ArgumentsInterface {
argumentList: ArgumentInterface[] argumentList: ArgumentInterface[]

@ -1,18 +1,9 @@
import styles from './styles.module.css' import styles from './styles.module.css'
import Options from "../options"; import Options from "../options";
import Arguments from "../arguments"; import Arguments from "../arguments";
import {OptionInterface} from "../option";
import {ArgumentInterface} from "../argument";
import {Provider} from "./context"; import {Provider} from "./context";
import {useEffect, useState} from "react"; import {useEffect, useState} from "react";
import {CommandInterface} from "../../../../../api/sm/responses/comamnds";
export interface CommandInterface {
class: string,
name: string,
description: string,
options: OptionInterface[],
arguments: ArgumentInterface[],
}
interface CommandComponentInterface { interface CommandComponentInterface {
command: CommandInterface, command: CommandInterface,

@ -2,19 +2,7 @@ import styles from './styles.module.css'
import {useContext} from "react"; import {useContext} from "react";
import Context, {ContextInterface} from "../command/context"; import Context, {ContextInterface} from "../command/context";
import {TextField} from "@mui/material"; import {TextField} from "@mui/material";
import {OptionInterface} from "../../../../../api/sm/responses/comamnds";
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
}
export default function Option(option: OptionInterface) { export default function Option(option: OptionInterface) {
let {optionList: ol, setOptionList} = useContext<ContextInterface>(Context) let {optionList: ol, setOptionList} = useContext<ContextInterface>(Context)

@ -1,8 +1,9 @@
import styles from './styles.module.css' import styles from './styles.module.css'
import Option, {OptionInterface} from '../option' import Option from '../option'
import {useContext, useEffect, useState} from "react"; import {useContext, useEffect, useState} from "react";
import Context, {ContextInterface} from "../command/context"; import Context, {ContextInterface} from "../command/context";
import {Select, OutlinedInput, FormControl, MenuItem, Checkbox, ListItemText} from "@mui/material"; import {Select, OutlinedInput, FormControl, MenuItem, Checkbox, ListItemText} from "@mui/material";
import {OptionInterface} from "../../../../../api/sm/responses/comamnds";
interface OptionsInterface { interface OptionsInterface {
optionList: OptionInterface[] optionList: OptionInterface[]

@ -1,6 +1,6 @@
import styles from './styles.module.css' import styles from './styles.module.css'
import {Table, TableBody, TableCell, TableHead, TableRow, IconButton, Autocomplete, TextField} from "@mui/material"; 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 {useContext, useEffect, useState} from "react";
import PlayCircleOutline from '@mui/icons-material/PlayCircleOutline'; import PlayCircleOutline from '@mui/icons-material/PlayCircleOutline';
import ConfirmDialog from "../confirm-dialog"; import ConfirmDialog from "../confirm-dialog";
@ -8,6 +8,7 @@ import TabContext from "../../../context/tab";
import {TabEnum} from "../../../pages"; import {TabEnum} from "../../../pages";
import smClient from "../../../api/sm/sm-client"; import smClient from "../../../api/sm/sm-client";
import Send from "@mui/icons-material/Send" import Send from "@mui/icons-material/Send"
import {CommandInterface} from "../../../api/sm/responses/comamnds";
export default function Commands() { export default function Commands() {
const {setTab} = useContext(TabContext) const {setTab} = useContext(TabContext)

@ -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 {Box, CircularProgress, IconButton, LinearProgress, TableContainer, Table, TableBody, TableCell, TableHead, TableRow, TablePagination} 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 {ProcessesResponseInterface, Status} from "../../../api/sm/responses/processes"; import {ProcessInterface, Status} from "../../../api/sm/responses/processes";
import Command, {CommandInterface} from "../commands/elements/command"; import Command from "../commands/elements/command";
import {CommandInterface} from "../../../api/sm/responses/comamnds";
enum Action { enum Action {
Run, Run,
@ -26,14 +27,14 @@ enum Action {
} }
export default function Processes() { export default function Processes() {
const [processes, setProcesses] = useState<ProcessesResponseInterface[]>([]); const [processes, setProcesses] = useState<ProcessInterface[]>([]);
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 [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);
const [command, setCommand] = useState<CommandInterface | null>(null); const [command, setCommand] = useState<CommandInterface | null>(null);
const [selectedProcess, setSelectedProcess] = useState<ProcessesResponseInterface | null>(null); const [selectedProcess, setSelectedProcess] = useState<ProcessInterface | null>(null);
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>>({});
@ -52,7 +53,7 @@ export default function Processes() {
setLoading(false) setLoading(false)
refreshLock = false refreshLock = false
} }
let output = async (process: ProcessesResponseInterface) => { let output = async (process: ProcessInterface) => {
const { data: output } = await smClient.getProcessOutput({ const { data: output } = await smClient.getProcessOutput({
id: process.id id: process.id
}) })
@ -76,13 +77,13 @@ export default function Processes() {
} }
}, [action]); }, [action]);
let isFinished = (process: ProcessesResponseInterface) => process.cancelledAt || process.completedAt let isFinished = (process: ProcessInterface) => process.cancelledAt || process.completedAt
const handleChangePage = (event: any, page: number) => { const handleChangePage = (event: any, page: number) => {
setPage(page); setPage(page);
} }
const openDialog = (process: ProcessesResponseInterface, action: Action) => { const openDialog = (process: ProcessInterface, action: Action) => {
setSelectedProcess(process) setSelectedProcess(process)
setAction(action) setAction(action)
} }
@ -144,7 +145,7 @@ export default function Processes() {
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody> <TableBody>
{processes.map((process: ProcessesResponseInterface, index: number) => ( {processes.map((process: ProcessInterface, index: number) => (
<TableRow key={process.id}> <TableRow key={process.id}>
<TableCell>{process.name}</TableCell> <TableCell>{process.name}</TableCell>
<TableCell> <TableCell>

Loading…
Cancel
Save