ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject ambari git commit: AMBARI-14691 Service uninstall: Integration with API. (atkach)
Date Mon, 18 Jan 2016 10:50:14 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 8f2c5dd1e -> 4876cf610


AMBARI-14691 Service uninstall: Integration with API. (atkach)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4876cf61
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4876cf61
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4876cf61

Branch: refs/heads/trunk
Commit: 4876cf6109a33bef6c44705df2b49f3f8341850b
Parents: 8f2c5dd
Author: Andrii Tkach <atkach@hortonworks.com>
Authored: Fri Jan 15 15:56:43 2016 +0200
Committer: Andrii Tkach <atkach@hortonworks.com>
Committed: Mon Jan 18 12:46:10 2016 +0200

----------------------------------------------------------------------
 ambari-web/app/controllers/main/service/item.js | 57 +++++++++++++++++++-
 ambari-web/app/utils/ajax/ajax.js               |  5 ++
 .../test/controllers/main/service/item_test.js  | 41 ++++++++++++++
 3 files changed, 101 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4876cf61/ambari-web/app/controllers/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/item.js b/ambari-web/app/controllers/main/service/item.js
index 85e7910..260b1d2 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -1009,15 +1009,48 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
    * @param {string} serviceName
    */
   confirmDeleteService: function (serviceName) {
-    var message = Em.I18n.t('services.service.confirmDelete.popup.body').format(App.format.role(serviceName));
-    var confirmKey = 'yes';
+    var message = Em.I18n.t('services.service.confirmDelete.popup.body').format(App.format.role(serviceName)),
+        confirmKey = 'yes',
+        self = this;
 
     App.ModalPopup.show({
+
+      /**
+       * @function onPrimary
+       */
+      onPrimary: function() {
+        self.deleteServiceCall(serviceName);
+        this._super();
+      },
+
+      /**
+       * @type {string}
+       */
       primary: Em.I18n.t('common.delete'),
+
+      /**
+       * @type {string}
+       */
       primaryClass: 'btn-danger',
+
+      /**
+       * @type {string}
+       */
       header: Em.I18n.t('services.service.confirmDelete.popup.header'),
+
+      /**
+       * @type {string}
+       */
       confirmInput: '',
+
+      /**
+       * @type {boolean}
+       */
       disablePrimary: Em.computed.notEqual('confirmInput', confirmKey),
+
+      /**
+       * @type {Em.View}
+       */
       bodyClass: Em.View.extend({
         confirmKey: confirmKey,
         template: Em.Handlebars.compile(message +
@@ -1027,6 +1060,26 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
         '</form>')
       })
     });
+  },
+
+  /**
+   * Ajax call to delete service
+   * @param {string} serviceName
+   * @returns {$.ajax}
+   */
+  deleteServiceCall: function(serviceName) {
+    return App.ajax.send({
+      name : 'service.item.delete',
+      sender: this,
+      data : {
+        serviceName : serviceName
+      },
+      success : 'deleteServiceCallSuccessCallback'
+    });
+  },
+
+  deleteServiceCallSuccessCallback: function(data, ajaxOptions, params) {
+    window.location.reload();
   }
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/4876cf61/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index b52bcfe..a7c9e4e 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -498,6 +498,11 @@ var urls = {
       };
     }
   },
+  'service.item.delete': {
+    'real': '/clusters/{clusterName}/services/{serviceName}',
+    'mock': '',
+    'type': 'DELETE'
+  },
   'service.item.smoke': {
     'real': '/clusters/{clusterName}/requests',
     'mock': '/data/wizard/deploy/poll_1.json',

http://git-wip-us.apache.org/repos/asf/ambari/blob/4876cf61/ambari-web/test/controllers/main/service/item_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/item_test.js b/ambari-web/test/controllers/main/service/item_test.js
index 4fe46dc..98ff890 100644
--- a/ambari-web/test/controllers/main/service/item_test.js
+++ b/ambari-web/test/controllers/main/service/item_test.js
@@ -1267,4 +1267,45 @@ describe('App.MainServiceItemController', function () {
     });
   });
 
+  describe("#deleteServiceCall()", function() {
+    var mainServiceItemController;
+
+    beforeEach(function() {
+      mainServiceItemController = App.MainServiceItemController.create({});
+      sinon.stub(App.ajax, 'send');
+    });
+    afterEach(function() {
+      App.ajax.send.restore();
+    });
+
+    it("App.ajax.send should be called", function() {
+      mainServiceItemController.deleteServiceCall('S1');
+      expect(App.ajax.send.getCall(0).args[0]).to.eql({
+        name : 'service.item.delete',
+        sender: mainServiceItemController,
+        data : {
+          serviceName : 'S1'
+        },
+        success : 'deleteServiceCallSuccessCallback'
+      })
+    });
+  });
+
+  describe("#deleteServiceCallSuccessCallback()", function() {
+    var mainServiceItemController;
+
+    beforeEach(function() {
+      mainServiceItemController = App.MainServiceItemController.create({});
+      sinon.stub(window.location, 'reload');
+    });
+    afterEach(function() {
+      window.location.reload.restore();
+    });
+
+    it("window.location.reload should be called", function() {
+      mainServiceItemController.deleteServiceCallSuccessCallback();
+      expect(window.location.reload.calledOnce).to.be.true;
+    });
+  });
+
 });


Mime
View raw message