From 6003cfde04413418046b30f33e56650f2e657d42 Mon Sep 17 00:00:00 2001 From: IDONTSUDO Date: Thu, 25 Jul 2024 11:50:43 +0300 Subject: [PATCH] scenes --- .vscode/settings.json | 2 +- scene_builder.json | 174 ------------------ .../src/core/controllers/http_controller.ts | 2 +- .../features/scene/delete_scene_scenario.ts | 21 ++- .../src/features/scene/scene_presentation.ts | 1 + ui/src/core/ui/pages/main_page.tsx | 2 +- .../behavior_tree_builder_screen.tsx | 2 +- .../presentation/scene_manager_store.ts | 7 +- ui/src/features/skils/skills_screen.tsx | 2 +- 9 files changed, 29 insertions(+), 184 deletions(-) delete mode 100644 scene_builder.json diff --git a/.vscode/settings.json b/.vscode/settings.json index df9a8fa..25b7215 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,7 +6,7 @@ "Количество", "может", "навык", - "Навыки", + "модели", "Новое", "отрицательное", "принимать", diff --git a/scene_builder.json b/scene_builder.json deleted file mode 100644 index 1a0c563..0000000 --- a/scene_builder.json +++ /dev/null @@ -1,174 +0,0 @@ -{ - "scene": [ - { - "type": "ROBOT", - "vector3": { - "x": 1.0, - "y": 1, - "z": 1 - }, - "quaternion": { - "x": 1, - "y": 2, - "z": 3, - "w": 4 - }, - "name": "ARM0", - "nDOF": 6, - "toolType": "RBS_GRIPPER", - "jointPosition": [ - 1.1, - 2.2, - 2.1, - 3.1, - 4.4 - ] - }, - { - "type": "CAMERA", - "vector3": { - "x": 1.0, - "y": 1, - "z": 1 - }, - "quaternion": { - "x": 1, - "y": 2, - "z": 3, - "w": 4 - }, - "parent": "WORLD", - "fixed": "null/true", - "topic": "123", - "name": "CAMERA1", - "cameraType": "RGB", - "width": 100, - "updateRate": 100, - "fov": 10.0, - "near": 10, - "far": 10, - "height": 10 - }, - { - "type": "SOLID", - "name":"21341qd", - "solidType": "ENV", - "vector3": { - "x": 1.0, - "y": 1, - "z": 1 - }, - "quaternion": { - "x": 1, - "y": 2, - "z": 3, - "w": 4 - }, - "inertia": 1, - "mass": 1, - "mesh": "", - "collisionMesh": "" - }, - { - "type": "SOLID", - "solidType": "ACTIVE", - "vector3": { - "x": 1.0, - "y": 1, - "z": 1 - }, - "quaternion": { - "x": 1, - "y": 2, - "z": 3, - "w": 4 - }, - "inertia": 1, - "mass": 1, - "mesh": "", - "collisionMesh": "", - "spawn": { - "type": "POINT", - "name": "123" - } - }, - { - "type": "POINT", - "name": "123", - "vector3": { - "x": 1.0, - "y": 1, - "z": 1 - }, - "quaternion": { - "x": 1, - "y": 2, - "z": 3, - "w": 4 - } - }, - { - "type": "SOLID", - "solidType": "ACTIVE", - "vector3": { - "x": 1.0, - "y": 1, - "z": 1 - }, - "quaternion": { - "x": 1, - "y": 2, - "z": 3, - "w": 4 - }, - "inertia": 1, - "mass": 1, - "visualMesh": "", - "collisionMesh": "", - "spawn": { - "type": "DEFAULT" - } - }, - { - "type": "SOLID", - "solidType": "ACTIVE", - "vector3": { - "x": 1.0, - "y": 1, - "z": 1 - }, - "quaternion": { - "x": 1, - "y": 2, - "z": 3, - "w": 4 - }, - "inertia": 1, - "mass": 1, - "visualMesh": 100, - "collisionMesh": 100, - "spawn": { - "type": "ZONE", - "name": "111" - } - }, - { - "type": "ZONE", - "name": "111", - "vector3": { - "x": 1.0, - "y": 1, - "z": 1 - }, - "quaternion": { - "x": 1, - "y": 2, - "z": 3, - "w": 4 - }, - "width": 100, - "height": 100, - "length": 100 - } - ] -} \ No newline at end of file diff --git a/server/src/core/controllers/http_controller.ts b/server/src/core/controllers/http_controller.ts index 5b5832d..3f39781 100644 --- a/server/src/core/controllers/http_controller.ts +++ b/server/src/core/controllers/http_controller.ts @@ -182,7 +182,7 @@ export class CoreHttpController implements ICoreHttpController { public put(usecase: any) { this.routes["PUT"] = usecase; } - public delete(usecase: CallbackStrategyWithValidationModel) { + public delete(usecase: any) { this.routes["DELETE"] = usecase; } public async requestResponseController( diff --git a/server/src/features/scene/delete_scene_scenario.ts b/server/src/features/scene/delete_scene_scenario.ts index ea1226d..1155e23 100644 --- a/server/src/features/scene/delete_scene_scenario.ts +++ b/server/src/features/scene/delete_scene_scenario.ts @@ -1,16 +1,31 @@ import { CallbackStrategyWithIdQuery, ResponseBase } from "../../core/controllers/http_controller"; import { Result } from "../../core/helpers/result"; +import { StaticFiles } from "../../core/models/static_files"; import { DeleteDataBaseModelUseCase } from "../../core/usecases/delete_database_model_usecase"; +import { DeleteFileUseCase } from "../../core/usecases/delete_file_usecase"; import { ReadByIdDataBaseModelUseCase } from "../../core/usecases/read_by_id_database_model_usecase"; +import { SearchManyDataBaseModelUseCase } from "../../core/usecases/search_many_database_model_usecase"; import { CoreValidation } from "../../core/validations/core_validation"; import { MongoIdValidation } from "../../core/validations/mongo_id_validation"; +import { IProjectModel, ProjectDBModel } from "../projects/models/project_model_database_model"; import { SceneModel } from "./create_new_scene_scenario"; export class DeleteSceneScenario extends CallbackStrategyWithIdQuery { idValidationExpression: CoreValidation = new MongoIdValidation(); call = async (id: string): ResponseBase => - (await new ReadByIdDataBaseModelUseCase(SceneModel).call(id)).map((sceneModel) => Result.ok() - // (await new DeleteDataBaseModelUseCase(SceneModel).call(id)).map(() => DeleteF ) + (await new ReadByIdDataBaseModelUseCase(SceneModel).call(id)).map(async (sceneModel) => + (await new DeleteDataBaseModelUseCase(SceneModel).call(id)).map(async () => + ( + await new SearchManyDataBaseModelUseCase(ProjectDBModel).call( + { isActive: true }, + "is dont active projects" + ) + ).map(async (projectModel) => { + const { rootDir } = projectModel[0]; + + (await new DeleteFileUseCase()).call(`${rootDir}${StaticFiles.scenes}${sceneModel.name}.json`); + return Result.ok("Delete scene"); + }) + ) ); } - diff --git a/server/src/features/scene/scene_presentation.ts b/server/src/features/scene/scene_presentation.ts index a885669..53a5d6c 100644 --- a/server/src/features/scene/scene_presentation.ts +++ b/server/src/features/scene/scene_presentation.ts @@ -16,6 +16,7 @@ export class ScenePresentation extends CrudController { { name: "Сборки", path: AssemblesScreenPath, icon: "Assembly" }, { name: "Датасеты", path: DatasetsScreenPath, icon: "Datasets" }, { name: "Сцена", path: SceneManagerPath, icon: "Scene" }, - { name: "Навыки", path: SkillScreenPath, icon: "Layers" }, + { name: "модели", path: SkillScreenPath, icon: "Layers" }, { name: "Поведение", path: BehaviorTreeBuilderPath, icon: "Rocket" }, { name: "Симуляция", path: SimulationScreenPath, icon: "Simulation" }, { name: "Оценка", path: EstimateScreenPath, icon: "Grade" }, 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 d132ec8..a187043 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 @@ -97,7 +97,7 @@ export const BehaviorTreeBuilderScreen = observer(() => { >
- +
{store.skillTemplates ? : null}
diff --git a/ui/src/features/scene_manager/presentation/scene_manager_store.ts b/ui/src/features/scene_manager/presentation/scene_manager_store.ts index 03f7ffc..936805c 100644 --- a/ui/src/features/scene_manager/presentation/scene_manager_store.ts +++ b/ui/src/features/scene_manager/presentation/scene_manager_store.ts @@ -193,14 +193,17 @@ export class SceneMangerStore extends UiDrawerFormState (this.isSceneMenuShow = false); - init = async () => {}; + init = async () => { + this.storeMode + .isEqualR(StoreMode.allScenes) + .map(() => this.mapOk("scenes", this.sceneHttpRepository.getAllScenes())); + }; initParam = (id: string | undefined) => { if (id) { this.activeSceneId = id; this.storeMode = StoreMode.sceneInstance; } else { this.storeMode = StoreMode.allScenes; - this.mapOk("scenes", this.sceneHttpRepository.getAllScenes()); } }; errorHandingStrategy = (error: HttpError) => diff --git a/ui/src/features/skils/skills_screen.tsx b/ui/src/features/skils/skills_screen.tsx index f679534..9afc380 100644 --- a/ui/src/features/skils/skills_screen.tsx +++ b/ui/src/features/skils/skills_screen.tsx @@ -27,7 +27,7 @@ export const SkillScreen = observer(() => { return ( <> {skills.map((el) => (