You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2016/12/15 15:56:19 UTC
ambari git commit: AMBARI-19213. DataNodes Live widget can't be
edited (onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 13dd1cf47 -> 65fe71a1b
AMBARI-19213. DataNodes Live widget can't be edited (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/65fe71a1
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/65fe71a1
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/65fe71a1
Branch: refs/heads/trunk
Commit: 65fe71a1bc41da9e935dff75e92988d4a1c8bff9
Parents: 13dd1cf
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Thu Dec 15 17:37:20 2016 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Thu Dec 15 17:56:15 2016 +0200
----------------------------------------------------------------------
.../mixins/main/dashboard/widgets/editable.js | 28 ++---
.../dashboard/widgets/editable_with_limit.js | 115 +++++++++----------
.../widgets/single_numeric_threshold.js | 108 ++++++++---------
ambari-web/app/styles/modal_popups.less | 12 --
.../edit_widget_popup_single_threshold.hbs | 9 --
ambari-web/app/views/main/dashboard/widget.js | 14 +--
.../views/main/dashboard/widgets/pxf_live.js | 2 +-
.../admin/highAvailability_controller_test.js | 2 +-
8 files changed, 122 insertions(+), 168 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/65fe71a1/ambari-web/app/mixins/main/dashboard/widgets/editable.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/dashboard/widgets/editable.js b/ambari-web/app/mixins/main/dashboard/widgets/editable.js
index 3206229..fcb6bfb 100644
--- a/ambari-web/app/mixins/main/dashboard/widgets/editable.js
+++ b/ambari-web/app/mixins/main/dashboard/widgets/editable.js
@@ -69,7 +69,6 @@ App.EditableWidgetMixin = Em.Mixin.create({
});
- var browserVersion = this.getInternetExplorerVersion();
App.ModalPopup.show({
header: Em.I18n.t('dashboard.widgets.popupHeader'),
classNames: [ 'modal-edit-widget'],
@@ -97,23 +96,16 @@ App.EditableWidgetMixin = Em.Mixin.create({
var colors = [App.healthStatusGreen, App.healthStatusOrange, App.healthStatusRed]; //color green, orange ,red
var handlers = [33, 66]; //fixed value
- if (browserVersion === -1 || browserVersion > 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) {
- self.updateColors(handlers, colors);
- }
- });
- } else {
- configObj.set('isIE9', true);
- configObj.set('isGreenOrangeRed', true);
- }
+ $("#slider-range").slider({
+ range: true,
+ disabled: true, //handlers cannot move
+ min: 0,
+ max: 100,
+ values: handlers,
+ create: function (event, ui) {
+ self.updateColors(handlers, colors);
+ }
+ });
}
});
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/65fe71a1/ambari-web/app/mixins/main/dashboard/widgets/editable_with_limit.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/dashboard/widgets/editable_with_limit.js b/ambari-web/app/mixins/main/dashboard/widgets/editable_with_limit.js
index df1b645..ddf2a26 100644
--- a/ambari-web/app/mixins/main/dashboard/widgets/editable_with_limit.js
+++ b/ambari-web/app/mixins/main/dashboard/widgets/editable_with_limit.js
@@ -29,56 +29,55 @@ App.EditableWithLimitWidgetMixin = Em.Mixin.create({
var parent = this;
var maxTmp = parseFloat(parent.get('maxValue'));
var configObj = Ember.Object.create({
- thresh1: parent.get('thresh1') + '',
- thresh2: parent.get('thresh2') + '',
+ thresholdMin: parent.get('thresholdMin') + '',
+ thresholdMax: parent.get('thresholdMax') + '',
hintInfo: parent.get('hintInfo'),
- isThresh1Error: false,
- isThresh2Error: false,
- errorMessage1: "",
- errorMessage2: "",
+ thresholdMinError: false,
+ thresholdMaxError: false,
+ thresholdMinErrorMessage: '',
+ thresholdMaxErrorMessage: '',
maxValue: maxTmp,
observeNewThresholdValue: function () {
- var thresh1 = this.get('thresh1');
- var thresh2 = this.get('thresh2');
- if (thresh1.trim() !== "") {
- if (isNaN(thresh1) || thresh1 > maxTmp || thresh1 < 0){
- this.set('isThresh1Error', true);
- this.set('errorMessage1', 'Invalid! Enter a number between 0 - ' + maxTmp);
- } 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 !');
+ var thresholdMin = this.get('thresholdMin');
+ var thresholdMax = this.get('thresholdMax');
+ if (thresholdMin.trim() !== '') {
+ if (isNaN(thresholdMin) || thresholdMin > maxTmp || thresholdMin < 0){
+ this.set('thresholdMinError', true);
+ this.set('thresholdMinErrorMessage', 'Invalid! Enter a number between 0 - ' + maxTmp);
+ } else if ( this.get('thresholdMaxError') === false && parseFloat(thresholdMax)<= parseFloat(thresholdMin)) {
+ this.set('thresholdMinError', true);
+ this.set('thresholdMinErrorMessage', 'Threshold 1 should be smaller than threshold 2 !');
} else {
- this.set('isThresh1Error', false);
- this.set('errorMessage1', '');
+ this.set('thresholdMinError', false);
+ this.set('thresholdMinErrorMessage', '');
}
} else {
- this.set('isThresh1Error', true);
- this.set('errorMessage1', 'This is required');
+ this.set('thresholdMinError', true);
+ this.set('thresholdMinErrorMessage', 'This is required');
}
- if (thresh2.trim() !== "") {
- if (isNaN(thresh2) || thresh2 > maxTmp || thresh2 < 0) {
- this.set('isThresh2Error', true);
- this.set('errorMessage2', 'Invalid! Enter a number between 0 - ' + maxTmp);
+ if (thresholdMax.trim() !== '') {
+ if (isNaN(thresholdMax) || thresholdMax > maxTmp || thresholdMax < 0) {
+ this.set('thresholdMaxError', true);
+ this.set('thresholdMaxErrorMessage', 'Invalid! Enter a number between 0 - ' + maxTmp);
} else {
- this.set('isThresh2Error', false);
- this.set('errorMessage2', '');
+ this.set('thresholdMaxError', false);
+ this.set('thresholdMaxErrorMessage', '');
}
} else {
- this.set('isThresh2Error', true);
- this.set('errorMessage2', 'This is required');
+ this.set('thresholdMaxError', true);
+ this.set('thresholdMaxErrorMessage', '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));
+ if (!this.get('thresholdMinError') && !this.get('thresholdMaxError')) {
+ $("#slider-range").slider('values', 0 , parseFloat(thresholdMin));
+ $("#slider-range").slider('values', 1 , parseFloat(thresholdMax));
}
- }.observes('thresh1', 'thresh2')
+ }.observes('thresholdMin', 'thresholdMax')
});
- var browserVerion = this.getInternetExplorerVersion();
App.ModalPopup.show({
header: Em.I18n.t('dashboard.widgets.popupHeader'),
classNames: ['modal-edit-widget'],
@@ -90,14 +89,14 @@ App.EditableWithLimitWidgetMixin = Em.Mixin.create({
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 (!configObj.thresholdMinError && !configObj.thresholdMaxError) {
+ parent.set('thresholdMin', parseFloat(configObj.get('thresholdMin')) );
+ parent.set('thresholdMax', parseFloat(configObj.get('thresholdMax')) );
if (!App.get('testMode')) {
var bigParent = parent.get('parentView');
bigParent.getUserPref(bigParent.get('persistKey'));
var oldValue = bigParent.get('currentPrefObject');
- oldValue.threshold[parseInt(parent.id, 10)] = [configObj.get('thresh1'), configObj.get('thresh2')];
+ oldValue.threshold[parseInt(parent.id, 10)] = [configObj.get('thresholdMin'), configObj.get('thresholdMax')];
bigParent.postUserPref(bigParent.get('persistKey'),oldValue);
}
this.hide();
@@ -106,33 +105,27 @@ App.EditableWithLimitWidgetMixin = Em.Mixin.create({
didInsertElement: function () {
this._super();
- var handlers = [configObj.get('thresh1'), configObj.get('thresh2')];
+ var handlers = [configObj.get('thresholdMin'), configObj.get('thresholdMax')];
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: maxTmp,
- values: handlers,
- create: function () {
- 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);
- }
+ $("#slider-range").slider({
+ range: true,
+ min: 0,
+ max: maxTmp,
+ values: handlers,
+ create: function () {
+ parent.updateColors(handlers, colors);
+ },
+ slide: function (event, ui) {
+ parent.updateColors(ui.values, colors);
+ configObj.set('thresholdMin', ui.values[0] + '');
+ configObj.set('thresholdMax', ui.values[1] + '');
+ },
+ change: function (event, ui) {
+ parent.updateColors(ui.values, colors);
+ }
+ });
+
}
});
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/65fe71a1/ambari-web/app/mixins/main/dashboard/widgets/single_numeric_threshold.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/dashboard/widgets/single_numeric_threshold.js b/ambari-web/app/mixins/main/dashboard/widgets/single_numeric_threshold.js
index 12c7d1a..06bcffe 100644
--- a/ambari-web/app/mixins/main/dashboard/widgets/single_numeric_threshold.js
+++ b/ambari-web/app/mixins/main/dashboard/widgets/single_numeric_threshold.js
@@ -28,18 +28,18 @@ App.SingleNumericThresholdMixin = Em.Mixin.create({
* @class
*/
widgetConfig: Ember.Object.extend({
- thresh1: '',
+ thresholdMin: '',
hintInfo: '',
isThresh1Error: false,
errorMessage1: "",
maxValue: 0,
observeThresh1Value: function () {
- var thresh1 = this.get('thresh1');
+ var thresholdMin = this.get('thresholdMin');
var maxValue = this.get('maxValue');
- if (thresh1.trim() !== "") {
- if (isNaN(thresh1) || thresh1 > maxValue || thresh1 < 0) {
+ if (thresholdMin.trim() !== "") {
+ if (isNaN(thresholdMin) || thresholdMin > maxValue || thresholdMin < 0) {
this.set('isThresh1Error', true);
this.set('errorMessage1', Em.I18n.t('dashboard.widgets.error.invalid').format(maxValue));
} else {
@@ -51,14 +51,14 @@ App.SingleNumericThresholdMixin = Em.Mixin.create({
this.set('errorMessage1', Em.I18n.t('admin.users.editError.requiredField'));
}
this.updateSlider();
- }.observes('thresh1', 'maxValue'),
+ }.observes('thresholdMin', 'maxValue'),
updateSlider: function () {
- var thresh1 = this.get('thresh1');
+ var thresholdMin = this.get('thresholdMin');
// update the slider handles and color
if (this.get('isThresh1Error') === false) {
$("#slider-range")
- .slider('values', 0, parseFloat(thresh1))
+ .slider('values', 0, parseFloat(thresholdMin))
}
}
}),
@@ -71,12 +71,11 @@ App.SingleNumericThresholdMixin = Em.Mixin.create({
var parent = this;
var maxTmp = parseFloat(this.get('maxValue'));
var configObj = this.get('widgetConfig').create({
- thresh1: this.get('thresh1') + '',
+ thresholdMin: this.get('thresholdMin') + '',
hintInfo: this.get('hintInfo') + '',
maxValue: parseFloat(this.get('maxValue'))
});
- var browserVersion = this.getInternetExplorerVersion();
App.ModalPopup.show({
header: Em.I18n.t('dashboard.widgets.popupHeader'),
classNames: ['modal-edit-widget'],
@@ -89,66 +88,59 @@ App.SingleNumericThresholdMixin = Em.Mixin.create({
onPrimary: function () {
configObj.observeThresh1Value();
if (!configObj.isThresh1Error) {
- parent.set('thresh1', parseFloat(configObj.get('thresh1')));
+ var bigParent = parent.get('parentView');
+ parent.set('thresholdMin', parseFloat(configObj.get('thresholdMin')));
if (!App.get('testMode')) {
// save to persist
- var bigParent = parent.get('parentView');
- bigParent.getUserPref(bigParent.get('persistKey')).complete(function () {
- var oldValue = bigParent.get('currentPrefObject');
- oldValue.threshold[parseInt(parent.id, 10)] = [configObj.get('thresh1')];
- bigParent.postUserPref(parent.get('persistKey'), oldValue);
- });
+ var userPreferences = bigParent.get('userPreferences');
+ userPreferences.threshold[parseInt(parent.get('id'), 10)] = [configObj.get('thresholdMin')];
+ bigParent.saveWidgetsSettings(userPreferences);
+ bigParent.renderWidgets();
}
this.hide();
}
},
didInsertElement: function () {
this._super();
- var handlers = [configObj.get('thresh1')];
- var colors = [App.healthStatusGreen, App.healthStatusRed]; //color green,red
+ var handlers = [configObj.get('thresholdMin')];
+ var _this = this;
- if (browserVersion === -1 || browserVersion > 9) {
- configObj.set('isIE9', false);
- configObj.set('isGreenRed', true);
- $("#slider-range").slider({
- range: false,
- min: 0,
- max: maxTmp,
- values: handlers,
- create: function () {
- updateColors(handlers);
- },
- slide: function (event, ui) {
- updateColors(ui.values);
- configObj.set('thresh1', ui.values[0] + '');
- },
- 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] * 100 / maxTmp + "%,";
- colorstops += colors[i + 1] + " " + handlers[i] * 100 / maxTmp + "%,";
- }
- colorstops += colors[colors.length - 1];
- var sliderElement = $('#slider-range');
- var css1 = '-webkit-linear-gradient(left,' + colorstops + ')'; // chrome & safari
- sliderElement.css('background-image', css1);
- var css2 = '-ms-linear-gradient(left,' + colorstops + ')'; // IE 10+
- sliderElement.css('background-image', css2);
- var css3 = '-moz-linear-gradient(left,' + colorstops + ')'; // Firefox
- sliderElement.css('background-image', css3);
-
- sliderElement.find('.ui-widget-header').css({'background-color': '#FF8E00', 'background-image': 'none'}); // change the original ranger color
+ $("#slider-range").slider({
+ range: false,
+ min: 0,
+ max: maxTmp,
+ values: handlers,
+ create: function () {
+ _this.updateColors(handlers);
+ },
+ slide: function (event, ui) {
+ _this.updateColors(ui.values);
+ configObj.set('thresholdMin', ui.values[0] + '');
+ },
+ change: function (event, ui) {
+ _this.updateColors(ui.values);
}
- } else {
- configObj.set('isIE9', true);
- configObj.set('isGreenRed', true);
- }
+ });
+ },
+
+ updateColors: function (handlers) {
+ var colors = [App.healthStatusGreen, App.healthStatusRed]; //color green,red
+ var colorstops = colors[0] + ", "; // start with the first color
+ for (var i = 0; i < handlers.length; i++) {
+ colorstops += colors[i] + " " + handlers[i] * 100 / maxTmp + "%,";
+ colorstops += colors[i + 1] + " " + handlers[i] * 100 / maxTmp + "%,";
}
+ colorstops += colors[colors.length - 1];
+ var sliderElement = $('#slider-range');
+ var css1 = '-webkit-linear-gradient(left,' + colorstops + ')'; // chrome & safari
+ sliderElement.css('background-image', css1);
+ var css2 = '-ms-linear-gradient(left,' + colorstops + ')'; // IE 10+
+ sliderElement.css('background-image', css2);
+ var css3 = '-moz-linear-gradient(left,' + colorstops + ')'; // Firefox
+ sliderElement.css('background-image', css3);
+
+ sliderElement.find('.ui-widget-header').css({'background-color': '#FF8E00', 'background-image': 'none'}); // change the original ranger color
+ }
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/65fe71a1/ambari-web/app/styles/modal_popups.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/modal_popups.less b/ambari-web/app/styles/modal_popups.less
index 0c87e63..c10ef30 100644
--- a/ambari-web/app/styles/modal_popups.less
+++ b/ambari-web/app/styles/modal_popups.less
@@ -156,18 +156,6 @@
.value-on-slider {
margin-top: 30px;
}
- .slider-error {
- color: #b94a48;
- .help-block {
- color: #b94a48;
- }
- input{
- border-color: #b94a48;
- -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
- -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
- box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
- }
- }
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/65fe71a1/ambari-web/app/templates/main/dashboard/edit_widget_popup_single_threshold.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/dashboard/edit_widget_popup_single_threshold.hbs b/ambari-web/app/templates/main/dashboard/edit_widget_popup_single_threshold.hbs
index 982dc9b..86ffb47 100644
--- a/ambari-web/app/templates/main/dashboard/edit_widget_popup_single_threshold.hbs
+++ b/ambari-web/app/templates/main/dashboard/edit_widget_popup_single_threshold.hbs
@@ -25,16 +25,7 @@
<div class="row" id= "min-height-limit">
<div class="col-md-12">
- {{#if view.configPropertyObj.isIE9}}
- {{#if view.configPropertyObj.isGreenRed}}
- <div class="progress">
- <div {{bindAttr class=":bar view.configPropertyObj.isGreenRed:bar-success:bar-danger"}} style="width: 33%;"></div>
- <div {{bindAttr class=":bar view.configPropertyObj.isGreenRed:bar-danger:bar-success"}} style="width: 34%;"></div>
- </div>
- {{/if}}
- {{else}}
<div id="slider-range"></div>
- {{/if}}
</div>
</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/65fe71a1/ambari-web/app/views/main/dashboard/widget.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widget.js b/ambari-web/app/views/main/dashboard/widget.js
index 563e31d..cacac1a 100644
--- a/ambari-web/app/views/main/dashboard/widget.js
+++ b/ambari-web/app/views/main/dashboard/widget.js
@@ -174,9 +174,8 @@ App.DashboardWidgetView = Em.View.extend({
var extendedModel = App.Service.extendedModel[source];
if (extendedModel) {
return App[extendedModel].find(source);
- } else {
- return App.Service.find(source);
}
+ return App.Service.find(source);
},
willDestroyElement : function() {
@@ -201,9 +200,8 @@ App.DashboardWidgetView = Em.View.extend({
/**
* edit widget
- * @param {object} event
*/
- editWidget: function (event) {
+ editWidget: function () {
var configObj = this.get('widgetConfig').create({
thresholdMin: this.get('thresholdMin') + '',
thresholdMax: this.get('thresholdMax') + '',
@@ -251,7 +249,7 @@ App.DashboardWidgetView = Em.View.extend({
didInsertElement: function () {
this._super();
- var self = this;
+ var _this = this;
var handlers = [configObj.get('thresholdMin'), configObj.get('thresholdMax')];
$("#slider-range").slider({
@@ -260,15 +258,15 @@ App.DashboardWidgetView = Em.View.extend({
max: maxValue,
values: handlers,
create: function () {
- self.updateColors(handlers);
+ _this.updateColors(handlers);
},
slide: function (event, ui) {
- self.updateColors(ui.values);
+ _this.updateColors(ui.values);
configObj.set('thresholdMin', ui.values[0] + '');
configObj.set('thresholdMax', ui.values[1] + '');
},
change: function (event, ui) {
- self.updateColors(ui.values);
+ _this.updateColors(ui.values);
}
});
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/65fe71a1/ambari-web/app/views/main/dashboard/widgets/pxf_live.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets/pxf_live.js b/ambari-web/app/views/main/dashboard/widgets/pxf_live.js
index a002fe3..a86f4d1 100644
--- a/ambari-web/app/views/main/dashboard/widgets/pxf_live.js
+++ b/ambari-web/app/views/main/dashboard/widgets/pxf_live.js
@@ -56,7 +56,7 @@ App.PxfUpView = App.TextDashboardSingleThresholdWidgetView.extend(App.SingleNume
if (this.get('someMetricsNA')) {
return null;
}
- return (this.get('pxfsTotal') - this.get('pxfsStarted') );
+ return this.get('pxfsTotal') - this.get('pxfsStarted');
}.property('model.pxfsTotal', 'pxfsStarted', 'someMetricsNA'),
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/65fe71a1/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js b/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js
index f5a144b..08cddaf 100644
--- a/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js
@@ -221,7 +221,7 @@ describe('App.MainAdminHighAvailabilityController', function () {
expect(controller.showErrorPopup.calledOnce).to.be.true;
});
- it('should show error popup if there is no NNs', function () {
+ it('should show error popup if there is no NNs (2)', function () {
this.mock.returns([
Em.Object.create({
componentName: 'NAMENODE',