-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbpmn-viewer-dialog.component.ts
More file actions
57 lines (50 loc) · 1.35 KB
/
bpmn-viewer-dialog.component.ts
File metadata and controls
57 lines (50 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
npm install bpmn-js
// bpmn-viewer-dialog.component.ts
import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import * as BpmnJS from 'bpmn-js';
@Component({
selector: 'app-bpmn-viewer-dialog',
template: `
<h2 mat-dialog-title>Workflow Viewer</h2>
<mat-dialog-content>
<div id="bpmn-container" style="height: 500px; width: 100%;"></div>
</mat-dialog-content>
<mat-dialog-actions>
<button mat-button (click)="onClose()">Close</button>
</mat-dialog-actions>
`,
styles: [`
#bpmn-container {
border: 1px solid #ccc;
}
`]
})
export class BpmnViewerDialogComponent implements OnInit {
private viewer: any;
constructor(
public dialogRef: MatDialogRef<BpmnViewerDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: { xml: string }
) {}
ngOnInit() {
this.viewer = new BpmnJS({
container: '#bpmn-container'
});
this.renderDiagram();
}
async renderDiagram() {
try {
if (this.data.xml) {
await this.viewer.importXML(this.data.xml);
const canvas = this.viewer.get('canvas');
canvas.zoom('fit-viewport');
}
} catch (err) {
console.error('Error rendering BPMN diagram:', err);
}
}
onClose(): void {
this.dialogRef.close();
this.viewer.destroy();
}
}