feat: embed Beam viewer in issue peek

This commit is contained in:
DCCONSTRUCTIONS
2026-06-05 12:46:47 +03:00
parent 15c9fb1df1
commit 867f7bc558
4 changed files with 492 additions and 221 deletions
+24 -5
View File
@@ -41,6 +41,21 @@ export type TBeamConversionStatus = {
updatedAt?: string;
};
export const BEAM_VIEWER_OPEN_EVENT = "nodedc:beam-viewer-open";
export type TBeamViewerOpenEventDetail = {
downloadUrl?: string;
fileExtension?: string;
fileName: string;
fileSize: number;
issueId: string;
viewerUrl: string;
};
export const dispatchBeamViewerOpenEvent = (detail: TBeamViewerOpenEventDetail) => {
window.dispatchEvent(new CustomEvent<TBeamViewerOpenEventDetail>(BEAM_VIEWER_OPEN_EVENT, { detail }));
};
const DEFAULT_BEAM_VIEWER_BASE_URL = "http://localhost:8080";
const BEAM_DIRECT_MODEL_TYPE_BY_EXTENSION: Record<string, string> = {
@@ -73,7 +88,10 @@ const getFileExtension = (name: string): string => {
};
const getUploadGroupId = (parts: Array<string | undefined>): string => {
const value = parts.filter(Boolean).join("_").replace(/[^a-zA-Z0-9_-]/g, "_");
const value = parts
.filter(Boolean)
.join("_")
.replace(/[^a-zA-Z0-9_-]/g, "_");
return value || "tasker";
};
@@ -142,9 +160,7 @@ export const getBeamViewerAttachment = (attachment: TIssueAttachment | undefined
return beamViewer;
};
export const fetchBeamConversionStatus = async (
beamViewer: TBeamViewerAttachment
): Promise<TBeamConversionStatus> => {
export const fetchBeamConversionStatus = async (beamViewer: TBeamViewerAttachment): Promise<TBeamConversionStatus> => {
const statusUrl = new URL("/api/conversions/status", `${getBeamApiBaseUrl()}/`);
statusUrl.searchParams.set("src", toBeamRelativeUploadSrc(beamViewer.src));
@@ -181,7 +197,10 @@ export const uploadBeamModelFile = (
const apiBaseUrl = getBeamApiBaseUrl();
const uploadUrl = new URL("/api/uploads", `${apiBaseUrl}/`);
uploadUrl.searchParams.set("filename", file.name);
uploadUrl.searchParams.set("projectId", getUploadGroupId([options.workspaceSlug, options.projectId, options.issueId]));
uploadUrl.searchParams.set(
"projectId",
getUploadGroupId([options.workspaceSlug, options.projectId, options.issueId])
);
const xhr = new XMLHttpRequest();
xhr.open("POST", uploadUrl.toString());