You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/06/11 02:21:34 UTC

svn commit: r1491658 [3/3] - in /incubator/ambari/trunk/ambari-web: app/ app/controllers/global/ app/mappers/ app/models/service/ app/styles/ app/templates/main/ app/templates/main/charts/ app/templates/main/dashboard/ app/views/common/chart/ app/views...

Added: incubator/ambari/trunk/ambari-web/app/views/main/dashboard/widgets/namenode_rpc.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/views/main/dashboard/widgets/namenode_rpc.js?rev=1491658&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/views/main/dashboard/widgets/namenode_rpc.js (added)
+++ incubator/ambari/trunk/ambari-web/app/views/main/dashboard/widgets/namenode_rpc.js Tue Jun 11 00:21:32 2013
@@ -0,0 +1,204 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.NameNodeRpcView = App.DashboardWidgetView.extend({
+
+  title: Em.I18n.t('dashboard.widgets.NameNodeRpc'),
+  id: '5',
+
+  isPieChart: false,
+  isText: true,
+  isProgressBar: false,
+  model_type: 'hdfs',
+  hiddenInfo: function () {
+    var result = [];
+    result.pushObject(this.get('content') + ' average RPC');
+    result.pushObject('queue wait time');
+    return result;
+  }.property('model.nameNodeRpc'),
+
+  classNameBindings: ['isRed', 'isOrange', 'isGreen', 'isNA'],
+  isGreen: function () {
+    var thresh1 = this.get('thresh1');
+    var thresh2 = this.get('thresh2');
+    return this.get('data') <= thresh1? true: false;
+  }.property('data','thresh1','thresh2'),
+  isOrange: function () {
+    var thresh1 = this.get('thresh1');
+    var thresh2 = this.get('thresh2');
+    return (this.get('data') <= thresh2 && this.get('data') > thresh1 )? true: false;
+  }.property('data','thresh1','thresh2'),
+  isRed: function () {
+    var thresh1 = this.get('thresh1');
+    var thresh2 = this.get('thresh2');
+    return this.get('data') > thresh2? true: false;
+  }.property('data','thresh1','thresh2'),
+  isNA: function () {
+    return this.get('data') === null;
+  }.property('data'),
+
+  thresh1: 0.5,
+  thresh2: 2,
+  maxValue: 'infinity',
+
+  data: function () {
+    if (this.get('model.nameNodeRpc')) {
+      return (this.get('model.nameNodeRpc')).toFixed(2);
+    } else {
+      if (this.get('model.nameNodeRpc') == 0) {
+        return 0;
+      } else {
+        return null;
+      }
+    }
+  }.property('model.nameNodeRpc'),
+
+  content: function () {
+    if (this.get('data') || this.get('data') == 0) {
+      return this.get('data') + " ms";
+    } else {
+      return this.t('services.service.summary.notAvailable');
+    }
+  }.property('model.nameNodeRpc'),
+
+  editWidget: function (event) {
+    var parent = this;
+    var configObj = Ember.Object.create({
+      thresh1: parent.get('thresh1') + '',
+      thresh2: parent.get('thresh2') + '',
+      hintInfo: 'Edit the thresholds to change the color of current widget. ' +
+        ' The unit is milli-second. '+
+        ' So enter two numbers larger than 0. ',
+      isThresh1Error: false,
+      isThresh2Error: false,
+      errorMessage1: "",
+      errorMessage2: "",
+      maxValue: 'infinity',
+      observeNewThresholdValue: function () {
+        var thresh1 = this.get('thresh1');
+        var thresh2 = this.get('thresh2');
+        if (thresh1.trim() != "") {
+          if (isNaN(thresh1) || thresh1 < 0) {
+            this.set('isThresh1Error', true);
+            this.set('errorMessage1', 'Invalid! Enter a number larger than 0');
+          } 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 < 0) {
+            this.set('isThresh2Error', true);
+            this.set('errorMessage2', 'Invalid! Enter a number larger than 0');
+          } else {
+            this.set('isThresh2Error', false);
+            this.set('errorMessage2', '');
+          }
+        } else {
+          this.set('isThresh2Error', true);
+          this.set('errorMessage2', 'This is required');
+        }
+      }.observes('thresh1', 'thresh2')
+
+    });
+
+    var browserVerion = this.getInternetExplorerVersion();
+    App.ModalPopup.show({
+      header: 'Customize Widget',
+      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.testMode) {
+            //save to persist
+            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();
+        }
+      },
+      secondary : Em.I18n.t('common.cancel'),
+      onSecondary: function () {
+        this.hide();
+      },
+
+      didInsertElement: function () {
+        var colors = ['#95A800', '#FF8E00', '#B80000']; //color green, orange ,red
+        var handlers = [33, 66]; //fixed value
+
+        if (browserVerion == -1 || browserVerion > 9) {
+          configObj.set('isIE9', false);
+          configObj.set('isGreenOrangeRed', true);
+          $("#slider-range").slider({
+            range:true,
+            disabled:true, //handlers cannot move
+            min: 0,
+            max: 100,
+            values: handlers,
+            create: function (event, ui) {
+              updateColors(handlers);
+            }
+          });
+
+          function updateColors (handlers) {
+            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] + "%,";
+            }
+            // end with the last color
+            colorstops += colors[colors.length - 1];
+            var css1 = '-webkit-linear-gradient(left,' + colorstops + ')'; // chrome & safari
+            $('#slider-range').css('background-image', css1);
+            var css2 = '-ms-linear-gradient(left,' + colorstops + ')'; // IE 10+
+            $('#slider-range').css('background-image', css2);
+            //$('#slider-range').css('filter', 'progid:DXImageTransform.Microsoft.gradient( startColorStr= ' + colors[0] + ', endColorStr= ' + colors[2] +',  GradientType=1 )' ); // IE 10-
+            var css3 = '-moz-linear-gradient(left,' + colorstops + ')'; // Firefox
+            $('#slider-range').css('background-image', css3);
+
+            $('#slider-range .ui-widget-header').css({'background-color': '#FF8E00', 'background-image': 'none'}); // change the  original ranger color
+          }
+        } else {
+          configObj.set('isIE9', true);
+          configObj.set('isGreenOrangeRed', true);
+        }
+      }
+    });
+  }
+
+})

Added: incubator/ambari/trunk/ambari-web/app/views/main/dashboard/widgets/namenode_uptime.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/views/main/dashboard/widgets/namenode_uptime.js?rev=1491658&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/views/main/dashboard/widgets/namenode_uptime.js (added)
+++ incubator/ambari/trunk/ambari-web/app/views/main/dashboard/widgets/namenode_uptime.js Tue Jun 11 00:21:32 2013
@@ -0,0 +1,134 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+var date = require('utils/date');
+
+App.NameNodeUptimeView = App.DashboardWidgetView.extend({
+
+  title: Em.I18n.t('dashboard.widgets.NameNodeUptime'),
+  id: '15',
+
+  isPieChart: false,
+  isText: true,
+  isProgressBar: false,
+  model_type: 'hdfs',
+  hiddenInfo: [],
+
+  classNameBindings: ['isRed', 'isOrange', 'isGreen', 'isNA'],
+  isGreen: function () {
+    return this.get('data') != null;
+  }.property('data'),
+  isOrange: function () {
+    return false;
+  }.property('data'),
+  isRed: function () {
+    return false;
+  }.property('data'),
+  isNA: function () {
+    return this.get('data') == null;
+  }.property('data'),
+
+  thresh1: 5,
+  thresh2: 10,
+  maxValue: 'infinity',
+
+  data: function () {
+    var uptime = this.get('model.nameNodeStartTime');
+    if (uptime && uptime > 0) {
+      var uptimeString = this.timeConverter(uptime);
+      var diff = (new Date()).getTime() - uptime;
+      if (diff < 0) {
+        diff = 0;
+      }
+      var formatted = date.timingFormat(diff); //17.67 days
+      var timeUnit = null;
+      switch (formatted.split(" ")[1]) {
+        case 'secs':
+          timeUnit = 's';
+          break;
+        case 'hours':
+          timeUnit = 'hr';
+          break;
+        case 'days':
+          timeUnit = 'd';
+          break;
+        case 'mins':
+          timeUnit = 'min';
+          break;
+        default:
+          timeUnit = formatted.split(" ")[1];
+      }
+      this.set('timeUnit', timeUnit);
+      this.set('hiddenInfo', []);
+      this.get('hiddenInfo').pushObject(formatted);
+      this.get('hiddenInfo').pushObject(uptimeString[0]);
+      this.get('hiddenInfo').pushObject(uptimeString[1]);
+      return parseFloat(formatted.split(" ")[0]);
+    }
+    this.set('hiddenInfo', []);
+    this.set('hiddenInfo', ['NameNode','Not running']);
+    return null;
+  }.property('model.nameNodeStartTime'),
+
+  timeUnit: null,
+
+  content: function () {
+    var data = this.get('data');
+    if (data) {
+      return data.toFixed(1) + ' '+ this.get('timeUnit');
+    } else {
+      return this.t('services.service.summary.notAvailable');
+    }
+  }.property('model.nameNodeStartTime'),
+
+
+  template: Ember.Handlebars.compile([
+
+    '<div class="has-hidden-info">',
+    '<li class="thumbnail row" >',
+    '<a class="corner-icon" href="#" {{action deleteWidget target="view"}}>','<i class="icon-remove-sign icon-large"></i>','</a>',
+    '<div class="caption span10">', '{{view.title}}','</div>',
+    '<div class="hidden-info-three-line">', '<table align="center">{{#each line in view.hiddenInfo}}', '<tr><td>{{line}}</td></tr>','{{/each}}</table>','</div>',
+    '<div class="widget-content">{{view.content}}</div>',
+    '</li>',
+    '</div>'
+  ].join('\n')),
+
+  timeConverter: function (timestamp){
+    var origin = new Date(timestamp);
+    origin = origin.toString();
+    var result = [];
+    var start = origin.indexOf('GMT');
+    if (start == -1) { // ie
+      var arr = origin.split(" ");
+      result.pushObject(arr[0] + " " + arr[1] + " " + arr[2] + " " + arr[3]);
+      var second = '';
+      for (var i = 4; i < arr.length; i++) {
+        second = second + " " + arr[i];
+      }
+      result.pushObject(second);
+    } else { // other browsers
+      var end = origin.indexOf(" ", start);
+      result.pushObject(origin.slice(0, start-10));
+      result.pushObject(origin.slice(start-9));
+    }
+    return result;
+  }
+
+})

Added: incubator/ambari/trunk/ambari-web/app/views/main/dashboard/widgets/tasktracker_live.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/views/main/dashboard/widgets/tasktracker_live.js?rev=1491658&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/views/main/dashboard/widgets/tasktracker_live.js (added)
+++ incubator/ambari/trunk/ambari-web/app/views/main/dashboard/widgets/tasktracker_live.js Tue Jun 11 00:21:32 2013
@@ -0,0 +1,205 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.TaskTrackerUpView = App.DashboardWidgetView.extend({
+
+  title: Em.I18n.t('dashboard.widgets.TaskTrackerUp'),
+  id: '8',
+
+  isPieChart: false,
+  isText: true,
+  isProgressBar: false,
+  model_type: 'mapreduce',
+
+  hiddenInfo: function () {
+    var svc = this.get('model');
+    var liveCount = svc.get('aliveTrackers').get('length');
+    var totalCount = svc.get('taskTrackers').get('length');
+    var template = this.t('dashboard.services.mapreduce.trackersSummary');
+    var result = [];
+    result.pushObject(template.format(liveCount, totalCount));
+    return result;
+  }.property('model.aliveTrackers.length', 'model.taskTrackers.length'),
+
+  classNameBindings: ['isRed', 'isOrange', 'isGreen'],
+  isRed: function () {
+    var thresh1 = this.get('thresh1');
+    var thresh2 = this.get('thresh2');
+    return this.get('data') <= thresh1? true: false;
+  }.property('data','thresh1','thresh2'),
+  isOrange: function () {
+    var thresh1 = this.get('thresh1');
+    var thresh2 = this.get('thresh2');
+    return (this.get('data') <= thresh2 && this.get('data') > thresh1 )? true: false;
+  }.property('data','thresh1','thresh2'),
+  isGreen: function () {
+    var thresh1 = this.get('thresh1');
+    var thresh2 = this.get('thresh2');
+    return this.get('data') > thresh2? true: false;
+  }.property('data','thresh1','thresh2'),
+
+  thresh1: 40,
+  thresh2: 70,
+  maxValue: 100,
+
+  data: function () {
+    return ((this.get('model.aliveTrackers.length')/ this.get('model.taskTrackers.length')).toFixed(2)) * 100;
+  }.property('model.taskTrackers.length', 'model.aliveTrackers.length'),
+
+  content: function () {
+    return this.get('model.aliveTrackers.length') + "/" + this.get('model.taskTrackers.length');
+  }.property('model.taskTrackers.length', 'model.aliveTrackers.length'),
+
+  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: 'Edit the percentage of thresholds to change the color of current widget. ' +
+        ' Assume all task trackers UP is 100, and all DOWN is 0. '+
+        ' So enter two numbers between 0 to ' + 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: 'Customize Widget',
+      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.testMode) {
+            //save to persit
+            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();
+        }
+      },
+      secondary : Em.I18n.t('common.cancel'),
+      onSecondary: function () {
+        this.hide();
+      },
+
+      didInsertElement: function () {
+        var handlers = [configObj.get('thresh1'), configObj.get('thresh2')];
+        var colors = ['#B80000', '#FF8E00', '#95A800']; //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) {
+              updateColors(handlers);
+            },
+            slide: function (event, ui) {
+              updateColors(ui.values);
+              configObj.set('thresh1', ui.values[0] + '');
+              configObj.set('thresh2', ui.values[1] + '');
+            },
+            change: function (event, ui) {
+              updateColors(ui.values);
+            }
+          });
+
+          function updateColors(handlers) {
+            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] + "%,";
+            }
+            // end with the last color
+            colorstops += colors[colors.length - 1];
+            var css1 = '-webkit-linear-gradient(left,' + colorstops + ')'; // chrome & safari
+            $('#slider-range').css('background-image', css1);
+            var css2 = '-ms-linear-gradient(left,' + colorstops + ')'; // IE 10+
+            $('#slider-range').css('background-image', css2);
+            //$('#slider-range').css('filter', 'progid:DXImageTransform.Microsoft.gradient( startColorStr= ' + colors[0] + ', endColorStr= ' + colors[2] +',  GradientType=1 )' ); // IE 10-
+            var css3 = '-moz-linear-gradient(left,' + colorstops + ')'; // Firefox
+            $('#slider-range').css('background-image', css3);
+
+            $('#slider-range .ui-widget-header').css({'background-color': '#FF8E00', 'background-image': 'none'}); // change the  original ranger color
+          }
+        } else {
+          configObj.set('isIE9', true);
+          configObj.set('isGreenOrangeRed', false);
+        }
+      }
+    });
+  }
+
+})

Modified: incubator/ambari/trunk/ambari-web/vendor/scripts/jquery.ui.sortable.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/vendor/scripts/jquery.ui.sortable.js?rev=1491658&r1=1491657&r2=1491658&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/vendor/scripts/jquery.ui.sortable.js (original)
+++ incubator/ambari/trunk/ambari-web/vendor/scripts/jquery.ui.sortable.js Tue Jun 11 00:21:32 2013
@@ -979,9 +979,10 @@ $.widget("ui.sortable", $.ui.mouse, {
 		this.counter = this.counter ? ++this.counter : 1;
 		var counter = this.counter;
 
-		this._delay(function() {
-			if(counter == this.counter) this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
-		});
+    // Cause error when sort widgets on dashboard. Error: Object has no _delay method
+    //this._delay(function() {
+    //if(counter == this.counter) this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
+    //});
 
 	},