@WidgetComponent

nm-workflow-viewer

File

src/app/shared/widgets/portal/workflow-viewer/workflow-viewer.component.ts

Metadata

providers WidgetframeService
selector nm-workflow-viewer
styleUrls workflow-viewer.component.scss
templateUrl ./workflow-viewer.component.html

Index

Widget inputs
Widget outputs
Properties
Methods

Constructor

constructor(widgetFrameService: WidgetframeService)
Parameters :
Name Type Optional
widgetFrameService WidgetframeService no

Methods

Protected configureWidget
configureWidget(configuration: WidgetConfig)
Decorators : WidgetConfigure
Parameters :
Name Type Optional
configuration WidgetConfig no
Returns : void
download
download()
Returns : void

Properties

Public _id
_id:
Decorators : WidgetId
Public configuration
configuration: WidgetConfig
Type : WidgetConfig
Decorators : WidgetConfiguration
Private name
name: string
Type : string
Public viewer
viewer: string
Type : string
Public workflowProcess
workflowProcess:
Default value : new Subject<any>()
Decorators : WidgetInput
Public workflowViewer
workflowViewer:
Default value : new Subject<any>()
Decorators : WidgetInput
Public xml
xml: string
Type : string
import { pluck, mergeMap, tap } from "rxjs/operators";
import { Component } from "@angular/core";
import { WidgetConfig } from "../../widget.configuration";
import {
  WidgetComponent,
  WidgetId,
  WidgetConfiguration,
  WidgetConfigure,
  WidgetInput,
} from "../../widget.metadata";
import { Subject } from "rxjs";
import { WidgetframeService } from "../../widgetframe/widgetframe.service";

declare var contextPath: string;
declare var $;

@WidgetComponent("nm-workflow-viewer")
@Component({
  selector: "nm-workflow-viewer",
  templateUrl: "./workflow-viewer.component.html",
  styleUrls: ["./workflow-viewer.component.scss"],
  providers: [WidgetframeService],
})
export class WorkflowViewerComponent {
  public xml: string;
  public viewer: string;

  @WidgetInput("workflow-viewer")
  public workflowViewer = new Subject<any>();

  @WidgetInput("workflow-process")
  public workflowProcess = new Subject<any>();

  @WidgetConfiguration()
  public configuration: WidgetConfig;

  @WidgetId()
  public _id;

  private name: string;
  constructor(private widgetFrameService: WidgetframeService) {}

  @WidgetConfigure()
  protected configureWidget(configuration: WidgetConfig) {
    this.workflowViewer.subscribe((data) => {
      this.viewer = data;
    });
    this.workflowProcess
      .pipe(
        tap(
          (link) =>
            (this.name = link.substring(link.lastIndexOf("/") + 1, link.length))
        ),
        mergeMap((link) => this.widgetFrameService.getData(link)),
        pluck("data")
      )
      .subscribe((data: string) => {
        this.xml = data;
      });
  }

  download() {
    if (this.xml) {
      const a = document.createElement("a");
      document.body.appendChild(a);
      const blob = new Blob([this.xml], { type: "application/xml" });
      const url = window.URL.createObjectURL(blob);
      a.href = url;
      a.download = this.name + ".xml";
      a.click();
      window.URL.revokeObjectURL(url);
      document.body.removeChild(a);
    }
  }
}
<nm-widgetframe
  [configuration]="configuration"
  [header]="configuration.configuration['header']"
  [infoTitle]="configuration.configuration.infoTitle"
  [infoText]="configuration.configuration.infoText"
  [infoPlacement]="'left'"
  widgetId="{{ _id }}"
>
  <div slot="buttons">
    <button
      mat-icon-button
      color="primary"
      class="nm-workflow__download"
      (click)="download()"
    >
      <mat-icon>file_download</mat-icon>
    </button>
  </div>

  <div slot="content" class="nm-widgetframe__content">
    <ng-container [ngSwitch]="viewer" *ngIf="viewer && xml">
      <nm-bpmnjs-viewer [xml]="xml" *ngSwitchCase="'bpmnjs'"></nm-bpmnjs-viewer>
      <div *ngSwitchDefault>
        {{ "apps.workflowviewer.no.viewer.selected" | translate }}
      </div>
    </ng-container>
    <div class="modeler">
      <div id="canvas"></div>
      <div id="properties"></div>
    </div>
  </div>
</nm-widgetframe>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""