AMBARI-19034 Upgrade History Displays Wrong Upgrade Type (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4b387915 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4b387915 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4b387915 Branch: refs/heads/branch-dev-patch-upgrade Commit: 4b387915117412b7153a7c36b3f26412538b756d Parents: dc5f4e2 Author: Andrii Tkach <atk...@apache.org> Authored: Thu Dec 1 12:11:52 2016 +0200 Committer: Andrii Tkach <atk...@apache.org> Committed: Thu Dec 1 12:48:41 2016 +0200 ---------------------------------------------------------------------- .../admin/stack_upgrade_history_controller.js | 2 +- .../app/mappers/stack_upgrade_history_mapper.js | 2 +- ambari-web/app/messages.js | 1 + .../stack_version/stack_upgrade_history.js | 2 +- ambari-web/app/styles/stack_versions.less | 16 +-- .../upgrade_history_details_view.js | 2 +- .../admin/stack_upgrade/upgrade_history_view.js | 120 ++++++++++--------- 7 files changed, 75 insertions(+), 70 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/4b387915/ambari-web/app/controllers/main/admin/stack_upgrade_history_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/stack_upgrade_history_controller.js b/ambari-web/app/controllers/main/admin/stack_upgrade_history_controller.js index 3a78e30..4c9abfe 100644 --- a/ambari-web/app/controllers/main/admin/stack_upgrade_history_controller.js +++ b/ambari-web/app/controllers/main/admin/stack_upgrade_history_controller.js @@ -213,5 +213,5 @@ App.MainAdminStackUpgradeHistoryController = Em.ArrayController.extend({ } else { return '' } - }.property('upgradeData.Upgrade.request_status'), + }.property('upgradeData.Upgrade.request_status') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/4b387915/ambari-web/app/mappers/stack_upgrade_history_mapper.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mappers/stack_upgrade_history_mapper.js b/ambari-web/app/mappers/stack_upgrade_history_mapper.js index 63088a7..823ae80 100644 --- a/ambari-web/app/mappers/stack_upgrade_history_mapper.js +++ b/ambari-web/app/mappers/stack_upgrade_history_mapper.js @@ -50,5 +50,5 @@ App.stackUpgradeHistoryMapper = App.QuickDataMapper.create({ App.store.loadMany(this.get('model'), result); App.store.commit(); App.set('isStackUpgradeHistoryLoaded',true); - }, + } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/4b387915/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index a16d0ea..90ad70f 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -346,6 +346,7 @@ Em.I18n.translations = { 'common.end.time': 'End Time', 'common.rolling': 'Rolling', 'common.express': 'Express', + 'common.hostOrdered': 'Host Ordered', 'common.rolling.downgrade': 'Rolling Downgrade', 'common.express.downgrade': 'Express Downgrade', http://git-wip-us.apache.org/repos/asf/ambari/blob/4b387915/ambari-web/app/models/stack_version/stack_upgrade_history.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/stack_version/stack_upgrade_history.js b/ambari-web/app/models/stack_version/stack_upgrade_history.js index d4a89dc..9e0439c 100644 --- a/ambari-web/app/models/stack_version/stack_upgrade_history.js +++ b/ambari-web/app/models/stack_version/stack_upgrade_history.js @@ -31,7 +31,7 @@ App.StackUpgradeHistory = DS.Model.extend({ skipServiceCheckFailures: DS.attr('boolean'), endTime: DS.attr('number'), startTime: DS.attr('number'), - createTime: DS.attr('number'), + createTime: DS.attr('number') }); App.StackUpgradeHistory.FIXTURES = []; http://git-wip-us.apache.org/repos/asf/ambari/blob/4b387915/ambari-web/app/styles/stack_versions.less ---------------------------------------------------------------------- diff --git a/ambari-web/app/styles/stack_versions.less b/ambari-web/app/styles/stack_versions.less index f67e03e..6698dfa 100644 --- a/ambari-web/app/styles/stack_versions.less +++ b/ambari-web/app/styles/stack_versions.less @@ -444,8 +444,14 @@ .method-options { margin: 10px; + .method-option { + margin-bottom: 5px; + } .img-thumbnail { - + background-color: #e4e4e4; + .method-name,.method-icon,.method-description { + color: #333; + } cursor: pointer; border: none; width: 99%; @@ -464,18 +470,12 @@ } } - .ROLLING, .NON_ROLLING { - background-color: #e4e4e4; - .method-name,.method-icon,.method-description { - color: #333; - } - } .ROLLING { .method-icon { margin-left: 88px; } } - .NON_ROLLING { + .NON_ROLLING, .HOST_ORDERED { .method-icon { margin-left: 94px; } http://git-wip-us.apache.org/repos/asf/ambari/blob/4b387915/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_details_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_details_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_details_view.js index 983c26a..dae236b 100644 --- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_details_view.js +++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_details_view.js @@ -81,5 +81,5 @@ App.MainAdminStackUpgradeHistoryDetailsView = Em.View.extend({ } else { return ""; } - }.property('controller.upgradeData.Upgrade.request_status', 'controller.isDowngrade'), + }.property('controller.upgradeData.Upgrade.request_status', 'controller.isDowngrade') }); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/4b387915/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_view.js index 31e1478..8817308 100644 --- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_view.js +++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_view.js @@ -75,7 +75,21 @@ App.MainAdminStackUpgradeHistoryView = App.TableView.extend(App.TableServerViewM labelKey: 'admin.stackVersions.upgradeHistory.filter.failed.downgrade', value: 'DOWNGRADE_FAILED', isSelected: false + }) + ], + upgradeMethods: [ + Em.Object.create({ + displayName: Em.I18n.t('common.rolling'), + type: 'ROLLING' + }), + Em.Object.create({ + displayName: Em.I18n.t('common.express'), + type: 'NON_ROLLING' }), + Em.Object.create({ + displayName: Em.I18n.t('common.hostOrdered'), + type: 'HOST_ORDERED' + }) ], /** @@ -83,7 +97,7 @@ App.MainAdminStackUpgradeHistoryView = App.TableView.extend(App.TableServerViewM */ selectedCategory: Em.computed.findBy('categories', 'isSelected', true), - filteredCount: function(){ + filteredCount: function () { var filteredContent = this.get('filteredContent').toArray(); return filteredContent.length; }.property('filteredContent'), @@ -92,13 +106,12 @@ App.MainAdminStackUpgradeHistoryView = App.TableView.extend(App.TableServerViewM * displaying content filtered by upgrade type and upgrade status. */ filteredContent: function () { - var result = []; var filterValue = 'ALL'; var category = this.get('selectedCategory'); - if (category) + if (category) { filterValue = category.get('value'); - var result = this.filterBy(filterValue); - return result.reverse(); + } + return this.filterBy(filterValue).reverse(); }.property('selectedCategory'), /** @@ -107,28 +120,25 @@ App.MainAdminStackUpgradeHistoryView = App.TableView.extend(App.TableServerViewM pageContent: function () { var content = this.get('filteredContent').toArray(); content = this.processForDisplay(content); - content = content.slice(this.get('startIndex') - 1, this.get('endIndex')) + content = content.slice(this.get('startIndex') - 1, this.get('endIndex')); return content; }.property('filteredContent', 'startIndex', 'endIndex'), - processForDisplay: function(content){ + processForDisplay: function (content) { var processedContent = []; - content.forEach(function(item){ - if('UPGRADE' == item.get('direction')) - item.set('directionLabel', Em.I18n.t('common.upgrade')); - else - item.set('directionLabel', Em.I18n.t('common.downgrade')); - - if('NON_ROLLING' == item.get('upgradeType')) - item.set('upgradeTypeLabel', Em.I18n.t('common.express')); - else - item.set('upgradeTypeLabel', Em.I18n.t('common.rolling')); - - item.set('startTimeLabel', date.startTime(item.get('startTime'))); - item.set('endTimeLabel', date.startTime(item.get('endTime'))); - item.set('duration', date.durationSummary(item.get('startTime'), item.get('endTime'))); + + content.forEach(function (item) { + var direction = item.get('direction') === 'UPGRADE' ? Em.I18n.t('common.upgrade') : Em.I18n.t('common.downgrade'); + var method = this.get('upgradeMethods').findProperty('type', item.get('upgradeType')); + item.setProperties({ + directionLabel: direction, + upgradeTypeLabel: method ? method.get('displayName') : method, + startTimeLabel: date.startTime(item.get('startTime')), + endTimeLabel: date.startTime(item.get('endTime')), + duration: date.durationSummary(item.get('startTime'), item.get('endTime')) + }); processedContent.push(item); - },this); + }, this); return processedContent; }, @@ -170,9 +180,9 @@ App.MainAdminStackUpgradeHistoryView = App.TableView.extend(App.TableServerViewM } }, - willInsertElement: function(){ + willInsertElement: function () { var self = this; - this.get('controller').loadStackUpgradeHistoryToModel().done(function(){ + this.get('controller').loadStackUpgradeHistoryToModel().done(function () { self.populateUpgradeHistorySummary(); }); }, @@ -181,31 +191,31 @@ App.MainAdminStackUpgradeHistoryView = App.TableView.extend(App.TableServerViewM this.observesCategories(); }, - observesCategories: function(){ + observesCategories: function () { this.get('categories').forEach(function (category) { var label = Em.I18n.t(category.labelKey).format(this.filterBy(category.value).length); category.set('label', label) }, this); }.observes('isReady'), - filterBy: function(filterValue){ + filterBy: function (filterValue) { if ('ALL' == filterValue) { var all_records = App.StackUpgradeHistory.find(); return all_records.toArray(); } else { var tokens = filterValue.split('_'); - var direction_token = null - var status_token = null + var direction_token = null; + var status_token = null; if (tokens.length == 1) { direction_token = tokens[0] } else if (tokens.length > 1) { - direction_token = tokens[0] - status_token = tokens[1] + direction_token = tokens[0]; + status_token = tokens[1]; } - var result = [] - App.StackUpgradeHistory.find().forEach(function(item){ + var result = []; + App.StackUpgradeHistory.find().forEach(function (item) { var direction = item.get('direction'); if (direction == direction_token) { if (status_token != null) { @@ -224,46 +234,46 @@ App.MainAdminStackUpgradeHistoryView = App.TableView.extend(App.TableServerViewM } }, - selectCategory: function(event){ + selectCategory: function (event) { this.get('categories').filterProperty('isSelected').setEach('isSelected', false); event.context.set('isSelected', true); }, - populateUpgradeHistorySummary: function(){ + populateUpgradeHistorySummary: function () { this.set('isReady', false); var result = [ Em.Object.create({ direction: 'UPGRADE', - label:Em.I18n.t('common.upgrade'), + label: Em.I18n.t('common.upgrade'), hasSuccess: false, - success:0, + success: 0, hasAbort: false, - abort:0, + abort: 0 }), Em.Object.create({ direction: 'DOWNGRADE', - label:Em.I18n.t('common.downgrade'), + label: Em.I18n.t('common.downgrade'), hasSuccess: false, - success:0, + success: 0, hasAbort: false, - abort:0, + abort: 0 }) ]; - App.StackUpgradeHistory.find().forEach(function(item){ + App.StackUpgradeHistory.find().forEach(function (item) { var direction = item.get('direction'); var status = item.get('requestStatus'); - if('UPGRADE' == direction){ - if('COMPLETED' == status){ + if ('UPGRADE' == direction) { + if ('COMPLETED' == status) { result[0].set('success', result[0].get('success') + 1); } else if ('ABORTED' == status) { result[0].set('abort', result[0].get('abort') + 1); } - } else if('DOWNGRADE' == direction){ - if('COMPLETED' == status){ - result[1].set('success', result[1].get('success')+1); - } else if ('ABORTED' == status){ - result[1].set('abort', result[1].get('abort')+1); + } else if ('DOWNGRADE' == direction) { + if ('COMPLETED' == status) { + result[1].set('success', result[1].get('success') + 1); + } else if ('ABORTED' == status) { + result[1].set('abort', result[1].get('abort') + 1); } } }, this); @@ -279,23 +289,17 @@ App.MainAdminStackUpgradeHistoryView = App.TableView.extend(App.TableServerViewM showUpgradeHistoryRecord: function (event) { var record = event.context; - var title = ''; var direction = App.format.normalizeName(record.get('direction')); - var type = record.get('upgradeType'); - if ('ROLLING' === type) { - type = App.format.normalizeName(type); - } else if ('NON_ROLLING' === type) { - type = 'Express' - } - - title = Em.I18n.t('admin.stackVersions.upgradeHistory.record.title').format(type, direction, record.get('fromVersion')); + var fromVersion = record.get('fromVersion'); + var type = this.get('upgradeMethods').findProperty('type', record.get('upgradeType')); + var displayName = type ? type.get('displayName') : App.format.normalizeName(record.get('upgradeType')); this.get('controller').set('currentUpgradeRecord', record); App.ModalPopup.show({ classNames: ['wizard-modal-wrapper'], modalDialogClasses: ['modal-xlg'], - header: title, + header: Em.I18n.t('admin.stackVersions.upgradeHistory.record.title').format(displayName, direction, fromVersion), bodyClass: App.MainAdminStackUpgradeHistoryDetailsView, primary: Em.I18n.t('common.dismiss'), secondary: null,