changeset 171:522da87ea068

Display system hostname in system-info and jvm-info breadcrumbs Reviewed-by: jkang Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-August/024712.html
author Andrew Azores <aazores@redhat.com>
date Mon, 28 Aug 2017 14:40:53 -0400
parents f47aa9ec9b92
children a318b066384b
files src/app/components/jvm-info/jvm-info.controller.js src/app/components/jvm-info/jvm-info.controller.spec.js src/app/components/jvm-info/jvm-info.html src/app/components/system-info/system-info.html
diffstat 4 files changed, 48 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/components/jvm-info/jvm-info.controller.js	Fri Aug 25 12:29:31 2017 -0400
+++ b/src/app/components/jvm-info/jvm-info.controller.js	Mon Aug 28 14:40:53 2017 -0400
@@ -27,14 +27,16 @@
 
 import filters from 'shared/filters/filters.module.js';
 import service from './jvm-info.service.js';
+import systemService from 'components/system-info/system-info.service.js';
 
 class JvmInfoController {
-  constructor ($scope, $state, systemId, jvmId, jvmInfoService, killVmService, $translate) {
+  constructor ($scope, $state, systemId, jvmId, jvmInfoService, killVmService, systemInfoService, $translate) {
     'ngInject';
     this.systemId = systemId;
     this.jvmId = jvmId;
     this.jvmInfoService = jvmInfoService;
     this.killVmService = killVmService;
+    this.systemInfoService = systemInfoService;
     this.jvmInfo = {};
     this.showErr = false;
     $translate('jvmInfo.killVm.FAIL_MSG_TITLE').then(s => this.errTitle = s);
@@ -47,6 +49,9 @@
       }
     });
 
+    this.systemHostname = this.systemId;
+    systemInfoService.getSystemInfo(this.systemId).then(res => this.systemHostname = res.data.response[0].hostname);
+
     this.update();
   }
 
@@ -86,7 +91,8 @@
     'patternfly',
     'ui.bootstrap',
     filters,
-    service
+    service,
+    systemService
   ])
   .controller('JvmInfoController', JvmInfoController)
   .name;
--- a/src/app/components/jvm-info/jvm-info.controller.spec.js	Fri Aug 25 12:29:31 2017 -0400
+++ b/src/app/components/jvm-info/jvm-info.controller.spec.js	Mon Aug 28 14:40:53 2017 -0400
@@ -29,7 +29,7 @@
 
   beforeEach(angular.mock.module('jvmInfo.controller'));
 
-  let scope, state, jvmInfoService, killVmService, ctrl, infoPromise, killPromise, translate;
+  let scope, state, jvmInfoService, killVmService, ctrl, infoPromise, killPromise, systemInfoService, systemInfoPromise, translate;
   beforeEach(inject($controller => {
     'ngInject';
 
@@ -55,6 +55,13 @@
       killVm: sinon.stub().returns(killPromise)
     };
 
+    systemInfoPromise = {
+      then: sinon.stub()
+    };
+    systemInfoService = {
+      getSystemInfo: sinon.stub().returns(systemInfoPromise)
+    };
+
     translate = sinon.stub().returns({
       then: sinon.stub().yields()
     });
@@ -66,6 +73,7 @@
       jvmId: 'foo-jvmId',
       jvmInfoService: jvmInfoService,
       killVmService: killVmService,
+      systemInfoService: systemInfoService,
       $translate: translate
     });
   }));
@@ -109,6 +117,35 @@
     ctrl.showErr.should.be.false();
   });
 
+  describe('systemHostname property', () => {
+    let successHandler, mockResult;
+    beforeEach(() => {
+      systemInfoPromise.then.should.be.calledOnce();
+      systemInfoPromise.then.should.be.calledWith(sinon.match.func);
+      successHandler = systemInfoPromise.then.args[0][0];
+      mockResult = {
+        data: {
+          response: [
+            {
+              hostname: 'foo-hostname'
+            }
+          ]
+        }
+      };
+    });
+
+    it('should default to systemId', () => {
+      ctrl.should.have.ownProperty('systemHostname');
+      ctrl.systemHostname.should.equal('bar-systemId');
+    });
+
+    it('should be set to resolved data', () => {
+      successHandler(mockResult);
+      ctrl.should.have.ownProperty('systemHostname');
+      ctrl.systemHostname.should.equal('foo-hostname');
+    });
+  });
+
   describe('killVm', () => {
     it('should delegate to killVmService', () => {
       killVmService.killVm.should.not.be.called();
--- a/src/app/components/jvm-info/jvm-info.html	Fri Aug 25 12:29:31 2017 -0400
+++ b/src/app/components/jvm-info/jvm-info.html	Mon Aug 28 14:40:53 2017 -0400
@@ -2,7 +2,7 @@
   <ol class="breadcrumb" style="margin-bottom: 0px;">
     <li><a ui-sref="landing">Thermostat</a></li>
     <li><a ui-sref="jvmList({ '#': ctrl.systemId })" translate>jvmInfo.JVM_LIST_BREADCRUMB</a></li>
-    <li><a ui-sref="systemInfo({ systemId: ctrl.systemId })">{{ctrl.systemId}}</a></li>
+    <li><a ui-sref="systemInfo({ systemId: ctrl.systemId })">{{ctrl.systemHostname}}</a></li>
     <li><a ui-sref="jvmInfo({ systemId: ctrl.systemId, jvmId: ctrl.jvmId })">{{ctrl.jvmInfo.mainClass | extractClass}}</a></li>
   </ol>
 
--- a/src/app/components/system-info/system-info.html	Fri Aug 25 12:29:31 2017 -0400
+++ b/src/app/components/system-info/system-info.html	Mon Aug 28 14:40:53 2017 -0400
@@ -2,7 +2,7 @@
   <ol class="breadcrumb" style="margin-bottom: 0px;">
     <li><a ui-sref="landing">Thermostat</a></li>
     <li><a ui-sref="jvmList({ '#': ctrl.systemId })" translate>systemInfo.JVM_LIST_BREADCRUMB</a></li>
-    <li><a ui-sref="systemInfo({ systemId: ctrl.systemId })">{{ctrl.systemId}}</a></li>
+    <li><a ui-sref="systemInfo({ systemId: ctrl.systemId })">{{ctrl.systemInfo.hostname || ctrl.systemId}}</a></li>
   </ol>
 
   <customizable-error-message ng-show="ctrl.showErr" dismissible="true" err-message="errMessage" err-title="errTitle"></customizable-error-message>