You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2016/02/04 19:16:00 UTC

ambari git commit: AMBARI-14889. Auto-start services: Create cluster level toggle switch (Zhe (Joe) Wang via srimanth)

Repository: ambari
Updated Branches:
  refs/heads/trunk 7d2191c9d -> 8c6c13da3


AMBARI-14889. Auto-start services: Create cluster level toggle switch (Zhe (Joe) Wang via srimanth)


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

Branch: refs/heads/trunk
Commit: 8c6c13da3ffbf9349232dfcaa7b7504c48156fcf
Parents: 7d2191c
Author: Srimanth Gunturi <sg...@hortonworks.com>
Authored: Thu Feb 4 10:15:19 2016 -0800
Committer: Srimanth Gunturi <sg...@hortonworks.com>
Committed: Thu Feb 4 10:15:25 2016 -0800

----------------------------------------------------------------------
 ambari-web/app/config.js                        |  3 +-
 .../nameNode/rollback_controller.js             | 10 +--
 .../main/admin/service_auto_start.js            | 21 +++++-
 ambari-web/app/messages.js                      |  2 +-
 ambari-web/app/styles/application.less          |  4 ++
 ambari-web/app/styles/widgets.less              | 71 +++++++++++---------
 .../templates/main/admin/service_auto_start.hbs | 11 ++-
 ambari-web/app/utils/ajax/ajax.js               |  6 +-
 ambari-web/app/views/main/admin.js              | 12 ++--
 .../app/views/main/admin/service_auto_start.js  | 64 +++++++++++++++++-
 ambari-web/app/views/main/menu.js               | 12 ++--
 ambari-web/config.coffee                        |  2 +
 ambari-web/karma.conf.js                        |  1 +
 13 files changed, 160 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8c6c13da/ambari-web/app/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/config.js b/ambari-web/app/config.js
index f2b7938..0beafb3 100644
--- a/ambari-web/app/config.js
+++ b/ambari-web/app/config.js
@@ -79,7 +79,8 @@ App.supports = {
   skipComponentStartAfterInstall: false,
   storeKDCCredentials: true,
   preInstallChecks: false,
-  hostComboSearchBox: false
+  hostComboSearchBox: false,
+  serviceAutoStart: false
 };
 
 if (App.enableExperimental) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/8c6c13da/ambari-web/app/controllers/main/admin/highAvailability/nameNode/rollback_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/highAvailability/nameNode/rollback_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/nameNode/rollback_controller.js
index aa3d3b0..465a1d2 100644
--- a/ambari-web/app/controllers/main/admin/highAvailability/nameNode/rollback_controller.js
+++ b/ambari-web/app/controllers/main/admin/highAvailability/nameNode/rollback_controller.js
@@ -351,7 +351,7 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl
   onLoadHbaseConfigs: function (data) {
     var hbaseSiteProperties = data.items.findProperty('type', 'hbase-site').properties;
     App.ajax.send({
-      name: 'admin.high_availability.save_configs',
+      name: 'admin.save_configs',
       sender: this,
       data: {
         siteName: 'hbase-site',
@@ -364,7 +364,7 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl
   onLoadAccumuloConfigs: function (data) {
     var accumuloSiteProperties = data.items.findProperty('type', 'accumulo-site').properties;
     App.ajax.send({
-      name: 'admin.high_availability.save_configs',
+      name: 'admin.save_configs',
       sender: this,
       data: {
         siteName: 'accumulo-site',
@@ -378,7 +378,7 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl
   onLoadHawqConfigs: function (data) {
     var hawqSiteProperties = data.items.findProperty('type', 'hawq-site').properties;
     App.ajax.send({
-      name: 'admin.high_availability.save_configs',
+      name: 'admin.save_configs',
       sender: this,
       data: {
         siteName: 'hawq-site',
@@ -415,7 +415,7 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl
   onLoadConfigs: function (data) {
     this.set('configsSaved', false);
     App.ajax.send({
-      name: 'admin.high_availability.save_configs',
+      name: 'admin.save_configs',
       sender: this,
       data: {
         siteName: 'hdfs-site',
@@ -425,7 +425,7 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl
       error: 'onTaskError'
     });
     App.ajax.send({
-      name: 'admin.high_availability.save_configs',
+      name: 'admin.save_configs',
       sender: this,
       data: {
         siteName: 'core-site',

http://git-wip-us.apache.org/repos/asf/ambari/blob/8c6c13da/ambari-web/app/controllers/main/admin/service_auto_start.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/service_auto_start.js b/ambari-web/app/controllers/main/admin/service_auto_start.js
index 1af7299..fd288ed 100644
--- a/ambari-web/app/controllers/main/admin/service_auto_start.js
+++ b/ambari-web/app/controllers/main/admin/service_auto_start.js
@@ -21,10 +21,25 @@ var App = require('app');
 App.MainAdminServiceAutoStartController = Em.Controller.extend({
   name: 'mainAdminServiceAutoStartController',
 
-  overallEnabled: true,
+  loadClusterConfig: function () {
+    return App.ajax.send({
+      name: 'config.tags.site',
+      sender: this,
+      data: {
+        site: 'cluster-env'
+      }
+    });
+  },
 
-  toggleOverallEnabled : function () {
-    this.toggleProperty('overallEnabled');
+  saveClusterConfigs: function (clusterConfigs) {
+    return App.ajax.send({
+      name: 'admin.save_configs',
+      sender: this,
+      data: {
+        siteName: 'cluster-env',
+        properties: clusterConfigs
+      }
+    });
   }
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/8c6c13da/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index a5421ea..e341de4 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1459,7 +1459,7 @@ Em.I18n.translations = {
   'admin.serviceAutoStart.title': "Service Auto Start",
   'admin.serviceAutoStart.header': "Service Auto Start Configuration",
   'admin.serviceAutoStart.header.text': "Ambari services can be configured to start automatically on system boot. Each service can be configured to start all components, masters and workers, or selectively.",
-  'admin.serviceAutoStart.button.text': "Ambari services can be configured to start automatically on system boot. Each service can be configured to start all components, masters and workers, or selectively.",
+  'admin.serviceAutoStart.body.text': "Auto-Start Services Enabled",
 
   'admin.stackVersions.filter.notInstalled': "Not Installed ({0})",
   'admin.stackVersions.filter.all': "All ({0})",

http://git-wip-us.apache.org/repos/asf/ambari/blob/8c6c13da/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 731903d..ce10a98 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -3802,6 +3802,10 @@ table.graphs {
   .span6 {
     margin-left: 0 !important;
   }
+
+  .bootstrap-switch {
+    margin-left: 20px;
+  }
 }
 
 .admin-user-settings {

http://git-wip-us.apache.org/repos/asf/ambari/blob/8c6c13da/ambari-web/app/styles/widgets.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/widgets.less b/ambari-web/app/styles/widgets.less
index 2196445..f385449 100644
--- a/ambari-web/app/styles/widgets.less
+++ b/ambari-web/app/styles/widgets.less
@@ -362,46 +362,53 @@
   .undo-button {
     margin-left: @undo-btn-margin;
   }
+}
 
-  .bootstrap-switch {
-    &,
-    &.bootstrap-switch-focused {
-      border-color: transparent;
-      box-shadow: none;
-    }
+.bootstrap-switch {
+  &,
+  &.bootstrap-switch-focused {
+    border-color: transparent;
+    box-shadow: none;
+  }
 
-    .bootstrap-switch-label {
-      background-color: @toggle-widget-handle-background-color;
-      background-image: none;
+  .bootstrap-switch-label {
+    background-color: @toggle-widget-handle-background-color;
+    background-image: none;
+    text-shadow: none;
+    border-width: 0;
+    padding: 2px 8px;
+    border-left: 1px solid transparent;
+    border-right: 1px solid transparent;
+    border-bottom: 1px solid @toggle-widget-handle-background-color;
+  }
+
+  .bootstrap-switch-handle-on,
+  .bootstrap-switch-handle-off {
+    color: @toggle-widget-text-color;
+    font-size: @toggle-widget-text-size;
+    background-image: none;
+    text-shadow: none;
+    border: none;
+    padding: 2px 0;
+
+    &:hover {
       text-shadow: none;
-      border-width: 0;
-      padding: 2px 8px;
-      border-left: 1px solid transparent;
-      border-right: 1px solid transparent;
-      border-bottom: 1px solid @toggle-widget-handle-background-color;
+      color: @toggle-widget-text-color;
     }
 
-    .bootstrap-switch-handle-on,
-    .bootstrap-switch-handle-off {
+    &.bootstrap-switch-default {
+      background-color: @toggle-widget-on-background-color;
+    }
+
+    &.bootstrap-switch-success {
+      background-color: @toggle-widget-off-background-color;
+    }
+
+    &.bootstrap-switch-default,
+    &.bootstrap-switch-success {
       color: @toggle-widget-text-color;
-      font-size: @toggle-widget-text-size;
       background-image: none;
       text-shadow: none;
-      border: none;
-      padding: 2px 0;
-
-      &:hover {
-        text-shadow: none;
-        color: @toggle-widget-text-color;
-      }
-
-      &.bootstrap-switch-default {
-        background-color: @toggle-widget-on-background-color;
-      }
-
-      &.bootstrap-switch-success {
-        background-color: @toggle-widget-off-background-color;
-      }
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/8c6c13da/ambari-web/app/templates/main/admin/service_auto_start.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/admin/service_auto_start.hbs b/ambari-web/app/templates/main/admin/service_auto_start.hbs
index 3ebdb7e..b5c1032 100644
--- a/ambari-web/app/templates/main/admin/service_auto_start.hbs
+++ b/ambari-web/app/templates/main/admin/service_auto_start.hbs
@@ -24,9 +24,14 @@
     {{t admin.serviceAutoStart.header.text}}
   </div>
   <br/>
-  <div>
-    <p>{{t admin.serviceAutoStart.title}}
-        <button class="btn btn-padding btn-success" {{bindAttr class="controller.overallEnabled:btn-success::btn-warning"}} {{action toggleOverallEnabled target="controller"}}>{{view.buttonText}}</button>
+  <div class="cluster-switcher">
+    <p>{{t admin.serviceAutoStart.body.text}}
+        {{view Ember.Checkbox checkedBinding="view.switcherValue"}}
     </p>
   </div>
+    {{#if view.switcherValue}}
+        <div>
+            <hr>
+        </div>
+    {{/if}}
 </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/8c6c13da/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 5ec03d4..423941f 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -768,6 +768,10 @@ var urls = {
     'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
     'mock': '/data/clusters/cluster.json'
   },
+  'config.tags.site': {
+    'real': '/clusters/{clusterName}?fields=Clusters/desired_configs/{site}',
+    'mock': ''
+  },
   'config.tags_and_groups': {
     'real': '/clusters/{clusterName}?fields=Clusters/desired_configs,config_groups/*{urlParams}',
     'mock': '/data/clusters/tags_and_groups.json'
@@ -1390,7 +1394,7 @@ var urls = {
     'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})',
     'mock': ''
   },
-  'admin.high_availability.save_configs': {
+  'admin.save_configs': {
     'real': '/clusters/{clusterName}',
     'mock': '',
     'type': 'PUT',

http://git-wip-us.apache.org/repos/asf/ambari/blob/8c6c13da/ambari-web/app/views/main/admin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin.js b/ambari-web/app/views/main/admin.js
index fa1ce7d..8b9ec03 100644
--- a/ambari-web/app/views/main/admin.js
+++ b/ambari-web/app/views/main/admin.js
@@ -45,11 +45,13 @@ App.MainAdminView = Em.View.extend({
       });
     }
     if (App.isAuthorized('SERVICE.START_STOP')) {
-      items.push({
-        name: 'serviceAutoStart',
-        url: 'adminServiceAutoStart',
-        label: Em.I18n.t('admin.serviceAutoStart.title')
-      });
+      if (App.supports.serviceAutoStart) {
+        items.push({
+          name: 'serviceAutoStart',
+          url: 'adminServiceAutoStart',
+          label: Em.I18n.t('admin.serviceAutoStart.title')
+        });
+      }
     }
     return items;
   }.property(''),

http://git-wip-us.apache.org/repos/asf/ambari/blob/8c6c13da/ambari-web/app/views/main/admin/service_auto_start.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/service_auto_start.js b/ambari-web/app/views/main/admin/service_auto_start.js
index 15f7148..2d3ae16 100644
--- a/ambari-web/app/views/main/admin/service_auto_start.js
+++ b/ambari-web/app/views/main/admin/service_auto_start.js
@@ -20,9 +20,67 @@ var App = require('app');
 
 App.MainAdminServiceAutoStartView = Em.View.extend({
   templateName: require('templates/main/admin/service_auto_start'),
+  /**
+   * Value used in the checkbox.
+   *
+   * @property switcherValue
+   * @type {boolean}
+   */
+  switcherValue: false,
 
-  buttonText: function () {
-    return this.get('controller.overallEnabled') ? Em.I18n.t('common.enabled') : Em.I18n.t('common.disabled');
-  }.property('controller.overallEnabled')
+  clusterConfigs: null,
+
+  didInsertElement: function () {
+    var self = this;
+    this.get('controller').loadClusterConfig().done(function (data) {
+      var tag = [
+        {
+          siteName: 'cluster-env',
+          tagName: data.Clusters.desired_configs['cluster-env'].tag,
+          newTagName: null
+        }
+      ];
+      App.router.get('configurationController').getConfigsByTags(tag).done(function (data) {
+        self.set('clusterConfigs', data[0].properties);
+        self.set('switcherValue', self.get('clusterConfigs.recovery_enabled') === 'true');
+        // plugin should be initiated after applying binding for switcherValue
+        Em.run.later('sync', function() {
+          self.initSwitcher();
+        }.bind(self), 10);
+      });
+    });
+  },
+
+  /**
+   * Init switcher plugin.
+   *
+   * @method initSwitcher
+   */
+  updateClusterConfigs: function (state){
+    this.set('switcherValue', state);
+    this.set('clusterConfigs.recovery_enabled', '' + state);
+    this.get('controller').saveClusterConfigs(this.get('clusterConfigs'));
+  },
+
+  /**
+   * Init switcher plugin.
+   *
+   * @method initSwitcher
+   */
+  initSwitcher: function () {
+    var self = this;
+    if (this.$()) {
+      var switcher = this.$("input:eq(0)").bootstrapSwitch({
+        onText: Em.I18n.t('common.enabled'),
+        offText: Em.I18n.t('common.disabled'),
+        offColor: 'default',
+        onColor: 'success',
+        handleWidth: Math.max(Em.I18n.t('common.enabled').length, Em.I18n.t('common.disabled').length) * 8,
+        onSwitchChange: function (event, state) {
+          self.updateClusterConfigs(state);
+        }
+      });
+    }
+  }
 });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8c6c13da/ambari-web/app/views/main/menu.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/menu.js b/ambari-web/app/views/main/menu.js
index 5df5d73..697c85d 100644
--- a/ambari-web/app/views/main/menu.js
+++ b/ambari-web/app/views/main/menu.js
@@ -132,11 +132,13 @@ App.MainMenuView = Em.CollectionView.extend({
           });
         }
         if (App.isAuthorized('SERVICE.START_STOP')) {
-          categories.push({
-            name: 'serviceAutoStart',
-            url: 'serviceAutoStart',
-            label: Em.I18n.t('admin.serviceAutoStart.title')
-          });
+          if (App.supports.serviceAutoStart) {
+            categories.push({
+              name: 'serviceAutoStart',
+              url: 'serviceAutoStart',
+              label: Em.I18n.t('admin.serviceAutoStart.title')
+            });
+          }
         }
       }
       return categories;

http://git-wip-us.apache.org/repos/asf/ambari/blob/8c6c13da/ambari-web/config.coffee
----------------------------------------------------------------------
diff --git a/ambari-web/config.coffee b/ambari-web/config.coffee
index de8566a..6ed0915 100644
--- a/ambari-web/config.coffee
+++ b/ambari-web/config.coffee
@@ -42,6 +42,7 @@ exports.config =
           'vendor/scripts/bootstrap-combobox.js',
           'vendor/scripts/bootstrap-checkbox.js',
           'vendor/scripts/bootstrap-slider.min.js',
+          'vendor/scripts/bootstrap-switch.min.js',
           'vendor/scripts/d3.v2.js',
           'vendor/scripts/cubism.v1.js',
           'vendor/scripts/jquery.ui.core.js',
@@ -86,6 +87,7 @@ exports.config =
           'vendor/styles/bootstrap-combobox.css',
           'vendor/styles/bootstrap-checkbox.css',
           'vendor/styles/bootstrap-slider.min.css',
+          'vendor/styles/bootstrap-switch.min.css',
           'vendor/styles/visualsearch-datauri.css'
         ],
         after: ['app/styles/custom-ui.css']

http://git-wip-us.apache.org/repos/asf/ambari/blob/8c6c13da/ambari-web/karma.conf.js
----------------------------------------------------------------------
diff --git a/ambari-web/karma.conf.js b/ambari-web/karma.conf.js
index 14af760..1a03381 100644
--- a/ambari-web/karma.conf.js
+++ b/ambari-web/karma.conf.js
@@ -54,6 +54,7 @@ module.exports = function(config) {
       'vendor/scripts/ember-i18n-1.4.1.js',
       'vendor/scripts/bootstrap.js',
       'vendor/scripts/bootstrap-combobox.js',
+      'vendor/scripts/bootstrap-switch.min.js',
       'vendor/scripts/d3.v2.js',
       'vendor/scripts/cubism.v1.js',
       'vendor/scripts/jquery.ui.core.js',