Fix Bug 2121: NG-UI uses unmaintained Chokidar version
[osm/NG-UI.git] / src / app / vim-accounts / info-vim / InfoVimComponent.ts
index d40b696..b89a1b9 100644 (file)
@@ -18,6 +18,7 @@
 /**
  * @file Info VIM Page
  */
+import { isNullOrUndefined } from 'util';
 import { Component, Injector, OnInit } from '@angular/core';
 import { ActivatedRoute, Router } from '@angular/router';
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
@@ -26,7 +27,6 @@ import { DataService } from 'DataService';
 import { environment } from 'environment';
 import * as HttpStatus from 'http-status-codes';
 import { RestService } from 'RestService';
-import { isNullOrUndefined } from 'util';
 import { CONFIG, VimAccountDetails, VIMData } from 'VimAccountModel';
 
 /**
@@ -47,7 +47,7 @@ export class InfoVimComponent implements OnInit {
   public vimAccountDetails: VimAccountDetails;
 
   /** Information Top Left @public */
-  public configParams: {}[] = [];
+  public configParams: {} = {};
 
   /** Showing more details of collapase */
   public isCollapsed: boolean = true;
@@ -95,7 +95,6 @@ export class InfoVimComponent implements OnInit {
    * Lifecyle Hooks the trigger before component is instantiate
    */
   public ngOnInit(): void {
-    // tslint:disable-next-line:no-backbone-get-set-outside-model
     this.paramsID = this.activatedRoute.snapshot.paramMap.get('id');
     this.dataService.currentMessage.subscribe((data: VIMData) => {
       this.vimId = data.identifier;
@@ -116,24 +115,36 @@ export class InfoVimComponent implements OnInit {
     this.restService.getResource(environment.VIMACCOUNTS_URL + '/' + this.paramsID)
       .subscribe((vimAccountsData: VimAccountDetails) => {
         this.showDetails(vimAccountsData);
-        if (vimAccountsData.config !== undefined) {
-          if (vimAccountsData.vim_type === 'openstack') {
-            this.showOpenstackConfig(vimAccountsData.config);
-          } else if (vimAccountsData.vim_type === 'aws') {
-            this.awsConfig(vimAccountsData.config);
-          } else if (vimAccountsData.vim_type === 'openvim' || vimAccountsData.vim_type === 'opennebula') {
-            this.openVIMOpenNebulaConfig(vimAccountsData.config);
-          } else if (vimAccountsData.vim_type === 'vmware') {
-            this.vmwareConfig(vimAccountsData.config);
-          } else if (vimAccountsData.vim_type === 'azure') {
-            this.azureConfig(vimAccountsData.config);
+        if (!isNullOrUndefined(vimAccountsData.config)) {
+          if (vimAccountsData.config.location !== undefined) {
+            const locationArr: string[] = vimAccountsData.config.location.split(',');
+            if (Array.isArray(locationArr)) {
+              vimAccountsData.config.location = locationArr[0];
+            }
           }
+          Object.keys(vimAccountsData.config).forEach((key: string) => {
+            // eslint-disable-next-line security/detect-object-injection
+            if (Array.isArray(vimAccountsData.config[key]) || typeof vimAccountsData.config[key] === 'object') {
+              // eslint-disable-next-line security/detect-object-injection
+              vimAccountsData.config[key] = JSON.stringify(vimAccountsData.config[key]);
+            }
+            const keyArr: string[] = key.split('_');
+            if (keyArr.length > 1) {
+              // eslint-disable-next-line security/detect-object-injection
+              vimAccountsData.config[key.split('_').join(' ')] = vimAccountsData.config[key];
+              // eslint-disable-next-line @typescript-eslint/no-dynamic-delete, security/detect-object-injection
+              delete vimAccountsData.config[key];
+            }
+          });
+          this.configParams = vimAccountsData.config;
         }
         this.isLoadingResults = false;
       }, (error: ERRORDATA) => {
         this.isLoadingResults = false;
         if (error.error.status === HttpStatus.NOT_FOUND || error.error.status === HttpStatus.UNAUTHORIZED) {
-          this.router.navigateByUrl('404', { skipLocationChange: true }).catch();
+          this.router.navigateByUrl('404', { skipLocationChange: true }).catch((): void => {
+            // Catch Navigation Error
+          });
         } else {
           this.restService.handleError(error, 'get');
         }
@@ -177,269 +188,4 @@ export class InfoVimComponent implements OnInit {
       }
     ];
   }
-
-  /** Openstack Config @public */
-  public showOpenstackConfig(config: CONFIG): void {
-    if (!isNullOrUndefined(config)) {
-      Object.keys(config).forEach((key: string) => {
-        if (Array.isArray(config[key])) {
-          config[key] = JSON.stringify(config[key]);
-        }
-      });
-    }
-    let location: string = config.location;
-    if (!isNullOrUndefined(location)) {
-      const locationArr: string[] = config.location.split(',');
-      if (Array.isArray(locationArr)) {
-        location = locationArr[0];
-      }
-    }
-
-    this.configParams = [
-      {
-        title: 'PAGE.VIMDETAILS.SDNCONTROLLER',
-        value: config.sdn_controller
-      },
-      {
-        title: 'PAGE.VIMDETAILS.SDNPORTMAPPING',
-        value: config.sdn_port_mapping
-      },
-      {
-        title: 'PAGE.VIMDETAILS.VIMNETWORKNAME',
-        value: config.vim_network_name
-      },
-      {
-        title: 'PAGE.VIMDETAILS.SECURITYGROUPS',
-        value: config.security_groups
-      },
-      {
-        title: 'PAGE.VIMDETAILS.AVAILABILITYZONE',
-        value: config.availabilityZone
-      },
-      {
-        title: 'PAGE.VIMDETAILS.REGIONALNAME',
-        value: config.region_name
-      },
-      {
-        title: 'PAGE.VIMDETAILS.INSECURE',
-        value: config.insecure
-      },
-      {
-        title: 'PAGE.VIMDETAILS.USEEXISTINGFLAVOURS',
-        value: config.use_existing_flavors
-      },
-      {
-        title: 'PAGE.VIMDETAILS.USEINTERNALENDPOINT',
-        value: config.use_internal_endpoint
-      },
-      {
-        title: 'PAGE.VIMDETAILS.ADDITIONALCONFIG',
-        value: config.additional_conf
-      },
-      {
-        title: 'PAGE.VIMDETAILS.APIVERSION',
-        value: config.APIversion
-      },
-      {
-        title: 'PAGE.VIMDETAILS.PROJECTDOMAINID',
-        value: config.project_domain_id
-      },
-      {
-        title: 'PAGE.VIMDETAILS.PROJECTDOMAINNAME',
-        value: config.project_domain_name
-      },
-      {
-        title: 'PAGE.VIMDETAILS.USERDOMAINID',
-        value: config.user_domain_id
-      },
-      {
-        title: 'PAGE.VIMDETAILS.USERDOMAINUSER',
-        value: config.user_domain_name
-      },
-      {
-        title: 'PAGE.VIMDETAILS.KEYPAIR',
-        value: config.keypair
-      },
-      {
-        title: 'PAGE.VIMDETAILS.DATAPLANEPHYSICALNET',
-        value: config.dataplane_physical_net
-      },
-      {
-        title: 'PAGE.VIMDETAILS.USEFLOATINGIP',
-        value: config.use_floating_ip
-      },
-      {
-        title: 'PAGE.VIMDETAILS.MICROVERSION',
-        value: config.microversion
-      },
-      {
-        title: 'PAGE.VIMDETAILS.VIMLOCATION',
-        value: location
-      }
-    ];
-  }
-
-  /** AWS Config @public */
-  public awsConfig(config: CONFIG): void {
-    this.configParams = [
-      {
-        title: 'PAGE.VIMDETAILS.SDNCONTROLLER',
-        value: config.sdn_controller
-      },
-      {
-        title: 'PAGE.VIMDETAILS.VPCCIDRBLOCK',
-        value: config.vpc_cidr_block
-      },
-      {
-        title: 'PAGE.VIMDETAILS.SDNPORTMAPPING',
-        value: config.sdn_port_mapping
-      },
-      {
-        title: 'PAGE.VIMDETAILS.SECURITYGROUPS',
-        value: config.security_groups
-      },
-      {
-        title: 'PAGE.VIMDETAILS.VIMNETWORKNAME',
-        value: config.vim_network_name
-      },
-      {
-        title: 'PAGE.VIMDETAILS.KEYPAIR',
-        value: config.keypair
-      },
-      {
-        title: 'PAGE.VIMDETAILS.REGIONALNAME',
-        value: config.region_name
-      },
-      {
-        title: 'PAGE.VIMDETAILS.FLAVORIINFO',
-        value: config.flavor_info
-      },
-      {
-        title: 'PAGE.VIMDETAILS.ADDITIONALCONFIG',
-        value: config.additional_conf
-      }
-    ];
-  }
-
-  /** Open vim and open nebula config @public */
-  public openVIMOpenNebulaConfig(config: CONFIG): void {
-    this.configParams = [
-      {
-        title: 'PAGE.VIMDETAILS.SDNCONTROLLER',
-        value: config.sdn_controller
-      },
-      {
-        title: 'PAGE.VIMDETAILS.SDNPORTMAPPING',
-        value: config.sdn_port_mapping
-      },
-      {
-        title: 'PAGE.VIMDETAILS.VIMNETWORKNAME',
-        value: config.vim_network_name
-      },
-      {
-        title: 'PAGE.VIMDETAILS.ADDITIONALCONFIG',
-        value: config.additional_conf
-      }
-    ];
-  }
-
-  /** vmware config @public */
-  public vmwareConfig(config: CONFIG): void {
-    this.configParams = [
-      {
-        title: 'PAGE.VIMDETAILS.SDNCONTROLLER',
-        value: config.sdn_controller
-      },
-      {
-        title: 'PAGE.VIMDETAILS.ORGNAME',
-        value: config.orgname
-      },
-      {
-        title: 'PAGE.VIMDETAILS.SDNPORTMAPPING',
-        value: config.sdn_port_mapping
-      },
-      {
-        title: 'PAGE.VIMDETAILS.VCENTERIP',
-        value: config.vcenter_ip
-      },
-      {
-        title: 'PAGE.VIMDETAILS.VIMNETWORKNAME',
-        value: config.vim_network_name
-      },
-      {
-        title: 'PAGE.VIMDETAILS.VCENTERPORT',
-        value: config.vcenter_port
-      },
-      {
-        title: 'PAGE.VIMDETAILS.ADMINUSERNAME',
-        value: config.admin_username
-      },
-      {
-        title: 'PAGE.VIMDETAILS.VCENTERUSER',
-        value: config.vcenter_user
-      },
-      {
-        title: 'PAGE.VIMDETAILS.ADMINPASSWORD',
-        value: config.admin_password
-      },
-      {
-        title: 'PAGE.VIMDETAILS.VCENTERPASSWORD',
-        value: config.vcenter_password
-      },
-      {
-        title: 'PAGE.VIMDETAILS.NSXMANAGER',
-        value: config.nsx_manager
-      },
-      {
-        title: 'PAGE.VIMDETAILS.VROPSSITE',
-        value: config.vrops_site
-      },
-      {
-        title: 'PAGE.VIMDETAILS.NSXUSER',
-        value: config.nsx_user
-      },
-      {
-        title: 'PAGE.VIMDETAILS.VROPSUSER',
-        value: config.vrops_user
-      },
-      {
-        title: 'PAGE.VIMDETAILS.NSXPASSWORD',
-        value: config.nsx_password
-      },
-      {
-        title: 'PAGE.VIMDETAILS.VROPSPASSWORD',
-        value: config.vrops_password
-      },
-      {
-        title: 'PAGE.VIMDETAILS.ADDITIONALCONFIG',
-        value: config.additional_conf
-      }
-    ];
-  }
-
-  /** Azure Config @public */
-  public azureConfig(config: CONFIG): void {
-    this.configParams = [
-      {
-        title: 'PAGE.VIMDETAILS.SUBSCRIPTIONID',
-        value: config.subscription_id
-      },
-      {
-        title: 'PAGE.VIMDETAILS.REGIONALNAME',
-        value: config.region_name
-      },
-      {
-        title: 'PAGE.VIMDETAILS.RESOURCEGROUP',
-        value: config.resource_group
-      },
-      {
-        title: 'PAGE.VIMDETAILS.VNETNAME',
-        value: config.vnet_name
-      },
-      {
-        title: 'PAGE.VIMDETAILS.FLAVORSPATTERN',
-        value: config.flavors_pattern
-      }
-    ];
-  }
 }