Add BIM viewer service launch integration

This commit is contained in:
DCCONSTRUCTIONS
2026-06-18 21:43:04 +03:00
parent ec021d1a95
commit 4584c227ff
3 changed files with 193 additions and 1 deletions
+32 -1
View File
@@ -422,6 +422,21 @@ app.get("/api/services/:serviceSlug/launch", requireSession, (req, res) => {
return;
}
if (isBimViewerServiceSlug(serviceSlug)) {
const handoffToken = createServiceHandoff(serviceSlug, runtimeContext.user);
const targetUrl = new URL("/auth/nodedc/handoff", getBimViewerBaseUrl(app));
const nextPath = sanitizeReturnTo(req.query.next_path || req.query.returnTo || "/");
targetUrl.searchParams.set("token", handoffToken);
if (nextPath && nextPath !== "/") {
targetUrl.searchParams.set("next_path", nextPath);
}
res.redirect(targetUrl.toString());
return;
}
if (serviceSlug !== "task-manager") {
res.redirect(app.openUrl || app.url || "/");
return;
@@ -3031,6 +3046,11 @@ function isEngineServiceSlug(serviceSlug) {
return slug === "nodedc" || slug === "engine" || slug === "nodedc-engine";
}
function isBimViewerServiceSlug(serviceSlug) {
const slug = sanitizeServiceSlug(serviceSlug);
return slug === "bim-viewer" || slug === "beam-viewer" || slug === "bim";
}
function specialRequiredGroups(serviceOrSlug) {
const slug = typeof serviceOrSlug === "string" ? serviceOrSlug : serviceOrSlug?.slug;
const applicationSlug = typeof serviceOrSlug === "string" ? null : serviceOrSlug?.authentikApplicationSlug;
@@ -3046,7 +3066,7 @@ function specialRequiredGroups(serviceOrSlug) {
}
function getServiceUrl(service) {
if (service.slug === "task-manager" || isEngineServiceSlug(service.slug)) {
if (service.slug === "task-manager" || isEngineServiceSlug(service.slug) || isBimViewerServiceSlug(service.slug)) {
return `/api/services/${encodeURIComponent(service.slug)}/launch`;
}
@@ -3066,6 +3086,17 @@ function getTaskBaseUrl() {
return taskBaseUrl.replace(/\/$/, "");
}
function getBimViewerBaseUrl(app = null) {
return String(
process.env.NODEDC_BIM_VIEWER_PUBLIC_URL ||
process.env.BIM_VIEWER_BASE_URL ||
app?.launchTargetUrl ||
app?.openUrl ||
app?.url ||
"http://localhost:8080"
).replace(/\/$/, "");
}
function getEnginePublicBaseUrl() {
return String(
process.env.NODEDC_ENGINE_PUBLIC_URL ||