Bläddra i källkod

AMBARI-4474 Maintenance Mode: Service Left Nav / Service Actions Button. (ababiichuk)

aBabiichuk 11 år sedan
förälder
incheckning
72535217cc

+ 1 - 1
ambari-web/app/controllers/global/update_controller.js

@@ -183,7 +183,7 @@ App.UpdateController = Em.Controller.extend({
   },
   updateServices: function (callback) {
     var testUrl = '/data/services/HDP2/services.json';
-    var componentConfigUrl = this.getUrl(testUrl, '/services?fields=alerts/summary,ServiceInfo/state&minimal_response=true');
+    var componentConfigUrl = this.getUrl(testUrl, '/services?fields=alerts/summary,ServiceInfo/state,ServiceInfo/passive_state&minimal_response=true');
     App.HttpClient.get(componentConfigUrl, App.serviceMapper, {
       complete: callback
     });

+ 23 - 0
ambari-web/app/controllers/main/service/item.js

@@ -193,10 +193,33 @@ App.MainServiceItemController = Em.Controller.extend({
     });
   },
 
+  turnOnOffPassive: function(label) {
+    var self = this;
+    var state = this.get('content.passiveState') == 'ACTIVE' ? 'PASSIVE' : 'ACTIVE';
+    var onOff = state === 'PASSIVE' ? "On" : "Off";
+    App.showConfirmationPopup(function() {
+          self.turnOnOffPassiveRequest(state, label)
+        },
+        Em.I18n.t('hosts.passiveMode.popup').format(onOff,self.get('content.displayName'))
+    );
+  },
+
   rollingRestart: function(hostComponentName) {
     batchUtils.launchHostComponentRollingRestart(hostComponentName, false);
   },
 
+  turnOnOffPassiveRequest: function(state,message) {
+    App.ajax.send({
+      'name': 'service.item.passive',
+      'sender': this,
+      'data': {
+        'requestInfo': message,
+        'serviceName': this.get('content.serviceName').toUpperCase(),
+        'passive_state': state
+      }
+    });
+  },
+
   runSmokeTestPrimary: function() {
     App.ajax.send({
       'name': 'service.item.smoke',

+ 2 - 1
ambari-web/app/mappers/service_mapper.js

@@ -26,7 +26,8 @@ App.serviceMapper = App.QuickDataMapper.create({
       var serviceData = {
         ServiceInfo: {
           service_name: service.ServiceInfo.service_name,
-          state: service.ServiceInfo.state
+          state: service.ServiceInfo.state,
+          passive_state: service.ServiceInfo.passive_state
         },
         host_components: [],
         components: []

+ 2 - 1
ambari-web/app/mappers/service_metrics_mapper.js

@@ -27,6 +27,7 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
     id: 'ServiceInfo.service_name',
     service_name: 'ServiceInfo.service_name',
     work_status: 'ServiceInfo.state',
+    passive_state: 'ServiceInfo.passive_state',
     critical_alerts_count: 'ServiceInfo.critical_alerts_count',
     $rand: Math.random(),
     $alerts: [ 1, 2, 3 ],
@@ -241,7 +242,7 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
         App.store.loadMany(this.get('model'), result);
       } else {
         result.forEach(function (serviceJson) {
-          var fields = ['work_status', 'rand', 'alerts', 'quick_links', 'host_components', 'tool_tip_content', 'critical_alerts_count'];
+          var fields = ['passive_state','work_status', 'rand', 'alerts', 'quick_links', 'host_components', 'tool_tip_content', 'critical_alerts_count'];
           var service = this.get('model').find(serviceJson.id);
           var modifiedData = this.getDiscrepancies(serviceJson, previousResponse.findProperty('id', serviceJson.id), fields);
           if (modifiedData.isLoadNeeded) {

+ 1 - 1
ambari-web/app/models/service.js

@@ -23,7 +23,7 @@ require('utils/config');
 App.Service = DS.Model.extend({
 
   serviceName: DS.attr('string'),
-
+  passiveState: DS.attr('string'),
   workStatus: DS.attr('string'),
   rand: DS.attr('string'),
   toolTipContent: DS.attr('string'),

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

@@ -2098,6 +2098,10 @@ width:100%;
   .operations-count {
     background: #953B39;
   }
+  .icon-medkit {
+    padding-left:6px;
+    color: black!important;
+  }
 }
 .quick-links-wrapper {
   margin-top: -53px;

+ 19 - 0
ambari-web/app/utils/ajax.js

@@ -98,6 +98,25 @@ var urls = {
       };
     }
   },
+  'service.item.passive': {
+    'real': '/clusters/{clusterName}/services/{serviceName}',
+    'mock': '',
+    'format': function (data) {
+      return {
+        type: 'PUT',
+        data: JSON.stringify({
+          RequestInfo: {
+            "context": data.requestInfo
+          },
+          Body: {
+            ServiceInfo: {
+              passive_state: data.passive_state
+            }
+          }
+        })
+      };
+    }
+  },
   'service.stale_host_components.start_stop': {
     'real': '/clusters/{clusterName}/host_components?' +
             'HostRoles/stale_configs=true&HostRoles/component_name.in({componentNames})',

+ 4 - 1
ambari-web/app/views/main/dashboard/service.js

@@ -59,6 +59,9 @@ App.MainDashboardServiceHealthView = Em.View.extend({
   },
 
   healthStatus: function () {
+    if (this.get('service.passiveState') != 'ACTIVE') {
+      return 'icon-medkit';
+    }
     var status = this.get('service.healthStatus');
     switch (status) {
       case 'green':
@@ -83,7 +86,7 @@ App.MainDashboardServiceHealthView = Em.View.extend({
     }
 
     return 'health-status-' + status;
-  }.property('service.healthStatus'),
+  }.property('service.healthStatus','service.passiveState'),
 
   didInsertElement: function () {
     this.updateToolTip();

+ 2 - 0
ambari-web/app/views/main/service/item.js

@@ -55,6 +55,8 @@ App.MainServiceItemView = Em.View.extend({
       default:
         options.push({action: 'runSmokeTest', cssClass: 'icon-thumbs-up-alt', 'label': Em.I18n.t('services.service.actions.run.smoke'), disabled:disabled});
     }
+    var passiveLabel = service.get('passiveState') === "ACTIVE" ? Em.I18n.t('passiveState.turnOn') : Em.I18n.t('passiveState.turnOff');
+    options.push({action:'turnOnOffPassive', cssClass: 'icon-medkit', context:passiveLabel, 'label':passiveLabel , disabled: false});
     return options;
   }.property('controller.content', 'controller.isStopDisabled'),
   isMaintenanceActive: function() {