瀏覽代碼

AMBARI-10130. Add ability to change rack directly in hosts table. (akovalenko)

Aleksandr Kovalenko 10 年之前
父節點
當前提交
d461e3330e

+ 12 - 0
ambari-web/app/controllers/main/host.js

@@ -948,6 +948,18 @@ App.MainHostController = Em.ArrayController.extend(App.TableServerMixin, {
       }
     });
   },
+
+  /**
+   * Call <code>setRackInfo</code> function to show Set Rack Id popup
+   * @param data
+   */
+  setRackId: function (data) {
+    var rack = data.context.get('rack');
+    var hosts = [data.context];
+    var operationData = {message: Em.I18n.t('hosts.host.details.setRackId')};
+    hostsManagement.setRackInfo(operationData, hosts, rack);
+  },
+
   /**
    * associations between host property and column index
    * @type {Array}

+ 4 - 0
ambari-web/app/styles/application.less

@@ -2870,6 +2870,10 @@ table.graphs {
 	thead {
       background: none repeat scroll 0 0 #F8F8F8;
     }
+
+    .set-rack-id {
+      text-decoration: none;
+    }
   }
 
   .status-dot-position {

+ 3 - 1
ambari-web/app/templates/main/host.hbs

@@ -129,7 +129,9 @@
           </td>
           <td class="host-ip">{{host.ip}}</td>
           {{#if App.supports.setRackId}}
-            <td>{{host.rack}}</td>
+            <td>
+              {{host.rack}} <a class="set-rack-id" {{action setRackId host target="controller"}}><i class="icon-pencil"></i></a>
+            </td>
           {{/if}}
           <td class="cores-formatted">{{host.coresFormatted}}</td>
           <td class="memory-formatted">{{host.memoryFormatted}}</td>

+ 24 - 0
ambari-web/test/controllers/main/host_test.js

@@ -18,6 +18,7 @@
 
 var App = require('app');
 var validator = require('utils/validator');
+var hostsManagement = require('utils/hosts');
 require('utils/batch_scheduled_requests');
 require('controllers/main/host');
 require('mappers/server_data_mapper');
@@ -241,4 +242,27 @@ describe('MainHostController', function () {
 
   });
 
+  describe('#setRackId', function () {
+
+    beforeEach(function () {
+      sinon.stub(hostsManagement, 'setRackInfo', Em.K);
+
+    });
+
+    afterEach(function () {
+      hostsManagement.setRackInfo.restore();
+    });
+
+    it('should call setRackInfo with appropriate arguments', function () {
+      var mockedHost = Em.Object.create({
+        rack: 'rackId'
+      });
+      hostController.setRackId({
+        context: mockedHost
+      });
+      expect(hostsManagement.setRackInfo.calledWith({message: Em.I18n.t('hosts.host.details.setRackId')}, [mockedHost], 'rackId')).to.be.true;
+    });
+
+  });
+
 });