Prechádzať zdrojové kódy

AMBARI-7290. Usability: show 'Restart Required' bar on Summary tab.(xiwang)

Xi Wang 10 rokov pred
rodič
commit
1dcb9dc62e

+ 5 - 4
ambari-web/app/controllers/main/service/info/configs.js

@@ -2328,9 +2328,10 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
    * trigger showItemsShouldBeRestarted popup with hosts that requires resetart
    * @method showHostsShouldBeRestarted
    */
-  showHostsShouldBeRestarted: function () {
+  showHostsShouldBeRestarted: function (restartRequiredHostsAndComponents) {
     var hosts = [];
-    for (var hostName in this.get('content.restartRequiredHostsAndComponents')) {
+    var rhc = this.get('content.restartRequiredHostsAndComponents') || restartRequiredHostsAndComponents;
+    for (var hostName in rhc) {
       hosts.push(hostName);
     }
     var hostsText = hosts.length == 1 ? Em.I18n.t('common.host') : Em.I18n.t('common.hosts');
@@ -2342,8 +2343,8 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
    * trigger showItemsShouldBeRestarted popup with components that requires resetart
    * @method showComponentsShouldBeRestarted
    */
-  showComponentsShouldBeRestarted: function () {
-    var rhc = this.get('content.restartRequiredHostsAndComponents');
+  showComponentsShouldBeRestarted: function (restartRequiredHostsAndComponents) {
+    var rhc = this.get('content.restartRequiredHostsAndComponents') || restartRequiredHostsAndComponents;
     var hostsComponets = [];
     var componentsObject = {};
     for (var hostName in rhc) {

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

@@ -1066,6 +1066,19 @@ h1 {
   padding: 8px 0;
 }
 
+#summary-restart-bar {
+  margin-top: 20px;
+  .alert{
+    .icon-refresh{
+      margin-left:10px;
+      color: #fdb82f;
+    }
+  }
+  .dropdown-menu > li > a:hover {
+    text-shadow: none;
+  }
+}
+
 #serviceConfig {
   margin-top: 20px;
   .alert{
@@ -5597,6 +5610,7 @@ ul.inline li {
     width:757px!important
   }
 
+
   .assign-masters {
     .host-assignments {
       margin-left: 0;

+ 1 - 1
ambari-web/app/templates/main/service/info/configs.hbs

@@ -23,7 +23,7 @@
         {{#if App.isAdmin}}
           <div>
             <div class="alert alert-warning clearfix">
-              <i class="icon-refresh"></i> {{{view.needToRestartMessage}}} {{t services.service.config.restartService.needToRestart}}  <a href="#" {{action showComponentsShouldBeRestarted target="controller"}}>{{view.componentsCount}} {{pluralize view.componentsCount singular="t:common.component" plural="t:common.components"}}</a> {{t on}} <a href="#" {{action showHostsShouldBeRestarted target="controller"}}>{{view.hostsCount}} {{pluralize view.hostsCount singular="t:common.host" plural="t:common.hosts"}}</a>
+              <i class="icon-refresh"></i> {{t services.service.config.restartService.needToRestart}}  <a href="#" {{action showComponentsShouldBeRestarted target="controller"}}>{{view.componentsCount}} {{pluralize view.componentsCount singular="t:common.component" plural="t:common.components"}}</a> {{t on}} <a href="#" {{action showHostsShouldBeRestarted target="controller"}}>{{view.hostsCount}} {{pluralize view.hostsCount singular="t:common.host" plural="t:common.hosts"}}</a>
               <span class="restart-components pull-right">&nbsp</span>
               <div class="btn-group pull-right">
                 <button type="button" class="btn btn-default dropdown-toggle btn-warning" data-toggle="dropdown">

+ 25 - 1
ambari-web/app/templates/main/service/info/summary.hbs

@@ -16,9 +16,33 @@
 * limitations under the License.
 }}
 
+{{#if App.supports.hostOverrides}}
+  {{#if view.service.isRestartRequired}}
+    {{#if App.isAdmin}}
+      <div id="summary-restart-bar">
+        <div class="alert alert-warning clearfix">
+          <i class="icon-refresh"></i> {{{view.needToRestartMessage}}} {{t services.service.config.restartService.needToRestart}}  <a href="#" {{action showComponentsShouldBeRestarted target="view"}}>{{view.componentsCount}} {{pluralize view.componentsCount singular="t:common.component" plural="t:common.components"}}</a> {{t on}} <a href="#" {{action showHostsShouldBeRestarted target="view"}}>{{view.hostsCount}} {{pluralize view.hostsCount singular="t:common.host" plural="t:common.hosts"}}</a>
+          <span class="restart-components pull-right">&nbsp</span>
+          <div class="btn-group pull-right">
+            <button type="button" class="btn btn-default dropdown-toggle btn-warning" data-toggle="dropdown">
+              {{t hosts.host.details.needToRestart.button}}
+                <span class="caret"></span>
+            </button>
+            <ul class="dropdown-menu">
+                <li><a href="#" {{action restartAllStaleConfigComponents target="view"}}>{{t restart.service.all}}</a></li>
+              {{#if view.rollingRestartSlaveComponentName}}
+                  <li><a href="#" {{action rollingRestartStaleConfigSlaveComponents view.rollingRestartSlaveComponentName target="view"}}>{{view.rollingRestartActionName}}</a></li>
+              {{/if}}
+            </ul>
+          </div>
+        </div>
+      </div>
+    {{/if}}
+  {{/if}}
+{{/if}}
+
 <div class="row-fluid service-block">
   <div class="span6">
-
     <div class="box">
       <div class="box-header">
         <h4>{{controller.content.label}} {{t services.service.info.menu.summary}}</h4>

+ 62 - 0
ambari-web/app/views/main/service/info/summary.js

@@ -16,6 +16,7 @@
  */
 
 var App = require('app');
+var batchUtils = require('utils/batch_scheduled_requests');
 require('views/main/service/service');
 
 App.AlertItemView = Em.View.extend({
@@ -252,6 +253,67 @@ App.MainServiceInfoSummaryView = Em.View.extend({
 
   oldServiceName:'',
 
+  /*
+   * 'Restart Required bar' start
+   */
+  componentsCount: null,
+  hostsCount: null,
+
+  restartRequiredHostsAndComponents:function () {
+    return this.get('controller.content.restartRequiredHostsAndComponents');
+  }.property('controller.content.restartRequiredHostsAndComponents'),
+
+  updateComponentInformation: function() {
+    var hc = this.get('restartRequiredHostsAndComponents');
+    var hostsCount = 0;
+    var componentsCount = 0;
+    for (var host in hc) {
+      hostsCount++;
+      componentsCount += hc[host].length;
+    }
+    this.set('componentsCount', componentsCount);
+    this.set('hostsCount', hostsCount);
+  }.observes('restartRequiredHostsAndComponents'),
+
+  rollingRestartSlaveComponentName : function() {
+    return batchUtils.getRollingRestartComponentName(this.get('serviceName'));
+  }.property('serviceName'),
+  rollingRestartActionName : function() {
+    var label = null;
+    var componentName = this.get('rollingRestartSlaveComponentName');
+    if (componentName) {
+      label = Em.I18n.t('rollingrestart.dialog.title').format(App.format.role(componentName));
+    }
+    return label;
+  }.property('rollingRestartSlaveComponentName'),
+  showComponentsShouldBeRestarted: function () {
+    var rhc = this.get('restartRequiredHostsAndComponents');
+    App.router.get('mainServiceInfoConfigsController').showComponentsShouldBeRestarted(rhc);
+  },
+  showHostsShouldBeRestarted: function () {
+    var rhc = this.get('restartRequiredHostsAndComponents');
+    App.router.get('mainServiceInfoConfigsController').showHostsShouldBeRestarted(rhc);
+  },
+  restartAllStaleConfigComponents: function () {
+    var self = this;
+    var serviceDisplayName = this.get('service.displayName');
+    var bodyMessage = Em.Object.create({
+      confirmMsg: Em.I18n.t('services.service.restartAll.confirmMsg').format(serviceDisplayName),
+      confirmButton: Em.I18n.t('services.service.restartAll.confirmButton'),
+      additionalWarningMsg: this.get('service.passiveState') === 'OFF' ? Em.I18n.t('services.service.restartAll.warningMsg.turnOnMM').format(serviceDisplayName) : null
+    });
+    return App.showConfirmationFeedBackPopup(function (query) {
+      var selectedService = self.get('service.id');
+      batchUtils.restartAllServiceHostComponents(selectedService, true, query);
+    }, bodyMessage);
+  },
+  rollingRestartStaleConfigSlaveComponents: function (componentName) {
+    batchUtils.launchHostComponentRollingRestart(componentName.context, this.get('service.displayName'), this.get('service.passiveState') === "ON", true);
+  },
+  /*
+   * 'Restart Required bar' ended
+   */
+
   /**
    * Contains graphs for this particular service
    */