fixed errors
This commit is contained in:
parent
fb4fa52c14
commit
ba5394107a
14 changed files with 131 additions and 104 deletions
8
ui/src/core/model/form.ts
Normal file
8
ui/src/core/model/form.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
export enum FormType {
|
||||
weights = "weights",
|
||||
robotName = "robot_name",
|
||||
cameraDeviceForm = "camera",
|
||||
topic = "topic",
|
||||
formBuilder = "formBuilder",
|
||||
moveToPose = "move_to_pose",
|
||||
}
|
|
@ -3,56 +3,57 @@ import { BehaviorTreeBuilderStore } from "../../features/behavior_tree_builder/p
|
|||
import { datasetFormMockContext, datasetFormMockResult, defaultFormValue } from "../../features/dataset/dataset_model";
|
||||
import { DependencyViewModel } from "./skill_model";
|
||||
import { ValidationModel } from "./validation_model";
|
||||
|
||||
import { FormType } from "./form";
|
||||
|
||||
export class FormBuilderValidationModel extends ValidationModel implements DependencyViewModel {
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
public result: string;
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
public context: string;
|
||||
public form: string[];
|
||||
public output: any;
|
||||
constructor(context: string, result: string, form: string[], output: string) {
|
||||
super();
|
||||
this.context = context;
|
||||
this.result = result;
|
||||
this.form = form;
|
||||
this.output = output;
|
||||
}
|
||||
toView = (store: BehaviorTreeBuilderStore | undefined) => <>IsFilled</>;
|
||||
static isEmpty = (formBuilderValidationModel: FormBuilderValidationModel) =>
|
||||
formBuilderValidationModel.context.isEmpty() &&
|
||||
formBuilderValidationModel.result.isEmpty() &&
|
||||
formBuilderValidationModel.form.isEmpty();
|
||||
|
||||
static datasetEmpty() {
|
||||
return new FormBuilderValidationModel(datasetFormMockContext, datasetFormMockResult, [], defaultFormValue);
|
||||
}
|
||||
static empty() {
|
||||
return new FormBuilderValidationModel("", "", [], "");
|
||||
}
|
||||
static emptyTest() {
|
||||
return new FormBuilderValidationModel(``, ``, [], defaultFormValue);
|
||||
}
|
||||
static creteDataSetTest() {
|
||||
return new FormBuilderValidationModel(``, scene, [], "");
|
||||
}
|
||||
static vision(): FormBuilderValidationModel {
|
||||
return new FormBuilderValidationModel(
|
||||
`ENUM PRETRAIN = "true","false";`,
|
||||
`{
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
public result: string;
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
public context: string;
|
||||
public form: string[];
|
||||
public output: any;
|
||||
constructor(context: string, result: string, form: string[], output: string) {
|
||||
super();
|
||||
this.context = context;
|
||||
this.result = result;
|
||||
this.form = form;
|
||||
this.output = output;
|
||||
}
|
||||
type: FormType = FormType.formBuilder;
|
||||
toView = (store: BehaviorTreeBuilderStore | undefined) => <>IsFilled</>;
|
||||
static isEmpty = (formBuilderValidationModel: FormBuilderValidationModel) =>
|
||||
formBuilderValidationModel.context.isEmpty() &&
|
||||
formBuilderValidationModel.result.isEmpty() &&
|
||||
formBuilderValidationModel.form.isEmpty();
|
||||
|
||||
static datasetEmpty() {
|
||||
return new FormBuilderValidationModel(datasetFormMockContext, datasetFormMockResult, [], defaultFormValue);
|
||||
}
|
||||
static empty() {
|
||||
return new FormBuilderValidationModel("", "", [], "");
|
||||
}
|
||||
static emptyTest() {
|
||||
return new FormBuilderValidationModel(``, ``, [], defaultFormValue);
|
||||
}
|
||||
static creteDataSetTest() {
|
||||
return new FormBuilderValidationModel(``, scene, [], "");
|
||||
}
|
||||
static vision(): FormBuilderValidationModel {
|
||||
return new FormBuilderValidationModel(
|
||||
`ENUM PRETRAIN = "true","false";`,
|
||||
`{
|
||||
"numberOfEpochs": \${numberOfEpochs:number:10},
|
||||
"selectDataset": \${<SelectDataset/>:OBJECT:{"dataset": {}},
|
||||
"pretrain": \${pretrain:Enum<PRETRAIN>:true}
|
||||
}`,
|
||||
[],
|
||||
""
|
||||
);
|
||||
}
|
||||
[],
|
||||
""
|
||||
);
|
||||
}
|
||||
export const scene = `{
|
||||
}
|
||||
export const scene = `{
|
||||
"center_shell": [\${CENTER_SHELL_1:number:0}, \${CENTER_SHELL_2:number:0}, \${CENTER_SHELL_3:number:0}],
|
||||
"scene":\${<SelectScene/>:OBJECT:{"details": []}
|
||||
}`;
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
import makeAutoObservable from "mobx-store-inheritance";
|
||||
import clone from "just-clone";
|
||||
import { IsArray, IsEnum, IsNotEmpty, IsOptional, IsString, ValidateNested } from "class-validator";
|
||||
import { Type } from "class-transformer";
|
||||
import { ISkillView } from "../../features/behavior_tree_builder/presentation/ui/skill_tree/skill_tree";
|
||||
|
@ -6,8 +8,10 @@ import { Result } from "../helper/result";
|
|||
import { ValidationModel } from "./validation_model";
|
||||
import { ITopicModel, TopicViewModel } from "../../features/topics/topic_view_model";
|
||||
import { BehaviorTreeBuilderStore } from "../../features/behavior_tree_builder/presentation/behavior_tree_builder_store";
|
||||
import makeAutoObservable from "mobx-store-inheritance";
|
||||
import clone from "just-clone";
|
||||
import { TopicDependencyViewModel } from "../../features/behavior_tree_builder/presentation/ui/forms/topics_form/topic_dependency_view_model";
|
||||
import { FormBuilderValidationModel } from "./form_builder_validation_model";
|
||||
import { FormType } from "./form";
|
||||
|
||||
export interface IDependency {
|
||||
skills: ISkillDependency[];
|
||||
}
|
||||
|
@ -22,8 +26,6 @@ export interface ISkill {
|
|||
SkillPackage: ISkillPackage;
|
||||
Module: IModule;
|
||||
BTAction: IBTAction[];
|
||||
// Interface: IInterface;
|
||||
// Settings: ISetting[];
|
||||
}
|
||||
export interface IWeightsDependency {
|
||||
weights_name: string;
|
||||
|
@ -40,14 +42,28 @@ export interface IParam {
|
|||
type: string;
|
||||
dependency?: DependencyViewModel;
|
||||
}
|
||||
export class DependencyViewModel {
|
||||
|
||||
abstract class IDependencyViewModel {
|
||||
abstract type: FormType;
|
||||
}
|
||||
export class DependencyViewModel implements IDependencyViewModel {
|
||||
type: FormType;
|
||||
static empty = () => new DependencyViewModel();
|
||||
toView = (store: BehaviorTreeBuilderStore | undefined): React.ReactNode => "string";
|
||||
toView = (store: BehaviorTreeBuilderStore | undefined): React.ReactNode => "Dependency view model error";
|
||||
}
|
||||
export class ParamViewModel implements IParam {
|
||||
type: string;
|
||||
|
||||
@Type(() => DependencyViewModel)
|
||||
@Type(() => DependencyViewModel, {
|
||||
discriminator: {
|
||||
property: "type",
|
||||
subTypes: [
|
||||
{ value: TopicDependencyViewModel, name: FormType.topic },
|
||||
{ value: FormBuilderValidationModel, name: FormType.formBuilder },
|
||||
],
|
||||
},
|
||||
keepDiscriminatorProperty: true,
|
||||
})
|
||||
dependency: DependencyViewModel;
|
||||
isFilled: boolean = false;
|
||||
constructor(type: string, dependency: DependencyViewModel) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import { SceneManagerPath } from "../../../features/scene_manager/presentation/s
|
|||
import { AssemblesScreenPath } from "../../../features/assembles/assembles_screen";
|
||||
import { SimulationScreenPath } from "../../../features/simulations/simulations_screen";
|
||||
import { EstimateScreenPath } from "../../../features/estimate/estimate_screen";
|
||||
import { BehaviorTreeBuilderPath } from "../../../features/behavior_tree_builder/presentation/behavior_tree_builder_screen";
|
||||
import { CalculationInstanceScreenPath as SkillScreenPath } from "../../../features/calculation_instance/presentation/calculation_instance_screen";
|
||||
import { UiBaseError } from "../../model/ui_base_error";
|
||||
import { DetailsScreenPath } from "../../../features/details/details_screen";
|
||||
|
@ -54,7 +53,6 @@ export interface IMainPageProps {
|
|||
bodyChildren?: JSX.Element;
|
||||
panelChildren?: JSX.Element;
|
||||
panelStyle?: React.CSSProperties;
|
||||
|
||||
isLoading?: boolean;
|
||||
maskLoader?: boolean;
|
||||
error?: UiBaseError[];
|
||||
|
|
|
@ -52,16 +52,22 @@ export class BehaviorTreeBuilderModel {
|
|||
}
|
||||
public static xmlFormat = (result: string, btRootTag: string): Result<string, string> => {
|
||||
try {
|
||||
return Result.ok(xmlFormat(btRootTag.replace("${bt}", result)));
|
||||
return Result.ok(
|
||||
xmlFormat(
|
||||
'<root BTCPP_format="4"><BehaviorTree ID="Main">${bt}</BehaviorTree></root>'.replace(
|
||||
"${bt}",
|
||||
btRootTag.replace("${bt}", result)
|
||||
)
|
||||
)
|
||||
);
|
||||
} catch (error) {
|
||||
console.log(result);
|
||||
console.log(btRootTag);
|
||||
console.log(error);
|
||||
console.log(btRootTag.replace("${bt}", result))
|
||||
return Result.error(error as string);
|
||||
}
|
||||
};
|
||||
public static getNodeLabelAtId(editor: NodeEditor<Schemes>, id: string, skills?: Skills,) {
|
||||
public static getNodeLabelAtId(editor: NodeEditor<Schemes>, id: string, skills?: Skills) {
|
||||
try {
|
||||
if (skills?.getSkillsNames().find((el) => el.name.isEqual(editor.getNode(id)!.label))) {
|
||||
return `Action ID="RbsAction" do="${skills.getSkillDo(editor.getNode(id)!.label)}" command="${
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import React from "react";
|
||||
import makeAutoObservable from "mobx-store-inheritance";
|
||||
import clone from "just-clone";
|
||||
import { message } from "antd";
|
||||
import { NavigateFunction } from "react-router-dom";
|
||||
import makeAutoObservable from "mobx-store-inheritance";
|
||||
import { v4 } from "uuid";
|
||||
import clone from "just-clone";
|
||||
import { CoreError, UiDrawerFormState } from "../../../core/store/base_store";
|
||||
import {
|
||||
BehaviorTreeBuilderModel,
|
||||
|
@ -21,7 +21,7 @@ import { DependencyViewModel, IParam, Skills } from "../../../core/model/skill_m
|
|||
import { ISkillView } from "./ui/skill_tree/skill_tree";
|
||||
import { BehaviorTreeViewModel } from "../model/behavior_tree_view_model";
|
||||
import { UiBaseError } from "../../../core/model/ui_base_error";
|
||||
import { BehaviorTreeBuilderPath, behaviorTreeBuilderStore } from "./behavior_tree_builder_screen";
|
||||
import { behaviorTreeBuilderStore } from "./behavior_tree_builder_screen";
|
||||
import { BehaviorTreeModel } from "../model/behavior_tree_model";
|
||||
import { PrimitiveViewModel, SystemPrimitive } from "../model/primitive_view_model";
|
||||
import { SceneAsset } from "../../../core/model/scene_asset";
|
||||
|
@ -149,12 +149,10 @@ export class BehaviorTreeBuilderStore extends UiDrawerFormState<BehaviorTreeView
|
|||
this.nodeUpdateObserver = undefined;
|
||||
}
|
||||
async init(navigate: NavigateFunction): Promise<void> {
|
||||
(await this.behaviorTreeBuilderHttpRepository.getActiveProjectId())
|
||||
// eslint-disable-next-line array-callback-return
|
||||
.map((el) => {
|
||||
this.activeProject = el.id;
|
||||
this.viewModel.project = this.activeProject;
|
||||
});
|
||||
(await this.behaviorTreeBuilderHttpRepository.getActiveProjectId()).map((el) => {
|
||||
this.activeProject = el.id;
|
||||
this.viewModel.project = this.activeProject;
|
||||
});
|
||||
(await this.behaviorTreeBuilderHttpRepository.getBtSkills()).fold(
|
||||
(model) => {
|
||||
this.skillTemplates = Skills.fromSkills(model);
|
||||
|
@ -164,7 +162,6 @@ export class BehaviorTreeBuilderStore extends UiDrawerFormState<BehaviorTreeView
|
|||
}
|
||||
return el;
|
||||
});
|
||||
// this.sceneAsset = this.behaviorTreeBuilderHttpRepository.getScene()
|
||||
},
|
||||
(e) => console.log(e)
|
||||
);
|
||||
|
|
|
@ -137,7 +137,11 @@ export async function createEditor(container: HTMLElement) {
|
|||
el.source.isEqual(event.id) || el.target.isEqual(event.id) ? editor.removeConnection(el.id) : null
|
||||
);
|
||||
areaContainer.removeNodeView(event.id);
|
||||
|
||||
editor.removeNode(event.id)
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
AreaExtensions.selectableNodes(areaContainer, AreaExtensions.selector(), {
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import React, { useEffect } from "react";
|
||||
import { useEffect } from "react";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { FormBuilderStore } from "./form_builder_store";
|
||||
import { Modal, message } from "antd";
|
||||
import { FormsFormBuilderStore } from "./form_builder_store";
|
||||
import { IPropsForm } from "../forms";
|
||||
import { useStore } from "../../../../../../core/helper/use_store";
|
||||
import { isBtScreen } from "../../../behavior_tree_builder_screen";
|
||||
import { CoreInput } from "../../../../../../core/ui/input/input";
|
||||
import { CoreButton } from "../../../../../../core/ui/button/button";
|
||||
import { Modal, message } from "antd";
|
||||
import { FormBuilder } from "../../../../../../core/ui/form_builder/form_builder";
|
||||
import { FormBuilderValidationModel } from "../../../../../../core/model/form_builder_validation_model";
|
||||
|
||||
export const FormBuilderForm = observer((props: IPropsForm<Partial<FormBuilderValidationModel>>) => {
|
||||
const store = useStore(FormBuilderStore);
|
||||
const store = useStore(FormsFormBuilderStore);
|
||||
useEffect(() => {
|
||||
store.initParam(isBtScreen(), props.store);
|
||||
}, []);
|
||||
|
|
|
@ -3,11 +3,8 @@ import { NavigateFunction } from "react-router-dom";
|
|||
import { FormState, CoreError } from "../../../../../../core/store/base_store";
|
||||
import { BehaviorTreeBuilderStore } from "../../../behavior_tree_builder_store";
|
||||
import { FormBuilderValidationModel } from "../../../../../../core/model/form_builder_validation_model";
|
||||
|
||||
export class FormBuilderStore extends FormState<FormBuilderValidationModel, CoreError> {
|
||||
openModal() {
|
||||
this.isModalOpen = true;
|
||||
}
|
||||
|
||||
export class FormsFormBuilderStore extends FormState<FormBuilderValidationModel, CoreError> {
|
||||
isBtScreen = false;
|
||||
isModalOpen = false;
|
||||
viewModel: FormBuilderValidationModel = FormBuilderValidationModel.empty();
|
||||
|
@ -18,6 +15,9 @@ export class FormBuilderStore extends FormState<FormBuilderValidationModel, Core
|
|||
errorHandingStrategy = (error: CoreError) => {};
|
||||
init = async (navigate?: NavigateFunction | undefined) => {};
|
||||
initParam = (isSkillScreen: boolean, store: BehaviorTreeBuilderStore | undefined) => {
|
||||
this.isBtScreen = true;
|
||||
this.isBtScreen = isSkillScreen;
|
||||
};
|
||||
openModal() {
|
||||
this.isModalOpen = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { FormType } from "../../../../../core/model/form";
|
||||
import { FormBuilderValidationModel } from "../../../../../core/model/form_builder_validation_model";
|
||||
import { DependencyViewModel } from "../../../../../core/model/skill_model";
|
||||
import { BehaviorTreeBuilderStore } from "../../behavior_tree_builder_store";
|
||||
|
@ -15,27 +16,20 @@ export interface IForms {
|
|||
name: string;
|
||||
component: JSX.Element;
|
||||
}
|
||||
export enum Form {
|
||||
weights = "weights",
|
||||
robotName = "robot_name",
|
||||
cameraDeviceForm = "camera",
|
||||
topic = "topic",
|
||||
formBuilder = "formBuilder",
|
||||
moveToPose = "move_to_pose",
|
||||
}
|
||||
|
||||
export interface BtDependencyFormBuilder {
|
||||
form: Form;
|
||||
form: FormType;
|
||||
component?: React.ReactNode;
|
||||
}
|
||||
|
||||
export const btDependencyFormBuilder = (onChange: (dependency: DependencyViewModel) => void) => [
|
||||
{ form: Form.weights, component: null },
|
||||
{ form: FormType.weights, component: null },
|
||||
{
|
||||
form: Form.topic,
|
||||
form: FormType.topic,
|
||||
component: <TopicsForm store={undefined} dependency={TopicDependencyViewModel.empty()} onChange={onChange} />,
|
||||
},
|
||||
{
|
||||
form: Form.formBuilder,
|
||||
form: FormType.formBuilder,
|
||||
component: (
|
||||
<FormBuilderForm store={undefined} dependency={FormBuilderValidationModel.empty()} onChange={onChange} />
|
||||
),
|
||||
|
@ -46,6 +40,6 @@ export const forms = (
|
|||
onChange: (dependency: DependencyViewModel) => void,
|
||||
store: BehaviorTreeBuilderStore
|
||||
): IForms[] => [
|
||||
{ name: Form.topic, component: <TopicsForm store={store} dependency={props} onChange={onChange} /> },
|
||||
{ name: Form.formBuilder, component: <FormBuilderForm store={store} dependency={props} onChange={onChange} /> },
|
||||
{ name: FormType.topic, component: <TopicsForm store={store} dependency={props} onChange={onChange} /> },
|
||||
{ name: FormType.formBuilder, component: <FormBuilderForm store={store} dependency={props} onChange={onChange} /> },
|
||||
];
|
||||
|
|
|
@ -5,19 +5,20 @@ import { StoreTopicType } from "./topics_form_store";
|
|||
import { DependencyViewModel } from "../../../../../../core/model/skill_model";
|
||||
import { BehaviorTreeBuilderStore } from "../../../behavior_tree_builder_store";
|
||||
import { CoreText, CoreTextType } from "../../../../../../core/ui/text/text";
|
||||
|
||||
import { FormType } from "../../../../../../core/model/form";
|
||||
|
||||
export class TopicDependencyViewModel extends ValidationModel implements DependencyViewModel {
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
type: string;
|
||||
type = FormType.topic;
|
||||
topicType?: string;
|
||||
|
||||
mode?: StoreTopicType;
|
||||
sid?: string;
|
||||
topicOut?: string;
|
||||
constructor(type: string, mode: StoreTopicType) {
|
||||
constructor() {
|
||||
super();
|
||||
makeAutoObservable(this);
|
||||
this.type = type;
|
||||
this.mode = mode;
|
||||
}
|
||||
toView = (store: BehaviorTreeBuilderStore | undefined): React.ReactNode => {
|
||||
if (store && this.sid) {
|
||||
|
@ -31,6 +32,6 @@ export class TopicDependencyViewModel extends ValidationModel implements Depende
|
|||
};
|
||||
|
||||
static empty() {
|
||||
return new TopicDependencyViewModel("", StoreTopicType.specifiesDependencies);
|
||||
return new TopicDependencyViewModel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ export const TopicsForm = observer((props: IPropsForm<Partial<TopicDependencyVie
|
|||
style={{ padding: 10 }}
|
||||
color={themeStore.theme.darkOnSurfaceVariant}
|
||||
/>
|
||||
{match(store.type)
|
||||
.with(StoreTopicType.btExecute, () => (
|
||||
{match(isBtScreen())
|
||||
.with(true, () => (
|
||||
<>
|
||||
<CoreText
|
||||
text={"Выберите топик"}
|
||||
|
@ -75,9 +75,9 @@ export const TopicsForm = observer((props: IPropsForm<Partial<TopicDependencyVie
|
|||
/>
|
||||
</>
|
||||
))
|
||||
.with(StoreTopicType.specifiesDependencies, () => (
|
||||
.with(false, () => (
|
||||
<>
|
||||
<CoreInput label={"Тип топика"} onChange={(text) => store.updateForm({ type: text })} />
|
||||
<CoreInput label={"Тип топика"} onChange={(text) => store.updateForm({ topicType: text })} />
|
||||
<div style={{ height: 10 }} />
|
||||
<CoreButton
|
||||
text="OK"
|
||||
|
|
|
@ -24,7 +24,8 @@ export class TopicsFormStore extends FormState<TopicDependencyViewModel, CoreErr
|
|||
init = async (navigate?: NavigateFunction | undefined) => {
|
||||
// await this.mapOk('topics', this.cameraDeviceHttpRepository.getAllTopics())
|
||||
};
|
||||
getAllTopicsMatched = () => this.topics?.filter((el) => el.type.isEqual(this.viewModel.type));
|
||||
getAllTopicsMatched = () => this.topics?.filter((el) => el.type.isEqual(this.viewModel.topicType ?? ""));
|
||||
|
||||
initParam = (isBtScreen: boolean, behaviorTreeBuilderStore: BehaviorTreeBuilderStore | undefined) => {
|
||||
isBtScreen ? (this.type = StoreTopicType.btExecute) : (this.type = StoreTopicType.specifiesDependencies);
|
||||
this.behaviorTreeBuilderStore = behaviorTreeBuilderStore;
|
||||
|
|
|
@ -3,9 +3,10 @@ import { UiDrawerFormState } from "../../core/store/base_store";
|
|||
import { NavigateFunction } from "react-router-dom";
|
||||
import { HttpError } from "../../core/repository/core_http_repository";
|
||||
import { DependencyViewModel, ParamViewModel, SkillModel } from "../../core/model/skill_model";
|
||||
import { Form } from "../behavior_tree_builder/presentation/ui/forms/forms";
|
||||
import { message } from "antd";
|
||||
import { SkillsHttpRepository } from "./skills_http_repository";
|
||||
import { FormType } from "../../core/model/form";
|
||||
|
||||
export enum DrawersSkills {
|
||||
newSkill = "Новый навык",
|
||||
}
|
||||
|
@ -14,7 +15,7 @@ export class SkillsStore extends UiDrawerFormState<SkillModel, HttpError> {
|
|||
activeIndex?: number;
|
||||
viewModel: SkillModel = SkillModel.empty();
|
||||
selectParam?: {
|
||||
form: Form;
|
||||
form: FormType;
|
||||
component?: React.ReactNode;
|
||||
};
|
||||
skills: SkillModel[];
|
||||
|
@ -66,7 +67,7 @@ export class SkillsStore extends UiDrawerFormState<SkillModel, HttpError> {
|
|||
}
|
||||
);
|
||||
|
||||
clickParam(el: { form: Form; component: null } | { form: Form; component: React.JSX.Element }): void {
|
||||
clickParam(el: { form: FormType; component: null } | { form: FormType; component: React.JSX.Element }): void {
|
||||
this.selectParam = el;
|
||||
if (el.component === null) this.onChangeBtDependency(DependencyViewModel.empty());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue