changeset 143:06baca9efd9a

jvm-list and jvm-info use isAlive property Reviewed-by: jerboaa Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-August/024402.html
author Andrew Azores <aazores@redhat.com>
date Tue, 01 Aug 2017 13:15:13 -0400
parents d78f6d641b7b
children 4fffcaa3b8cc
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/jvm-list/jvm-list.controller.js src/app/components/jvm-list/jvm-list.controller.spec.js src/app/components/jvm-list/jvm-list.html
diffstat 6 files changed, 4 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/components/jvm-info/jvm-info.controller.js	Mon Jul 31 11:17:38 2017 -0400
+++ b/src/app/components/jvm-info/jvm-info.controller.js	Tue Aug 01 13:15:13 2017 -0400
@@ -60,15 +60,6 @@
     );
   }
 
-  isAlive () {
-    return true;
-    //FIXME: web-gateway responses do not yet include isAlive, and stopTime is not updated for dead JVMs
-    // if (this.jvmInfo.hasOwnProperty('isAlive')) {
-    //   return this.jvmInfo.isAlive;
-    // }
-    // return this.jvmInfo.stopTime > 0;
-  }
-
   killVm () {
     this.killVmService.killVm(this.systemId, this.jvmInfo.agentId, this.jvmId, this.jvmInfo.jvmPid).then(
       response => {
--- a/src/app/components/jvm-info/jvm-info.controller.spec.js	Mon Jul 31 11:17:38 2017 -0400
+++ b/src/app/components/jvm-info/jvm-info.controller.spec.js	Tue Aug 01 13:15:13 2017 -0400
@@ -104,12 +104,6 @@
     ctrl.showErr.should.be.false();
   });
 
-  describe('isAlive', () => {
-    it('should return true', () => {
-      ctrl.isAlive().should.be.true();
-    });
-  });
-
   describe('killVm', () => {
     it('should delegate to killVmService', () => {
       killVmService.killVm.should.not.be.called();
--- a/src/app/components/jvm-info/jvm-info.html	Mon Jul 31 11:17:38 2017 -0400
+++ b/src/app/components/jvm-info/jvm-info.html	Tue Aug 01 13:15:13 2017 -0400
@@ -38,11 +38,11 @@
             <td>Start Time</td>
             <td>{{ctrl.jvmInfo.startTime | date:"medium"}}</td>
           </tr>
-          <tr ng-show="ctrl.isAlive()">
+          <tr ng-show="ctrl.jvmInfo.isAlive">
             <td>Stop Time</td>
             <td>{{ctrl.jvmInfo.stopTime | date:"medium"}}</td>
           </tr>
-          <tr ng-show="ctrl.isAlive()"</tr>
+          <tr ng-show="ctrl.jvmInfo.isAlive"</tr>
             <td>Last Updated</td>
             <td>{{ctrl.jvmInfo.lastUpdated | date:"medium"}}</td>
           </tr>
@@ -93,7 +93,7 @@
           </tr>
           <tr>
             <td>
-              <btn ng-show="ctrl.isAlive()" class="btn btn-default" ng-click="ctrl.killVm()">Kill VM</btn>
+              <btn ng-show="ctrl.jvmInfo.isAlive" class="btn btn-default" ng-click="ctrl.killVm()">Kill VM</btn>
             </td>
           </tr>
         </tbody>
--- a/src/app/components/jvm-list/jvm-list.controller.js	Mon Jul 31 11:17:38 2017 -0400
+++ b/src/app/components/jvm-list/jvm-list.controller.js	Tue Aug 01 13:15:13 2017 -0400
@@ -49,14 +49,6 @@
       this.loadData();
     });
 
-    this.scope.isAlive = jvm => {
-      if (!jvm.hasOwnProperty('stopTime')) {
-        return false;
-      }
-
-      return parseInt(jvm.stopTime.$numberLong) < 0;
-    };
-
     this.title = 'JVM Listing';
     this.showErr = false;
     this.systemsOpen = {};
--- a/src/app/components/jvm-list/jvm-list.controller.spec.js	Mon Jul 31 11:17:38 2017 -0400
+++ b/src/app/components/jvm-list/jvm-list.controller.spec.js	Tue Aug 01 13:15:13 2017 -0400
@@ -172,29 +172,6 @@
     });
   });
 
-  describe('isAlive', () => {
-    it('should be a scope function', () => {
-      scope.should.have.ownProperty('isAlive');
-      scope.isAlive.should.be.a.Function();
-    });
-
-    it('should return false for object without stopTime', () => {
-      scope.isAlive({ foo: 'bar'} ).should.equal(false);
-    });
-
-    it('should return false for object with positive stopTime', () => {
-      scope.isAlive({ stopTime: { $numberLong: '100' } }).should.equal(false);
-    });
-
-    it('should return true for object with negative stopTime', () => {
-      scope.isAlive({ stopTime: { $numberLong: '-100' } }).should.equal(true);
-    });
-
-    it('should return false for object with zero stopTime', () => {
-      scope.isAlive({ stopTime: { $numberLong: '0' } }).should.equal(false);
-    });
-  });
-
   describe('aliveOnly', () => {
     it('should default to true', () => {
       ctrl.should.have.ownProperty('aliveOnly');
--- a/src/app/components/jvm-list/jvm-list.html	Mon Jul 31 11:17:38 2017 -0400
+++ b/src/app/components/jvm-list/jvm-list.html	Tue Aug 01 13:15:13 2017 -0400
@@ -48,7 +48,7 @@
                     </h2>
                     <div class="card-pf-info text-center">
                       <strong>Created On</strong> {{jvm.startTime | timestampToDate}}
-                      <span class="pull-right pficon" ng-class="isAlive(jvm) ? 'pficon-ok' : 'pficon-error-circle-o'"></span>
+                      <span class="pull-right pficon" ng-class="jvm.isAlive ? 'pficon-ok' : 'pficon-error-circle-o'"></span>
                     </div>
                   </div>
                 </div>