Добавлены модули создания проектов сборки и подготовки датасетов

This commit is contained in:
IDONTSUDO 2024-04-23 10:32:43 +00:00 committed by Igor Brylyov
parent 40b9b116c1
commit f57438b404
173 changed files with 6750 additions and 1857 deletions

View file

@ -1,30 +1,20 @@
import makeAutoObservable from "mobx-store-inheritance";
import { CreateProjectRepository, PipelineModel } from "./create_project_repository";
import { CreateProjectRepository } from "./create_project_repository";
import { message } from "antd";
import { SimpleErrorState } from "../../core/store/base_store";
export class CreateProjectStore extends SimpleErrorState {
repository: CreateProjectRepository;
pipelineModels?: PipelineModel[];
newProjectDescription: string = "";
newProjectViews: PipelineModel[] = [];
file?: File;
constructor(repository: CreateProjectRepository) {
super();
this.repository = repository;
makeAutoObservable(this);
}
async init() {
await this.loadPipelines();
}
async addPipeline(model: PipelineModel) {
this.newProjectViews.push(model);
}
async loadPipelines() {
this.mapOk("pipelineModels", this.repository.getAllPipelines());
}
async init() {}
setDescriptionToNewProject(value: string): void {
this.newProjectDescription = value;
@ -35,27 +25,27 @@ export class CreateProjectStore extends SimpleErrorState {
message.error("project description is not empty");
return;
}
if (this.newProjectViews.isEmpty()) {
message.error("project view is not empty");
if (this.file === undefined) {
message.error("upload file");
return;
}
this.isLoading = true;
const result = await this.repository.saveProject({
description: this.newProjectDescription,
pipelines: this.newProjectViews.map((el) => el._id ?? ""),
});
this.newProjectDescription = "";
this.newProjectViews = [];
this.isLoading = false;
result.fold(
(_s) => {
message.success("save");
(
await this.repository.saveProject({
description: this.newProjectDescription,
})
).fold(
(uuid) => {
this.newProjectDescription = "";
this.isLoading = false;
this.repository.setProjectRootFile(this.file as File, uuid.id);
},
(_e) => {
(_) => {
this.isError = true;
}
);
//
}
}