@WidgetComponent
File
Description
Used in iPIM Analytics.
Uses message input channel to recive a list of productNo and transfers it to backend
Implements
Metadata
selector |
nm-worklistexport |
Index
Widget inputs
|
|
|
Widget outputs
|
|
Properties
|
|
Methods
|
|
Constructor
constructor(_exportService: WorklistexportService, _halService: HalService, _notificationService: NotificationsService, _appdataStore: AppdataStore, translateService: TranslateService, dialog: MatDialog)
|
|
Parameters :
Name |
Type |
Optional |
_exportService |
WorklistexportService
|
no
|
_halService |
HalService
|
no
|
_notificationService |
NotificationsService
|
no
|
_appdataStore |
AppdataStore
|
no
|
translateService |
TranslateService
|
no
|
dialog |
MatDialog
|
no
|
|
Methods
Protected
configureWidget
|
configureWidget(configuration: WidgetConfig)
|
Decorators : WidgetConfigure
|
|
|
ngOnDestroy
|
ngOnDestroy()
|
|
|
Public
dialog
|
dialog: MatDialog
|
Type : MatDialog
|
|
Public
formActionName
|
formActionName:
|
|
Public
href
|
href: Subject<String>
|
Type : Subject<String>
|
Default value : new ReplaySubject<String>(1)
|
|
Private
inputChannel
|
inputChannel: Subject<any>
|
Type : Subject<any>
|
Default value : new Subject<any>()
|
Decorators : WidgetInput
|
|
Private
unsubscribe
|
unsubscribe:
|
Default value : NgUnsubscribe.create()
|
|
import { filter, takeUntil, map, mergeMap } from "rxjs/operators";
import { Component, OnDestroy, Input } from "@angular/core";
import { Subject, ReplaySubject } from "rxjs";
import { WorklistexportService } from "./worklistexport.service";
import { AppdataStore } from "../../../components/appdata/appdata.store";
import { HalService } from "../../../components/hal/hal.service";
import { FormGroup } from "@angular/forms";
import { TranslateService } from "@ngx-translate/core";
import { WidgetConfig } from "../../widget.configuration";
import {
WidgetComponent,
WidgetId,
WidgetConfiguration,
WidgetConfigure,
WidgetInput,
} from "../../widget.metadata";
import { NgUnsubscribe } from "../../../ng-unsubscribe";
import { NotificationsService } from "../../../components/notifications/services/notifications.service";
import { MatDialog } from "@angular/material/dialog";
import { WorklistexportComponentPopup } from "./worklistexportpopup.component";
/**
* Used in iPIM Analytics.
*
* Uses message input channel to recive a list of productNo and transfers it to backend
*/
@WidgetComponent("nm-worklistexport")
@Component({
selector: "nm-worklistexport",
template: "",
})
export class WorklistexportComponent implements OnDestroy {
// Toggles visibility of
@Input("visible") visible: boolean;
@Input("cartId") cartId: string = "";
@Input("formHref") formHref: string = "";
@WidgetConfiguration()
private configuration: WidgetConfig;
// The message input from the kibana iframe
@WidgetInput("messages-output")
private inputChannel: Subject<any> = new Subject<any>();
@WidgetId()
private _id: string;
public href: Subject<String> = new ReplaySubject<String>(1);
public formGroup: FormGroup;
public action;
public formActionName;
private unsubscribe = NgUnsubscribe.create();
constructor(
private _exportService: WorklistexportService,
private _halService: HalService,
private _notificationService: NotificationsService,
private _appdataStore: AppdataStore,
private translateService: TranslateService,
public dialog: MatDialog
) {
this.formGroup = new FormGroup({});
}
@WidgetConfigure()
protected configureWidget(configuration: WidgetConfig) {
this.formActionName = this.configuration.configuration["formActionName"];
this.inputChannel
.asObservable()
.pipe(takeUntil(this.unsubscribe))
.subscribe((resp) => {
if (this.formActionName === resp.data.action) {
this._appdataStore
.getAppdata()
.pipe(
map((data) => {
return data["analytics"]._links["worklists"].href;
}),
mergeMap((href) => this._exportService.getData(href)),
takeUntil(this.unsubscribe)
)
.subscribe((data) => {
let dialogRef = this.dialog.open(WorklistexportComponentPopup, {
minHeight: "550px",
data: {
productNumbers: resp.data.data,
action: data._actions[this.formActionName],
},
});
});
}
});
this._halService
.getActionEvents()
.pipe(
filter((event) => event.name === this.formActionName),
map((event) => (<any>event).response),
takeUntil(this.unsubscribe)
)
.subscribe((resp) => {
if (resp.message !== undefined) {
this._notificationService.success(resp.title, resp.message);
} else {
this._notificationService.success(
this.translateService.instant("message.success.title"),
this.translateService.instant("message.success.body")
);
}
});
}
ngOnDestroy(): void {
this.unsubscribe.destroy();
}
}
Legend
Html element with directive