Repository: ambari Updated Branches: refs/heads/trunk 1bddc0364 -> 6d11d6780
AMBARI-5067. Status of UI for various tasks when starting all components on a hosts does not get updated. (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6d11d678 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6d11d678 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6d11d678 Branch: refs/heads/trunk Commit: 6d11d67806d88eaaa457807d7807684962e071ad Parents: 1bddc03 Author: Oleg Nechiporenko <[email protected]> Authored: Thu Mar 13 14:51:23 2014 +0200 Committer: Oleg Nechiporenko <[email protected]> Committed: Thu Mar 13 14:58:16 2014 +0200 ---------------------------------------------------------------------- ambari-web/app/utils/host_progress_popup.js | 153 ++++++++++++------- .../test/utils/host_progress_popup_test.js | 147 +++++++++--------- 2 files changed, 165 insertions(+), 135 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/6d11d678/ambari-web/app/utils/host_progress_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/host_progress_popup.js b/ambari-web/app/utils/host_progress_popup.js index f009d06..a9eebf7 100644 --- a/ambari-web/app/utils/host_progress_popup.js +++ b/ambari-web/app/utils/host_progress_popup.js @@ -28,32 +28,48 @@ App.HostPopup = Em.Object.create({ servicesInfo: null, hosts: null, inputData: null, + + /** + * @type {string} + */ serviceName: "", + + /** + * @type {Number} + */ currentServiceId: null, previousServiceId: null, + + /** + * @type {string} + */ popupHeaderName: "", + + /** + * @type {App.Controller} + */ dataSourceController: null, + + /** + * @type {bool} + */ isBackgroundOperations: false, + + /** + * @type {string} + */ currentHostName: null, - isPopup: null, /** - * Sort object array - * @param array - * @param p - * @return {*} + * @type {App.ModalPopup} */ - sortArray: function (array, p) { - return array.sort(function (a, b) { - return (a[p] > b[p]) ? 1 : (a[p] < b[p]) ? -1 : 0; - }); - }, + isPopup: null, /** * Entering point of this component - * @param serviceName - * @param controller - * @param isBackgroundOperations + * @param {String} serviceName + * @param {App.Controller} controller + * @param {bool} isBackgroundOperations */ initPopup: function (serviceName, controller, isBackgroundOperations) { if (!isBackgroundOperations) { @@ -72,6 +88,9 @@ App.HostPopup = Em.Object.create({ return this.createPopup(); }, + /** + * clear info popup data + */ clearHostPopup: function () { this.set('servicesInfo', null); this.set('hosts', null); @@ -87,7 +106,7 @@ App.HostPopup = Em.Object.create({ /** * Depending on tasks status - * @param tasks + * @param {Array} tasks * @return {Array} [Status, Icon type, Progressbar color, is IN_PROGRESS] */ getStatus: function(tasks){ @@ -135,14 +154,14 @@ App.HostPopup = Em.Object.create({ /** * Progress of host or service depending on tasks status - * @param tasks + * @param {Array} tasks * @return {Number} percent of completion */ getProgress: function (tasks) { var completedActions = 0; var queuedActions = 0; var inProgressActions = 0; - tasks.forEach(function(task){ + tasks.forEach(function(task) { if(['COMPLETED', 'FAILED', 'ABORTED', 'TIMEDOUT'].contains(task.Tasks.status)){ completedActions++; } else if(task.Tasks.status === 'QUEUED'){ @@ -153,10 +172,11 @@ App.HostPopup = Em.Object.create({ }); return Math.ceil(((queuedActions * 0.09) + (inProgressActions * 0.35) + completedActions ) / tasks.length * 100); }, + /** * Count number of operations for select box options - * @param obj - * @param categories + * @param {Object[]} obj + * @param {Object[]} categories */ setSelectCount: function (obj, categories) { if (!obj) return; @@ -194,7 +214,7 @@ App.HostPopup = Em.Object.create({ countTimedout++; break; } - }, this); + }); categories.findProperty("value", 'all').set("count", countAll); categories.findProperty("value", 'pending').set("count", countPending); @@ -207,7 +227,7 @@ App.HostPopup = Em.Object.create({ /** * For Background operation popup calculate number of running Operations, and set popup header - * @param isServiceListHidden + * @param {bool} isServiceListHidden */ setBackgroundOperationHeader: function (isServiceListHidden) { if (this.get('isBackgroundOperations') && !isServiceListHidden) { @@ -219,6 +239,7 @@ App.HostPopup = Em.Object.create({ /** * Create services obj data structure for popup * Set data for services + * @param {bool} isServiceListHidden */ onServiceUpdate: function (isServiceListHidden) { if (this.get('isBackgroundOperations') && this.get("inputData")) { @@ -261,11 +282,11 @@ App.HostPopup = Em.Object.create({ /** * create task Ember object - * @param _task - * @return {*} + * @param {Object} _task + * @return {Em.Object} */ createTask: function (_task) { - return Ember.Object.create({ + return Em.Object.create({ id: _task.Tasks.id, hostName: _task.Tasks.host_name, command: ( _task.Tasks.command.toLowerCase() != 'service_check') ? _task.Tasks.command.toLowerCase() : '', @@ -293,6 +314,7 @@ App.HostPopup = Em.Object.create({ }.property('status') }); }, + /** * Create hosts and tasks data structure for popup * Set data for hosts and tasks @@ -400,7 +422,7 @@ App.HostPopup = Em.Object.create({ /** * Show popup - * @return PopupObject For testing purposes + * @return {App.ModalPopup} PopupObject For testing purposes */ createPopup: function () { var self = this; @@ -416,21 +438,51 @@ App.HostPopup = Em.Object.create({ }.property('count') }); self.set('isPopup', App.ModalPopup.show({ - //no need to track is it loaded when popup contain only list of hosts + /** + * no need to track is it loaded when popup contain only list of hosts + * @type {bool} + */ isLoaded: !isBackgroundOperations, + + /** + * is BG-popup opened + * @type {bool} + */ isOpen: false, + didInsertElement: function(){ this._super(); this.set('isOpen', true); }, - headerClass: Ember.View.extend({ + + /** + * @type {Em.View} + */ + headerClass: Em.View.extend({ controller: this, template: Ember.Handlebars.compile('{{popupHeaderName}}') }), + + /** + * @type {String[]} + */ classNames: ['sixty-percent-width-modal', 'host-progress-popup'], - // for the checkbox: do not show this dialog again + + /** + * for the checkbox: do not show this dialog again + * @type {bool} + */ hasFooterCheckbox: true, + + /** + * Auto-display BG-popup + * @type {bool} + */ isNotShowBgChecked : null, + + /** + * Save user pref about auto-display BG-popup + */ updateNotShowBgChecked: function () { var curVal = !this.get('isNotShowBgChecked'); var key = App.router.get('applicationController').persistKey(); @@ -458,7 +510,7 @@ App.HostPopup = Em.Object.create({ }, secondary: null, - bodyClass: Ember.View.extend({ + bodyClass: Em.View.extend({ templateName: require('templates/common/host_progress_popup'), isLogWrapHidden: true, isTaskListHidden: true, @@ -574,7 +626,7 @@ App.HostPopup = Em.Object.create({ * Depending on selected filter type, set object visibility value * @param filter * @param obj - * @return {Boolean} isEmptyList + * @return {bool} isEmptyList */ setVisibility: function (filter, obj) { var isEmptyList = true; @@ -661,22 +713,19 @@ App.HostPopup = Em.Object.create({ }, /** * Onclick handler for button <-Tasks - * @param event - * @param context */ - backToTaskList: function (event, context) { + backToTaskList: function () { this.destroyClipBoard(); this.set("openedTaskId", 0); this.set("isLogWrapHidden", true); this.set("isTaskListHidden", false); + this.switchLevel("TASKS_LIST"); }, /** * Onclick handler for button <-Hosts - * @param event - * @param context */ - backToHostList: function (event, context) { + backToHostList: function () { this.set("isHostListHidden", false); this.set("isTaskListHidden", true); this.get("controller").set("popupHeaderName", this.get("controller.serviceName")); @@ -685,10 +734,8 @@ App.HostPopup = Em.Object.create({ /** * Onclick handler for button <-Services - * @param event - * @param context */ - backToServiceList: function (event, context) { + backToServiceList: function () { this.get("controller").set("serviceName", ""); this.set("isHostListHidden", true); this.set("isServiceListHidden", false); @@ -700,10 +747,9 @@ App.HostPopup = Em.Object.create({ /** * Onclick handler for selected Service - * @param event - * @param context + * @param {Object} event */ - gotoHosts: function (event, context) { + gotoHosts: function (event) { this.get("controller").set("serviceName", event.context.get("name")); this.get("controller").set("currentServiceId", event.context.get("id")); this.get("controller").set("currentHostName", null); @@ -724,7 +770,7 @@ App.HostPopup = Em.Object.create({ $(".modal").scrollTop(0); $(".modal-body").scrollTop(0); if (servicesInfo.length > 100) { - Ember.run.next(this, function(){ + Em.run.next(this, function(){ this.set('hosts', this.get('hosts').concat(servicesInfo.slice(50, servicesInfo.length))); }); } @@ -793,10 +839,9 @@ App.HostPopup = Em.Object.create({ /** * Onclick handler for selected Host - * @param event - * @param context + * @param {Object} event */ - gotoTasks: function (event, context) { + gotoTasks: function (event) { var tasksInfo = []; event.context.logTasks.forEach(function (_task) { tasksInfo.pushObject(this.get("controller").createTask(_task)); @@ -840,10 +885,9 @@ App.HostPopup = Em.Object.create({ /** * Onclick event for show task detail info - * @param event - * @param context + * @param {Object} event */ - toggleTaskLog: function (event, context) { + toggleTaskLog: function (event) { var taskInfo = event.context; this.set("isLogWrapHidden", false); if ($(".task-detail-log-clipboard").length > 0) { @@ -859,14 +903,9 @@ App.HostPopup = Em.Object.create({ /** * Onclick event for copy to clipboard button - * @param event */ - textTrigger: function (event) { - if ($(".task-detail-log-clipboard").length > 0) { - this.destroyClipBoard(); - } else { - this.createClipBoard(); - } + textTrigger: function () { + $(".task-detail-log-clipboard").length > 0 ? this.destroyClipBoard() : this.createClipBoard(); }, /** @@ -891,10 +930,10 @@ App.HostPopup = Em.Object.create({ $(".task-detail-log-clipboard").remove(); $(".task-detail-log-maintext").css("display", "block"); } + }) })); return self.get('isPopup'); } -}); - +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/6d11d678/ambari-web/test/utils/host_progress_popup_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/host_progress_popup_test.js b/ambari-web/test/utils/host_progress_popup_test.js index 0d90b1d..e341a6b 100644 --- a/ambari-web/test/utils/host_progress_popup_test.js +++ b/ambari-web/test/utils/host_progress_popup_test.js @@ -241,77 +241,76 @@ describe('App.HostPopup', function () { } ]; - var itemsForStatusTest = [ - { - title: 'Empty', - data: [], - result: [0, 0, 0, 0, 0, 0, 0] - }, - { - title: 'All Pending', - data: [ - {status: 'pending'}, - {status: 'queued'} - ], - result: [2, 2, 0, 0, 0, 0, 0] - }, - { - title: 'All Completed', - data: [ - {status: 'success'}, - {status: 'completed'} - ], - result: [2, 0, 0, 0, 2, 0, 0] - }, - { - title: 'All Failed', - data: [ - {status: 'failed'}, - {status: 'failed'} - ], - result: [2, 0, 0, 2, 0, 0, 0] - }, - { - title: 'All InProgress', - data: [ - {status: 'in_progress'}, - {status: 'in_progress'} - ], - result: [2, 0, 2, 0, 0, 0, 0] - }, - { - title: 'All Aborted', - data: [ - {status: 'aborted'}, - {status: 'aborted'} - ], - result: [2, 0, 0, 0, 0, 2, 0] - }, - { - title: 'All Timedout', - data: [ - {status: 'timedout'}, - {status: 'timedout'} - ], - result: [2, 0, 0, 0, 0, 0, 2] - }, - { - title: 'Every Category', - data: [ - {status: 'pending'}, - {status: 'queued'}, - {status: 'success'}, - {status: 'completed'}, - {status: 'failed'}, - {status: 'in_progress'}, - {status: 'aborted'}, - {status: 'timedout'} - ], - result: [8, 2, 1, 1, 2, 1, 1] - } - ]; - describe('#setSelectCount', function () { + var itemsForStatusTest = [ + { + title: 'Empty', + data: [], + result: [0, 0, 0, 0, 0, 0, 0] + }, + { + title: 'All Pending', + data: [ + {status: 'pending'}, + {status: 'queued'} + ], + result: [2, 2, 0, 0, 0, 0, 0] + }, + { + title: 'All Completed', + data: [ + {status: 'success'}, + {status: 'completed'} + ], + result: [2, 0, 0, 0, 2, 0, 0] + }, + { + title: 'All Failed', + data: [ + {status: 'failed'}, + {status: 'failed'} + ], + result: [2, 0, 0, 2, 0, 0, 0] + }, + { + title: 'All InProgress', + data: [ + {status: 'in_progress'}, + {status: 'in_progress'} + ], + result: [2, 0, 2, 0, 0, 0, 0] + }, + { + title: 'All Aborted', + data: [ + {status: 'aborted'}, + {status: 'aborted'} + ], + result: [2, 0, 0, 0, 0, 2, 0] + }, + { + title: 'All Timedout', + data: [ + {status: 'timedout'}, + {status: 'timedout'} + ], + result: [2, 0, 0, 0, 0, 0, 2] + }, + { + title: 'Every Category', + data: [ + {status: 'pending'}, + {status: 'queued'}, + {status: 'success'}, + {status: 'completed'}, + {status: 'failed'}, + {status: 'in_progress'}, + {status: 'aborted'}, + {status: 'timedout'} + ], + result: [8, 2, 1, 1, 2, 1, 1] + } + ]; var categories = [ Ember.Object.create({value: 'all'}), Ember.Object.create({value: 'pending'}), @@ -345,12 +344,4 @@ describe('App.HostPopup', function () { }); }); - describe('#sortTasksById', function() { - test_tasks.forEach(function(test_task) { - it(test_task.m, function() { - expect(App.HostPopup.sortTasksById(test_task.t).mapProperty('Tasks.id')).to.eql(test_task.ids); - }); - }); - }); - });
