progress scene builder
This commit is contained in:
parent
0a4eea19c5
commit
50d0c4c12b
64 changed files with 858 additions and 1315 deletions
|
@ -4,6 +4,7 @@ import { WeightsPresentation } from "../../features/weights/weights_presentation
|
|||
import { ProjectsPresentation } from "../../features/projects/projects_presentation";
|
||||
import { extensions } from "../extensions/extensions";
|
||||
import { Routes } from "../interfaces/router";
|
||||
import { ScenePresentation } from "../../features/scene/scene_presentation";
|
||||
|
||||
extensions();
|
||||
|
||||
|
@ -12,4 +13,5 @@ export const httpRoutes: Routes[] = [
|
|||
new DatasetsPresentation(),
|
||||
new BehaviorTreesPresentation(),
|
||||
new WeightsPresentation(),
|
||||
new ScenePresentation()
|
||||
].map((el) => el.call());
|
||||
|
|
|
@ -9,25 +9,37 @@ export interface Parts {
|
|||
name: string;
|
||||
part_path: string;
|
||||
material_path: string;
|
||||
stlUrl?: string;
|
||||
stlUrl: string;
|
||||
image: string;
|
||||
glUrl: string;
|
||||
}
|
||||
|
||||
export class RobossemblerAssetsNetworkMapperScenario extends CallbackStrategyWithEmpty {
|
||||
call = async (): ResponseBase => (await new SearchManyDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call({ isActive: true }, 'is dont active projects')).map((projectModel) => {
|
||||
const { rootDir } = projectModel[0];
|
||||
return new GetServerAddressUseCase().call().map(async (address) =>
|
||||
(
|
||||
await new ReadFileAndParseJsonUseCase().call<Parts[]>(
|
||||
rootDir + StaticFiles.parts
|
||||
)
|
||||
).map((model) => {
|
||||
call = async (): ResponseBase =>
|
||||
(
|
||||
await new SearchManyDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call(
|
||||
{ isActive: true },
|
||||
"is dont active projects"
|
||||
)
|
||||
).map((projectModel) => {
|
||||
const { rootDir } = projectModel[0];
|
||||
return new GetServerAddressUseCase().call().map(async (serverAddress) =>
|
||||
(await new ReadFileAndParseJsonUseCase().call<Parts[]>(rootDir + StaticFiles.parts)).map((model) => {
|
||||
const assetAddress =
|
||||
serverAddress +
|
||||
"/" +
|
||||
rootDir.match(new RegExp(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gm))[0] +
|
||||
"/assets/";
|
||||
model.map((el) => {
|
||||
const assetLibsAddress = assetAddress + "libs/objects/" + el.name;
|
||||
|
||||
model.map((el) => {
|
||||
el.stlUrl = address + '/' + rootDir.match(new RegExp(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gm))[0] + '/assets/' + el.part_path
|
||||
return el
|
||||
el.stlUrl = `${assetAddress}${el.part_path}`;
|
||||
el.glUrl = `${assetLibsAddress}.glb`;
|
||||
el.image = `${assetLibsAddress}.png`;
|
||||
return el;
|
||||
});
|
||||
return Result.ok(model);
|
||||
})
|
||||
return Result.ok(model);
|
||||
|
||||
})
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,22 +7,24 @@ import { ReadByIdDataBaseModelUseCase } from "../../../core/usecases/read_by_id_
|
|||
import { UpdateDataBaseModelUseCase } from "../../../core/usecases/update_database_model_usecase";
|
||||
import { MongoIdValidation } from "../../../core/validations/mongo_id_validation";
|
||||
import { IProjectModel, ProjectDBModel } from "../models/project_model_database_model";
|
||||
|
||||
|
||||
export class SetActiveProjectScenario extends CallbackStrategyWithIdQuery {
|
||||
idValidationExpression = new MongoIdValidation();
|
||||
|
||||
call = async (id: string): ResponseBase => (await (await new ReadByIdDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call(id)).map(async (model) => await (
|
||||
await new CreateFolderUseCase().call(model.rootDir)
|
||||
).map(async () => {
|
||||
model.isActive = true;
|
||||
return (await new UpdateDataBaseModelUseCase(ProjectDBModel).call(model)).map(async (el) => {
|
||||
await ProjectDBModel.updateMany(
|
||||
{ _id: { $ne: el._id }, isActive: { $eq: true } },
|
||||
{ isActive: false }
|
||||
);
|
||||
await new SetLastActivePipelineToRealTimeServiceScenario().call();
|
||||
return Result.ok(`project ${id} is active`);
|
||||
});
|
||||
})))
|
||||
call = async (id: string): ResponseBase =>
|
||||
await (
|
||||
await new ReadByIdDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call(id)
|
||||
).map(
|
||||
async (model) =>
|
||||
await (
|
||||
await new CreateFolderUseCase().call(model.rootDir)
|
||||
).map(async () => {
|
||||
model.isActive = true;
|
||||
return (await new UpdateDataBaseModelUseCase(ProjectDBModel).call(model)).map(async (el) => {
|
||||
await ProjectDBModel.updateMany({ _id: { $ne: el._id }, isActive: { $eq: true } }, { isActive: false });
|
||||
await new SetLastActivePipelineToRealTimeServiceScenario().call();
|
||||
return Result.ok(`project ${id} is active`);
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
|
13
server/src/features/scene/scene_database_model.ts
Normal file
13
server/src/features/scene/scene_database_model.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { Schema, model } from "mongoose";
|
||||
export interface IScene {
|
||||
name: string;
|
||||
}
|
||||
export const SceneSchema = new Schema({
|
||||
name: {
|
||||
type: String,
|
||||
},
|
||||
}).plugin(require("mongoose-autopopulate"));
|
||||
|
||||
export const schemaSceneName = "Scene";
|
||||
|
||||
export const SceneDBModel = model<IScene>(schemaSceneName, SceneSchema);
|
13
server/src/features/scene/scene_presentation.ts
Normal file
13
server/src/features/scene/scene_presentation.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { CrudController } from "../../core/controllers/crud_controller";
|
||||
import { SceneDBModel } from "./scene_database_model";
|
||||
import { SceneValidationModel } from "./scene_validation_model";
|
||||
|
||||
export class ScenePresentation extends CrudController<SceneValidationModel, typeof SceneDBModel> {
|
||||
constructor() {
|
||||
super({
|
||||
url: "scenes",
|
||||
validationModel: SceneValidationModel,
|
||||
databaseModel: SceneDBModel,
|
||||
});
|
||||
}
|
||||
}
|
7
server/src/features/scene/scene_validation_model.ts
Normal file
7
server/src/features/scene/scene_validation_model.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { IsString } from "class-validator";
|
||||
import { IScene } from "./scene_database_model";
|
||||
|
||||
export class SceneValidationModel implements IScene {
|
||||
@IsString()
|
||||
public name: string;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue