Browse Source

AMBARI-10366. Rack: ui cleanup #1 (alexantonenko)

Alex Antonenko 10 years ago
parent
commit
1afb7e6a7f

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

@@ -949,17 +949,6 @@ 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}

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

@@ -573,6 +573,17 @@ App.MainHostDetailsController = Em.Controller.extend({
     return true;
   },
 
+  /**
+   * 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);
+  },
+
   /**
    * Call load tags
    * @method checkHiveDone

+ 4 - 3
ambari-web/app/messages.js

@@ -116,7 +116,8 @@ Em.I18n.translations = {
   'common.ipAddress':'IP Address',
   'common.rack':'Rack',
   'common.cpu':'CPU',
-  'common.cores': 'Cores (CPU)',
+  'common.cores': 'Cores',
+  'common.cores.cpu': 'Cores (CPU)',
   'common.ram':'RAM',
   'common.disk':'Disk',
   'common.diskUsage':'Disk Usage',
@@ -314,7 +315,7 @@ Em.I18n.translations = {
   'hostPopup.setRackId.success': 'Updating rack id to \"{0}\". It may take a few moments for it to get refreshed.',
   'hostPopup.setRackId.error': 'Updating the rack id failed.',
   'hostPopup.setRackId.invalid': 'Should start with a forward slash it may include alphanumeric chars, dots, dashes and forward slashes.',
-  'hostPopup.RackId': 'Rack Id',
+  'hostPopup.RackId': 'Rack',
   'hostPopup.recommendation.beforeDecommission': '{0} Maintenance Mode is pre required for decommissioning.',
 
   'question.sure':'Are you sure?',
@@ -2098,7 +2099,7 @@ Em.I18n.translations = {
   'hosts.host.details.restartAllComponents':'Restart All Components',
   'hosts.host.details.refreshConfigs':'Refresh configs',
   'hosts.host.details.for.postfix':'{0} for host',
-  'hosts.host.details.setRackId':'Set Rack Id',
+  'hosts.host.details.setRackId':'Set Rack',
   'host.host.details.installClients': 'Install clients',
 
   'host.host.componentFilter.master':'Master Components',

File diff suppressed because it is too large
+ 27 - 1
ambari-web/app/styles/application.less


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

@@ -129,8 +129,8 @@
           </td>
           <td class="host-ip">{{host.ip}}</td>
           {{#if App.supports.setRackId}}
-            <td>
-              {{host.rack}} <a class="set-rack-id" {{action setRackId host target="controller"}}><i class="icon-pencil"></i></a>
+            <td rel="UsageTooltip" {{bindAttr title="host.rack"}} class="rack-id">
+              {{host.rack}}
             </td>
           {{/if}}
           <td class="cores-formatted">{{host.coresFormatted}}</td>
@@ -204,4 +204,3 @@
     </div>
   </div>
 </div>
-

+ 2 - 2
ambari-web/app/templates/main/host/summary.hbs

@@ -136,13 +136,13 @@
 
                         {{#if App.supports.setRackId}}
                           <dt>{{t common.rack}}:</dt>
-                          <dd>&nbsp;{{view.content.rack}}</dd>
+                          <dd>&nbsp;{{view.content.rack}} <a class="set-rack-id" {{action setRackId view.content target="controller"}}><i class="icon-pencil"></i></a></dd>
                         {{/if}}
 
                         <dt class="summary-os-label">{{t common.os}}:</dt>
                           <dd class="summary-os-value">&nbsp;{{view.content.osType}}&nbsp;({{view.content.osArch}})</dd>
 
-                        <dt class="summary-cores-label">{{t common.cores}}:</dt>
+                        <dt class="summary-cores-label">{{t common.cores.cpu}}:</dt>
                           <dd class="summary-cores-value">&nbsp;{{view.content.coresFormatted}}</dd>
 
                         <dt class="summary-disk-label">{{t common.disk}}:</dt>

+ 8 - 8
ambari-web/app/utils/hosts.js

@@ -5,9 +5,9 @@
  * licenses this file to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -23,13 +23,13 @@ var validator = require('utils/validator');
 module.exports = {
 
   /**
-   * Launches a dialog to select hosts from the provided available hosts. 
-   * 
-   * Once the user clicks OK or Cancel, the callback is called with the 
+   * Launches a dialog to select hosts from the provided available hosts.
+   *
+   * Once the user clicks OK or Cancel, the callback is called with the
    * array of hosts (App.Host[]) selected. If the dialog was cancelled
    * or closed, <code>null</code> is provided to the callback. Else
    * an array (maybe empty) will be provided to the callback.
-   * 
+   *
    * @param initialHosts  {App.Host[]} List of hosts to pick from
    * @param selectedHosts {App.Host[]} List of hosts already selected from the available hosts
    * @param selectAtleastOneHost  {boolean} If true atleast one host has to be selected
@@ -190,7 +190,7 @@ module.exports = {
     var hostNames = hosts.mapProperty('hostName');
     return App.ModalPopup.show({
       header: Em.I18n.t('hosts.host.details.setRackId'),
-      disablePrimary: false,
+      disablePrimary: true,
       rackId: rackId,
       bodyClass: Em.View.extend({
         templateName: require('templates/main/host/rack_id_popup'),
@@ -227,4 +227,4 @@ module.exports = {
   errorRackId: function () {
     App.showAlertPopup(Em.I18n.t('common.error'), Em.I18n.t('hostPopup.setRackId.error'));
   }
-};
+};

+ 2 - 2
ambari-web/app/utils/validator.js

@@ -206,7 +206,7 @@ module.exports = {
       return true;
     };
     if (/^[\?\|\*\!,]/.test(value)) return false;
-    return /^((\.\*?)?([\w\s\[\]\?\-_,\|\*\!\{\}]*)?)+(\.\*?)?$/g.test(value) && (checkPair(['[',']'])) && (checkPair(['{','}']));
+    return /^((\.\*?)?([\w\s\[\]\/\?\-_,\|\*\!\{\}]*)?)+(\.\*?)?$/g.test(value) && (checkPair(['[',']'])) && (checkPair(['{','}']));
   },
 
   /**
@@ -218,7 +218,7 @@ module.exports = {
       // true is there is no host with this component
       return hostComponents.filterProperty("componentName", item["component-name"]).filterProperty("hostName", item.host).length === 0;
     });
-  }, 
+  },
 
   isValidRackId: function(path) {
     // See app/message.js:hostPopup.setRackId.invalid

+ 28 - 5
ambari-web/app/views/main/host.js

@@ -362,6 +362,11 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
         break;
     }
 
+    if (operationData.action === 'SET_RACK_INFO') {
+      this.getHostsForBulkOperations(queryParams, operationData, null);
+      return;
+    }
+
     var loadingPopup = App.ModalPopup.show({
       header: Em.I18n.t('jobs.loadingTasks'),
       primary: false,
@@ -370,13 +375,22 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
         template: Ember.Handlebars.compile('<div class="spinner"></div>')
       })
     });
-    var parameters = App.router.get('updateController').computeParameters(queryParams);
-    if (!parameters.length) parameters = '&';
+
+    this.getHostsForBulkOperations(queryParams, operationData, loadingPopup);
+  },
+
+  getHostsForBulkOperations: function (queryParams, operationData, loadingPopup) {
+    var params = App.router.get('updateController').computeParameters(queryParams);
+
+    if (!params.length) {
+      params = '&';
+    }
+
     App.ajax.send({
       name: 'hosts.bulk.operations',
       sender: this,
       data: {
-        parameters: parameters.substring(0, parameters.length - 1),
+        parameters: params.substring(0, params.length - 1),
         operationData: operationData,
         loadingPopup: loadingPopup
       },
@@ -439,7 +453,16 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
     else {
       message = Em.I18n.t('hosts.bulkOperation.confirmation.hosts').format(operationData.message, hostNames.length);
     }
-    param.loadingPopup.hide();
+
+    if (param.loadingPopup) {
+      param.loadingPopup.hide();
+    }
+
+    if (operationData.action === 'SET_RACK_INFO') {
+      self.get('controller').bulkOperation(operationData, hosts);
+      return;
+    }
+
     App.ModalPopup.show({
       header: Em.I18n.t('hosts.bulkOperation.confirmation.header'),
       hostNames: hostNames.join("\n"),
@@ -853,7 +876,7 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
    */
   rackFilterView: filters.createTextView({
     column: 12,
-    fieldType: 'filter-input-width',
+    fieldType: 'filter-input-width rack-input',
     onChangeValue: function(){
       this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
     }

+ 25 - 4
ambari-web/test/controllers/main/host/details_test.js

@@ -24,6 +24,7 @@ require('models/host_component');
 require('models/host_stack_version');
 var batchUtils = require('utils/batch_scheduled_requests');
 var componentsUtils = require('utils/components');
+var hostsManagement = require('utils/hosts');
 var controller;
 
 describe('App.MainHostDetailsController', function () {
@@ -1702,6 +1703,26 @@ describe('App.MainHostDetailsController', 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'
+      });
+      controller.setRackId({
+        context: mockedHost
+      });
+      expect(hostsManagement.setRackInfo.calledWith({message: Em.I18n.t('hosts.host.details.setRackId')}, [mockedHost], 'rackId')).to.be.true;
+    });
+  });
+
   describe('#restartAllStaleConfigComponents()', function () {
 
     beforeEach(function () {
@@ -1911,13 +1932,13 @@ describe('App.MainHostDetailsController', function () {
 
   describe('#_doDeleteHostComponentSuccessCallback()', function () {
     beforeEach(function() {
-      sinon.stub(controller, 'removeHostComponentModel', Em.K);      
+      sinon.stub(controller, 'removeHostComponentModel', Em.K);
     });
-    
+
     afterEach(function() {
-      controller.removeHostComponentModel.restore();      
+      controller.removeHostComponentModel.restore();
     });
-    
+
     it('ZOOKEEPER_SERVER component', function () {
       var data = {
         componentName: 'ZOOKEEPER_SERVER'

+ 1 - 25
ambari-web/test/controllers/main/host_test.js

@@ -18,7 +18,6 @@
 
 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');
@@ -199,7 +198,7 @@ describe('MainHostController', function () {
         }];
       });
     });
-    
+
     afterEach(function() {
       App.db.getFilterConditions.restore();
       hostController.getRegExp.restore();
@@ -242,27 +241,4 @@ 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;
-    });
-
-  });
-
 });

+ 1 - 0
ambari-web/test/utils/validator_test.js

@@ -393,6 +393,7 @@ describe('validator', function () {
         { value: 'a1[1]asd[1]', expected: true },
         { value: 'a1[1]asd[1][', expected: false },
         { value: 'a1[1|1]asd[1]', expected: true },
+        { value: '/a1[1|1]asd[1]', expected: true },
         { value: 'a1-2!', expected: true },
         { value: '|a1-2', expected: false },
         { value: '[a1', expected: false },

Some files were not shown because too many files changed in this diff