X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Fapp%2Finstances%2Fns-instances%2FNSInstancesComponent.ts;h=34719f3d806abd2c05688c2a41cbb98d66307005;hb=8ead52b5bf62525b2697b7ca6aaf0b896bbd3400;hp=5cc55195c3189267a8ea2ea8595202bc01c9f78e;hpb=0a34dfa32165036b380ec6ac493469b34007df0a;p=osm%2FNG-UI.git diff --git a/src/app/instances/ns-instances/NSInstancesComponent.ts b/src/app/instances/ns-instances/NSInstancesComponent.ts index 5cc5519..34719f3 100644 --- a/src/app/instances/ns-instances/NSInstancesComponent.ts +++ b/src/app/instances/ns-instances/NSInstancesComponent.ts @@ -18,18 +18,20 @@ /** * @file NS Instance Component */ -import { Component, Injector, OnInit } from '@angular/core'; +import { Component, Injector, OnInit, ViewChild } from '@angular/core'; import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; import { TranslateService } from '@ngx-translate/core'; import { CONFIGCONSTANT, ERRORDATA, MODALCLOSERESPONSEDATA } from 'CommonModel'; import { DataService } from 'DataService'; +import { DeleteComponent } from 'DeleteComponent'; import { environment } from 'environment'; import { InstantiateNsComponent } from 'InstantiateNs'; -import { LocalDataSource } from 'ng2-smart-table'; +import { LocalDataSource, Ng2SmartTableComponent } from 'ng2-smart-table'; import { NSDInstanceData, NSInstanceDetails } from 'NSInstanceModel'; import { NSInstancesActionComponent } from 'NSInstancesActionComponent'; import { RestService } from 'RestService'; import { Subscription } from 'rxjs'; +import { isNullOrUndefined } from 'SharedService'; import { SharedService } from 'SharedService'; /** @@ -42,6 +44,8 @@ import { SharedService } from 'SharedService'; }) /** Exporting a class @exports NSInstancesComponent */ export class NSInstancesComponent implements OnInit { + @ViewChild('table') table: Ng2SmartTableComponent; + /** Injector to invoke other services @public */ public injector: Injector; @@ -52,10 +56,11 @@ export class NSInstancesComponent implements OnInit { public dataSource: LocalDataSource = new LocalDataSource(); /** SelectedRows array @public */ - public selectedRows: object[] = []; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + public selectedRows: any; /** Selected list array @public */ - public selectList: object[] = []; + public selectList: [] = []; /** Instance component are stored in settings @public */ public settings: {} = {}; @@ -84,6 +89,9 @@ export class NSInstancesComponent implements OnInit { /** operational State scaling data @public */ public operationalStateFourthStep: string = CONFIGCONSTANT.operationalStateFourthStep; + /** operational State healing data @public */ + public operationalStateFifthStep: string = CONFIGCONSTANT.operationalStateFifthStep; + /** Config State init data @public */ public configStateFirstStep: string = CONFIGCONSTANT.configStateFirstStep; @@ -133,6 +141,7 @@ export class NSInstancesComponent implements OnInit { /** Generate smart table row title and filters @public */ public generateTableSettings(): void { this.settings = { + selectMode: 'multi', columns: this.columnList, actions: { add: false, edit: false, delete: false, position: 'right' }, attr: this.sharedService.tableClassConfig(), @@ -144,9 +153,13 @@ export class NSInstancesComponent implements OnInit { /** Generate smart table row title and filters @public */ public generateTableColumn(): void { this.columnList = { - name: { title: this.translateService.instant('NAME'), width: '15%', sortDirection: 'asc' }, + name: { title: this.translateService.instant('NAME'), width: '15%' }, identifier: { title: this.translateService.instant('IDENTIFIER'), width: '20%' }, NsdName: { title: this.translateService.instant('NSDNAME'), width: '15%' }, + 'create-time': { + title: this.translateService.instant('DATE'), width: '15%', sortDirection: 'desc', + compareFunction: this.sharedService.compareFunction + }, OperationalStatus: { title: this.translateService.instant('OPERATIONALSTATUS'), width: '10%', type: 'html', filter: { @@ -157,27 +170,33 @@ export class NSInstancesComponent implements OnInit { { value: this.operationalStateFirstStep, title: this.operationalStateFirstStep }, { value: this.operationalStateSecondStep, title: this.operationalStateSecondStep }, { value: this.operationalStateThirdStep, title: this.operationalStateThirdStep }, - { value: this.operationalStateFourthStep, title: this.operationalStateFourthStep } + { value: this.operationalStateFourthStep, title: this.operationalStateFourthStep }, + { value: this.operationalStateFifthStep, title: this.operationalStateFifthStep } ] } }, valuePrepareFunction: (cell: NSDInstanceData, row: NSDInstanceData): string => { if (row.OperationalStatus === this.operationalStateFirstStep) { return ` - - `; + + `; } else if (row.OperationalStatus === this.operationalStateSecondStep) { return ` - - `; + + `; } else if (row.OperationalStatus === this.operationalStateThirdStep) { return ` - - `; + + `; } else if (row.OperationalStatus === this.operationalStateFourthStep) { return ` - - `; + + `; + } + else if (row.OperationalStatus === this.operationalStateFifthStep) { + return ` + + `; } else { return `${row.OperationalStatus}`; } @@ -199,16 +218,16 @@ export class NSInstancesComponent implements OnInit { valuePrepareFunction: (cell: NSDInstanceData, row: NSDInstanceData): string => { if (row.ConfigStatus === this.configStateFirstStep) { return ` - - `; + + `; } else if (row.ConfigStatus === this.configStateSecondStep) { return ` - - `; + + `; } else if (row.ConfigStatus === this.configStateThirdStep) { return ` - - `; + + `; } else { return `${row.ConfigStatus}`; } @@ -244,7 +263,8 @@ export class NSInstancesComponent implements OnInit { nsd: nsdInstanceData.nsd, 'nsd-id': nsdInstanceData['nsd-id'], vcaStatus: nsdInstanceData.vcaStatus, - constituent: nsdInstanceData['constituent-vnfr-ref'] + constituent: nsdInstanceData['constituent-vnfr-ref'], + 'create-time': this.sharedService.convertEpochTime(Number(nsdInstanceData['create-time'])) }; this.nsInstanceData.push(nsDataObj); }); @@ -271,14 +291,46 @@ export class NSInstancesComponent implements OnInit { /** smart table listing manipulation @public */ public onUserRowSelect(event: MessageEvent): void { - Object.assign(event.data, { page: 'ns-instance' }); - this.dataService.changeMessage(event.data); + if (!isNullOrUndefined(event)) { + this.selectedRows = event; + if (this.selectedRows.selected.length !== 0) { + this.selectList = this.selectedRows.selected; + } else { + if (!isNullOrUndefined(event.data)) { + Object.assign(event.data, { page: 'ns-instance' }); + this.dataService.changeMessage(event.data); + } + this.selectList.length = 0; + } + } + } + + /** delete NS using modalservice @public */ + public deleteNS(): void { + // eslint-disable-next-line security/detect-non-literal-fs-filename + const modalRef: NgbModalRef = this.modalService.open(DeleteComponent, { backdrop: 'static' }); + modalRef.componentInstance.params = { + identifierList: this.selectList, + page: 'instantiateNS' + }; + modalRef.result.then((result: MODALCLOSERESPONSEDATA) => { + if (result) { + this.sharedService.callData(); + this.table.isAllSelected = false; + this.selectList.length = 0; + } + }).catch((): void => { + // Catch Navigation Error + }); } /** Instantiate NS using modalservice @public */ public instantiateNS(): void { // eslint-disable-next-line security/detect-non-literal-fs-filename const modalRef: NgbModalRef = this.modalService.open(InstantiateNsComponent, { backdrop: 'static' }); + modalRef.componentInstance.params = { + titleName: 'instantiateNS' + }; modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => { if (result) { this.generateData();