changeset 227:ca1ab4a5dc73

Fix bug where jvm-memory charts' units do not update Reviewed-by: jkang Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-September/025212.html
author Andrew Azores <aazores@redhat.com>
date Wed, 27 Sep 2017 17:19:32 -0400
parents 78c7d1c23616
children 4d79a8984071
files src/app/components/jvm-info/jvm-memory/jvm-memory.controller.js
diffstat 1 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/components/jvm-info/jvm-memory/jvm-memory.controller.js	Tue Sep 26 09:49:49 2017 -0400
+++ b/src/app/components/jvm-info/jvm-memory/jvm-memory.controller.js	Wed Sep 27 17:19:32 2017 -0400
@@ -120,7 +120,13 @@
       let metaspaceScale = this._scaleBytes.format(data.metaspaceUsed);
       this.metaspaceData.used = this.convertMemStat(data.metaspaceUsed, metaspaceScale.scale);
       this.metaspaceData.total = this.convertMemStat(data.metaspaceCapacity, metaspaceScale.scale);
-      this.metaspaceConfig.units = metaspaceScale.unit;
+
+      // re-assign chart config so that Angular picks up the change. If we only re-assign property values
+      // on the same config object, those config updates are not detected and do not reflect in the charts.
+      this.metaspaceConfig = {
+        chartId: this.metaspaceConfig.chartId,
+        units: metaspaceScale.unit
+      };
 
       for (let i = 0; i < data.generations.length; i++) {
         let generation = data.generations[i];
@@ -152,14 +158,10 @@
           }
 
           let spaceKey = 'gen-' + gen.index + '-space-' + space.index;
-          if (!this.spaceConfigs.hasOwnProperty(spaceKey)) {
-            this.spaceConfigs[spaceKey] = {
-              chartId: spaceKey,
-              units: genScale.unit
-            };
-          } else {
-            this.spaceConfigs[spaceKey].units = genScale.unit;
-          }
+          this.spaceConfigs[spaceKey] = {
+            chartId: spaceKey,
+            units: genScale.unit
+          };
         }
         this.generationData[i] = gen;
       }