Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0427217BEF for ; Wed, 4 Mar 2015 02:33:15 +0000 (UTC) Received: (qmail 80185 invoked by uid 500); 4 Mar 2015 02:33:11 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 80154 invoked by uid 500); 4 Mar 2015 02:33:11 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 80145 invoked by uid 99); 4 Mar 2015 02:33:11 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Mar 2015 02:33:11 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id BEC2CE07F3; Wed, 4 Mar 2015 02:33:11 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: alexantonenko@apache.org To: commits@ambari.apache.org Message-Id: <6746ea4ab6f0436a8a7f345d01d7f542@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: ambari git commit: AMBARI-9899. Resource Manager Dashboard widget thresholds null after upgrade (alexantonenko) Date: Wed, 4 Mar 2015 02:33:11 +0000 (UTC) Repository: ambari Updated Branches: refs/heads/trunk 33a84155f -> 81209311e AMBARI-9899. Resource Manager Dashboard widget thresholds null after upgrade (alexantonenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/81209311 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/81209311 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/81209311 Branch: refs/heads/trunk Commit: 81209311ef259b2a16a2f7319ea7470b6ca11698 Parents: 33a8415 Author: Alex Antonenko Authored: Wed Mar 4 06:26:22 2015 +0200 Committer: Alex Antonenko Committed: Wed Mar 4 06:33:05 2015 +0200 ---------------------------------------------------------------------- ambari-web/app/views/common/table_view.js | 8 +++++--- ambari-web/app/views/main/dashboard/widgets.js | 9 +++++++++ .../test/views/main/dashboard/widget_test.js | 4 ++-- .../test/views/main/dashboard/widgets_test.js | 17 ++++++++++++++++- 4 files changed, 32 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/81209311/ambari-web/app/views/common/table_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/table_view.js b/ambari-web/app/views/common/table_view.js index cc1c2d6..72c4bf7 100644 --- a/ambari-web/app/views/common/table_view.js +++ b/ambari-web/app/views/common/table_view.js @@ -86,9 +86,11 @@ App.TableView = Em.View.extend(App.UserPref, { self.initFilters(); }); } else { - this.getUserPref(this.displayLengthKey()).complete(function () { - self.initFilters(); - }); + if (!$.mocho) { + this.getUserPref(this.displayLengthKey()).complete(function () { + self.initFilters(); + }); + } } } }, http://git-wip-us.apache.org/repos/asf/ambari/blob/81209311/ambari-web/app/views/main/dashboard/widgets.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/dashboard/widgets.js b/ambari-web/app/views/main/dashboard/widgets.js index d39c12f..79cf392 100644 --- a/ambari-web/app/views/main/dashboard/widgets.js +++ b/ambari-web/app/views/main/dashboard/widgets.js @@ -477,6 +477,15 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, { getUserPrefSuccessCallback: function (response, request, data) { if (response) { console.log('Got persist value from server with key ' + data.key + '. Value is: ' + response); + var initPrefObject = this.get('initPrefObject'); + initPrefObject.get('threshold'); + for(var k in response.threshold) { + if (response.threshold.hasOwnProperty(k)) { + if (response.threshold[k].length === 0 && initPrefObject.get('threshold')[k] && initPrefObject.get('threshold')[k].length) { + response.threshold[k] = initPrefObject.get('threshold')[k]; + } + } + } this.set('currentPrefObject', response); } }, http://git-wip-us.apache.org/repos/asf/ambari/blob/81209311/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 b0c249c..0625474 100644 --- a/ambari-web/test/views/main/dashboard/widget_test.js +++ b/ambari-web/test/views/main/dashboard/widget_test.js @@ -23,7 +23,7 @@ describe('App.DashboardWidgetView', function () { var dashboardWidgetView = App.DashboardWidgetView.create({ parentView: Em.Object.create({ widgetsMapper: Em.K, - getUserPref: Em.K, + getUserPref: function () {return {complete: Em.K}}, postUserPref: Em.K, translateToReal: Em.K, visibleWidgets: [], @@ -404,4 +404,4 @@ describe('App.DashboardWidgetView', function () { }); }); }); -}); \ No newline at end of file +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/81209311/ambari-web/test/views/main/dashboard/widgets_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/dashboard/widgets_test.js b/ambari-web/test/views/main/dashboard/widgets_test.js index e02fb7f..0768c77 100644 --- a/ambari-web/test/views/main/dashboard/widgets_test.js +++ b/ambari-web/test/views/main/dashboard/widgets_test.js @@ -414,16 +414,31 @@ describe('App.MainDashboardWidgetsView', function () { }); describe("#getUserPrefSuccessCallback()", function () { + it("response is null", function () { view.set('currentPrefObject', null); view.getUserPrefSuccessCallback(null, {}, {}); expect(view.get('currentPrefObject')).to.be.null; }); + it("response is correct", function () { view.set('currentPrefObject', null); view.getUserPrefSuccessCallback({}, {}, {}); expect(view.get('currentPrefObject')).to.eql({}); }); + + it('should update missing thresholds', function () { + + view.set('currentPrefObject', null); + view.getUserPrefSuccessCallback({ + threshold: { + 17: [] + } + }, {}, {}); + expect(view.get('currentPrefObject.threshold')['17']).to.eql([70, 90]); + + }); + }); describe("#resetAllWidgets()", function () { @@ -499,4 +514,4 @@ describe('App.MainDashboardWidgetsView', function () { }); }); -}); \ No newline at end of file +});