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