From 5ff2fbbc398c6b0873301d3011493daa842e2673 Mon Sep 17 00:00:00 2001 From: Rinsvent Date: Wed, 25 Jan 2023 00:18:55 +0700 Subject: [PATCH] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B4=D0=B8=D0=B7=D0=B0=D0=B9=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/sm/sm-client.ts | 11 ++++ .../commands/elements/argument/index.tsx | 3 +- .../commands/elements/command/index.tsx | 9 ++-- .../commands/elements/options/index.tsx | 5 +- components/elements/commands/index.tsx | 50 ++++++------------- components/elements/confirm-dialog/index.tsx | 25 +++++----- components/elements/processes/index.tsx | 35 +++++++++++-- pages/index.tsx | 1 - 8 files changed, 80 insertions(+), 59 deletions(-) diff --git a/api/sm/sm-client.ts b/api/sm/sm-client.ts index 8759255..2d6b667 100644 --- a/api/sm/sm-client.ts +++ b/api/sm/sm-client.ts @@ -15,6 +15,7 @@ import playProcessSchema from "./schemas/play-process"; import pauseProcessSchema from "./schemas/pause-process"; import stopProcessSchema from "./schemas/stop-process"; import killProcessSchema from "./schemas/kill-process"; +import commandSchema from "./schemas/command"; export class SMClient { schemaClient: SchemaClient @@ -33,6 +34,16 @@ export class SMClient { } } + async getCommand(name: string): Promise> { + let { responseData, headers } = await this.schemaClient.send(commandSchema, { + commandName: name + }) + return { + data: responseData, + headers: headers + } + } + async runCommand(data: any): Promise { let { headers } = await this.schemaClient.send(runCommandsSchema, data) return { diff --git a/components/elements/commands/elements/argument/index.tsx b/components/elements/commands/elements/argument/index.tsx index 4fe6b69..a7024f6 100644 --- a/components/elements/commands/elements/argument/index.tsx +++ b/components/elements/commands/elements/argument/index.tsx @@ -28,8 +28,7 @@ export default function Argument(argument: ArgumentInterface) { } return ( -   - {/* */} +   ) } diff --git a/components/elements/commands/elements/command/index.tsx b/components/elements/commands/elements/command/index.tsx index a207c4f..147bb9a 100644 --- a/components/elements/commands/elements/command/index.tsx +++ b/components/elements/commands/elements/command/index.tsx @@ -17,11 +17,13 @@ export interface CommandInterface { interface CommandComponentInterface { command: CommandInterface, callback: any, + optionsParams?: Record, + argumentsParams?: Record, } -export default function Command({command, callback}: CommandComponentInterface) { - const [optionList, setOptionList] = useState>({}); - const [argumentList, setArgumentList] = useState>({}); +export default function Command({command, callback, optionsParams, argumentsParams}: CommandComponentInterface) { + const [optionList, setOptionList] = useState>(optionsParams || {}); + const [argumentList, setArgumentList] = useState>(argumentsParams || {}); useEffect(() => { callback && callback(command.name, optionList, argumentList) @@ -31,7 +33,6 @@ export default function Command({command, callback}: CommandComponentInterface)
- {command.name} 
diff --git a/components/elements/commands/elements/options/index.tsx b/components/elements/commands/elements/options/index.tsx index c2b6e49..4e0a236 100644 --- a/components/elements/commands/elements/options/index.tsx +++ b/components/elements/commands/elements/options/index.tsx @@ -2,7 +2,7 @@ import styles from './styles.module.css' import Option, {OptionInterface} from '../option' import {useContext, useEffect, useState} from "react"; import Context, {ContextInterface} from "../command/context"; -import {Select, MenuItem, Checkbox, ListItemText} from "@mui/material"; +import {Select, OutlinedInput, FormControl, MenuItem, Checkbox, ListItemText} from "@mui/material"; interface OptionsInterface { optionList: OptionInterface[] @@ -45,10 +45,11 @@ export default function Options({optionList}: OptionsInterface) { <>