add new feature
This commit is contained in:
parent
8696d99194
commit
12c09c4461
24 changed files with 305 additions and 266 deletions
|
@ -4,7 +4,8 @@ import { CalculationInstanceValidationModel } from "./models/calculations_instan
|
|||
import { CalculationInstanceDBModel } from "./models/calculations_instance_database_model";
|
||||
import { CreateCalculationInstanceScenario } from "./domain/create_calculation_instance_scenario";
|
||||
import { DeleteCalculationsInstanceScenario } from "./domain/delete_calculations_instance_scenario";
|
||||
|
||||
import { GetAllEndCalculationsInstanceActiveProjectScenarios } from "./domain/get_all_end_calculations_instance_active_project_scenarios";
|
||||
|
||||
|
||||
export class CalculationsInstancesPresentation extends CrudController<
|
||||
CalculationInstanceValidationModel,
|
||||
|
@ -19,7 +20,12 @@ export class CalculationsInstancesPresentation extends CrudController<
|
|||
|
||||
super.delete(new DeleteCalculationsInstanceScenario().call);
|
||||
super.post(new CreateCalculationInstanceScenario().call);
|
||||
|
||||
this.subRoutes.push({
|
||||
method: "POST",
|
||||
subUrl: "get/all/end/calculations",
|
||||
//@ts-expect-error
|
||||
fn: new GetAllEndCalculationsInstanceActiveProjectScenarios(),
|
||||
})
|
||||
this.subRoutes.push({
|
||||
method: "GET",
|
||||
subUrl: "exec",
|
||||
|
@ -27,4 +33,3 @@ export class CalculationsInstancesPresentation extends CrudController<
|
|||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import { IsString } from "class-validator";
|
||||
import { CallbackStrategyWithValidationModel, ResponseBase } from "../../../core/controllers/http_controller";
|
||||
import { SearchManyDataBaseModelUseCase } from "../../../core/usecases/search_many_database_model_usecase";
|
||||
import { GetActiveProjectIdScenario } from "../../projects/domain/get_active_project_id_scenario";
|
||||
import { ICalculationInstance, CalculationInstanceDBModel } from "../models/calculations_instance_database_model";
|
||||
|
||||
|
||||
export class CalculationInstanceType {
|
||||
@IsString()
|
||||
type: string;
|
||||
}
|
||||
|
||||
export class GetAllEndCalculationsInstanceActiveProjectScenarios extends CallbackStrategyWithValidationModel<CalculationInstanceType> {
|
||||
validationModel: CalculationInstanceType = new CalculationInstanceType();
|
||||
call = async (model: CalculationInstanceType): ResponseBase => (await new GetActiveProjectIdScenario().call()).map(
|
||||
async (activeProjectModel) => await new SearchManyDataBaseModelUseCase<ICalculationInstance>(CalculationInstanceDBModel).call({ project: activeProjectModel.id, isEnd: true, type: model.type }),
|
||||
);
|
||||
|
||||
|
||||
}
|
|
@ -62,6 +62,7 @@ export const CalculationInstanceSchema = new Schema({
|
|||
instancePath: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
project: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: projectSchema,
|
||||
|
|
|
@ -10,6 +10,11 @@ export const ArrayExtensions = () => {
|
|||
return Result.ok(this);
|
||||
};
|
||||
}
|
||||
if ([].whereOne === undefined) {
|
||||
Array.prototype.whereOne = function (predicate) {
|
||||
return this.filter(predicate).atR(0);
|
||||
}
|
||||
}
|
||||
if ([].atR === undefined) {
|
||||
Array.prototype.atR = function (index) {
|
||||
if (index === undefined) {
|
||||
|
|
|
@ -30,6 +30,7 @@ declare global {
|
|||
someR(predicate: (value: T) => boolean): Result<void, Array<T>>;
|
||||
updateAll(value: Partial<T>): Array<T>;
|
||||
atR(index: number | undefined): Result<void, T>;
|
||||
whereOne(predicate: (value: T) => boolean): Result<void, T>;
|
||||
}
|
||||
interface Date {
|
||||
formatDate(): string;
|
||||
|
|
|
@ -1,19 +1,12 @@
|
|||
import { IsNotEmpty, IsString } from "class-validator";
|
||||
import { BehaviorTreeBuilderStore } from "../../features/behavior_tree_builder/presentation/behavior_tree_builder_store";
|
||||
import {
|
||||
datasetFormMockContext,
|
||||
datasetFormMockResult,
|
||||
defaultFormValue,
|
||||
} from "../../features/dataset/dataset_model";
|
||||
import { datasetFormMockContext, datasetFormMockResult, defaultFormValue } from "../../features/dataset/dataset_model";
|
||||
import { DependencyViewModel } from "./skill_model";
|
||||
import { ValidationModel } from "./validation_model";
|
||||
import { FormType } from "./form";
|
||||
import makeAutoObservable from "mobx-store-inheritance";
|
||||
|
||||
export class FormBuilderValidationModel
|
||||
extends ValidationModel
|
||||
implements DependencyViewModel
|
||||
{
|
||||
export class FormBuilderValidationModel extends ValidationModel implements DependencyViewModel {
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
public result: string;
|
||||
|
@ -36,22 +29,13 @@ export class FormBuilderValidationModel
|
|||
formBuilderValidationModel.context.isEmpty() &&
|
||||
formBuilderValidationModel.result.isEmpty() &&
|
||||
formBuilderValidationModel.form.isEmpty();
|
||||
static test = () =>
|
||||
new FormBuilderValidationModel(ffContext, ff1Result, [], "");
|
||||
static test = () => new FormBuilderValidationModel(ffContext, ff1Result, [], "");
|
||||
static datasetEmpty = () =>
|
||||
new FormBuilderValidationModel(
|
||||
datasetFormMockContext,
|
||||
datasetFormMockResult,
|
||||
[],
|
||||
defaultFormValue
|
||||
);
|
||||
new FormBuilderValidationModel(datasetFormMockContext, datasetFormMockResult, [], defaultFormValue);
|
||||
static empty = () => new FormBuilderValidationModel("", "", [], "");
|
||||
static emptyTest = () =>
|
||||
new FormBuilderValidationModel(``, ``, [], defaultFormValue);
|
||||
static creteDataSetTest = () =>
|
||||
new FormBuilderValidationModel(``, scene, [], "");
|
||||
static emptySimple = () =>
|
||||
new FormBuilderValidationModel("", simpleFormBuilder, [], "");
|
||||
static emptyTest = () => new FormBuilderValidationModel(``, ``, [], defaultFormValue);
|
||||
static creteDataSetTest = () => new FormBuilderValidationModel(``, scene, [], "");
|
||||
static emptySimple = () => new FormBuilderValidationModel("", simpleFormBuilder, [], "");
|
||||
static vision = () =>
|
||||
new FormBuilderValidationModel(
|
||||
`
|
||||
|
@ -96,6 +80,7 @@ export class FormBuilderValidationModel
|
|||
};`,
|
||||
`
|
||||
{
|
||||
"process":\${<SelectProcess/>:OBJECT:{"type": "OBJECT_DETECTION"},
|
||||
"datasetObjects":\${<SelectDetail/>:OBJECT:{"details": []},
|
||||
"typedataset": \${typedataset:Enum<T>:ObjectDetection},
|
||||
"models_randomization":{
|
||||
|
|
|
@ -127,6 +127,3 @@ export abstract class FormState<V, E> extends UiErrorState<E> {
|
|||
this.viewModel = plainToInstance(instance, viewModel);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,9 +1,5 @@
|
|||
import * as React from "react";
|
||||
import {
|
||||
FormViewModel,
|
||||
InputBuilderViewModel,
|
||||
InputType,
|
||||
} from "./form_view_model";
|
||||
import { FormViewModel, InputBuilderViewModel, InputType } from "./form_view_model";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { FormBuilderStore } from "./form_builder_store";
|
||||
import { CoreSelect } from "../select/select";
|
||||
|
@ -13,219 +9,162 @@ import { CoreText, CoreTextType } from "../text/text";
|
|||
import { getFormBuilderComponents } from "./forms/form_builder_components";
|
||||
import { FormBuilderValidationModel } from "../../model/form_builder_validation_model";
|
||||
|
||||
export interface IFormBuilder {
|
||||
formBuilder: FormBuilderValidationModel;
|
||||
onChange: (change: FormBuilderValidationModel) => void;
|
||||
}
|
||||
export const FormBuilder = observer(
|
||||
(props: { formBuilder: FormBuilderValidationModel; onChange: (change: FormBuilderValidationModel) => void }) => {
|
||||
const [store] = React.useState(() => new FormBuilderStore());
|
||||
|
||||
export const FormBuilder = observer((props: IFormBuilder) => {
|
||||
const [store] = React.useState(() => new FormBuilderStore());
|
||||
React.useEffect(() => {
|
||||
store.init(props.formBuilder.context, props.formBuilder.result);
|
||||
if (props.formBuilder.form.isNotEmpty()) {
|
||||
store.formViewModel = new FormViewModel(
|
||||
props.formBuilder.form.map((el) => InputBuilderViewModel.fromJSON(el)),
|
||||
props.formBuilder.result,
|
||||
props.formBuilder.context
|
||||
);
|
||||
props.formBuilder.form.map((el) => InputBuilderViewModel.fromJSON(el));
|
||||
}
|
||||
store.changerForm.on((event) => {
|
||||
if (event) props.onChange(event);
|
||||
});
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
store.init(props.formBuilder.context, props.formBuilder.result);
|
||||
if (props.formBuilder.form.isNotEmpty()) {
|
||||
store.formViewModel = new FormViewModel(
|
||||
props.formBuilder.form.map((el) => InputBuilderViewModel.fromJSON(el)),
|
||||
props.formBuilder.result,
|
||||
props.formBuilder.context
|
||||
);
|
||||
props.formBuilder.form.map((el) => InputBuilderViewModel.fromJSON(el));
|
||||
}
|
||||
store.changerForm.on((event) => {
|
||||
if (event) props.onChange(event);
|
||||
});
|
||||
}, []);
|
||||
return (
|
||||
<div>
|
||||
{store.isError ? (
|
||||
<>Error</>
|
||||
) : (
|
||||
<div>
|
||||
{store.formViewModel?.inputs?.map((element, index) => {
|
||||
if (element.type?.isEqual(InputType.ENUM)) {
|
||||
const values = element.values as string[];
|
||||
return (
|
||||
<CoreSelect
|
||||
key={index}
|
||||
items={values}
|
||||
value={element.totalValue ?? element.defaultValue}
|
||||
onChange={(value) => store.changeTotalValue(element.id, value)}
|
||||
label={element.name}
|
||||
style={{ margin: 20 }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (element.type?.isEqual(InputType.ARRAY)) {
|
||||
return (
|
||||
<div key={index} style={{ border: "1px black solid", margin: 20 }}>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
margin: 20,
|
||||
alignItems: "center",
|
||||
paddingRight: 20,
|
||||
}}
|
||||
onClick={() => {
|
||||
store.open(element.id);
|
||||
}}
|
||||
>
|
||||
<CoreText text={element.name} type={CoreTextType.large} />
|
||||
<Icon type="PlusCircle" style={{ width: 33 }} />
|
||||
</div>
|
||||
|
||||
return (
|
||||
<div>
|
||||
{store.isError ? (
|
||||
<>Error</>
|
||||
) : (
|
||||
<div>
|
||||
{store.formViewModel?.inputs?.map((element, index) => {
|
||||
if (element.type?.isEqual(InputType.ENUM)) {
|
||||
const values = element.values as string[];
|
||||
return (
|
||||
<CoreSelect
|
||||
key={index}
|
||||
items={values}
|
||||
value={element.totalValue ?? element.defaultValue}
|
||||
onChange={(value) =>
|
||||
store.changeTotalValue(element.id, value)
|
||||
}
|
||||
label={element.name}
|
||||
style={{ margin: 20 }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (element.type?.isEqual(InputType.ARRAY)) {
|
||||
return (
|
||||
<div
|
||||
key={index}
|
||||
style={{ border: "1px black solid", margin: 20 }}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
margin: 20,
|
||||
alignItems: "center",
|
||||
paddingRight: 20,
|
||||
}}
|
||||
onClick={() => {
|
||||
store.open(element.id);
|
||||
}}
|
||||
>
|
||||
<CoreText text={element.name} type={CoreTextType.large} />
|
||||
<Icon type="PlusCircle" style={{ width: 33 }} />
|
||||
</div>
|
||||
{element.isOpen ? (
|
||||
<div style={{ margin: 20 }}>
|
||||
{element.totalValue instanceof Array
|
||||
? element.totalValue?.map((subArray, index) => {
|
||||
return (
|
||||
<div style={{ margin: 20 }}>
|
||||
<div style={{ display: "flex" }}>
|
||||
<CoreText text={(element.subType ?? "") + ` ${index}`} type={CoreTextType.medium} />
|
||||
<Icon
|
||||
style={{ paddingLeft: 20 }}
|
||||
type="DeleteCircle"
|
||||
onClick={() => store.deleteTotalValueSubItem(element.id, index)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{element.isOpen ? (
|
||||
<div style={{ margin: 20 }}>
|
||||
{element.totalValue instanceof Array
|
||||
? element.totalValue?.map((subArray, index) => {
|
||||
return (
|
||||
<div style={{ margin: 20 }}>
|
||||
<div style={{ display: "flex" }}>
|
||||
<CoreText
|
||||
text={(element.subType ?? "") + ` ${index}`}
|
||||
type={CoreTextType.medium}
|
||||
/>
|
||||
<Icon
|
||||
style={{ paddingLeft: 20 }}
|
||||
type="DeleteCircle"
|
||||
onClick={() =>
|
||||
store.deleteTotalValueSubItem(
|
||||
element.id,
|
||||
index
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{subArray.map(
|
||||
(
|
||||
subSubArrayItem: InputBuilderViewModel,
|
||||
subIndex: number
|
||||
) => {
|
||||
if (
|
||||
subSubArrayItem.type.isEqual(
|
||||
InputType.ENUM
|
||||
)
|
||||
) {
|
||||
{subArray.map((subSubArrayItem: InputBuilderViewModel, subIndex: number) => {
|
||||
if (subSubArrayItem.type.isEqual(InputType.ENUM)) {
|
||||
return (
|
||||
<>
|
||||
<CoreSelect
|
||||
items={
|
||||
subSubArrayItem.values?.map(
|
||||
(el) => String(el)
|
||||
) ?? []
|
||||
}
|
||||
value={
|
||||
subSubArrayItem.totalValue ??
|
||||
subSubArrayItem.defaultValue
|
||||
}
|
||||
onChange={(value) => console.log(subSubArrayItem.id)
|
||||
}
|
||||
items={subSubArrayItem.values?.map((el) => String(el)) ?? []}
|
||||
value={subSubArrayItem.totalValue ?? subSubArrayItem.defaultValue}
|
||||
onChange={(value) => console.log(subSubArrayItem.id)}
|
||||
label={element.name}
|
||||
style={{ margin: 5 }}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
if (
|
||||
subSubArrayItem.type.isEqualMany([
|
||||
InputType.NUMBER,
|
||||
InputType.STRING,
|
||||
])
|
||||
)
|
||||
if (subSubArrayItem.type.isEqualMany([InputType.NUMBER, InputType.STRING]))
|
||||
return (
|
||||
<div>
|
||||
<CoreInput
|
||||
isFormBuilder={true}
|
||||
style={{ margin: 5 }}
|
||||
onChange={(e) =>
|
||||
store.changeTotalSubValue(
|
||||
element.id,
|
||||
subIndex,
|
||||
e,
|
||||
index
|
||||
)
|
||||
}
|
||||
onChange={(e) => store.changeTotalSubValue(element.id, subIndex, e, index)}
|
||||
validation={
|
||||
subSubArrayItem.type.isEqual(
|
||||
InputType.NUMBER
|
||||
)
|
||||
subSubArrayItem.type.isEqual(InputType.NUMBER)
|
||||
? (el) => Number().isValid(el)
|
||||
: undefined
|
||||
}
|
||||
error="только числа"
|
||||
value={
|
||||
subSubArrayItem.totalValue ??
|
||||
subSubArrayItem.defaultValue
|
||||
}
|
||||
value={subSubArrayItem.totalValue ?? subSubArrayItem.defaultValue}
|
||||
label={subSubArrayItem.name}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
return <>Error</>;
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})
|
||||
: null}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
})
|
||||
: null}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (element.type?.isEqualMany([InputType.NUMBER, InputType.STRING]))
|
||||
return (
|
||||
<div>
|
||||
<CoreInput
|
||||
isFormBuilder={true}
|
||||
validation={
|
||||
element.type.isEqual(InputType.NUMBER)
|
||||
? (el) => Number().isValid(el)
|
||||
: undefined
|
||||
}
|
||||
onChange={(e) => {
|
||||
store.changeTotalValue(element.id, e);
|
||||
}}
|
||||
value={element.totalValue ?? element.defaultValue}
|
||||
error="только числа"
|
||||
label={element.name}
|
||||
style={{ margin: 20 }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
if (element.type?.isEqual(InputType.OBJECT))
|
||||
return (
|
||||
<>
|
||||
{getFormBuilderComponents(
|
||||
element.name
|
||||
.replace(">", "")
|
||||
.replace("<", "")
|
||||
.replace("/", ""),
|
||||
element.totalValue ?? element.defaultValue,
|
||||
(text) => store.changeTotalValue(element.id, text)
|
||||
).fold(
|
||||
(s) => (
|
||||
<>{s}</>
|
||||
),
|
||||
(error) => (
|
||||
<>{error}</>
|
||||
)
|
||||
)}
|
||||
</>
|
||||
);
|
||||
return <div>Error {String(element)}</div>;
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
if (element.type?.isEqualMany([InputType.NUMBER, InputType.STRING]))
|
||||
return (
|
||||
<div>
|
||||
<CoreInput
|
||||
isFormBuilder={true}
|
||||
validation={element.type.isEqual(InputType.NUMBER) ? (el) => Number().isValid(el) : undefined}
|
||||
onChange={(e) => {
|
||||
store.changeTotalValue(element.id, e);
|
||||
}}
|
||||
value={element.totalValue ?? element.defaultValue}
|
||||
error="только числа"
|
||||
label={element.name}
|
||||
style={{ margin: 20 }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
if (element.type?.isEqual(InputType.OBJECT))
|
||||
return (
|
||||
<>
|
||||
{getFormBuilderComponents(
|
||||
element.name.replace(">", "").replace("<", "").replace("/", ""),
|
||||
element.totalValue ?? element.defaultValue,
|
||||
(text) => store.changeTotalValue(element.id, text)
|
||||
).fold(
|
||||
(s) => (
|
||||
<>{s}</>
|
||||
),
|
||||
(error) => (
|
||||
<>{error}</>
|
||||
)
|
||||
)}
|
||||
</>
|
||||
);
|
||||
return <div>Error {String(element)}</div>;
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { Result } from "../../../helper/result";
|
||||
import { SelectDatasetScreen } from "./select_dataset/presentation/select_dataset_screen";
|
||||
import { SelectProcess } from "./select_dataset/presentation/select_process";
|
||||
import { SelectDetail } from "./select_detail/presentation/select_detail_screen";
|
||||
|
||||
export enum FormBuilderComponents {
|
||||
SelectDetail = "SelectDetail",
|
||||
SelectDataset = "SelectDataset",
|
||||
SelectProcess = "SelectProcess",
|
||||
}
|
||||
export interface IFormBuilderComponentsProps<T> {
|
||||
dependency: T;
|
||||
|
@ -18,8 +18,8 @@ export const getFormBuilderComponents = (
|
|||
if (name.isEqual(FormBuilderComponents.SelectDetail)) {
|
||||
return Result.ok(<SelectDetail dependency={dependency} onChange={onChange} />);
|
||||
}
|
||||
if (name.isEqual(FormBuilderComponents.SelectDataset)) {
|
||||
return Result.ok(<SelectDatasetScreen dependency={dependency} onChange={onChange} />);
|
||||
if (name.isEqual(FormBuilderComponents.SelectProcess)) {
|
||||
return Result.ok(<SelectProcess dependency={dependency} onChange={onChange} />);
|
||||
}
|
||||
return Result.error(name);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
import { CoreHttpRepository, HttpMethod } from "../../../../../repository/core_http_repository";
|
||||
|
||||
export class SelectProcessRepository extends CoreHttpRepository {
|
||||
getAllProcessByType = (type: string) => this._jsonRequest(HttpMethod.POST, '/calculations/instances/get/all/end/calculations', { type: type })
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
import { IsString } from "class-validator";
|
||||
import { ValidationModel } from "../../../../../model/validation_model";
|
||||
|
||||
|
||||
export class SelectProcessModel extends ValidationModel {
|
||||
@IsString()
|
||||
type: string;
|
||||
@IsString()
|
||||
selectProcess?: any;
|
||||
@IsString()
|
||||
process?: string;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
import { observer } from "mobx-react-lite";
|
||||
import { IFormBuilderComponentsProps } from "../../form_builder_components";
|
||||
|
||||
export const SelectDatasetScreen = observer((props:IFormBuilderComponentsProps<any>) => {
|
||||
return <>SELECT DATASET</>;
|
||||
});
|
|
@ -0,0 +1,35 @@
|
|||
import React, { useState } from "react";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { IFormBuilderComponentsProps } from "../../form_builder_components";
|
||||
import { useStore } from "../../../../../helper/use_store";
|
||||
import { SelectProcessStore } from "./select_process_store";
|
||||
import { useEffect } from "react";
|
||||
import { SelectProcessModel } from "../model/select_process_model";
|
||||
import { Loader } from "../../../../loader/loader";
|
||||
import { CoreSelect } from "../../../../select/select";
|
||||
|
||||
export const SelectProcess = observer((props: IFormBuilderComponentsProps<any>) => {
|
||||
const [store] = useState(new SelectProcessStore());
|
||||
useEffect(() => {
|
||||
store.loadClassInstance(SelectProcessModel, props.dependency);
|
||||
store.init();
|
||||
}, []);
|
||||
return (
|
||||
<div>
|
||||
{store.isLoading ? (
|
||||
<Loader />
|
||||
) : (
|
||||
<div>
|
||||
<CoreSelect
|
||||
items={store.calculationInstances.map((el) => el.name)}
|
||||
value={store.viewModel.selectProcess?.name}
|
||||
label={`Процесс тип ${store.viewModel.type}`}
|
||||
onChange={(value: string, index: number) =>
|
||||
store.updateForm({ selectProcess: store.calculationInstances.atR(index).map((el) => el) })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
import { NavigateFunction } from "react-router-dom";
|
||||
import { FormState } from "../../../../../store/base_store";
|
||||
import { SelectProcessModel } from "../model/select_process_model";
|
||||
import { SelectProcessRepository } from "../data/select_process_repository";
|
||||
import { CalculationModel } from "../../../../../../features/calculation_instance/model/calculation_model";
|
||||
import makeAutoObservable from "mobx-store-inheritance";
|
||||
|
||||
export class SelectProcessStore extends FormState<SelectProcessModel, any> {
|
||||
selectProcessRepository = new SelectProcessRepository();
|
||||
viewModel: SelectProcessModel;
|
||||
calculationInstances: CalculationModel[] = [];
|
||||
constructor() {
|
||||
super();
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
async init(navigate?: NavigateFunction | undefined): Promise<any> {
|
||||
await this.mapOk('calculationInstances', this.selectProcessRepository.getAllProcessByType(this.viewModel.type));
|
||||
console.log(this.calculationInstances);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
// @ts-nocheck
|
||||
|
||||
import React from "react";
|
||||
import { IFormBuilderComponentsProps } from "../../form_builder_components";
|
||||
import { observer } from "mobx-react-lite";
|
||||
|
@ -10,7 +10,7 @@ import { plainToInstance } from "class-transformer";
|
|||
export const SelectDetail = observer((props: IFormBuilderComponentsProps<SelectDetailViewModel>) => {
|
||||
const [store] = React.useState(() => new SelectDetailStore());
|
||||
React.useEffect(() => {
|
||||
console.log(props.dependency.details);
|
||||
|
||||
store.viewModel = new SelectDetailViewModel(props.dependency.details);
|
||||
store.isLoading = false;
|
||||
store.init();
|
||||
|
|
|
@ -9,7 +9,7 @@ import { FormBuilder } from "./form_builder";
|
|||
import makeAutoObservable from "mobx-store-inheritance";
|
||||
|
||||
class FormBuilderTextStore extends ModalStore {
|
||||
viewModel = FormBuilderValidationModel.empty();
|
||||
viewModel = FormBuilderValidationModel.vision();
|
||||
constructor() {
|
||||
super();
|
||||
makeAutoObservable(this);
|
||||
|
@ -21,6 +21,7 @@ export const FormBuildTest = observer(() => {
|
|||
|
||||
return (
|
||||
<div>
|
||||
|
||||
<InputV2 label={"result"} onChange={(text) => (store.viewModel.result = text)} />
|
||||
<InputV2 label={"context"} onChange={(text) => (store.viewModel.context = text)} />
|
||||
<CoreButton text="click" onClick={() => (store.isModalOpen = true)} />
|
||||
|
@ -33,15 +34,15 @@ export const FormBuildTest = observer(() => {
|
|||
onCancel={() => {
|
||||
store.isModalOpen = false;
|
||||
}}
|
||||
>
|
||||
<FormBuilder
|
||||
formBuilder={store.viewModel}
|
||||
onChange={(e) => {
|
||||
console.log(e.output);
|
||||
// console.log(JSON.stringify(e.output))
|
||||
}}
|
||||
/>
|
||||
</Modal>
|
||||
></Modal>
|
||||
<div style={{height:50}}/>
|
||||
<FormBuilder
|
||||
formBuilder={store.viewModel}
|
||||
onChange={(e) => {
|
||||
console.log(e.output);
|
||||
// console.log(JSON.stringify(e.output))
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@ interface ICoreSelectProps extends IStyle {
|
|||
items: string[];
|
||||
value: string;
|
||||
label: string;
|
||||
onChange: (value: string) => void;
|
||||
onChange: (value: string, index: number) => void;
|
||||
}
|
||||
export const CoreSelect = (props: ICoreSelectProps) => {
|
||||
const ref = React.useRef<HTMLDivElement>(null);
|
||||
|
@ -52,7 +52,7 @@ export const CoreSelect = (props: ICoreSelectProps) => {
|
|||
key={i}
|
||||
onClick={() => {
|
||||
setValue(el);
|
||||
props.onChange(el);
|
||||
props.onChange(el, i);
|
||||
}}
|
||||
style={{
|
||||
backgroundColor: "rgba(230, 224, 233, 1)",
|
||||
|
|
|
@ -28,7 +28,6 @@ export const CalculationInstanceScreenPath = "/calculation";
|
|||
|
||||
export const CalculationInstanceScreen = observer(() => {
|
||||
const store = useStore(CalculationInstanceStore);
|
||||
// console.log(200);
|
||||
return (
|
||||
<>
|
||||
<MainPage
|
||||
|
@ -60,7 +59,8 @@ export const CalculationInstanceScreen = observer(() => {
|
|||
() => store.makeEditProcess(el),
|
||||
() => store.deleteInstance(el._id ?? ""),
|
||||
() => store.execSkill(el._id ?? ""),
|
||||
() => store.execSkill(el._id ?? "")
|
||||
() => store.execSkill(el._id ?? ""),
|
||||
() => store.changeProcessStatus(el._id ?? ''),
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
|
|
|
@ -5,7 +5,7 @@ import { Drawer, UiDrawerFormState } from "../../../core/store/base_store";
|
|||
import { CalculationHttpRepository } from "../data/calculation_http_repository";
|
||||
import { message } from "antd";
|
||||
import { UUID } from "../../all_projects/data/project_http_repository";
|
||||
import { CalculationModel } from "../model/calculation_model";
|
||||
import { CalculationModel as calculationModel } from "../model/calculation_model";
|
||||
import { ProcessUpdate, CalculationSocketRepository } from "../data/calculation_socket_repository";
|
||||
import { match } from "ts-pattern";
|
||||
import { plainToInstance } from "class-transformer";
|
||||
|
@ -20,16 +20,16 @@ export enum StoreTypes {
|
|||
empty = "empty",
|
||||
}
|
||||
|
||||
export class CalculationInstanceStore extends UiDrawerFormState<CalculationModel, HttpError> {
|
||||
export class CalculationInstanceStore extends UiDrawerFormState<calculationModel, HttpError> {
|
||||
calculationHttpRepository: CalculationHttpRepository = new CalculationHttpRepository();
|
||||
calculationSocketRepository: CalculationSocketRepository = new CalculationSocketRepository();
|
||||
activeProjectId?: UUID;
|
||||
storeType: StoreTypes = StoreTypes.empty;
|
||||
viewModel: CalculationModel = CalculationModel.empty();
|
||||
modelTemplate?: CalculationModel[];
|
||||
editProcess?: CalculationModel;
|
||||
calculationInstances?: CalculationModel[];
|
||||
selectTemplate?: CalculationModel;
|
||||
viewModel: calculationModel = calculationModel.empty();
|
||||
modelTemplate?: calculationModel[];
|
||||
editProcess?: calculationModel;
|
||||
calculationInstances?: calculationModel[];
|
||||
selectTemplate?: calculationModel;
|
||||
titleDrawer: string = DrawersSkill.NEW_SKILL;
|
||||
drawers: Drawer[];
|
||||
isModalOpen: boolean = false;
|
||||
|
@ -41,7 +41,7 @@ export class CalculationInstanceStore extends UiDrawerFormState<CalculationModel
|
|||
status: false,
|
||||
};
|
||||
});
|
||||
this.viewModel = CalculationModel.empty();
|
||||
this.viewModel = calculationModel.empty();
|
||||
this.calculationSocketRepository.on(this.socketUpdate);
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
@ -67,9 +67,9 @@ export class CalculationInstanceStore extends UiDrawerFormState<CalculationModel
|
|||
successMessage: "Процесс запущен",
|
||||
});
|
||||
|
||||
setSelectTemplate = (el: CalculationModel) => {
|
||||
setSelectTemplate = (el: calculationModel) => {
|
||||
this.selectTemplate = el;
|
||||
const instance = plainToInstance(CalculationModel, el);
|
||||
const instance = plainToInstance(calculationModel, el);
|
||||
instance.instanceName = this?.viewModel.instanceName;
|
||||
this.viewModel = instance;
|
||||
};
|
||||
|
@ -84,7 +84,7 @@ export class CalculationInstanceStore extends UiDrawerFormState<CalculationModel
|
|||
match(this.storeType)
|
||||
.with(StoreTypes.empty, () => {})
|
||||
.with(StoreTypes.newType, async () =>
|
||||
(await this.viewModel.valid<CalculationModel>()).fold(
|
||||
(await this.viewModel.valid<calculationModel>()).fold(
|
||||
async (model) => {
|
||||
model.project = this.activeProjectId?.id;
|
||||
|
||||
|
@ -99,7 +99,7 @@ export class CalculationInstanceStore extends UiDrawerFormState<CalculationModel
|
|||
)
|
||||
)
|
||||
.with(StoreTypes.newModel, async () => {
|
||||
(await this.viewModel.valid<CalculationModel>()).fold(
|
||||
(await this.viewModel.valid<calculationModel>()).fold(
|
||||
async (model) => {
|
||||
delete model._id;
|
||||
model.project = this.activeProjectId?.id;
|
||||
|
@ -128,20 +128,30 @@ export class CalculationInstanceStore extends UiDrawerFormState<CalculationModel
|
|||
|
||||
saveEdiSkill = async () => {
|
||||
this.editDrawer(DrawersSkill.EDIT_SKILL, false);
|
||||
(await this.viewModel.valid<CalculationModel>()).fold(
|
||||
(await this.viewModel.valid<calculationModel>()).fold(
|
||||
async (model) => await this.calculationHttpRepository.editCalculation(model),
|
||||
async (err) => message.error(err)
|
||||
);
|
||||
};
|
||||
makeEditProcess = (el: CalculationModel) => {
|
||||
makeEditProcess = (el: calculationModel) => {
|
||||
this.editProcess = el;
|
||||
this.loadClassInstance(CalculationModel, el);
|
||||
this.loadClassInstance(calculationModel, el);
|
||||
this.editDrawer(DrawersSkill.EDIT_SKILL, true);
|
||||
};
|
||||
deleteTemplate = async (el: CalculationModel) => {
|
||||
deleteTemplate = async (el: calculationModel) => {
|
||||
await this.messageHttp(this.calculationHttpRepository.deleteTemplate(el._id ?? ""), {
|
||||
successMessage: "Удален",
|
||||
});
|
||||
await this.mapOk("modelTemplate", this.calculationHttpRepository.getAllTemplates());
|
||||
};
|
||||
changeProcessStatus = async (id: string) =>
|
||||
this!
|
||||
.calculationInstances!.whereOne((el) => el._id === id)
|
||||
.map(
|
||||
async (calculationModel) => (
|
||||
(calculationModel.isEnd = !calculationModel.isEnd),
|
||||
await this.calculationHttpRepository.editCalculation(calculationModel),
|
||||
await this.init(undefined)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { match } from "ts-pattern";
|
||||
import { PoseEstimateCard } from "./pose_estimate_card/model_card";
|
||||
import { Dropdown, MenuProps, message } from "antd";
|
||||
import { Checkbox, Dropdown, MenuProps, message } from "antd";
|
||||
import { CoreText, CoreTextType } from "../../../../../core/ui/text/text";
|
||||
import { IMenuItem } from "../../../../dataset/card_dataset";
|
||||
import { Icon } from "../../../../../core/ui/icons/icons";
|
||||
|
@ -15,7 +15,8 @@ export const getModelCard = (
|
|||
onEdit: Function,
|
||||
onDelete: Function,
|
||||
onPlay: Function,
|
||||
onPause: Function
|
||||
onPause: Function,
|
||||
onChangeProcessIsEnd: Function
|
||||
) => {
|
||||
const menu: IMenuItem[] = [
|
||||
{
|
||||
|
@ -26,6 +27,10 @@ export const getModelCard = (
|
|||
onClick: () => onDelete(),
|
||||
name: "Удалить",
|
||||
},
|
||||
{
|
||||
onClick: () => onChangeProcessIsEnd(),
|
||||
name: calculationModel.isEnd ? "Вернуть на доработку" : "Завершить",
|
||||
},
|
||||
];
|
||||
|
||||
const items: MenuProps["items"] = menu.map((el, index) => {
|
||||
|
|
|
@ -7,6 +7,9 @@ import { RouterProvider } from "react-router-dom";
|
|||
import { router } from "./core/routers/routers";
|
||||
import { configure } from "mobx";
|
||||
import { ThemeStore } from "./core/store/theme_store";
|
||||
import { FormBuilder } from "./core/ui/form_builder/form_builder";
|
||||
import { FormBuilderComponents } from "./core/ui/form_builder/forms/form_builder_components";
|
||||
import { FormBuildTest } from "./core/ui/form_builder/test";
|
||||
|
||||
configure({
|
||||
enforceActions: "never",
|
||||
|
@ -19,8 +22,9 @@ export const themeStore = new ThemeStore();
|
|||
|
||||
root.render(
|
||||
<>
|
||||
<SocketListener>
|
||||
{/* <SocketListener>
|
||||
<RouterProvider router={router} />
|
||||
</SocketListener>
|
||||
</SocketListener> */}
|
||||
<FormBuildTest />
|
||||
</>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue