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

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,
}
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[],
}
}

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

@ -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<ResponseInterface<CommandResponseInterface[]>> {
async getCommands(): Promise<ResponseInterface<CommandInterface[]>> {
let { responseData, headers } = await this.send(commandsSchema, {})
return {
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, {
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)
return {
data: responseData,
@ -57,7 +57,7 @@ export class SMClient extends SchemaClient {
async repeatProcess(data: RepeatProcessRequest): Promise<ResponseInterface> {
let { responseData, headers } = await this.send(repeatProcessSchema, data)
return {
data: responseData as ProcessesResponseInterface[],
data: responseData as ProcessInterface[],
headers: headers
}
}

@ -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<ContextInterface>(Context)

@ -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[]

@ -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,

@ -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<ContextInterface>(Context)

@ -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[]

@ -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)

@ -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<ProcessesResponseInterface[]>([]);
const [processes, setProcesses] = useState<ProcessInterface[]>([]);
const [page, setPage] = useState<number>(0);
const [count, setCount] = useState<number>(0);
const [loading, setLoading] = useState<boolean>(true);
const [modalLoading, setModalLoading] = useState<boolean>(true);
const [action, setAction] = useState<Action | 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 [argumentList, setArgumentList] = useState<Record<string, any>>({});
@ -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() {
</TableRow>
</TableHead>
<TableBody>
{processes.map((process: ProcessesResponseInterface, index: number) => (
{processes.map((process: ProcessInterface, index: number) => (
<TableRow key={process.id}>
<TableCell>{process.name}</TableCell>
<TableCell>

Loading…
Cancel
Save