Add Revit XLSX settings page
This commit is contained in:
parent
1cfeb06ec7
commit
c633e78cd4
15 changed files with 259 additions and 1025 deletions
|
|
@ -0,0 +1,60 @@
|
|||
import { randomUUID } from "node:crypto";
|
||||
import type { Request, Response } from "express";
|
||||
import { createExternalModelConfigurationUpdateProjectCommand } from "../../domain/models/external-model-configuration-project-command.model.js";
|
||||
import { assertExternalModelConfiguration } from "../../external-model/configuration/external-model-configuration.js";
|
||||
import { parseExternalXlsx } from "../../external-model/xlsx/external-xlsx-transport.js";
|
||||
import { externalModelConfigurationRepository } from "../composition/application-repositories.js";
|
||||
import { projectCommandService } from "../composition/project-command-stores.js";
|
||||
import { respondWithProjectCommandError } from "./project-command.controller.js";
|
||||
|
||||
export function getExternalModelConfiguration(req: Request, res: Response) {
|
||||
const projectId = String(req.params.projectId ?? "");
|
||||
const result = externalModelConfigurationRepository.getByProject(projectId);
|
||||
if (!result.projectExists) return res.status(404).json({ error: "Projekt nicht gefunden." });
|
||||
return res.json({ configuration: result.configuration });
|
||||
}
|
||||
|
||||
export function updateExternalModelConfiguration(req: Request, res: Response) {
|
||||
const projectId = String(req.params.projectId ?? "");
|
||||
const expectedRevision = req.body?.expectedRevision;
|
||||
if (!Number.isSafeInteger(expectedRevision) || expectedRevision < 0) {
|
||||
return res.status(400).json({ error: "Ungültige Projektrevision." });
|
||||
}
|
||||
try {
|
||||
assertExternalModelConfiguration(req.body?.configuration);
|
||||
const current = externalModelConfigurationRepository.getByProject(projectId);
|
||||
if (!current.projectExists) return res.status(404).json({ error: "Projekt nicht gefunden." });
|
||||
const target = {
|
||||
id: current.configuration?.id ?? randomUUID(),
|
||||
projectId,
|
||||
configuration: req.body.configuration,
|
||||
};
|
||||
const result = projectCommandService.executeUser({
|
||||
projectId,
|
||||
expectedRevision,
|
||||
description: "Revit-XLSX-Einstellungen gespeichert",
|
||||
command: createExternalModelConfigurationUpdateProjectCommand(current.configuration, target),
|
||||
});
|
||||
return res.json({ configuration: target, history: result.history });
|
||||
} catch (error) {
|
||||
return respondWithProjectCommandError(error, res);
|
||||
}
|
||||
}
|
||||
|
||||
export async function detectExternalModelWorkbook(req: Request, res: Response) {
|
||||
try {
|
||||
assertExternalModelConfiguration(req.body?.configuration);
|
||||
const document = await parseExternalXlsx({
|
||||
fileName: req.body?.fileName,
|
||||
bytes: Buffer.from(req.body?.contentBase64 ?? "", "base64"),
|
||||
configuration: req.body.configuration,
|
||||
});
|
||||
return res.json({
|
||||
sheetName: document.sheetName,
|
||||
columnCount: document.columns.length,
|
||||
objectCount: document.rows.filter((row) => row.classification === "object").length,
|
||||
});
|
||||
} catch (error) {
|
||||
return res.status(400).json({ error: error instanceof Error ? error.message : "Musterdatei konnte nicht gelesen werden." });
|
||||
}
|
||||
}
|
||||
|
|
@ -53,6 +53,11 @@ import {
|
|||
importProjectTransfer,
|
||||
importProjectTransferAsNewProject,
|
||||
} from "../controllers/project-transfer.controller.js";
|
||||
import {
|
||||
getExternalModelConfiguration,
|
||||
detectExternalModelWorkbook,
|
||||
updateExternalModelConfiguration,
|
||||
} from "../controllers/external-model-configuration.controller.js";
|
||||
|
||||
export const projectRouter = Router();
|
||||
|
||||
|
|
@ -74,6 +79,9 @@ projectRouter.post(
|
|||
restoreProjectSnapshot
|
||||
);
|
||||
projectRouter.put("/:projectId", updateProjectSettings);
|
||||
projectRouter.get("/:projectId/external-model/configuration", getExternalModelConfiguration);
|
||||
projectRouter.put("/:projectId/external-model/configuration", updateExternalModelConfiguration);
|
||||
projectRouter.post("/:projectId/external-model/configuration/detect", detectExternalModelWorkbook);
|
||||
projectRouter.get("/:projectId/distribution-boards", listDistributionBoardsByProject);
|
||||
projectRouter.post("/:projectId/distribution-boards", createDistributionBoard);
|
||||
projectRouter.post(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue