diff --git a/server/src/core/controllers/app.ts b/server/src/core/controllers/app.ts index 41a52e7..c1dca95 100644 --- a/server/src/core/controllers/app.ts +++ b/server/src/core/controllers/app.ts @@ -9,6 +9,9 @@ import { dirname } from "path"; import { CheckAndCreateStaticFilesFolderUseCase } from "../usecases/check_and_create_static_files_folder_usecase"; import { DataBaseConnectUseCase } from "../usecases/database_connect_usecase"; import { TypedEvent } from "../helpers/typed_event"; +import { CalculationInstanceDBModel } from "../../features/calculations_instance/models/calculations_instance_database_model"; +import * as fs from "fs"; +import { WriteFileSystemFileUseCase } from "../usecases/write_file_system_file_usecase"; export enum ServerStatus { init = "init", @@ -85,7 +88,25 @@ export class App extends TypedEvent { this.app.use(express.json()); this.app.use(express.urlencoded({ extended: true })); this.app.use(express.static(App.staticFilesStoreDir())); + this.app.get('/logs', async (req, res) => { + const id = req.query.id; + if (id === undefined) { + return res.status(400).json('need req query id?=') + } + + const calculationInstanceDBModel = await CalculationInstanceDBModel.findById(id) + if (calculationInstanceDBModel === null) { + return res.status(400).json("calcultaion db model is null"); + } + const p = App.staticFilesStoreDir() + '/log.txt'; + + (await new WriteFileSystemFileUseCase().call(p, calculationInstanceDBModel.lastProcessLogs)).map(() => { + return res.sendFile(p); + }) + + + }) this.app.use( fileUpload({ createParentPath: true, diff --git a/server/src/core/controllers/http_controller.ts b/server/src/core/controllers/http_controller.ts index 5b61528..9542de1 100644 --- a/server/src/core/controllers/http_controller.ts +++ b/server/src/core/controllers/http_controller.ts @@ -65,12 +65,12 @@ interface ISubSetFeatureRouter { method: HttpMethodType; subUrl: string; fn: - | CallbackStrategyWithValidationModel - | CallbackStrategyWithEmpty - | CallbackStrategyWithIdQuery - | CallBackStrategyWithQueryPage - | CallbackStrategyWithFileUpload - | CallbackStrategyWithFilesUploads; + | CallbackStrategyWithValidationModel + | CallbackStrategyWithEmpty + | CallbackStrategyWithIdQuery + | CallBackStrategyWithQueryPage + | CallbackStrategyWithFileUpload + | CallbackStrategyWithFilesUploads; } abstract class ICoreHttpController { @@ -234,6 +234,7 @@ export class CoreHttpController implements ICoreHttpController { return res.json(ok); }, (err) => { + return res.status(400).json({ error: String(err) }); } ); diff --git a/server/src/features/calculations_instance/domain/log_to_text_proces_usecase.ts b/server/src/features/calculations_instance/domain/log_to_text_proces_usecase.ts new file mode 100644 index 0000000..bed8aa0 --- /dev/null +++ b/server/src/features/calculations_instance/domain/log_to_text_proces_usecase.ts @@ -0,0 +1,11 @@ +import { CallbackStrategyWithIdQuery, ResponseBase } from "../../../core/controllers/http_controller"; +import { ReadByIdDataBaseModelUseCase } from "../../../core/usecases/read_database_model_usecase"; +import { CoreValidation } from "../../../core/validations/core_validation"; +import { MongoIdValidation } from "../../../core/validations/mongo_id_validation"; +import { ICalculationInstance, CalculationInstanceDBModel } from "../models/calculations_instance_database_model"; + +// export class LogToProcessUseCase extends CallbackStrategyWithIdQuery { +// idValidationExpression: CoreValidation = new MongoIdValidation(); +// call = async (id: string): ResponseBase => (await new ReadByIdDataBaseModelUseCase(CalculationInstanceDBModel).call(id)).map((model) => ); + +// } \ No newline at end of file diff --git a/server/src/main.ts b/server/src/main.ts index 492c873..d88e058 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -4,7 +4,6 @@ import { SocketSubscriber } from "./core/controllers/socket_controller"; import { extensions } from "./core/extensions/extensions"; import { httpRoutes } from "./core/controllers/routes"; import { executorProgramService } from "./core/usecases/exec_process_usecase"; -// import { main } from "./p"; import { executorProgramServiceV2 } from "./core/scenarios/exec_process_scenario_v2"; extensions(); @@ -12,4 +11,3 @@ extensions(); const socketSubscribers = [new SocketSubscriber(executorProgramService, "realtime"), new SocketSubscriber(executorProgramServiceV2, 'realtimeV2',)]; new App(httpRoutes, socketSubscribers).listen(); -// main() \ No newline at end of file diff --git a/ui/src/core/ui/drawer/drawer.tsx b/ui/src/core/ui/drawer/drawer.tsx index cf5092a..14f9f5d 100644 --- a/ui/src/core/ui/drawer/drawer.tsx +++ b/ui/src/core/ui/drawer/drawer.tsx @@ -7,14 +7,15 @@ export const DrawerV2: React.FC<{ title?: string; onClose: () => void; children: React.ReactNode; -}> = ({ isOpen, onClose, children, title }) => { + width?: number; +}> = ({ isOpen, onClose, children, title, width }) => { return (
{ backgroundColor: "rgba(254, 247, 255, 1)", border: "1px #6750a4 solid", width: "100%", - height: 110, display: "flex", justifyContent: "space-between", alignItems: "center", diff --git a/ui/src/features/behavior_tree_builder/presentation/behavior_tree_builder_screen.tsx b/ui/src/features/behavior_tree_builder/presentation/behavior_tree_builder_screen.tsx index 896cb49..67f44a6 100644 --- a/ui/src/features/behavior_tree_builder/presentation/behavior_tree_builder_screen.tsx +++ b/ui/src/features/behavior_tree_builder/presentation/behavior_tree_builder_screen.tsx @@ -186,8 +186,17 @@ export const BehaviorTreeBuilderScreen = observer(() => { title={store.titleDrawer} onClose={() => store.editDrawer(DrawerState.editThreadBehaviorTree, false)} isOpen={store.drawers.find((el) => el.name === DrawerState.editThreadBehaviorTree)?.status} + width={window.innerWidth / 2} > -
+
{store.skillTemplates?.getForms(store.selected ?? "").map((formType, index) => forms( diff --git a/ui/src/features/behavior_tree_manager/behavior_tree_manager_screen.tsx b/ui/src/features/behavior_tree_manager/behavior_tree_manager_screen.tsx index fe8d179..482bbc2 100644 --- a/ui/src/features/behavior_tree_manager/behavior_tree_manager_screen.tsx +++ b/ui/src/features/behavior_tree_manager/behavior_tree_manager_screen.tsx @@ -1,6 +1,6 @@ import { observer } from "mobx-react-lite"; import { BehaviorTreeManagerStore } from "./behavior_tree_manager_store"; -import React from "react"; +import React, { useEffect } from "react"; import { useStore } from "../../core/helper/use_store"; import { ButtonV2, ButtonV2Type } from "../../core/ui/button/button_v2"; import { CoreCard } from "../../core/ui/card/card"; @@ -16,13 +16,13 @@ export const BehaviorTreeManagerScreenPath = "/behavior/tree/manager"; export const BehaviorTreeManagerScreen = observer(() => { const store = useStore(BehaviorTreeManagerStore); - + useEffect(() => {}, []); return ( <> -
+
} @@ -65,9 +65,13 @@ export const BehaviorTreeManagerScreen = observer(() => { }} />
- store.updateForm({ name: text })} /> + store.updateForm({ name: text })} />
- store.updateForm({ description: text })} /> + store.updateForm({ description: text })} + />
({ name: el.name, value: el._id })) ?? []} diff --git a/ui/src/features/calculation_instance/data/calculation_http_repository.ts b/ui/src/features/calculation_instance/data/calculation_http_repository.ts index 90e4695..2b60a10 100644 --- a/ui/src/features/calculation_instance/data/calculation_http_repository.ts +++ b/ui/src/features/calculation_instance/data/calculation_http_repository.ts @@ -14,7 +14,13 @@ export interface ISkils { } export class CalculationHttpRepository extends CoreHttpRepository { - + async getLogs(id: string) { + + await this._request(HttpMethod.GET, `/logs?id=${id}`) + window.location.href = 'http://localhost:4001/log.txt'; + + } + featureApi = `/calculations/instances`; subFeatureApi = `/calculations/template`; diff --git a/ui/src/features/calculation_instance/presentation/calculation_instance_screen.tsx b/ui/src/features/calculation_instance/presentation/calculation_instance_screen.tsx index 33eeb39..7a56975 100644 --- a/ui/src/features/calculation_instance/presentation/calculation_instance_screen.tsx +++ b/ui/src/features/calculation_instance/presentation/calculation_instance_screen.tsx @@ -60,7 +60,8 @@ export const CalculationInstanceScreen = observer(() => { () => store.deleteInstance(el._id ?? ""), () => store.execSkill(el._id ?? ""), () => store.execSkill(el._id ?? ""), - () => store.changeProcessStatus(el._id ?? "") + () => store.changeProcessStatus(el._id ?? ""), + () => store.getTxtLog(el._id ?? "") )} ); diff --git a/ui/src/features/calculation_instance/presentation/calculation_instance_store.tsx b/ui/src/features/calculation_instance/presentation/calculation_instance_store.tsx index cb9f0dd..bb68c7e 100644 --- a/ui/src/features/calculation_instance/presentation/calculation_instance_store.tsx +++ b/ui/src/features/calculation_instance/presentation/calculation_instance_store.tsx @@ -21,6 +21,7 @@ export enum StoreTypes { } export class CalculationInstanceStore extends UiDrawerFormState { + getTxtLog = (id: string) => this.calculationHttpRepository.getLogs(id); calculationHttpRepository: CalculationHttpRepository = new CalculationHttpRepository(); calculationSocketRepository: CalculationSocketRepository = new CalculationSocketRepository(); activeProjectId?: UUID; diff --git a/ui/src/features/calculation_instance/presentation/ui/cards/get_model_card.tsx b/ui/src/features/calculation_instance/presentation/ui/cards/get_model_card.tsx index fdb16ca..c0fdb2c 100644 --- a/ui/src/features/calculation_instance/presentation/ui/cards/get_model_card.tsx +++ b/ui/src/features/calculation_instance/presentation/ui/cards/get_model_card.tsx @@ -1,6 +1,6 @@ import { match } from "ts-pattern"; import { PoseEstimateCard } from "./pose_estimate_card/model_card"; -import { Checkbox, Dropdown, MenuProps, message } from "antd"; +import { Dropdown, MenuProps, } from "antd"; import { CoreText, CoreTextType } from "../../../../../core/ui/text/text"; import { IMenuItem } from "../../../../dataset/card_dataset"; import { Icon } from "../../../../../core/ui/icons/icons"; @@ -16,7 +16,8 @@ export const getModelCard = ( onDelete: Function, onPlay: Function, onPause: Function, - onChangeProcessIsEnd: Function + onChangeProcessIsEnd: Function, + onLog: Function ) => { const menu: IMenuItem[] = [ { @@ -68,7 +69,8 @@ export const getModelCard = ( - window.prompt("Copy to clipboard: Ctrl+C, Enter", calculationModel.lastProcessLogs ?? "Not found logs") + // window.prompt("Copy to clipboard: Ctrl+C, Enter", calculationModel.lastProcessLogs ?? "Not found logs") + onLog() } />