progress
This commit is contained in:
parent
d7ea79935e
commit
c2da1d8f4c
19 changed files with 76 additions and 38 deletions
|
@ -8,6 +8,9 @@ import { SaveBtScenario as FillBtScenario } from "./domain/save_bt_scenario";
|
|||
import { GetCameraUseCase } from "./domain/get_cameras_usecase";
|
||||
import { GetRobotsUseCase } from "./domain/get_robots_usecase";
|
||||
import { GetTopicsUseCase } from "./domain/get_topics_usecase";
|
||||
import { DeleteBehaviorTreeScenario } from "./domain/delete_behavior_tree_scenario";
|
||||
|
||||
|
||||
|
||||
export class BehaviorTreesPresentation extends CrudController<BehaviorTreeValidationModel, typeof BehaviorTreeDBModel> {
|
||||
constructor() {
|
||||
|
@ -43,6 +46,11 @@ export class BehaviorTreesPresentation extends CrudController<BehaviorTreeValida
|
|||
subUrl: "topics",
|
||||
fn: new GetTopicsUseCase()
|
||||
})
|
||||
this.subRoutes.push({
|
||||
method: "POST",
|
||||
subUrl: "delete/bt",
|
||||
fn: new DeleteBehaviorTreeScenario(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
import { CallbackStrategyWithIdQuery, ResponseBase } from "../../../core/controllers/http_controller";
|
||||
import { StaticFilesProject } from "../../../core/models/static_files";
|
||||
import { DeleteDataBaseModelUseCase } from "../../../core/usecases/delete_database_model_usecase";
|
||||
import { DeleteRecursiveFolderUseCase } from "../../../core/usecases/delete_recursive_folder_usecase";
|
||||
import { SearchOneDataBaseModelUseCase } from "../../../core/usecases/search_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 { BehaviorTreeDBModel } from "../models/behavior_tree_database_model";
|
||||
|
||||
export class DeleteBehaviorTreeScenario extends CallbackStrategyWithIdQuery {
|
||||
idValidationExpression: CoreValidation = new MongoIdValidation();
|
||||
call = async (id: string): ResponseBase => (
|
||||
await new SearchOneDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call({ isActive: true }, "no active projects")
|
||||
).map(async (model) => (await (new DeleteRecursiveFolderUseCase().call(`${model.rootDir}/${StaticFilesProject.behaviorTrees}`))).map(async () => (await new DeleteDataBaseModelUseCase(BehaviorTreeDBModel).call(id))));
|
||||
}
|
|
@ -4,9 +4,8 @@ import { SearchOneDataBaseModelUseCase } from "../../../core/usecases/search_dat
|
|||
import { IProjectModel, ProjectDBModel } from "../models/project_model_database_model";
|
||||
|
||||
export class GetActiveProjectIdScenario extends CallbackStrategyWithEmpty {
|
||||
async call(): Promise<Result<any, { id: string }>> {
|
||||
return (
|
||||
await new SearchOneDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call({ isActive: true }, "no active projects")
|
||||
).map((model) => Result.ok({ id: model._id }));
|
||||
}
|
||||
call = async (): Promise<Result<any, { id: string }>> => (
|
||||
await new SearchOneDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call({ isActive: true }, "no active projects")
|
||||
).map((model) => Result.ok({ id: model._id }));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,11 @@ 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";
|
||||
|
||||
extensions();
|
||||
|
||||
const socketSubscribers = [new SocketSubscriber(executorProgramService, "realtime")];
|
||||
|
||||
new App(httpRoutes, socketSubscribers).listen();
|
||||
// main()
|
|
@ -10,7 +10,6 @@ export class FormBuilderValidationModel extends ValidationModel implements Depen
|
|||
@IsNotEmpty()
|
||||
@IsString()
|
||||
public result: string;
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
public context: string;
|
||||
public form: string[];
|
||||
|
@ -36,6 +35,19 @@ export class FormBuilderValidationModel extends ValidationModel implements Depen
|
|||
static emptyTest = () => new FormBuilderValidationModel(``, ``, [], defaultFormValue);
|
||||
static creteDataSetTest = () => new FormBuilderValidationModel(``, scene, [], "");
|
||||
static emptySimple = () => new FormBuilderValidationModel("", simpleFormBuilder, [], "");
|
||||
static eee = () =>
|
||||
new FormBuilderValidationModel(
|
||||
``,
|
||||
`{
|
||||
"robot_name": \${ROBOT_NAME:string:rbs_arm},
|
||||
"pose": {
|
||||
"position": { "x": \${X:number:0.1}, "y": \${Y:number:0.1}, "z": \${Z:number:0.7} },
|
||||
"orientation": { "x": \${X:number:0.1}, "y": \${Y:number:0.1}, "z": \${Z:number:0.7} }
|
||||
}
|
||||
}`,
|
||||
[],
|
||||
""
|
||||
);
|
||||
static vision = () =>
|
||||
new FormBuilderValidationModel(
|
||||
`
|
||||
|
|
|
@ -16,11 +16,10 @@ export const DrawerV2: React.FC<{
|
|||
right: isOpen ? 0 : -300,
|
||||
width: 300,
|
||||
height: "100%",
|
||||
backgroundColor: themeStore.theme.darkSurface,
|
||||
backgroundColor: "#880ef8",
|
||||
boxShadow: "-2px 0 5px rgba(0, 0, 0, 0.5)",
|
||||
transition: "right 0.3s ease",
|
||||
zIndex: 1000,
|
||||
|
||||
}}
|
||||
>
|
||||
<div style={{ height: "100%", width: "100%" }}>
|
||||
|
|
|
@ -100,7 +100,7 @@ export const FormBuilder = observer(
|
|||
return (
|
||||
<div>
|
||||
<CoreInput
|
||||
isFormBuilder={true}
|
||||
|
||||
style={{ margin: 5 }}
|
||||
onChange={(e) => store.changeTotalSubValue(element.id, subIndex, e, index)}
|
||||
validation={
|
||||
|
@ -131,7 +131,7 @@ export const FormBuilder = observer(
|
|||
return (
|
||||
<div>
|
||||
<CoreInput
|
||||
isFormBuilder={true}
|
||||
|
||||
validation={element.type.isEqual(InputType.NUMBER) ? (el) => Number().isValid(el) : undefined}
|
||||
onChange={(e) => {
|
||||
store.changeTotalValue(element.id, e);
|
||||
|
|
|
@ -95,7 +95,7 @@ export class FormViewModel {
|
|||
.replace(/[^\x00-\x7F]/g, "")
|
||||
.replaceAll("\n", "")
|
||||
.replaceAll("\\", "")
|
||||
// .replaceAll("/", "")
|
||||
// .replaceAll("/", "")
|
||||
);
|
||||
} catch (error) {
|
||||
console.log("ERROR: FormViewModel json() " + result);
|
||||
|
@ -190,8 +190,9 @@ export class FormViewModel {
|
|||
});
|
||||
return result as unknown as string;
|
||||
}
|
||||
static fromString(result: string, context: string): Result<void, FormViewModel> {
|
||||
static fromString(result: string = '', context: string = ''): Result<void, FormViewModel> {
|
||||
try {
|
||||
|
||||
if (result.isEmpty() && context.isEmpty()) {
|
||||
return Result.error(undefined);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import { message } from "antd";
|
|||
export const SelectProcess = observer((props: IFormBuilderComponentsProps<any>) => {
|
||||
const [store] = useState(new SelectProcessStore());
|
||||
useEffect(() => {
|
||||
console.log(props.dependency)
|
||||
store.loadClassInstance(SelectProcessModel, props.dependency);
|
||||
store.init();
|
||||
}, []);
|
||||
|
|
|
@ -9,7 +9,7 @@ import { FormBuilder } from "./form_builder";
|
|||
import makeAutoObservable from "mobx-store-inheritance";
|
||||
|
||||
class FormBuilderTextStore extends ModalStore {
|
||||
viewModel = FormBuilderValidationModel.vision();
|
||||
viewModel = FormBuilderValidationModel.eee();
|
||||
constructor() {
|
||||
super();
|
||||
makeAutoObservable(this);
|
||||
|
@ -39,6 +39,7 @@ export const FormBuildTest = observer(() => {
|
|||
<FormBuilder
|
||||
formBuilder={store.viewModel}
|
||||
onChange={(e) => {
|
||||
console.log(e)
|
||||
// console.log(e.output);
|
||||
console.log(JSON.stringify(e.output))
|
||||
}}
|
||||
|
|
|
@ -16,7 +16,6 @@ interface IInputProps extends IStyle {
|
|||
type?: CoreInputType;
|
||||
trim?: boolean;
|
||||
styleContentEditable?: React.CSSProperties;
|
||||
isFormBuilder?: boolean;
|
||||
}
|
||||
|
||||
export const CoreInput = (props: IInputProps) => {
|
||||
|
@ -29,15 +28,6 @@ export const CoreInput = (props: IInputProps) => {
|
|||
setAppendInnerText(false);
|
||||
}
|
||||
}, [ref, value, isAppendInnerText, setAppendInnerText, props]);
|
||||
// React.useEffect(() => {
|
||||
// if (props.isFormBuilder) {
|
||||
// if (ref.current && props.value) {
|
||||
// ref.current.innerText = value;
|
||||
// setValue(props.value);
|
||||
// console.log(props.value);
|
||||
// }
|
||||
// }
|
||||
// }, [props.value]);
|
||||
|
||||
const isSmall = props.type !== undefined && props.type.isEqual(CoreInputType.small);
|
||||
return (
|
||||
|
|
|
@ -2,15 +2,16 @@ import { themeStore } from "../../..";
|
|||
import { Icon } from "../icons/icons";
|
||||
import { CoreText, CoreTextType, FontType } from "../text/text";
|
||||
|
||||
interface InputV2Props {
|
||||
export const InputV2: React.FC<{
|
||||
style?: React.CSSProperties;
|
||||
label: string;
|
||||
value?: string;
|
||||
trim?: boolean;
|
||||
validation?: (value: string) => boolean;
|
||||
error?: string;
|
||||
height?: number;
|
||||
onChange?: (text: string) => void;
|
||||
|
||||
}
|
||||
export const InputV2: React.FC<InputV2Props> = ({ label, height, value, onChange, trim }) => {
|
||||
}> = ({ label, height, value, onChange, trim }) => {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
|
|
|
@ -21,7 +21,6 @@ export class BehaviorTreeBuilderHttpRepository extends CoreHttpRepository {
|
|||
`${this.featureApi}/by_id?id=${id}`,
|
||||
BehaviorTreeModel
|
||||
) as unknown as Promise<Result<HttpError, BehaviorTreeModel>>;
|
||||
deleteBt = (id: string) => this._jsonRequest(HttpMethod.DELETE, `${this.featureApi}?id=${id}`);
|
||||
editBt = async (model: BehaviorTreeModel) => {
|
||||
await this._jsonRequest(HttpMethod.POST, `${this.featureApi}/fill/tree`, model);
|
||||
model.__v = undefined
|
||||
|
|
|
@ -148,7 +148,7 @@ export const BehaviorTreeBuilderScreen = observer(() => {
|
|||
width: "calc(100% - 300px)",
|
||||
}}
|
||||
>
|
||||
<PanelGroup direction="horizontal" style={{ width: "100%" }}>
|
||||
{/* <PanelGroup direction="horizontal" style={{ width: "100%" }}>
|
||||
<Panel>
|
||||
<div
|
||||
ref={ref}
|
||||
|
@ -160,11 +160,18 @@ export const BehaviorTreeBuilderScreen = observer(() => {
|
|||
}}
|
||||
/>
|
||||
</Panel>
|
||||
<PanelResizeHandle>
|
||||
<div style={{ width: 10, height: "100%", backgroundColor: "beige" }}></div>
|
||||
</PanelResizeHandle>
|
||||
<Panel defaultSize={0}> </Panel>
|
||||
</PanelGroup>
|
||||
{store.panels.map((el) => (
|
||||
<>
|
||||
<PanelResizeHandle>
|
||||
<div style={{ width: "100%", color: "white" }}>BANE</div>
|
||||
<div
|
||||
style={{ width: 10, height: "100%", backgroundColor: "beige", border: "1px solid black" }}
|
||||
></div>
|
||||
</PanelResizeHandle>
|
||||
<Panel defaultSize={0}> </Panel>
|
||||
</>
|
||||
))}
|
||||
</PanelGroup> */}
|
||||
</div>
|
||||
</>
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ export class BehaviorTreeBuilderStore extends UiDrawerFormState<BehaviorTreeView
|
|||
},
|
||||
],
|
||||
};
|
||||
panels = [1, 1, 1, 1];
|
||||
|
||||
constructor() {
|
||||
super(DrawerState);
|
||||
|
|
|
@ -81,7 +81,7 @@ export const FormBuilderForm = observer((props: IPropsForm<Partial<FormBuilderVa
|
|||
store.isModalOpen = false;
|
||||
}}
|
||||
>
|
||||
<FormBuilder formBuilder={store.viewModel} onChange={() => {}} />
|
||||
<FormBuilder formBuilder={store.viewModel} onChange={(form) => (console.log(form), props.onChange(form))} />
|
||||
</Modal>
|
||||
</>
|
||||
)}
|
||||
|
|
|
@ -4,7 +4,7 @@ import { BehaviorTreeViewModel } from "../behavior_tree_builder/model/behavior_t
|
|||
|
||||
export class BehaviorTreeManagerHttpRepository extends CoreHttpRepository {
|
||||
featureApi = `/behavior/trees`;
|
||||
deleteBt = (id: string) => this._jsonRequest(HttpMethod.DELETE, `${this.featureApi}?id=${id}`);
|
||||
deleteBt = (id: string) => this._jsonRequest(HttpMethod.POST, `${this.featureApi}/delete/bt?id=${id}`);
|
||||
saveNewBt = async (model: BehaviorTreeViewModel) => this._jsonRequest(HttpMethod.POST, this.featureApi, model);
|
||||
getAllBtInstances = async () => this._jsonRequest<BehaviorTreeModel[]>(HttpMethod.GET, this.featureApi);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import { useStore } from "../../core/helper/use_store";
|
|||
import { FormBuilder } from "../../core/ui/form_builder/form_builder";
|
||||
import { ButtonV2 } from "../../core/ui/button/button_v2";
|
||||
import { Result } from "../../core/helper/result";
|
||||
import { plainToInstance } from "class-transformer";
|
||||
|
||||
export const isValidJson = <T,>(json: any): Result<string, T> => {
|
||||
try {
|
||||
|
@ -288,3 +287,4 @@ export const SkillsScreen = observer(() => {
|
|||
</>
|
||||
);
|
||||
});
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import "reflect-metadata";
|
||||
import "antd/dist/antd.min.css";
|
||||
import ReactDOM from "react-dom/client";
|
||||
|
@ -8,6 +7,7 @@ import { RouterProvider } from "react-router-dom";
|
|||
import { router } from "./core/routers/routers";
|
||||
import { configure } from "mobx";
|
||||
import { ThemeStore } from "./core/store/theme_store";
|
||||
import { FormBuildTest } from "./core/ui/form_builder/test";
|
||||
|
||||
configure({
|
||||
enforceActions: "never",
|
||||
|
@ -23,5 +23,6 @@ root.render(
|
|||
<SocketListener>
|
||||
<RouterProvider router={router} />
|
||||
</SocketListener>
|
||||
{/* <FormBuildTest /> */}
|
||||
</>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue