X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Fapp%2Fdashboard%2FDashboardComponent.ts;h=2feef7c0c567f24f59325d0a65a54ad43e6c6640;hb=86be6393a128843c691414901896e99ca82b76fd;hp=4660732f80ffefd48309e1e2a69f98ba9c2588bc;hpb=cedffeca6ea3cabc282b753c62a849ca273dfb42;p=osm%2FNG-UI.git diff --git a/src/app/dashboard/DashboardComponent.ts b/src/app/dashboard/DashboardComponent.ts index 4660732..2feef7c 100644 --- a/src/app/dashboard/DashboardComponent.ts +++ b/src/app/dashboard/DashboardComponent.ts @@ -20,9 +20,11 @@ */ import { Component, Injector, OnInit } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; +import { NotifierService } from 'angular-notifier'; import { AuthenticationService } from 'AuthenticationService'; -import { ActiveElement, Chart, ChartEvent } from 'chart.js'; -import { ERRORDATA } from 'CommonModel'; +import { Chart } from 'chart.js'; +import 'chartjs-plugin-labels'; +import { ERRORDATA, TYPESECTION, VIM_TYPES } from 'CommonModel'; import { environment } from 'environment'; import { NSDDetails } from 'NSDModel'; import { NSInstanceDetails } from 'NSInstanceModel'; @@ -33,6 +35,7 @@ import { Observable, Subscription } from 'rxjs'; import { SDNControllerModel } from 'SDNControllerModel'; import { SharedService } from 'SharedService'; import { ProjectRoleMappings, UserDetail } from 'UserModel'; +import { isNullOrUndefined } from 'util'; import { VimAccountDetails } from 'VimAccountModel'; import { VNFInstanceDetails } from 'VNFInstanceModel'; @@ -108,6 +111,18 @@ export class DashboardComponent implements OnInit { /** List of NS Success Instances @public */ public nsRunningInstance: string[] = []; + /** Contains VIM Account details @public */ + public vimData: VimAccountDetails[] = []; + + /** Contains Selected VIM Details @public */ + public selectedVIMDetails: VimAccountDetails = null; + + /** List of VIM_TYPES @public */ + public vimTypes: TYPESECTION[] = VIM_TYPES; + + /** Array holds Vim data filtered with selected vimtype */ + public vimList: VimAccountDetails[] = []; + /** List of color for Instances @private */ private backgroundColor: string[] = []; @@ -159,6 +174,9 @@ export class DashboardComponent implements OnInit { /** Contians hour converter @private */ private hourConverter: number = 3600; + /** Notifier service to popup notification @private */ + private notifierService: NotifierService; + constructor(injector: Injector) { this.injector = injector; this.restService = this.injector.get(RestService); @@ -166,6 +184,7 @@ export class DashboardComponent implements OnInit { this.projectService = this.injector.get(ProjectService); this.sharedService = this.injector.get(SharedService); this.translateService = this.injector.get(TranslateService); + this.notifierService = this.injector.get(NotifierService); } /** @@ -303,29 +322,42 @@ export class DashboardComponent implements OnInit { data: this.noOfHours, label: this.translateService.instant('NOOFHOURS'), borderColor: this.backgroundColor, + fill: false, backgroundColor: this.backgroundColor }] }, options: { - onHover: (evt: ChartEvent, elements):void => { - const el: HTMLElement = document.getElementById('canvas'); - el.style.cursor = elements[0] ? 'pointer' : 'default'; + hover: { + onHover(evt: Event, item: {}): void { + const el: HTMLElement = document.getElementById('canvas'); + el.style.cursor = item[0] ? 'pointer' : 'default'; + } }, plugins: { - legend: { display: false }, + labels: { + // render 'label', 'value', 'percentage', 'image' or custom function, default is 'percentage' + render: 'value' + } }, + legend: { display: false }, scales: { - x: { + xAxes: [{ display: true, - labels: [this.translateService.instant('INSTANCES')], - }, - y: { + scaleLabel: { + display: true, + labelString: this.translateService.instant('INSTANCES') + } + }], + yAxes: [{ ticks: { - labelOffset: 0, + beginAtZero: true }, display: true, - labels: [this.translateService.instant('NOOFHOURS')] - }, + scaleLabel: { + display: true, + labelString: this.translateService.instant('NOOFHOURS') + } + }] } } }); @@ -346,6 +378,7 @@ export class DashboardComponent implements OnInit { this.vimAccountCountSub = this.restService.getResource(environment.VIMACCOUNTS_URL) .subscribe((vimAccountData: VimAccountDetails[]): void => { this.vimAccountCount = vimAccountData.length; + this.vimData = vimAccountData; }, (error: ERRORDATA): void => { this.restService.handleError(error, 'get'); }); @@ -361,6 +394,22 @@ export class DashboardComponent implements OnInit { }); } + /** Get Vim data filtered by the selected Vim Type @public */ + public getSelectedVimTypeList(selectedVIMType: string): void { + this.vimList = this.vimData.filter((vimData: VimAccountDetails): boolean => + vimData.vim_type === selectedVIMType); + + } + + /** Get Selected VIM details @public */ + public getSelectedVIMDetails(vimDetails: VimAccountDetails): void { + if (!isNullOrUndefined(vimDetails.resources)) { + this.selectedVIMDetails = vimDetails; + } else { + this.notifierService.notify('error', this.translateService.instant('RESOURCESNOTFOUND')); + } + } + /** * Lifecyle Hooks the trigger before component is deleted */