ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject [1/2] ambari git commit: AMBARI-15180. Remove duplicate code from widgets views (onechiporenko)
Date Thu, 25 Feb 2016 12:15:46 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk afc2f7b24 -> 87f8746f4


http://git-wip-us.apache.org/repos/asf/ambari/blob/87f8746f/ambari-web/app/views/main/dashboard/widgets/resource_manager_heap.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets/resource_manager_heap.js b/ambari-web/app/views/main/dashboard/widgets/resource_manager_heap.js
index 3e165f6..9509053 100644
--- a/ambari-web/app/views/main/dashboard/widgets/resource_manager_heap.js
+++ b/ambari-web/app/views/main/dashboard/widgets/resource_manager_heap.js
@@ -17,7 +17,6 @@
  */
 
 var App = require('app');
-var numberUtils = require('utils/number_utils');
 
 App.ResourceManagerHeapPieChartView = App.PieChartDashboardWidgetView.extend({
 
@@ -30,11 +29,11 @@ App.ResourceManagerHeapPieChartView = App.PieChartDashboardWidgetView.extend({
   widgetHtmlId: 'widget-rm-heap',
 
   getUsed: function() {
-    return (this.get('model').get(this.get('modelFieldUsed')) / (1024 * 1024)) || 0;
+    return this.get('model').get(this.get('modelFieldUsed')) / (1024 * 1024) || 0;
   },
 
   getMax: function() {
-    return (this.get('model').get(this.get('modelFieldMax')) / (1024 * 1024)) || 0;
+    return this.get('model').get(this.get('modelFieldMax')) / (1024 * 1024) || 0;
   },
 
   didInsertElement: function() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/87f8746f/ambari-web/app/views/main/dashboard/widgets/resource_manager_uptime.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets/resource_manager_uptime.js b/ambari-web/app/views/main/dashboard/widgets/resource_manager_uptime.js
index e67cf39..6d87741 100644
--- a/ambari-web/app/views/main/dashboard/widgets/resource_manager_uptime.js
+++ b/ambari-web/app/views/main/dashboard/widgets/resource_manager_uptime.js
@@ -17,7 +17,6 @@
  */
 
 var App = require('app');
-var date = require('utils/date/date');
 
 App.ResourceManagerUptimeView = App.UptimeTextDashboardWidgetView.extend({
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/87f8746f/ambari-web/app/views/main/dashboard/widgets/supervisor_live.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets/supervisor_live.js b/ambari-web/app/views/main/dashboard/widgets/supervisor_live.js
index 3b9e928..b8e36ca 100644
--- a/ambari-web/app/views/main/dashboard/widgets/supervisor_live.js
+++ b/ambari-web/app/views/main/dashboard/widgets/supervisor_live.js
@@ -18,22 +18,20 @@
 
 var App = require('app');
 
-App.SuperVisorUpView = App.TextDashboardWidgetView.extend({
+App.SuperVisorUpView = App.TextDashboardWidgetView.extend(App.EditableWithLimitWidgetMixin,
{
 
   title: Em.I18n.t('dashboard.widgets.SuperVisorUp'),
   id: '21',
 
-  isPieChart: false,
-  isText: true,
-  isProgressBar: false,
   model_type: 'storm',
 
   hiddenInfo: function () {
-    var result = [];
-    result.pushObject(this.get('superVisorsLive') + ' ' + Em.I18n.t('dashboard.services.hdfs.nodes.live'));
-    result.pushObject(this.get('superVisorsDead') + ' ' + Em.I18n.t('dashboard.services.hdfs.nodes.dead'));
-    return result;
+    return [
+      this.get('superVisorsLive') + ' ' + Em.I18n.t('dashboard.services.hdfs.nodes.live'),
+      this.get('superVisorsDead') + ' ' + Em.I18n.t('dashboard.services.hdfs.nodes.dead')
+    ];
   }.property('superVisorsLive', 'superVisorsDead'),
+
   hiddenInfoClass: "hidden-info-two-line",
 
   thresh1: 40,
@@ -49,126 +47,19 @@ App.SuperVisorUpView = App.TextDashboardWidgetView.extend({
   data: function () {
     if ( !this.get('superVisorsTotal') || Em.isNone(this.get('superVisorsLive'))) {
       return -1;
-    } else {
-      return ((this.get('superVisorsLive') / this.get('superVisorsTotal')).toFixed(2)) *
100;
     }
+    return (this.get('superVisorsLive') / this.get('superVisorsTotal')).toFixed(2) * 100;
   }.property('superVisorsTotal', 'superVisorsLive'),
 
   content: function () {
     if (!Em.isNone(this.get('superVisorsTotal')) && !Em.isNone(this.get('superVisorsLive')))
{
       return this.get('superVisorsLive') + "/" + this.get('superVisorsTotal');
-    } else {
-      return Em.I18n.t('services.service.summary.notAvailable');
     }
+    return Em.I18n.t('services.service.summary.notAvailable');
   }.property('superVisorsLive', 'superVisorsTotal'),
 
-  editWidget: function (event) {
-    var parent = this;
-    var max_tmp =  parseFloat(parent.get('maxValue'));
-    var configObj = Ember.Object.create({
-      thresh1: parent.get('thresh1') + '',
-      thresh2: parent.get('thresh2') + '',
-      hintInfo: Em.I18n.t('dashboard.widgets.hintInfo.hint1').format(max_tmp),
-      isThresh1Error: false,
-      isThresh2Error: false,
-      errorMessage1: "",
-      errorMessage2: "",
-      maxValue: max_tmp,
-      observeNewThresholdValue: function () {
-        var thresh1 = this.get('thresh1');
-        var thresh2 = this.get('thresh2');
-        if (thresh1.trim() != "") {
-          if (isNaN(thresh1) || thresh1 > max_tmp || thresh1 < 0){
-            this.set('isThresh1Error', true);
-            this.set('errorMessage1', 'Invalid! Enter a number between 0 - ' + max_tmp);
-          } else if ( this.get('isThresh2Error') === false && parseFloat(thresh2)<=
parseFloat(thresh1)) {
-            this.set('isThresh1Error', true);
-            this.set('errorMessage1', 'Threshold 1 should be smaller than threshold 2 !');
-          } else {
-            this.set('isThresh1Error', false);
-            this.set('errorMessage1', '');
-          }
-        } else {
-          this.set('isThresh1Error', true);
-          this.set('errorMessage1', 'This is required');
-        }
-
-        if (thresh2.trim() != "") {
-          if (isNaN(thresh2) || thresh2 > max_tmp || thresh2 < 0) {
-            this.set('isThresh2Error', true);
-            this.set('errorMessage2', 'Invalid! Enter a number between 0 - ' + max_tmp);
-          } else {
-            this.set('isThresh2Error', false);
-            this.set('errorMessage2', '');
-          }
-        } else {
-          this.set('isThresh2Error', true);
-          this.set('errorMessage2', 'This is required');
-        }
-
-        // update the slider handles and color
-        if (this.get('isThresh1Error') === false && this.get('isThresh2Error') ===
false) {
-          $("#slider-range").slider('values', 0 , parseFloat(thresh1));
-          $("#slider-range").slider('values', 1 , parseFloat(thresh2));
-        }
-      }.observes('thresh1', 'thresh2')
-
-    });
-
-    var browserVerion = this.getInternetExplorerVersion();
-    App.ModalPopup.show({
-      header: Em.I18n.t('dashboard.widgets.popupHeader'),
-      classNames: [ 'sixty-percent-width-modal-edit-widget'],
-      bodyClass: Ember.View.extend({
-        templateName: require('templates/main/dashboard/edit_widget_popup'),
-        configPropertyObj: configObj
-      }),
-      primary: Em.I18n.t('common.apply'),
-      onPrimary: function () {
-        configObj.observeNewThresholdValue();
-        if (!configObj.isThresh1Error && !configObj.isThresh2Error) {
-          parent.set('thresh1', parseFloat(configObj.get('thresh1')) );
-          parent.set('thresh2', parseFloat(configObj.get('thresh2')) );
-          if (!App.get('testMode')) {
-            var big_parent = parent.get('parentView');
-            big_parent.getUserPref(big_parent.get('persistKey'));
-            var oldValue = big_parent.get('currentPrefObject');
-            oldValue.threshold[parseInt(parent.id)] = [configObj.get('thresh1'), configObj.get('thresh2')];
-            big_parent.postUserPref(big_parent.get('persistKey'),oldValue);
-          }
-          this.hide();
-        }
-      },
-
-      didInsertElement: function () {
-        var handlers = [configObj.get('thresh1'), configObj.get('thresh2')];
-        var colors = [App.healthStatusRed, App.healthStatusOrange, App.healthStatusGreen];
//color red, orange, green
-
-        if (browserVerion == -1 || browserVerion > 9) {
-          configObj.set('isIE9', false);
-          configObj.set('isGreenOrangeRed', false);
-          $("#slider-range").slider({
-            range: true,
-            min: 0,
-            max: max_tmp,
-            values: handlers,
-            create: function (event, ui) {
-              parent.updateColors(handlers, colors);
-            },
-            slide: function (event, ui) {
-              parent.updateColors(ui.values, colors);
-              configObj.set('thresh1', ui.values[0] + '');
-              configObj.set('thresh2', ui.values[1] + '');
-            },
-            change: function (event, ui) {
-              parent.updateColors(ui.values, colors);
-            }
-          });
-        } else {
-          configObj.set('isIE9', true);
-          configObj.set('isGreenOrangeRed', false);
-        }
-      }
-    });
-  }
+  hintInfo: function () {
+    var maxTmp = parseFloat(parent.get('maxValue'));
+    return Em.I18n.t('dashboard.widgets.hintInfo.hint1').format(maxTmp);
+  }.property('maxValue')
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/87f8746f/ambari-web/app/views/main/dashboard/widgets/text_widget.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets/text_widget.js b/ambari-web/app/views/main/dashboard/widgets/text_widget.js
index 6d257a1..388ea52 100644
--- a/ambari-web/app/views/main/dashboard/widgets/text_widget.js
+++ b/ambari-web/app/views/main/dashboard/widgets/text_widget.js
@@ -17,7 +17,6 @@
  */
 
 var App = require('app');
-var date = require('utils/date/date');
 
 App.TextDashboardWidgetView = App.DashboardWidgetView.extend({
 
@@ -34,14 +33,14 @@ App.TextDashboardWidgetView = App.DashboardWidgetView.extend({
   }.property('data'),
 
   hiddenInfo: [],
-  thresh1: null,
-  thresh2: null,
+
   maxValue: null,
-  updateColors: function(handlers, colors) {
+
+  updateColors: function (handlers, colors) {
     var colorstops = colors[0] + ", "; // start with the first color
     for (var i = 0; i < handlers.length; i++) {
       colorstops += colors[i] + " " + handlers[i] + "%,";
-      colorstops += colors[i+1] + " " + handlers[i] + "%,";
+      colorstops += colors[i + 1] + " " + handlers[i] + "%,";
     }
     colorstops += colors[colors.length - 1];
     var cssForChromeAndSafari = '-webkit-linear-gradient(left,' + colorstops + ')'; // chrome
& safari

http://git-wip-us.apache.org/repos/asf/ambari/blob/87f8746f/ambari-web/app/views/main/dashboard/widgets/uptime_text_widget.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets/uptime_text_widget.js b/ambari-web/app/views/main/dashboard/widgets/uptime_text_widget.js
index 726ebb8..792aa70 100644
--- a/ambari-web/app/views/main/dashboard/widgets/uptime_text_widget.js
+++ b/ambari-web/app/views/main/dashboard/widgets/uptime_text_widget.js
@@ -51,7 +51,7 @@ App.UptimeTextDashboardWidgetView = App.TextDashboardWidgetView.extend({
   isRed: false,
 
   timeConverter: function (timestamp) {
-    var m = moment((new Date(timestamp)));
+    var m = moment(new Date(timestamp));
     return [m.format('ddd MMM DD YYYY'), m.format('HH:mm:ss')];
   },
 
@@ -83,7 +83,7 @@ App.UptimeTextDashboardWidgetView = App.TextDashboardWidgetView.extend({
     }
     var formatted = date.timingFormat(diff); //17.67 days
     var timeUnit = null;
-    if (formatted != null) {
+    if (formatted) {
       switch (formatted.split(" ")[1]) {
         case 'secs':
           timeUnit = 's';

http://git-wip-us.apache.org/repos/asf/ambari/blob/87f8746f/ambari-web/app/views/main/dashboard/widgets/yarn_memory.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets/yarn_memory.js b/ambari-web/app/views/main/dashboard/widgets/yarn_memory.js
index 6a86b56..b4dc9b7 100644
--- a/ambari-web/app/views/main/dashboard/widgets/yarn_memory.js
+++ b/ambari-web/app/views/main/dashboard/widgets/yarn_memory.js
@@ -17,7 +17,6 @@
  */
 
 var App = require('app');
-var numberUtils = require('utils/number_utils');
 
 App.YARNMemoryPieChartView = App.PieChartDashboardWidgetView.extend({
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/87f8746f/ambari-web/test/views/main/dashboard/widget_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widget_test.js b/ambari-web/test/views/main/dashboard/widget_test.js
index 1a77efe..0544ff6 100644
--- a/ambari-web/test/views/main/dashboard/widget_test.js
+++ b/ambari-web/test/views/main/dashboard/widget_test.js
@@ -20,6 +20,7 @@ var App = require('app');
 require('views/main/dashboard/widget');
 
 describe('App.DashboardWidgetView', function () {
+
   var dashboardWidgetView = App.DashboardWidgetView.create({
     parentView: Em.Object.create({
       widgetsMapper: Em.K,
@@ -439,4 +440,5 @@ describe('App.DashboardWidgetView', function () {
       });
     });
   });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/87f8746f/ambari-web/test/views/main/dashboard/widgets/datanode_live_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/datanode_live_test.js b/ambari-web/test/views/main/dashboard/widgets/datanode_live_test.js
index 10ddd3b..fb47298 100644
--- a/ambari-web/test/views/main/dashboard/widgets/datanode_live_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/datanode_live_test.js
@@ -22,54 +22,57 @@ require('views/main/dashboard/widget');
 require('views/main/dashboard/widgets/text_widget');
 require('views/main/dashboard/widgets/datanode_live');
 
-describe('App.DataNodeUpView', function() {
+var view;
 
-  var tests = [
-    {
-      data: 100,
-      e: {
-        isRed: false,
-        isOrange: false,
-        isGreen: true
-      }
-    },
-    {
-      data: 0,
-      e: {
-        isRed: true,
-        isOrange: false,
-        isGreen: false
-      }
-    },
-    {
-      data: 50,
-      e: {
-        isRed: false,
-        isOrange: true,
-        isGreen: false
-      }
-    }
-  ];
-
-  tests.forEach(function(test, index) {
-
-    describe('test#' + (index + 1), function () {
-
-      var dataNodeUpView = App.DataNodeUpView.create({model_type:null, data: test.data, content:
test.data.toString()});
-
-      it('isRed', function() {
-        expect(dataNodeUpView.get('isRed')).to.equal(test.e.isRed);
-      });
+function testCounterOrNa(propertyName, dependentKey) {
+  describe('#' + propertyName, function () {
 
-      it('isOrange', function() {
-        expect(dataNodeUpView.get('isOrange')).to.equal(test.e.isOrange);
+    beforeEach(function () {
+      view.reopen({
+        model: Em.Object.create({
+          metricsNotAvailable: true
+        })
       });
+      view.get('model').set(dependentKey, []);
+    });
 
-      it('isGreen', function() {
-        expect(dataNodeUpView.get('isGreen')).to.equal(test.e.isGreen);
-      });
+    it('n/a (1)', function () {
+      view.get('model').set(dependentKey, []);
+      view.get('model').set('metricsNotAvailable', true);
+      expect(view.get(propertyName)).to.be.equal(Em.I18n.t('services.service.summary.notAvailable'));
+    });
+
+    it('n/a (2)', function () {
+      view.get('model').set(dependentKey, null);
+      view.get('model').set('metricsNotAvailable', true);
+      expect(view.get(propertyName)).to.be.equal(Em.I18n.t('services.service.summary.notAvailable'));
+    });
+
+    it('n/a (3)', function () {
+      view.get('model').set(dependentKey, null);
+      view.get('model').set('metricsNotAvailable', false);
+      expect(view.get(propertyName)).to.be.equal(Em.I18n.t('services.service.summary.notAvailable'));
+    });
 
+    it('value exist', function () {
+      view.get('model').set(dependentKey, [{}]);
+      view.get('model').set('metricsNotAvailable', false);
+      expect(view.get(propertyName)).to.be.equal(1);
     });
+
+  });
+}
+
+describe('App.DataNodeUpView', function() {
+
+  beforeEach(function () {
+    view = App.DataNodeUpView.create();
   });
 
+  testCounterOrNa('dataNodesLive', 'liveDataNodes');
+
+  testCounterOrNa('dataNodesDead', 'deadDataNodes');
+
+  testCounterOrNa('dataNodesDecom', 'decommissionDataNodes');
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/87f8746f/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js b/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js
index c4a1687..452e1a9 100644
--- a/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js
@@ -22,48 +22,44 @@ require('views/main/dashboard/widget');
 require('views/main/dashboard/widgets/text_widget');
 require('views/main/dashboard/widgets/hawqsegment_live');
 
-describe('App.HawqSegmentUpView', function() {
+var view;
 
-  var tests = [
-    {
-      data: 100,
-      e: {
-        isRed: false,
-        isOrange: false,
-        isGreen: true
-      }
-    },
-    {
-      data: 0,
-      e: {
-        isRed: true,
-        isOrange: false,
-        isGreen: false
-      }
-    },
-    {
-      data: 50,
-      e: {
-        isRed: false,
-        isOrange: true,
-        isGreen: false
-      }
-    }
-  ];
+function testCounterOrNa(propertyName, dependentKey) {
+  describe('#' + propertyName, function () {
 
-  tests.forEach(function(test) {
-    describe('data -' + test.data, function() {
-      var hawqSegmentUpView = App.HawqSegmentUpView.create({model_type:null, data: test.data,
content: test.data.toString()});
-      it('shows red', function() {
-        expect(hawqSegmentUpView.get('isRed')).to.equal(test.e.isRed);
-      });
-      it('shows orange', function() {
-        expect(hawqSegmentUpView.get('isOrange')).to.equal(test.e.isOrange);
-      });
-      it('shows green', function() {
-        expect(hawqSegmentUpView.get('isGreen')).to.equal(test.e.isGreen);
+    beforeEach(function () {
+      view.reopen({
+        model: Em.Object.create()
       });
+      view.get('model').set(dependentKey, []);
+    });
+
+    it('n/a (1)', function () {
+      view.get('model').set(dependentKey, null);
+      expect(view.get(propertyName)).to.be.equal(Em.I18n.t('services.service.summary.notAvailable'));
+    });
+
+    it('n/a (2)', function () {
+      view.get('model').set(dependentKey, undefined);
+      expect(view.get(propertyName)).to.be.equal(Em.I18n.t('services.service.summary.notAvailable'));
     });
+
+    it('value exist', function () {
+      view.get('model').set(dependentKey, 123);
+      expect(view.get(propertyName)).to.be.equal(123);
+    });
+
   });
+}
+
+describe('App.HawqSegmentUpView', function() {
+
+  beforeEach(function () {
+    view = App.HawqSegmentUpView.create();
+  });
+
+  testCounterOrNa('hawqSegmentsStarted', 'hawqSegmentsStarted');
+  testCounterOrNa('hawqSegmentsInstalled', 'hawqSegmentsInstalled');
+  testCounterOrNa('hawqSegmentsStarted', 'hawqSegmentsStarted');
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/87f8746f/ambari-web/test/views/main/dashboard/widgets/hbase_average_load_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/hbase_average_load_test.js b/ambari-web/test/views/main/dashboard/widgets/hbase_average_load_test.js
index 6fc484f..e3a08c9 100644
--- a/ambari-web/test/views/main/dashboard/widgets/hbase_average_load_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/hbase_average_load_test.js
@@ -35,9 +35,6 @@ describe('App.HBaseAverageLoadView', function() {
         averageLoad: 1
       },
       e: {
-        isRed: false,
-        isOrange: true,
-        isGreen: false,
         isNA: false,
         content: '1'
       }
@@ -47,9 +44,6 @@ describe('App.HBaseAverageLoadView', function() {
         averageLoad: 10
       },
       e: {
-        isRed: true,
-        isOrange: false,
-        isGreen: false,
         isNA: false,
         content: '10'
       }
@@ -59,9 +53,6 @@ describe('App.HBaseAverageLoadView', function() {
         averageLoad: 0
       },
       e: {
-        isRed: false,
-        isOrange: false,
-        isGreen: true,
         isNA: false,
         content: '0'
       }
@@ -71,9 +62,6 @@ describe('App.HBaseAverageLoadView', function() {
         averageLoad: null
       },
       e: {
-        isRed: false,
-        isOrange: false,
-        isGreen: true,
         isNA: true,
         content: Em.I18n.t('services.service.summary.notAvailable')
       }
@@ -86,18 +74,6 @@ describe('App.HBaseAverageLoadView', function() {
       it('content', function() {
         expect(hBaseAverageLoadView.get('content')).to.equal(test.e.content);
       });
-      it('data', function() {
-        expect(hBaseAverageLoadView.get('data')).to.equal(test.model.averageLoad);
-      });
-      it('isRed', function() {
-        expect(hBaseAverageLoadView.get('isRed')).to.equal(test.e.isRed);
-      });
-      it('isOrange', function() {
-        expect(hBaseAverageLoadView.get('isOrange')).to.equal(test.e.isOrange);
-      });
-      it('isGreen', function() {
-        expect(hBaseAverageLoadView.get('isGreen')).to.equal(test.e.isGreen);
-      });
       it('isNA', function() {
         expect(hBaseAverageLoadView.get('isNA')).to.equal(test.e.isNA);
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/87f8746f/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js
b/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js
index ce39742..8ad1531 100644
--- a/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js
@@ -34,9 +34,6 @@ describe('App.HBaseRegionsInTransitionView', function() {
         regionsInTransition: 1
       },
       e: {
-        isRed: false,
-        isOrange: true,
-        isGreen: false,
         isNA: false,
         content: '1'
       }
@@ -46,9 +43,6 @@ describe('App.HBaseRegionsInTransitionView', function() {
         regionsInTransition: 10
       },
       e: {
-        isRed: true,
-        isOrange: false,
-        isGreen: false,
         isNA: false,
         content: '10'
       }
@@ -58,9 +52,6 @@ describe('App.HBaseRegionsInTransitionView', function() {
         regionsInTransition: 0
       },
       e: {
-        isRed: false,
-        isOrange: false,
-        isGreen: true,
         isNA: false,
         content: '0'
       }
@@ -70,9 +61,6 @@ describe('App.HBaseRegionsInTransitionView', function() {
         regionsInTransition: null
       },
       e: {
-        isRed: false,
-        isOrange: false,
-        isGreen: true,
         isNA: true,
         content: 'null'
       }
@@ -85,18 +73,6 @@ describe('App.HBaseRegionsInTransitionView', function() {
       it('content', function() {
         expect(hBaseRegionsInTransitionView.get('content')).to.equal(test.e.content);
       });
-      it('data', function() {
-        expect(hBaseRegionsInTransitionView.get('data')).to.equal(test.model.regionsInTransition);
-      });
-      it('isRed', function() {
-        expect(hBaseRegionsInTransitionView.get('isRed')).to.equal(test.e.isRed);
-      });
-      it('isOrange', function() {
-        expect(hBaseRegionsInTransitionView.get('isOrange')).to.equal(test.e.isOrange);
-      });
-      it('isGreen', function() {
-        expect(hBaseRegionsInTransitionView.get('isGreen')).to.equal(test.e.isGreen);
-      });
       it('isNA', function() {
         expect(hBaseRegionsInTransitionView.get('isNA')).to.equal(test.e.isNA);
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/87f8746f/ambari-web/test/views/main/dashboard/widgets/links_widget_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/links_widget_test.js b/ambari-web/test/views/main/dashboard/widgets/links_widget_test.js
index 4796bde..2ba8e8d 100644
--- a/ambari-web/test/views/main/dashboard/widgets/links_widget_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/links_widget_test.js
@@ -29,13 +29,16 @@ describe('App.LinkDashboardWidgetView', function() {
       publicHostName: 'host1'
     })
   });
+
   var linkDashboardWidgetView = App.LinkDashboardWidgetView.create({
     model_type: null,
     model: model,
     port: 1234,
     modelField: 'field'
   });
+
   linkDashboardWidgetView.calc();
+
   describe('#webUrl', function() {
     it('calc', function() {
       expect(linkDashboardWidgetView.get('webUrl')).to.equal('http://host1:1234');

http://git-wip-us.apache.org/repos/asf/ambari/blob/87f8746f/ambari-web/test/views/main/dashboard/widgets/namenode_rpc_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/namenode_rpc_test.js b/ambari-web/test/views/main/dashboard/widgets/namenode_rpc_test.js
index 96cafc4..474d099 100644
--- a/ambari-web/test/views/main/dashboard/widgets/namenode_rpc_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/namenode_rpc_test.js
@@ -35,9 +35,7 @@ describe('App.NameNodeRpcView', function() {
         nameNodeRpc: 1
       },
       e: {
-        isRed: false,
         isOrange: true,
-        isGreen: false,
         isNA: false,
         content: '1.00 ms',
         data: '1.00'
@@ -48,9 +46,7 @@ describe('App.NameNodeRpcView', function() {
         nameNodeRpc: 10
       },
       e: {
-        isRed: true,
         isOrange: false,
-        isGreen: false,
         isNA: false,
         content: '10.00 ms',
         data: '10.00'
@@ -61,9 +57,7 @@ describe('App.NameNodeRpcView', function() {
         nameNodeRpc: 0
       },
       e: {
-        isRed: false,
         isOrange: false,
-        isGreen: true,
         isNA: false,
         content: '0 ms',
         data: 0
@@ -74,9 +68,7 @@ describe('App.NameNodeRpcView', function() {
         nameNodeRpc: null
       },
       e: {
-        isRed: false,
         isOrange: false,
-        isGreen: true,
         isNA: true,
         content: Em.I18n.t('services.service.summary.notAvailable'),
         data: null
@@ -93,15 +85,9 @@ describe('App.NameNodeRpcView', function() {
       it('data', function() {
         expect(jobTrackerRpcView.get('data')).to.equal(test.e.data);
       });
-      it('isRed', function() {
-        expect(jobTrackerRpcView.get('isRed')).to.equal(test.e.isRed);
-      });
       it('isOrange', function() {
         expect(jobTrackerRpcView.get('isOrange')).to.equal(test.e.isOrange);
       });
-      it('isGreen', function() {
-        expect(jobTrackerRpcView.get('isGreen')).to.equal(test.e.isGreen);
-      });
       it('isNA', function() {
         expect(jobTrackerRpcView.get('isNA')).to.equal(test.e.isNA);
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/87f8746f/ambari-web/test/views/main/dashboard/widgets/resource_manager_uptime_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/resource_manager_uptime_test.js
b/ambari-web/test/views/main/dashboard/widgets/resource_manager_uptime_test.js
index 1dd4df1..d4a9b34 100644
--- a/ambari-web/test/views/main/dashboard/widgets/resource_manager_uptime_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/resource_manager_uptime_test.js
@@ -31,8 +31,6 @@ describe('App.ResourceManagerUptimeView', function() {
         resourceManagerStartTime: (new Date()).getTime() - 192.1*24*3600*1000
       }),
       e: {
-        isRed: false,
-        isOrange: false,
         isGreen: true,
         isNA: false,
         content: '192.1 d',
@@ -44,8 +42,6 @@ describe('App.ResourceManagerUptimeView', function() {
         resourceManagerStartTime: 0
       }),
       e: {
-        isRed: false,
-        isOrange: false,
         isGreen: false,
         isNA: true,
         content: Em.I18n.t('services.service.summary.notAvailable'),
@@ -57,8 +53,6 @@ describe('App.ResourceManagerUptimeView', function() {
         resourceManagerStartTime: null
       }),
       e: {
-        isRed: false,
-        isOrange: false,
         isGreen: false,
         isNA: true,
         content: Em.I18n.t('services.service.summary.notAvailable'),
@@ -77,12 +71,6 @@ describe('App.ResourceManagerUptimeView', function() {
       it('data', function() {
         expect(resourceManagerUptimeView.get('data')).to.equal(test.e.data);
       });
-      it('isRed', function() {
-        expect(resourceManagerUptimeView.get('isRed')).to.equal(test.e.isRed);
-      });
-      it('isOrange', function() {
-        expect(resourceManagerUptimeView.get('isOrange')).to.equal(test.e.isOrange);
-      });
       it('isGreen', function() {
         expect(resourceManagerUptimeView.get('isGreen')).to.equal(test.e.isGreen);
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/87f8746f/ambari-web/test/views/main/dashboard/widgets/text_widget_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/text_widget_test.js b/ambari-web/test/views/main/dashboard/widgets/text_widget_test.js
index 5dbb599..730e209 100644
--- a/ambari-web/test/views/main/dashboard/widgets/text_widget_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/text_widget_test.js
@@ -31,36 +31,12 @@ describe('App.TextDashboardWidgetView', function() {
     {
       data: 100,
       e: {
-        isRed: false,
-        isOrange: false,
-        isGreen: true,
-        isNA: false
-      }
-    },
-    {
-      data: 1,
-      e: {
-        isRed: true,
-        isOrange: false,
-        isGreen: false,
-        isNA: false
-      }
-    },
-    {
-      data: 50,
-      e: {
-        isRed: false,
-        isOrange: true,
-        isGreen: false,
         isNA: false
       }
     },
     {
       data: null,
       e: {
-        isRed: true,
-        isOrange: false,
-        isGreen: false,
         isNA: true
       }
     }
@@ -70,15 +46,6 @@ describe('App.TextDashboardWidgetView', function() {
     describe('data - ' + test.data + ' | thresh1 - 40 | thresh2 - 70', function() {
       var textDashboardWidgetView = App.TextDashboardWidgetView.create({thresh1:40, thresh2:70});
       textDashboardWidgetView.set('data', test.data);
-      it('isRed', function() {
-        expect(textDashboardWidgetView.get('isRed')).to.equal(test.e.isRed);
-      });
-      it('isOrange', function() {
-        expect(textDashboardWidgetView.get('isOrange')).to.equal(test.e.isOrange);
-      });
-      it('isGreen', function() {
-        expect(textDashboardWidgetView.get('isGreen')).to.equal(test.e.isGreen);
-      });
       it('isNA', function() {
         expect(textDashboardWidgetView.get('isNA')).to.equal(test.e.isNA);
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/87f8746f/ambari-web/test/views/main/dashboard/widgets/uptime_text_widget_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/uptime_text_widget_test.js b/ambari-web/test/views/main/dashboard/widgets/uptime_text_widget_test.js
index 808e67b..fbe2694 100644
--- a/ambari-web/test/views/main/dashboard/widgets/uptime_text_widget_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/uptime_text_widget_test.js
@@ -21,8 +21,13 @@ require('views/main/dashboard/widget');
 require('views/main/dashboard/widgets/text_widget');
 require('views/main/dashboard/widgets/uptime_text_widget');
 
+var uptimeTextDashboardWidgetView;
 describe('App.UptimeTextDashboardWidgetView', function() {
 
+  beforeEach(function () {
+    uptimeTextDashboardWidgetView = App.UptimeTextDashboardWidgetView.create({thresh1:40,
thresh2:70});
+  });
+
   describe('#timeConverter', function() {
     var ts1 = 1358245370553, ts2 = 0;
     var timestamps = [
@@ -42,7 +47,6 @@ describe('App.UptimeTextDashboardWidgetView', function() {
       }
     ];
     timestamps.forEach(function(timestamp) {
-      var uptimeTextDashboardWidgetView = App.UptimeTextDashboardWidgetView.create({thresh1:40,
thresh2:70});
       it('timestamp ' + timestamp.t, function() {
         var result = uptimeTextDashboardWidgetView.timeConverter(timestamp.t);
         expect(result.length).to.equal(timestamp.e.l);
@@ -79,7 +83,6 @@ describe('App.UptimeTextDashboardWidgetView', function() {
       }
     ];
     timestamps.forEach(function(timestamp) {
-      var uptimeTextDashboardWidgetView = App.UptimeTextDashboardWidgetView.create({thresh1:40,
thresh2:70});
       it('timestamp {0}. timeUnit should be "{1}"'.format(timestamp.t, timestamp.e.timeUnit),
function() {
         uptimeTextDashboardWidgetView.uptimeProcessing(new Date().getTime() - timestamp.diff);
         expect(uptimeTextDashboardWidgetView.get('timeUnit')).to.equal(timestamp.e.timeUnit);


Mime
View raw message