Coverity-CWE 922: Insecure Storage of Sensitive Information(localStorage write)
[osm/NG-UI.git] / src / app / dashboard / DashboardComponent.ts
index 2feef7c..3c856dd 100644 (file)
@@ -57,7 +57,7 @@ export class DashboardComponent implements OnInit {
     /** Invoke service injectors @public */
     public injector: Injector;
 
-    /** handle translate @public */
+    /** Handle translate @public */
     public translateService: TranslateService;
 
     /** Observable holds logined value  @public */
@@ -123,6 +123,9 @@ export class DashboardComponent implements OnInit {
     /** Array holds Vim data filtered with selected vimtype  */
     public vimList: VimAccountDetails[] = [];
 
+    /** Model value used to hold selected vimtype Data @public */
+    public vimListData: string;
+
     /** List of color for Instances @private */
     private backgroundColor: string[] = [];
 
@@ -174,6 +177,9 @@ export class DashboardComponent implements OnInit {
     /** Contians hour converter @private */
     private hourConverter: number = 3600;
 
+    /** Converter used to round off time to one decimal point @private */
+    private converter: number = 10;
+
     /** Notifier service to popup notification @private */
     private notifierService: NotifierService;
 
@@ -192,7 +198,7 @@ export class DashboardComponent implements OnInit {
      */
     public ngOnInit(): void {
         this.username$ = this.authService.username;
-        this.isAdmin = (localStorage.getItem('isAdmin') === 'true') ? true : false;
+        this.isAdmin = (sessionStorage.getItem('isAdmin') === 'true') ? true : false;
         this.selectedProject = this.authService.ProjectName;
         this.checkAdminPrivilege();
         this.getUserAccessedProjects();
@@ -307,7 +313,7 @@ export class DashboardComponent implements OnInit {
         const now: Date = new Date();
         const currentTime: number = Number((now.getTime().toString().slice(0, this.sliceLimit)));
         this.createdTimes.forEach((createdTime: string): void => {
-            this.noOfHours.push((Math.round((currentTime - Number(createdTime)) / this.hourConverter)));
+            this.noOfHours.push(Math.floor(((currentTime - Number(createdTime)) / this.hourConverter) * (this.converter)) / this.converter);
         });
         this.drawNsChart();
     }
@@ -327,6 +333,11 @@ export class DashboardComponent implements OnInit {
                 }]
             },
             options: {
+                layout: {
+                    padding: {
+                        top: 20
+                    }
+                },
                 hover: {
                     onHover(evt: Event, item: {}): void {
                         const el: HTMLElement = document.getElementById('canvas');
@@ -345,7 +356,7 @@ export class DashboardComponent implements OnInit {
                         display: true,
                         scaleLabel: {
                             display: true,
-                            labelString: this.translateService.instant('INSTANCES')
+                            labelString: this.translateService.instant('NSINSTANCES')
                         }
                     }],
                     yAxes: [{
@@ -365,7 +376,7 @@ export class DashboardComponent implements OnInit {
 
     /** Get VNFD instance details @public */
     public getVnfInstanceCount(): void {
-        this.vnfInstanceCountSub = this.restService.getResource(environment.NSDINSTANCES_URL)
+        this.vnfInstanceCountSub = this.restService.getResource(environment.VNFINSTANCES_URL)
             .subscribe((vnfInstanceData: VNFInstanceDetails[]): void => {
                 this.vnfInstanceCount = vnfInstanceData.length;
             }, (error: ERRORDATA): void => {
@@ -398,6 +409,9 @@ export class DashboardComponent implements OnInit {
     public getSelectedVimTypeList(selectedVIMType: string): void {
         this.vimList = this.vimData.filter((vimData: VimAccountDetails): boolean =>
             vimData.vim_type === selectedVIMType);
+        if (this.vimList.length === 0) {
+            this.vimListData = null;
+        }
 
     }