fix
This commit is contained in:
parent
00c553ecd7
commit
29dcfb6ac1
5 changed files with 59 additions and 6 deletions
|
@ -0,0 +1,48 @@
|
|||
import { CallbackStrategyWithEmpty, ResponseBase } from "../../../core/controllers/http_controller";
|
||||
import { Result } from "../../../core/helpers/result";
|
||||
import { StaticFilesProject } from "../../../core/models/static_files";
|
||||
import { ReadFileAndParseJsonUseCase } from "../../../core/usecases/read_file_and_parse_json";
|
||||
import { SearchManyDataBaseModelUseCase } from "../../../core/usecases/search_many_database_model_usecase";
|
||||
import { IProjectModel, ProjectDBModel } from "../models/project_model_database_model";
|
||||
|
||||
export interface Parts {
|
||||
name: string;
|
||||
part_path: string;
|
||||
material_path: string;
|
||||
stlUrl: string;
|
||||
image: string;
|
||||
glUrl: string;
|
||||
daeUrl: string;
|
||||
fbx: string;
|
||||
objUrl: string;
|
||||
solidType: string;
|
||||
}
|
||||
|
||||
export class RobossemblerAssetsLocaleMapperScenario extends CallbackStrategyWithEmpty {
|
||||
call = async (): ResponseBase =>
|
||||
(
|
||||
await new SearchManyDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call(
|
||||
{ isActive: true },
|
||||
"is dont active projects"
|
||||
)
|
||||
).map(async (projectModel) => {
|
||||
const { rootDir } = projectModel[0];
|
||||
return (await new ReadFileAndParseJsonUseCase().call<Parts[]>(rootDir + StaticFilesProject.parts)).map(
|
||||
(model) => {
|
||||
model.map((el) => {
|
||||
const assetLibsAddress = rootDir + "/libs/objects/" + el.name;
|
||||
el.fbx = `${assetLibsAddress}.fbx`;
|
||||
el.stlUrl = `${assetLibsAddress}${el.part_path}`;
|
||||
el.glUrl = `${assetLibsAddress}.glb`;
|
||||
el.daeUrl = `${assetLibsAddress}.dae`;
|
||||
el.objUrl = `${assetLibsAddress}.obj`;
|
||||
el.image = `${assetLibsAddress}.png`;
|
||||
el.solidType = "active";
|
||||
return el;
|
||||
});
|
||||
return Result.ok(model);
|
||||
}
|
||||
);
|
||||
// );
|
||||
});
|
||||
}
|
|
@ -2,6 +2,7 @@ import { CrudController } from "../../core/controllers/crud_controller";
|
|||
import { SearchManyDataBaseModelUseCase } from "../../core/usecases/search_many_database_model_usecase";
|
||||
import { CreateNewProjectInstanceScenario, ProjectValidationModel } from "./domain/create_new_project_scenario";
|
||||
import { GetActiveProjectIdScenario } from "./domain/get_active_project_id_scenario";
|
||||
import { RobossemblerAssetsLocaleMapperScenario } from "./domain/robossembler_assets_absolute_path_mapper_scenario";
|
||||
import { RobossemblerAssetsNetworkMapperScenario } from "./domain/robossembler_assets_network_mapper_scenario";
|
||||
import { SetActiveProjectScenario } from "./domain/set_active_project_use_scenario";
|
||||
import { UploadCadFileToProjectScenario } from "./domain/upload_file_to_to_project_scenario";
|
||||
|
@ -39,11 +40,12 @@ export class ProjectsPresentation extends CrudController<ProjectValidationModel,
|
|||
subUrl: "assets",
|
||||
fn: new RobossemblerAssetsNetworkMapperScenario(),
|
||||
});
|
||||
// this.subRoutes.push({
|
||||
// method: "POST",
|
||||
// subUrl: "upload/env",
|
||||
// fn: new UploadNewEnvScenario(),
|
||||
// });
|
||||
this.subRoutes.push({
|
||||
method: "GET",
|
||||
subUrl: "local/assets",
|
||||
fn: new RobossemblerAssetsLocaleMapperScenario(),
|
||||
});
|
||||
|
||||
this.router.post("/projects/upload/env", async (req, res) => {
|
||||
try {
|
||||
} catch (error) {}
|
||||
|
|
|
@ -132,6 +132,7 @@ export class CoreHttpRepository extends HttpRepository {
|
|||
getAssetsActiveProject = async (): Promise<Result<HttpError, Parts[]>> => {
|
||||
return this._jsonRequest<Parts[]>(HttpMethod.GET, "/projects/assets");
|
||||
};
|
||||
|
||||
getSceneAsset = (id: string) =>
|
||||
this._jsonToClassInstanceRequest(HttpMethod.GET, `/scenes/by_id?id=${id}`, SceneAsset) as Promise<
|
||||
Result<HttpError, SceneAsset>
|
||||
|
|
|
@ -23,7 +23,7 @@ export class SelectDetailStore extends FormState<SelectDetailViewModel, any> {
|
|||
return false;
|
||||
};
|
||||
init = async () => {
|
||||
await this.mapOk("parts", this.dataSetRepository.getAssetsActiveProject());
|
||||
await this.mapOk("parts", this.dataSetRepository.getLocalParts());
|
||||
};
|
||||
updateCheckbox(el: Parts): void {
|
||||
el.isSelect = true;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Result } from "../../core/helper/result";
|
||||
import { HttpError, HttpMethod, CoreHttpRepository } from "../../core/repository/core_http_repository";
|
||||
import { Parts } from "../details/details_http_repository";
|
||||
import { DataSetModel, Dataset, IDatasetModel } from "./dataset_model";
|
||||
|
||||
export class DataSetHttpRepository extends CoreHttpRepository {
|
||||
|
@ -13,4 +14,5 @@ export class DataSetHttpRepository extends CoreHttpRepository {
|
|||
execDatasetProcess = async (id: string) => this._jsonRequest(HttpMethod.POST, `${this.featureApi}/exec?id=${id}`);
|
||||
isRunningProcess = async () => this._jsonRequest(HttpMethod.GET, `${this.featureApi}/is/running`);
|
||||
deleteProcess = async () => this._jsonRequest(HttpMethod.GET, `${this.featureApi}/delete/process`);
|
||||
getLocalParts = () => this._jsonRequest<Parts>(HttpMethod.GET,`/projects/local/assets`)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue