From 25e50def4ea4ded8f4fbb81f6e8c16f395d7fc7f Mon Sep 17 00:00:00 2001 From: Meina Zhou Date: Wed, 12 Sep 2018 14:27:47 +0800 Subject: [PATCH] add vic appliance ip information in summary view Signed-off-by: Meina Zhou --- .../create-vch-wizard.service.spec.ts | 18 ++--- .../create-vch-wizard.service.ts | 36 +++++---- .../summary-view/summary-view.component.html | 78 ++++++++++++------- .../summary-view.component.spec.ts | 3 + .../summary-view/summary-view.component.ts | 20 ++++- .../app/summary-view/vic-summary-view.scss | 17 +++- 6 files changed, 116 insertions(+), 56 deletions(-) diff --git a/h5c/vic/src/vic-webapp/src/app/create-vch-wizard/create-vch-wizard.service.spec.ts b/h5c/vic/src/vic-webapp/src/app/create-vch-wizard/create-vch-wizard.service.spec.ts index 5c63ce293..584ea0de1 100644 --- a/h5c/vic/src/vic-webapp/src/app/create-vch-wizard/create-vch-wizard.service.spec.ts +++ b/h5c/vic/src/vic-webapp/src/app/create-vch-wizard/create-vch-wizard.service.spec.ts @@ -205,19 +205,17 @@ describe('CreateVchWizardService', () => { expect(response).toBe('10.20.250.255'); }); - connection.mockRespond(new Response(new ResponseOptions({ - body: ['vic-ova-2: v1.2.0-12000-bbbbbb, 10.20.250.255', 'vic-ova-1: v1.1.0-11000-aaaaaa, 10.20.250.254'] - }))); + if (!connection.response) { + connection.mockRespond(new Response(new ResponseOptions({ + body: ['vic-ova-2: v1.2.0-12000-bbbbbb, 10.20.250.255', 'vic-ova-1: v1.1.0-11000-aaaaaa, 10.20.250.254'] + }))); + } }); - it('should handle invalid response from VIC appliance lookup endpoint', async() => { - service.getVicApplianceIp().subscribe(response => {}, err => { - expect(err).toBeTruthy(); + it('should get value from cache if invoke ip address api second time', async() => { + service.getVicApplianceIp().subscribe(response => { + expect(response).toBe('10.20.250.255'); }); - - connection.mockRespond(new Response(new ResponseOptions({ - body: 'not an array of string values' - }))); }); it('should retrieve a list of distributed port groups', async() => { diff --git a/h5c/vic/src/vic-webapp/src/app/create-vch-wizard/create-vch-wizard.service.ts b/h5c/vic/src/vic-webapp/src/app/create-vch-wizard/create-vch-wizard.service.ts index 69faca596..77e1d2400 100644 --- a/h5c/vic/src/vic-webapp/src/app/create-vch-wizard/create-vch-wizard.service.ts +++ b/h5c/vic/src/vic-webapp/src/app/create-vch-wizard/create-vch-wizard.service.ts @@ -14,10 +14,6 @@ limitations under the License. */ -import 'rxjs/add/observable/timer'; -import 'rxjs/add/observable/zip'; -import 'rxjs/add/operator/mergeAll'; -import 'rxjs/add/operator/mergeMap'; import { CHECK_RP_UNIQUENESS_URL, @@ -31,6 +27,10 @@ import { Http, URLSearchParams } from '@angular/http'; import { GlobalsService } from '../shared'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/observable/timer'; +import 'rxjs/add/observable/zip'; +import 'rxjs/add/operator/mergeAll'; +import 'rxjs/add/operator/mergeMap'; import { byteToLegibleUnit } from '../shared/utils/filesize'; import { flattenArray } from '../shared/utils/array-utils'; import { @@ -52,6 +52,7 @@ export class CreateVchWizardService { private _userId: string = null; private _serverGuid: string[] = []; private _userSession: any = null; + private _appliance: Observable ; constructor( private http: Http, @@ -60,6 +61,20 @@ export class CreateVchWizardService { private vicVmViewService: VicVmViewService ) { this.getUserSession(); + this._appliance = this.setAppliance(); + } + + setAppliance(): Observable { + return this.http.get(VIC_APPLIANCES_LOOKUP_URL) + .publishReplay(1, 2000) + .refCount() + .take(1) + .catch(err => Observable.throw(err)) + .map(response => response.json()); + } + + getAppliance() { + return this._appliance; } getClusterConfiguration(objRef: string): Observable { @@ -539,22 +554,11 @@ export class CreateVchWizardService { }); } - /** - * Look up and return from the vSphere inventory name, version and IP address - * for all VIC appliance VMs - * @returns {Observable} array of VIC appliances info sorted by build # - */ - private getVicAppliancesList(): Observable { - return this.http.get(VIC_APPLIANCES_LOOKUP_URL) - .catch(err => Observable.throw(err)) - .map(response => response.json()); - } - /** * Get the IP address of the newest VIC appliance */ public getVicApplianceIp(): Observable { - return this.getVicAppliancesList() + return this.getAppliance() .catch(err => Observable.throw(err)) .switchMap((list: string[]) => { if (!list || !list.length) { diff --git a/h5c/vic/src/vic-webapp/src/app/summary-view/summary-view.component.html b/h5c/vic/src/vic-webapp/src/app/summary-view/summary-view.component.html index a2dc8cc5e..277b7996f 100644 --- a/h5c/vic/src/vic-webapp/src/app/summary-view/summary-view.component.html +++ b/h5c/vic/src/vic-webapp/src/app/summary-view/summary-view.component.html @@ -7,34 +7,58 @@ -
+
-
    -
  • - - {{ vicI18n.translate(WS_SUMMARY_CONSTANTS, 'VENDOR') }} - - - VMware - -
  • -
  • - - {{ vicI18n.translate(WS_SUMMARY_CONSTANTS, 'VERSION') }} - - - {{ pluginVersion }} - -
  • -
  • - - {{ vicI18n.translate(WS_SUMMARY_CONSTANTS, 'VCH') }} - - - {{ vchVmsLen }} - -
  • -
+
+
VIC PLUGIN INFORMATION
+
    +
  • + + {{ vicI18n.translate(WS_SUMMARY_CONSTANTS, 'VENDOR') }} + + + VMware + +
  • +
  • + + {{ vicI18n.translate(WS_SUMMARY_CONSTANTS, 'VERSION') }} + + + {{ pluginVersion }} + +
  • +
  • + + {{ vicI18n.translate(WS_SUMMARY_CONSTANTS, 'VCH') }} + + + {{ vchVmsLen }} + +
  • +
+
+
+
VIC APPLIANCE INFORMATION
+
    +
  • + + {{ vicI18n.translate(WS_SUMMARY_CONSTANTS, 'VERSION') }} + + + {{applianceVersion}} + +
  • +
  • + + IP Address + + + {{applianceIp}} + +
  • +
+

diff --git a/h5c/vic/src/vic-webapp/src/app/summary-view/summary-view.component.spec.ts b/h5c/vic/src/vic-webapp/src/app/summary-view/summary-view.component.spec.ts index d3dfc8df3..9f8a2acd4 100644 --- a/h5c/vic/src/vic-webapp/src/app/summary-view/summary-view.component.spec.ts +++ b/h5c/vic/src/vic-webapp/src/app/summary-view/summary-view.component.spec.ts @@ -69,6 +69,9 @@ describe('VIC object view: Summary tab', () => { { provide: CreateVchWizardService, useValue: { verifyVicMachineApiEndpoint() { return Observable.of('10.10.10.10'); + }, + getAppliance() { + return Observable.of(['vic-ova-2: v1.2.0-12000-bbbbbb, 10.20.250.255']); } }} ], diff --git a/h5c/vic/src/vic-webapp/src/app/summary-view/summary-view.component.ts b/h5c/vic/src/vic-webapp/src/app/summary-view/summary-view.component.ts index 72597a2a6..db3962876 100644 --- a/h5c/vic/src/vic-webapp/src/app/summary-view/summary-view.component.ts +++ b/h5c/vic/src/vic-webapp/src/app/summary-view/summary-view.component.ts @@ -24,7 +24,7 @@ import { import { CreateVchWizardService } from '../create-vch-wizard/create-vch-wizard.service'; import { DataPropertyService } from '../services/data-property.service'; import { Observable } from 'rxjs/Observable'; -import { Subscription } from 'rxjs/Rx'; +import { Subscription, Subject} from 'rxjs/Rx'; import { Vic18nService } from '../shared/vic-i18n.service'; @Component({ @@ -37,10 +37,13 @@ export class VicSummaryViewComponent implements OnInit, OnDestroy { public vicLogoPath: string; public pluginVersion: string; public vchVmsLen: number; + public appliance = new Subject(); public readonly WS_SUMMARY_CONSTANTS = WS_SUMMARY; private rootInfoSubscription: Subscription; private refreshSubscription: Subscription; public error: any; + public applianceIp: string; + public applianceVersion: string; constructor( private zone: NgZone, @@ -87,11 +90,24 @@ export class VicSummaryViewComponent implements OnInit, OnDestroy { ngOnInit() { this.fetchRootInfo(); - // verify the appliance endpoint + this.getApplianceInfo(); this.checkVicMachineServer(); } + getApplianceInfo() { + this.createWzService.getAppliance() + .subscribe( + (response) => { + if (response.length > 0) { + const splitByColon = response[0].split(':'); + this.applianceVersion = splitByColon[0]; + this.applianceIp = splitByColon[1].split(',')[1].trim(); + } + } + ) + } + checkVicMachineServer() { this.createWzService.verifyVicMachineApiEndpoint() .subscribe( diff --git a/h5c/vic/src/vic-webapp/src/app/summary-view/vic-summary-view.scss b/h5c/vic/src/vic-webapp/src/app/summary-view/vic-summary-view.scss index 0cd8eba73..86cefa533 100644 --- a/h5c/vic/src/vic-webapp/src/app/summary-view/vic-summary-view.scss +++ b/h5c/vic/src/vic-webapp/src/app/summary-view/vic-summary-view.scss @@ -18,6 +18,7 @@ div.summary-container { padding-top: 10px; font-size: 13px; img.vic-summary-view-logo { + height:100px; padding-right: 2em; vertical-align: top; } @@ -29,7 +30,7 @@ ul.summary-items-list { display: table-row-group; span.summary-label { display: table-cell; - width: auto; + min-width: 145px; } span.summary-value { display: table-cell; @@ -48,3 +49,17 @@ p.summary-intro { .mb-2 { margin-bottom: 2rem !important; } + +.summary-wrapper { + display: flex; + + .summary-content { + margin-right: 80px; + min-width:340px; + } + + .summary-title { + font-weight: bold; + margin-bottom: 10px; + } +}