|
@@ -78,8 +78,8 @@ App.MainHostDetailsController = Em.Controller.extend({
|
|
|
|
|
|
error: function (request, ajaxOptions, error) {
|
|
|
//do something
|
|
|
- callback(null);
|
|
|
- console.log('error on change component host status')
|
|
|
+ console.log('error on change component host status');
|
|
|
+ App.ajax.defaultErrorHandler(request, url, method);
|
|
|
},
|
|
|
|
|
|
statusCode: require('data/statusCodes')
|
|
@@ -94,38 +94,130 @@ App.MainHostDetailsController = Em.Controller.extend({
|
|
|
var self = this;
|
|
|
App.showConfirmationPopup(function() {
|
|
|
var component = event.context;
|
|
|
-
|
|
|
- self.sendCommandToServer('/hosts/' + self.get('content.hostName') + '/host_components/' + component.get('componentName').toUpperCase(),{
|
|
|
- RequestInfo : {
|
|
|
- "context" : Em.I18n.t('requestInfo.startHostComponent') + " " + component.get('displayName')
|
|
|
- },
|
|
|
- Body:{
|
|
|
- HostRoles:{
|
|
|
- state: 'STARTED'
|
|
|
- }
|
|
|
+ var context = Em.I18n.t('requestInfo.startHostComponent') + " " + component.get('displayName');
|
|
|
+ self.sendStartComponentCommand(component, context);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * PUTs a command to server to start a component. If no
|
|
|
+ * specific component is provided, all components are started.
|
|
|
+ * @param component When <code>null</code> all startable components are started.
|
|
|
+ * @param context Context under which this command is beign sent.
|
|
|
+ */
|
|
|
+ sendStartComponentCommand: function(component, context) {
|
|
|
+ var url = component !== null ?
|
|
|
+ '/hosts/' + this.get('content.hostName') + '/host_components/' + component.get('componentName').toUpperCase() :
|
|
|
+ '/hosts/' + this.get('content.hostName') + '/host_components';
|
|
|
+ var dataToSend = {
|
|
|
+ RequestInfo : {
|
|
|
+ "context" : context
|
|
|
+ },
|
|
|
+ Body:{
|
|
|
+ HostRoles:{
|
|
|
+ state: 'STARTED'
|
|
|
}
|
|
|
- }, 'PUT',
|
|
|
- function(requestId){
|
|
|
-
|
|
|
- if(!requestId){
|
|
|
- return;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ if (component === null) {
|
|
|
+ var allComponents = this.get('content.hostComponents');
|
|
|
+ var startable = [];
|
|
|
+ allComponents.forEach(function (c) {
|
|
|
+ if (c.get('isMaster') || c.get('isSlave')) {
|
|
|
+ startable.push(c.get('componentName'));
|
|
|
}
|
|
|
+ });
|
|
|
+ dataToSend.RequestInfo.query = "HostRoles/component_name.in(" + startable.join(',') + ")";
|
|
|
+ }
|
|
|
+ this.sendCommandToServer(url, dataToSend, 'PUT',
|
|
|
+ function(requestId){
|
|
|
+
|
|
|
+ if(!requestId){
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- console.log('Send request for STARTING successfully');
|
|
|
+ console.log('Send request for STARTING successfully');
|
|
|
|
|
|
- if (App.testMode) {
|
|
|
+ if (App.testMode) {
|
|
|
+ if(component === null){
|
|
|
+ var allComponents = this.get('content.hostComponents');
|
|
|
+ allComponents.forEach(function(component){
|
|
|
+ component.set('workStatus', App.HostComponentStatus.stopping);
|
|
|
+ setTimeout(function(){
|
|
|
+ component.set('workStatus', App.HostComponentStatus.stopped);
|
|
|
+ },App.testModeDelayForActions);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
component.set('workStatus', App.HostComponentStatus.starting);
|
|
|
setTimeout(function(){
|
|
|
component.set('workStatus', App.HostComponentStatus.started);
|
|
|
},App.testModeDelayForActions);
|
|
|
- } else {
|
|
|
- App.router.get('clusterController').loadUpdatedStatusDelayed(500);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ App.router.get('clusterController').loadUpdatedStatusDelayed(500);
|
|
|
+ }
|
|
|
+ App.router.get('backgroundOperationsController').showPopup();
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
- App.router.get('backgroundOperationsController').showPopup();
|
|
|
-
|
|
|
- });
|
|
|
+ /**
|
|
|
+ * Deletes the given host component, or all host components.
|
|
|
+ *
|
|
|
+ * @param component When <code>null</code> all host components are deleted.
|
|
|
+ * @return <code>null</code> when components get deleted.
|
|
|
+ * <code>{xhr: XhrObj, url: "http://", method: "DELETE"}</code>
|
|
|
+ * when components failed to get deleted.
|
|
|
+ */
|
|
|
+ _doDeleteHostComponent: function(component) {
|
|
|
+ var url = component !== null ?
|
|
|
+ '/hosts/' + this.get('content.hostName') + '/host_components/' + component.get('componentName').toUpperCase() :
|
|
|
+ '/hosts/' + this.get('content.hostName') + '/host_components';
|
|
|
+ url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + url;
|
|
|
+ var deleted = null;
|
|
|
+ $.ajax({
|
|
|
+ type: 'DELETE',
|
|
|
+ url: url,
|
|
|
+ timeout: App.timeout,
|
|
|
+ async: false,
|
|
|
+ success: function (data) {
|
|
|
+ deleted = null;
|
|
|
+ // If ZooKeeper Server component was removed,
|
|
|
+ // restart ZooKeeper service.
|
|
|
+ /*
|
|
|
+ * Commenting it out as user can restart service
|
|
|
+ * whenever they want. We mention in message.
|
|
|
+ if (component.get('componentName') === 'ZOOKEEPER_SERVER') {
|
|
|
+ App.ajax.send({
|
|
|
+ 'name': 'service.item.start_stop',
|
|
|
+ 'sender': this,
|
|
|
+ 'data': {
|
|
|
+ 'requestInfo': 'Stop ZooKeeper',
|
|
|
+ 'serviceName': 'ZOOKEEPER',
|
|
|
+ 'state': 'INSTALLED'
|
|
|
+ },
|
|
|
+ 'callback': function() {
|
|
|
+ App.ajax.send({
|
|
|
+ 'name': 'service.item.start_stop',
|
|
|
+ 'sender': this,
|
|
|
+ 'data': {
|
|
|
+ 'requestInfo': 'Start ZooKeeper',
|
|
|
+ 'serviceName': 'ZOOKEEPER',
|
|
|
+ 'state': 'STARTED'
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }*/
|
|
|
+ },
|
|
|
+ error: function (xhr, textStatus, errorThrown) {
|
|
|
+ console.log('Error deleting host component');
|
|
|
+ console.log(textStatus);
|
|
|
+ console.log(errorThrown);
|
|
|
+ deleted = {xhr: xhr, url: url, method: 'DELETE'};
|
|
|
+ },
|
|
|
+ statusCode: require('data/statusCodes')
|
|
|
});
|
|
|
+ return deleted;
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -176,36 +268,68 @@ App.MainHostDetailsController = Em.Controller.extend({
|
|
|
var self = this;
|
|
|
App.showConfirmationPopup(function() {
|
|
|
var component = event.context;
|
|
|
- self.sendCommandToServer('/hosts/' + self.get('content.hostName') + '/host_components/' + component.get('componentName').toUpperCase(),{
|
|
|
- RequestInfo : {
|
|
|
- "context" : Em.I18n.t('requestInfo.stopHostComponent')+ " " + component.get('displayName')
|
|
|
- },
|
|
|
- Body:{
|
|
|
- HostRoles:{
|
|
|
- state: 'INSTALLED'
|
|
|
- }
|
|
|
+ var context = Em.I18n.t('requestInfo.stopHostComponent')+ " " + component.get('displayName');
|
|
|
+ self.sendStopComponentCommand(component, context);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * PUTs a command to server to stop a component. If no
|
|
|
+ * specific component is provided, all components are stopped.
|
|
|
+ * @param component When <code>null</code> all components are stopped.
|
|
|
+ * @param context Context under which this command is beign sent.
|
|
|
+ */
|
|
|
+ sendStopComponentCommand: function(component, context){
|
|
|
+ var url = component !== null ?
|
|
|
+ '/hosts/' + this.get('content.hostName') + '/host_components/' + component.get('componentName').toUpperCase() :
|
|
|
+ '/hosts/' + this.get('content.hostName') + '/host_components';
|
|
|
+ var dataToSend = {
|
|
|
+ RequestInfo : {
|
|
|
+ "context" : context
|
|
|
+ },
|
|
|
+ Body:{
|
|
|
+ HostRoles:{
|
|
|
+ state: 'INSTALLED'
|
|
|
}
|
|
|
- }, 'PUT',
|
|
|
- function(requestId){
|
|
|
- if(!requestId){
|
|
|
- return;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ if (component === null) {
|
|
|
+ var allComponents = this.get('content.hostComponents');
|
|
|
+ var startable = [];
|
|
|
+ allComponents.forEach(function (c) {
|
|
|
+ if (c.get('isMaster') || c.get('isSlave')) {
|
|
|
+ startable.push(c.get('componentName'));
|
|
|
}
|
|
|
+ });
|
|
|
+ dataToSend.RequestInfo.query = "HostRoles/component_name.in(" + startable.join(',') + ")";
|
|
|
+ }
|
|
|
+ this.sendCommandToServer( url, dataToSend, 'PUT',
|
|
|
+ function(requestId){
|
|
|
+ if(!requestId){
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- console.log('Send request for STOPPING successfully');
|
|
|
+ console.log('Send request for STOPPING successfully');
|
|
|
|
|
|
- if (App.testMode) {
|
|
|
+ if (App.testMode) {
|
|
|
+ if(component === null){
|
|
|
+ var allComponents = this.get('content.hostComponents');
|
|
|
+ allComponents.forEach(function(component){
|
|
|
+ component.set('workStatus', App.HostComponentStatus.stopping);
|
|
|
+ setTimeout(function(){
|
|
|
+ component.set('workStatus', App.HostComponentStatus.stopped);
|
|
|
+ },App.testModeDelayForActions);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
component.set('workStatus', App.HostComponentStatus.stopping);
|
|
|
setTimeout(function(){
|
|
|
component.set('workStatus', App.HostComponentStatus.stopped);
|
|
|
},App.testModeDelayForActions);
|
|
|
- } else {
|
|
|
- App.router.get('clusterController').loadUpdatedStatusDelayed(500);
|
|
|
}
|
|
|
-
|
|
|
- App.router.get('backgroundOperationsController').showPopup();
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
+ } else {
|
|
|
+ App.router.get('clusterController').loadUpdatedStatusDelayed(500);
|
|
|
+ }
|
|
|
+ App.router.get('backgroundOperationsController').showPopup();
|
|
|
});
|
|
|
},
|
|
|
|
|
@@ -217,6 +341,7 @@ App.MainHostDetailsController = Em.Controller.extend({
|
|
|
var self = this;
|
|
|
var component = event.context;
|
|
|
var componentName = component.get('componentName').toUpperCase().toString();
|
|
|
+ var subComponentNames = component.get('subComponentNames');
|
|
|
var displayName = component.get('displayName');
|
|
|
|
|
|
var securityEnabled = App.router.get('mainAdminSecurityController').getUpdatedSecurityStatus();
|
|
@@ -227,19 +352,40 @@ App.MainHostDetailsController = Em.Controller.extend({
|
|
|
}, Em.I18n.t('hosts.host.addComponent.securityNote').format(componentName,self.get('content.hostName')));
|
|
|
}
|
|
|
else {
|
|
|
+ var dn = displayName;
|
|
|
+ if (subComponentNames !== null && subComponentNames.length > 0) {
|
|
|
+ var dns = [];
|
|
|
+ subComponentNames.forEach(function(scn){
|
|
|
+ dns.push(App.format.role(scn));
|
|
|
+ });
|
|
|
+ dn += " ("+dns.join(", ")+")";
|
|
|
+ }
|
|
|
+ var dialogContent =
|
|
|
+ [Em.I18n.t('hosts.host.addComponent.msg').format(dn) + "<br><br>",
|
|
|
+ '{{t hosts.host.addComponent.note}}'];
|
|
|
App.ModalPopup.show({
|
|
|
primary: Em.I18n.t('yes'),
|
|
|
secondary: Em.I18n.t('no'),
|
|
|
header: Em.I18n.t('popup.confirmation.commonHeader'),
|
|
|
bodyClass: Ember.View.extend({
|
|
|
- template: Ember.Handlebars.compile([
|
|
|
- '{{t hosts.delete.popup.body}}<br><br>',
|
|
|
- '{{t hosts.host.addComponent.note}}'
|
|
|
- ].join(''))
|
|
|
+ template: Ember.Handlebars.compile(dialogContent.join(''))
|
|
|
}),
|
|
|
onPrimary: function () {
|
|
|
this.hide();
|
|
|
- self.primary(component);
|
|
|
+ if (component.get('componentName') === 'CLIENTS') {
|
|
|
+ // Clients component has many sub-components which
|
|
|
+ // need to be installed.
|
|
|
+ var scs = component.get('subComponentNames');
|
|
|
+ scs.forEach(function (sc) {
|
|
|
+ var c = Em.Object.create({
|
|
|
+ displayName: App.format.role(sc),
|
|
|
+ componentName: sc
|
|
|
+ });
|
|
|
+ self.primary(c);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ self.primary(component);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -483,43 +629,116 @@ App.MainHostDetailsController = Em.Controller.extend({
|
|
|
App.router.get('backgroundOperationsController').showPopup();
|
|
|
});
|
|
|
},
|
|
|
+
|
|
|
+ doAction: function(option) {
|
|
|
+ switch (option.context.action) {
|
|
|
+ case "deleteHost":
|
|
|
+ this.validateAndDeleteHost();
|
|
|
+ break;
|
|
|
+ case "startAllComponents":
|
|
|
+ this.doStartAllComponents();
|
|
|
+ break;
|
|
|
+ case "stopAllComponents":
|
|
|
+ this.doStopAllComponents();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ doStartAllComponents: function() {
|
|
|
+ var self = this;
|
|
|
+ var components = this.get('content.hostComponents');
|
|
|
+ var componentsLength = components == null ? 0 : components.get('length');
|
|
|
+ if (componentsLength > 0) {
|
|
|
+ App.showConfirmationPopup(function() {
|
|
|
+ self.sendStartComponentCommand(null,
|
|
|
+ Em.I18n.t('hosts.host.maintainance.startAllComponents.context'));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ doStopAllComponents: function() {
|
|
|
+ var self = this;
|
|
|
+ var components = this.get('content.hostComponents');
|
|
|
+ var componentsLength = components == null ? 0 : components.get('length');
|
|
|
+ if (componentsLength > 0) {
|
|
|
+ App.showConfirmationPopup(function() {
|
|
|
+ self.sendStopComponentCommand(null,
|
|
|
+ Em.I18n.t('hosts.host.maintainance.stopAllComponents.context'));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
/**
|
|
|
* Deletion of hosts not supported for this version
|
|
|
- *
|
|
|
- * validateDeletion: function () { var slaveComponents = [ 'DataNode',
|
|
|
- * 'TaskTracker', 'RegionServer' ]; var masterComponents = []; var
|
|
|
- * workingComponents = [];
|
|
|
- *
|
|
|
- * var components = this.get('content.components');
|
|
|
- * components.forEach(function (cInstance) { var cName =
|
|
|
- * cInstance.get('componentName'); if (slaveComponents.contains(cName)) { if
|
|
|
- * (cInstance.get('workStatus') === App.HostComponentStatus.stopped &&
|
|
|
- * !cInstance.get('decommissioned')) { workingComponents.push(cName); } } else {
|
|
|
- * masterComponents.push(cName); } }); // debugger; if
|
|
|
- * (workingComponents.length || masterComponents.length) {
|
|
|
- * this.raiseWarning(workingComponents, masterComponents); } else {
|
|
|
- * this.deleteButtonPopup(); } },
|
|
|
*/
|
|
|
-
|
|
|
- raiseWarning: function (workingComponents, masterComponents) {
|
|
|
+ validateAndDeleteHost: function () {
|
|
|
+ if (!App.supports.deleteHost) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var stoppedStates = [App.HostComponentStatus.stopped,
|
|
|
+ App.HostComponentStatus.install_failed,
|
|
|
+ App.HostComponentStatus.upgrade_failed];
|
|
|
+ var masterComponents = [];
|
|
|
+ var runningComponents = [];
|
|
|
+ var unknownComponents = [];
|
|
|
+ var nonDeletableComponents = [];
|
|
|
+ var components = this.get('content.hostComponents');
|
|
|
+ if (components!=null && components.get('length')>0){
|
|
|
+ components.forEach(function (cInstance) {
|
|
|
+ var workStatus = cInstance.get('workStatus');
|
|
|
+ if (cInstance.get('isMaster') && !cInstance.get('isDeletable')) {
|
|
|
+ masterComponents.push(cInstance.get('displayName'));
|
|
|
+ }
|
|
|
+ if (stoppedStates.indexOf(workStatus) < 0) {
|
|
|
+ runningComponents.push(cInstance.get('displayName'));
|
|
|
+ }
|
|
|
+ if (!cInstance.get('isDeletable')) {
|
|
|
+ nonDeletableComponents.push(cInstance.get('displayName'));
|
|
|
+ }
|
|
|
+ if (workStatus === App.HostComponentStatus.unknown) {
|
|
|
+ unknownComponents.push(cInstance.get('displayName'));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (masterComponents.length > 0) {
|
|
|
+ var bodyHtml = "<p><i class=\"icon-warning-sign\"></i> ";
|
|
|
+ bodyHtml += Em.I18n.t('hosts.cant.do.popup.masterList.body').format(masterComponents.length);
|
|
|
+ bodyHtml += "</p><i>";
|
|
|
+ bodyHtml += masterComponents.join(", ");
|
|
|
+ bodyHtml += "</i>";
|
|
|
+ this.raiseDeleteComponentsError(bodyHtml);
|
|
|
+ return;
|
|
|
+ } else if (nonDeletableComponents.length > 0) {
|
|
|
+ var bodyHtml = "<p><i class=\"icon-warning-sign\"></i> ";
|
|
|
+ bodyHtml += Em.I18n.t('hosts.cant.do.popup.nonDeletableList.body').format(nonDeletableComponents.length);
|
|
|
+ bodyHtml += "</p><i>";
|
|
|
+ bodyHtml += nonDeletableComponents.join(", ");
|
|
|
+ bodyHtml += "</i>";
|
|
|
+ this.raiseDeleteComponentsError(bodyHtml);
|
|
|
+ return;
|
|
|
+ } else if(runningComponents.length > 0) {
|
|
|
+ var bodyHtml = "<p><i class=\"icon-warning-sign\"></i> ";
|
|
|
+ bodyHtml += Em.I18n.t('hosts.cant.do.popup.runningList.body').format(runningComponents.length);
|
|
|
+ bodyHtml += "</p><i>";
|
|
|
+ bodyHtml += runningComponents.join(", ");
|
|
|
+ bodyHtml += "</i><br><br><p>";
|
|
|
+ bodyHtml += Em.I18n.t('hosts.cant.do.popup.runningList.body.end');
|
|
|
+ bodyHtml += "</p>";
|
|
|
+ this.raiseDeleteComponentsError(bodyHtml);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this._doDeleteHost(unknownComponents);
|
|
|
+ },
|
|
|
+
|
|
|
+ raiseDeleteComponentsError: function (bodyHtml) {
|
|
|
var self = this;
|
|
|
- var masterString = '';
|
|
|
- var workingString = '';
|
|
|
- if(masterComponents && masterComponents.length) {
|
|
|
- var masterList = masterComponents.join(', ');
|
|
|
- var ml_text = Em.I18n.t('hosts.cant.do.popup.masterList.body');
|
|
|
- masterString = ml_text.format(masterList);
|
|
|
- }
|
|
|
- if(workingComponents && workingComponents.length) {
|
|
|
- var workingList = workingComponents.join(', ');
|
|
|
- var wl_text = Em.I18n.t('hosts.cant.do.popup.workingList.body');
|
|
|
- workingString = wl_text.format(workingList);
|
|
|
- }
|
|
|
App.ModalPopup.show({
|
|
|
- header: Em.I18n.t('hosts.cant.do.popup.header'),
|
|
|
+ header: Em.I18n.t('hosts.cant.do.popup.title'),
|
|
|
html: true,
|
|
|
- body: masterString + workingString,
|
|
|
+ encodeBody: false,
|
|
|
+ body: bodyHtml,
|
|
|
primary: Em.I18n.t('ok'),
|
|
|
secondary: null,
|
|
|
onPrimary: function() {
|
|
@@ -531,19 +750,73 @@ App.MainHostDetailsController = Em.Controller.extend({
|
|
|
/**
|
|
|
* show confirmation popup to delete host
|
|
|
*/
|
|
|
- deleteButtonPopup: function() {
|
|
|
+ _doDeleteHost: function(unknownComponents) {
|
|
|
var self = this;
|
|
|
- App.showConfirmationPopup(function(){
|
|
|
- self.removeHost();
|
|
|
- });
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * remove host and open hosts page
|
|
|
- */
|
|
|
- removeHost: function () {
|
|
|
- App.router.get('mainHostController').checkRemoved(this.get('content.id'));
|
|
|
- App.router.transitionTo('hosts');
|
|
|
+ var bodyHtml = "<p><i class=\"icon-warning-sign\"></i> ";
|
|
|
+ bodyHtml += Em.I18n.t('hosts.delete.popup.body').format("<i>"+this.get('content.publicHostName')+"</i>");
|
|
|
+ bodyHtml += "</p>";
|
|
|
+ if (unknownComponents!=null && unknownComponents.length > 0) {
|
|
|
+ bodyHtml += "<div class=\"alert\">";
|
|
|
+ bodyHtml += Em.I18n.t('hosts.delete.popup.unknownComponents') + "<br>";
|
|
|
+ bodyHtml += "<i>"
|
|
|
+ bodyHtml += unknownComponents.join(", ");
|
|
|
+ bodyHtml += "</i></div>";
|
|
|
+ }
|
|
|
+ bodyHtml += "<p>";
|
|
|
+ bodyHtml += Em.I18n.t('hosts.delete.popup.body.msg1');
|
|
|
+ bodyHtml += "</p><p>";
|
|
|
+ bodyHtml += Em.I18n.t('hosts.delete.popup.body.msg2');
|
|
|
+ bodyHtml += "</p><p>";
|
|
|
+ bodyHtml += "<span class=\"label label-important\">"+Em.I18n.t('common.important')+"</span> ";
|
|
|
+ bodyHtml += Em.I18n.t('hosts.delete.popup.body.msg3');
|
|
|
+ bodyHtml += "</p>";
|
|
|
+ App.ModalPopup.show({
|
|
|
+ header: Em.I18n.t('hosts.delete.popup.title'),
|
|
|
+ html: true,
|
|
|
+ encodeBody: false,
|
|
|
+ body: bodyHtml,
|
|
|
+ primary: Em.I18n.t('ok'),
|
|
|
+ secondary: Em.I18n.t('common.cancel'),
|
|
|
+ onPrimary: function() {
|
|
|
+ var dialogSelf = this;
|
|
|
+ var allComponents = self.get('content.hostComponents');
|
|
|
+ var deleteError = null;
|
|
|
+ allComponents.forEach(function(component){
|
|
|
+ if (!deleteError) {
|
|
|
+ deleteError = self._doDeleteHostComponent(component);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (!deleteError) {
|
|
|
+ var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/hosts/' + self.get('content.hostName');
|
|
|
+ $.ajax({
|
|
|
+ type: 'DELETE',
|
|
|
+ url: url,
|
|
|
+ timeout: App.timeout,
|
|
|
+ async: false,
|
|
|
+ success: function (data) {
|
|
|
+ dialogSelf.hide();
|
|
|
+ App.router.get('updateController').updateAll();
|
|
|
+ App.router.transitionTo('hosts.index');
|
|
|
+ },
|
|
|
+ error: function (xhr, textStatus, errorThrown) {
|
|
|
+ console.log('Error deleting host component');
|
|
|
+ console.log(textStatus);
|
|
|
+ console.log(errorThrown);
|
|
|
+ dialogSelf.hide();
|
|
|
+ xhr.responseText = "{\"message\": \"" + xhr.statusText + "\"}";
|
|
|
+ App.ajax.defaultErrorHandler(xhr, url, 'DELETE', xhr.status);
|
|
|
+ },
|
|
|
+ statusCode: require('data/statusCodes')
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ dialogSelf.hide();
|
|
|
+ deleteError.xhr.responseText = "{\"message\": \"" + deleteError.xhr.statusText + "\"}";
|
|
|
+ App.ajax.defaultErrorHandler(deleteError.xhr, deleteError.url, deleteError.method, deleteError.xhr.status);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onSecondary: function() {
|
|
|
+ this.hide();
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
-
|
|
|
})
|