1 import {AfterViewChecked, Component, ViewChild} from '@angular/core';
2 import {ServiceInfoService} from '../shared/server/serviceInfo/serviceInfo.service';
3 import {ServiceInfoModel} from '../shared/server/serviceInfo/serviceInfo.model';
4 import {InstantiationStatusComponentService} from './instantiationStatus.component.service';
5 import {ContextMenuComponent, ContextMenuService} from 'ngx-contextmenu';
6 import {AuditInfoModalComponent} from "./auditInfoModal/auditInfoModal.component";
7 import * as _ from 'lodash';
8 import {ScrollToConfigOptions, ScrollToService} from '@nicky-lenaers/ngx-scroll-to';
9 import {ConfigurationService} from "../services/configuration.service";
10 import {LogService} from '../shared/utils/log/log.service';
14 selector : 'instantiation-status',
15 templateUrl : './instantiationStatus.component.html',
16 styleUrls : ['./instantiationStatus.component.scss']
18 export class InstantiationStatusComponent implements AfterViewChecked{
21 TIMER_TIME_IN_SECONDS : number = 0;
23 dataIsReady : boolean = false;
24 scroll : boolean = false;
25 lastUpdatedDate: Date = null;
26 currentJobId: string = null;
27 instantiationStatusComponentService: InstantiationStatusComponentService;
28 configurationService : ConfigurationService;
29 serviceInfoData: Array<ServiceInfoModel> = null;
30 @ViewChild(ContextMenuComponent) public contextMenu: ContextMenuComponent;
32 constructor(private _serviceInfoService: ServiceInfoService,
33 private _instantiationStatusComponentService : InstantiationStatusComponentService,
34 private _contextMenuService: ContextMenuService,
35 private _configurationService : ConfigurationService,
36 private _scrollToService: ScrollToService,
37 private _logService : LogService) {
38 this.instantiationStatusComponentService = _instantiationStatusComponentService;
39 this.configurationService = this._configurationService;
40 this.configurationService.getConfiguration("refreshTimeInstantiationDashboard").subscribe(response => {
41 this.TIMER_TIME_IN_SECONDS = _.isNumber(response) ? response : 0;
42 this.activateInterval();
48 if (this.TIMER_TIME_IN_SECONDS > 0) {
49 this.timer = setInterval(() => {
51 }, this.TIMER_TIME_IN_SECONDS * 1000);
55 deactivateInterval() {
56 clearInterval(this.timer);
60 this.dataIsReady = false;
61 this._serviceInfoService.getServicesJobInfo(true)
62 .subscribe((res: Array<ServiceInfoModel>) => {
63 this._instantiationStatusComponentService.convertObjectToArray(res).subscribe((res) => {
64 this._logService.info('refresh instantiation status table', res);
65 this.dataIsReady = true;
66 this.lastUpdatedDate = new Date();
67 if (!_.isEqual(this.serviceInfoData, res)) {
68 this.serviceInfoData = res;
77 this.scrollToElement();
84 isDeleteEnabled(item):boolean {
85 return _.includes(['PENDING', 'STOPPED'], item.jobStatus);
88 deleteItem(item): void {
89 this._serviceInfoService.deleteJob(item.jobId).subscribe(() => {
94 hideItem(item): void {
95 this._serviceInfoService.hideJob(item.jobId).subscribe(() => {
100 auditInfo(jobData : ServiceInfoModel): void {
101 AuditInfoModalComponent.openModal.next(jobData);
105 isOpenVisible(item):boolean {
106 return _.includes(['COMPLETED', 'PAUSE'], item.jobStatus);
111 `subscriberId=${item['subscriberName']}&` +
112 `serviceType=${item['serviceType']}&` +
113 `serviceInstanceId=${item['serviceInstanceId']}`;
115 window.parent.location.assign('../../serviceModels.htm#/instantiate?' + query);
118 public onContextMenu($event: MouseEvent, item: any): void {
119 this._contextMenuService.show.next({
120 contextMenu: this.contextMenu,
124 $event.preventDefault();
125 $event.stopPropagation();
128 getImagesSrc(imageName : string) : string {
129 return './' + imageName + '.svg';
132 isHideEnabled(item: any):boolean {
133 return _.includes(['COMPLETED', 'FAILED', 'STOPPED'], item.jobStatus);
136 if(this.currentJobId){
137 const config: ScrollToConfigOptions = {
138 target: this.currentJobId,
140 offset: -35 //header height
142 this._scrollToService.scrollTo(config);