Updated Branches: refs/heads/trunk a440c0a84 -> ad3bc8efb
AMBARI-4229 Maintenance Mode: Host Detail page (Components Section). (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ad3bc8ef Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ad3bc8ef Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ad3bc8ef Branch: refs/heads/trunk Commit: ad3bc8efbc3d93edc1294ce39230e605fd9c338d Parents: a440c0a Author: aBabiichuk <[email protected]> Authored: Mon Jan 6 19:02:37 2014 +0200 Committer: aBabiichuk <[email protected]> Committed: Mon Jan 6 19:02:37 2014 +0200 ---------------------------------------------------------------------- ambari-web/app/controllers/main/host/details.js | 36 ++++++++- ambari-web/app/messages.js | 3 + ambari-web/app/models/host_component.js | 2 + ambari-web/app/templates/main/host/summary.hbs | 82 ++++++++++++-------- ambari-web/app/utils/ajax.js | 20 +++++ ambari-web/app/views/main/host/summary.js | 13 ++++ 6 files changed, 121 insertions(+), 35 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/ad3bc8ef/ambari-web/app/controllers/main/host/details.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js index fe46dcc..2304a47 100644 --- a/ambari-web/app/controllers/main/host/details.js +++ b/ambari-web/app/controllers/main/host/details.js @@ -796,7 +796,7 @@ App.MainHostDetailsController = Em.Controller.extend({ break; } }, - + doStartAllComponents: function() { var self = this; var components = this.get('content.hostComponents'); @@ -1076,6 +1076,38 @@ App.MainHostDetailsController = Em.Controller.extend({ reassignMasterController.setCurrentStep('1'); App.router.transitionTo('services.reassign'); }); - } + }, + + turnOnOffMaintenanceConfirmation: function(event){ + var self = this; + var component = event.context; + var componentName = component.get('componentName').toUpperCase(); + var state, onOff; + if (component.get("workStatus") == App.HostComponentStatus.maintenance) { + onOff = "Off"; + state = App.HostComponentStatus.stopped; + } else { + onOff = "On"; + state = App.HostComponentStatus.maintenance; + } + App.showConfirmationPopup(function() { + self.turnOnOffmaintenance(state, componentName) + }, + Em.I18n.t('hosts.maintenanceMode.popup').format(onOff,component.get('displayName')) + ); + }, + turnOnOffmaintenance: function(state,componentName) { + var hostName = this.get('content.hostName'); + App.ajax.send({ + name: 'host_component.maintenance_mode', + sender: this, + data: { + hostName: hostName, + componentName: componentName, + state: state, + requestInfo: componentName + " " + state + } + }); + } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/ad3bc8ef/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index 8ded97d..9e96578 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -165,6 +165,8 @@ Em.I18n.translations = { 'common.discard': 'Discard', 'common.actions': 'Actions', 'common.maintenance': 'Maintenance', + 'maintenance.turnOn':'Turn On Maintenance Mode', + 'maintenance.turnOff':'Turn Off Maintenance Mode', 'requestInfo.installComponents':'Install Components', 'requestInfo.installServices':'Install Services', @@ -1408,6 +1410,7 @@ Em.I18n.translations = { 'If this host has a DataNode, it should be decommissioned first to prevent data loss.', 'hosts.add.header':'Add Host Wizard', 'hosts.assignRack':'Assign Rack', + 'hosts.maintenanceMode.popup':'Are you sure you want to Turn {0} Maintenance Mode for {1}?', 'charts.horizon.chart.showText':'show', 'charts.horizon.chart.hideText':'hide', http://git-wip-us.apache.org/repos/asf/ambari/blob/ad3bc8ef/ambari-web/app/models/host_component.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/host_component.js b/ambari-web/app/models/host_component.js index 081442c..ca65b75 100644 --- a/ambari-web/app/models/host_component.js +++ b/ambari-web/app/models/host_component.js @@ -217,6 +217,8 @@ App.HostComponentStatus = { return 'Heartbeat lost...'; case this.upgrade_failed: return 'Upgrade Failed'; + case this.maintenance: + return 'Maintenance'; } return 'Unknown'; } http://git-wip-us.apache.org/repos/asf/ambari/blob/ad3bc8ef/ambari-web/app/templates/main/host/summary.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/host/summary.hbs b/ambari-web/app/templates/main/host/summary.hbs index f8de8cf..a64d664 100644 --- a/ambari-web/app/templates/main/host/summary.hbs +++ b/ambari-web/app/templates/main/host/summary.hbs @@ -103,40 +103,56 @@ </li> {{/if}} {{#unless view.isInstalling}} - {{#if view.isStart}} - <li {{bindAttr class=" view.isDecommissioning:hidden view.noActionAvailable"}}> - <a href="javascript:void(null)" data-toggle="modal" {{action "stopComponent" view.content target="controller"}}> - {{t common.stop}} - </a> - </li> - {{/if}} - {{#unless view.isStart}} - <li {{bindAttr class="view.isUpgradeFailed:hidden view.isInstallFailed:hidden view.isDecommissioning:hidden view.noActionAvailable"}}> - <a href="javascript:void(null)" data-toggle="modal" {{action "startComponent" view.content target="controller"}}> - {{t common.start}} - </a> - </li> + {{#unless view.isInMaintenance}} + {{#if view.isStart}} + <li {{bindAttr class=" view.isDecommissioning:hidden view.noActionAvailable"}}> + <a href="javascript:void(null)" data-toggle="modal" {{action "stopComponent" view.content target="controller"}}> + {{t common.stop}} + </a> + </li> + {{/if}} + {{#unless view.isStart}} + <li {{bindAttr class="view.isUpgradeFailed:hidden view.isInstallFailed:hidden view.isDecommissioning:hidden view.noActionAvailable"}}> + <a href="javascript:void(null)" data-toggle="modal" {{action "startComponent" view.content target="controller"}}> + {{t common.start}} + </a> + </li> + {{/unless}} + {{#if view.isUpgradeFailed}} + <li {{bindAttr class="view.noActionAvailable"}}> + <a href="javascript:void(null)" data-toggle="modal" {{action "upgradeComponent" view.content target="controller"}}> + {{t common.reUpgrade}} + </a> + </li> + {{/if}} + {{#if view.isInstallFailed}} + <li {{bindAttr class="view.noActionAvailable"}}> + <a href="javascript:void(null)" data-toggle="modal" {{action "installComponent" view.content target="controller"}}> + {{t common.reinstall}} + </a> + </li> + {{/if}} + {{#if view.isReassignable}} + <li {{bindAttr class="view.noActionAvailable"}}> + <a href="javascript:void(null)" data-toggle="modal" {{action "moveComponent" view.content target="controller"}}> + {{t common.move}} + </a> + </li> + {{/if}} + {{#if view.isStop}} + <li {{bindAttr class="view.noActionAvailable"}}> + <a href="javascript:void(null)" data-toggle="modal" {{action "turnOnOffMaintenanceConfirmation" view.content target="controller"}}> + {{t maintenance.turnOn}} + </a> + </li> + {{/if}} {{/unless}} - {{#if view.isUpgradeFailed}} - <li {{bindAttr class="view.noActionAvailable"}}> - <a href="javascript:void(null)" data-toggle="modal" {{action "upgradeComponent" view.content target="controller"}}> - {{t common.reUpgrade}} - </a> - </li> - {{/if}} - {{#if view.isInstallFailed}} - <li {{bindAttr class="view.noActionAvailable"}}> - <a href="javascript:void(null)" data-toggle="modal" {{action "installComponent" view.content target="controller"}}> - {{t common.reinstall}} - </a> - </li> - {{/if}} - {{#if view.isReassignable}} - <li {{bindAttr class="view.noActionAvailable"}}> - <a href="javascript:void(null)" data-toggle="modal" {{action "moveComponent" view.content target="controller"}}> - {{t common.move}} - </a> - </li> + {{#if view.isInMaintenance}} + <li {{bindAttr class="view.noActionAvailable"}}> + <a href="javascript:void(null)" data-toggle="modal" {{action "turnOnOffMaintenanceConfirmation" view.content target="controller"}}> + {{t maintenance.turnOff}} + </a> + </li> {{/if}} {{/unless}} </ul> http://git-wip-us.apache.org/repos/asf/ambari/blob/ad3bc8ef/ambari-web/app/utils/ajax.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/ajax.js b/ambari-web/app/utils/ajax.js index 51c204e..992f12d 100644 --- a/ambari-web/app/utils/ajax.js +++ b/ambari-web/app/utils/ajax.js @@ -199,6 +199,26 @@ var urls = { } }, + 'host_component.maintenance_mode': { + 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}', + 'mock': '', + 'type': 'PUT', + 'format': function (data, opt) { + return { + data: JSON.stringify({ + RequestInfo: { + "context": data.requestInfo + }, + Body: { + HostRoles: { + state: data.state + } + } + }) + }; + } + }, + 'config.advanced': { 'real': '{stack2VersionUrl}/stackServices/{serviceName}/configurations?fields=*', 'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json', http://git-wip-us.apache.org/repos/asf/ambari/blob/ad3bc8ef/ambari-web/app/views/main/host/summary.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/summary.js b/ambari-web/app/views/main/host/summary.js index 211e065..7f4aab0 100644 --- a/ambari-web/app/views/main/host/summary.js +++ b/ambari-web/app/views/main/host/summary.js @@ -356,6 +356,11 @@ App.MainHostSummaryView = Em.View.extend({ return 'health-status-color-blue icon-cog'; } + //Class when maintenance + if (this.get('workStatus') === App.HostComponentStatus.maintenance) { + return 'icon-medkit'; + } + //For all other cases return 'health-status-' + App.HostComponentStatus.getKeyName(this.get('workStatus')); }.property('workStatus', 'isDataNodeRecommissionAvailable', 'this.content.isDecommissioning'), @@ -409,6 +414,10 @@ App.MainHostSummaryView = Em.View.extend({ return (this.get('workStatus') == App.HostComponentStatus.started || this.get('workStatus') == App.HostComponentStatus.starting); }.property('workStatus'), + isStop: function () { + return (this.get('workStatus') == App.HostComponentStatus.stopped); + }.property('workStatus'), + isInstalling: function () { return (this.get('workStatus') == App.HostComponentStatus.installing); }.property('workStatus'), @@ -441,6 +450,10 @@ App.MainHostSummaryView = Em.View.extend({ return this.get('isDataNode') && this.get("isDataNodeRecommissionAvailable") && hostComponentDecommissioning; }.property("workStatus", "isDataNodeRecommissionAvailable", "hostComponent.isDecommissioning"), + isInMaintenance: function () { + return (this.get('workStatus') == App.HostComponentStatus.maintenance); + }.property("workStatus"), + /** * Set in template via binding from parent view */
