You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2014/02/08 02:20:01 UTC

git commit: AMBARI-4565. Jobs: Admin config to turn Apps on/off for non-admin users. (alexantonenko)

Updated Branches:
  refs/heads/trunk 6516491ed -> 9d9e70486


AMBARI-4565. Jobs: Admin config to turn Apps on/off for non-admin users. (alexantonenko)


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

Branch: refs/heads/trunk
Commit: 9d9e70486fa33bbf2634e97b8e13dd084b01d0cb
Parents: 6516491
Author: Alex Antonenko <hi...@gmail.com>
Authored: Sat Feb 8 03:08:47 2014 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Sat Feb 8 03:09:08 2014 +0200

----------------------------------------------------------------------
 ambari-web/app/controllers.js                   |  1 +
 .../controllers/main/admin/access_controller.js | 37 ++++++++++++++++++++
 ambari-web/app/messages.js                      |  3 ++
 ambari-web/app/routes/main.js                   | 14 ++++++++
 ambari-web/app/styles/application.less          | 11 ++++++
 ambari-web/app/templates/main/admin/access.hbs  | 33 +++++++++++++++++
 ambari-web/app/utils/db.js                      | 19 ++++++++++
 ambari-web/app/views.js                         |  1 +
 ambari-web/app/views/main/admin.js              |  5 +++
 ambari-web/app/views/main/admin/access_view.js  | 26 ++++++++++++++
 ambari-web/app/views/main/menu.js               |  2 +-
 11 files changed, 151 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9d9e7048/ambari-web/app/controllers.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers.js b/ambari-web/app/controllers.js
index 95f8b6b..c93c616 100644
--- a/ambari-web/app/controllers.js
+++ b/ambari-web/app/controllers.js
@@ -47,6 +47,7 @@ require('controllers/main/admin/cluster');
 require('controllers/main/admin/stack_upgrade_controller');
 require('controllers/main/admin/user');
 require('controllers/main/admin/misc_controller');
+require('controllers/main/admin/access_controller');
 require('controllers/main/admin/user/edit');
 require('controllers/main/admin/user/create');
 require('controllers/main/admin/advanced');

http://git-wip-us.apache.org/repos/asf/ambari/blob/9d9e7048/ambari-web/app/controllers/main/admin/access_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/access_controller.js b/ambari-web/app/controllers/main/admin/access_controller.js
new file mode 100644
index 0000000..452e660
--- /dev/null
+++ b/ambari-web/app/controllers/main/admin/access_controller.js
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF 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 License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.MainAdminAccessController = Em.Controller.extend({
+  name:'mainAdminAccessController',
+
+  showJobs: true,
+
+  /* Handle Save button click event*/
+  save: function() {
+    App.db.setShowJobsForNonAdmin(this.get('showJobs'));
+    App.clusterStatus.setClusterStatus({
+      localdb: App.db.data
+    });
+  },
+
+  loadData: function() {
+    this.set('showJobs',  App.db.getShowJobsForNonAdmin());
+  }
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/9d9e7048/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 344697a..162dde4 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -51,6 +51,7 @@ Em.I18n.translations = {
   'add': 'Add',
 
 
+  'common.access':'Access',
   'common.learnMore':'Learn more',
   'common.back':'Back',
   'common.prev':'Prev',
@@ -940,6 +941,8 @@ Em.I18n.translations = {
   'admin.users.createError.userNameExists': 'User with the same name is already exists',
   'admin.users.editError.requiredField': 'This is required',
 
+  'admin.access.showJobs':'Enable Jobs tab for non-admin users',
+
   'admin.confirmUninstall':'Confirm Uninstall',
   'admin.cluster.stackVersion':'Cluster Stack Version',
   'admin.cluster.upgradeAvailable':'Upgrade available',

http://git-wip-us.apache.org/repos/asf/ambari/blob/9d9e7048/ambari-web/app/routes/main.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js
index ce28325..b13512e 100644
--- a/ambari-web/app/routes/main.js
+++ b/ambari-web/app/routes/main.js
@@ -114,6 +114,13 @@ module.exports = Em.Route.extend({
 
   jobs : Em.Route.extend({
     route : '/jobs',
+    enter: function () {
+      if(!App.db.getShowJobsForNonAdmin() && !App.get('isAdmin')){
+        Em.run.next(function () {
+          router.transitionTo('main.dashboard');
+        });
+      }
+    },
     index: Ember.Route.extend({
       route: '/',
       connectOutlets : function(router) {
@@ -525,6 +532,13 @@ module.exports = Em.Route.extend({
         router.get('mainAdminController').connectOutlet('mainAdminMisc');
       }
     }),
+    adminAccess: Em.Route.extend({
+      route: '/access',
+      connectOutlets: function (router) {
+        router.set('mainAdminController.category', "access");
+        router.get('mainAdminController').connectOutlet('mainAdminAccess');
+      }
+    }),
 
     adminAudit: Em.Route.extend({
       route: '/audit',

http://git-wip-us.apache.org/repos/asf/ambari/blob/9d9e7048/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 1645ac6..3443af4 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -3384,6 +3384,17 @@ background: url(	data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByU
 }
 /*End Admin*/
 
+/* Start Admin Access*/
+#access{
+  .checkbox{
+    margin: 0;
+  }
+  .acces-values{
+    padding-bottom: 15px;
+  }
+}
+/* End Admin Access*/
+
 /*Start About*/
 .about {
   .logo {

http://git-wip-us.apache.org/repos/asf/ambari/blob/9d9e7048/ambari-web/app/templates/main/admin/access.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/admin/access.hbs b/ambari-web/app/templates/main/admin/access.hbs
new file mode 100644
index 0000000..eda62c3
--- /dev/null
+++ b/ambari-web/app/templates/main/admin/access.hbs
@@ -0,0 +1,33 @@
+{{!
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF 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 License for the specific language governing permissions and
+* limitations under the License.
+}}
+<div id="access">
+  <div class="header">
+      <strong>{{t common.access}}</strong>
+  </div>
+  <div class="acces-values">
+      <label>
+        {{view Ember.Checkbox checkedBinding="showJobs" class="checkbox"}}
+        {{t admin.access.showJobs}}
+      </label>
+  </div>
+  <div class="control-group">
+      <div class="controls">
+          <button type="submit" class="btn btn-primary" {{action save target="controller"}}>{{t common.save}}</button>
+      </div>
+  </div>
+</div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/9d9e7048/ambari-web/app/utils/db.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/db.js b/ambari-web/app/utils/db.js
index d56a48a..e5b5417 100644
--- a/ambari-web/app/utils/db.js
+++ b/ambari-web/app/utils/db.js
@@ -27,6 +27,9 @@ var InitialData =  {
       'displayLength': {},
       'startIndex': {},
       'sortingConditions': {}
+    },
+    'access': {
+      'showJobsForNonAdmin': ''
     }
   },
 
@@ -176,6 +179,13 @@ App.db.setDisplayLength = function(name, displayLength) {
   localStorage.setObject('ambari', App.db.data);
 };
 
+App.db.setShowJobsForNonAdmin = function(showJobsForNonAdmin) {
+  console.log('TRACE: Entering db:setShowJobsForNonAdmin function');
+  App.db.data = localStorage.getObject('ambari');
+  App.db.data.app.access.showJobsForNonAdmin = showJobsForNonAdmin;
+  localStorage.setObject('ambari', App.db.data);
+};
+
 App.db.setStartIndex = function(name, startIndex) {
   console.log('TRACE: Entering db:setStartIndex function');
   App.db.data = localStorage.getObject('ambari');
@@ -554,6 +564,15 @@ App.db.getDisplayLength = function(name) {
   return null;
 };
 
+App.db.getShowJobsForNonAdmin = function() {
+  console.log('TRACE: Entering db:getShowJobsForNonAdmin function');
+  App.db.data = localStorage.getObject('ambari');
+  if (App.db.data.app.access && typeof (App.db.data.app.access.showJobsForNonAdmin) ==  "boolean") {
+    return App.db.data.app.access.showJobsForNonAdmin;
+  }
+  return true;
+};
+
 App.db.getStartIndex = function(name) {
   console.log('TRACE: Entering db:getStartIndex function');
   App.db.data = localStorage.getObject('ambari');

http://git-wip-us.apache.org/repos/asf/ambari/blob/9d9e7048/ambari-web/app/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js
index 9dbf61f..8a6fa9f 100644
--- a/ambari-web/app/views.js
+++ b/ambari-web/app/views.js
@@ -79,6 +79,7 @@ require('views/main/admin/cluster');
 require('views/main/admin/misc_view');
 require('views/main/admin/stack_upgrade');
 require('views/main/admin/advanced');
+require('views/main/admin/access_view');
 require('views/main/admin/advanced/password');
 require('views/main/admin/audit');
 require('views/main/admin/authentication');

http://git-wip-us.apache.org/repos/asf/ambari/blob/9d9e7048/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 faea2bd..ce7f73c 100644
--- a/ambari-web/app/views/main/admin.js
+++ b/ambari-web/app/views/main/admin.js
@@ -51,6 +51,11 @@ App.MainAdminView = Em.View.extend({
       url: 'adminMisc',
       label: Em.I18n.t('common.misc')
     });
+    items.push({
+      name: 'access',
+      url: 'adminAccess',
+      label: Em.I18n.t('common.access')
+    });
     return items;
   }.property(''),
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/9d9e7048/ambari-web/app/views/main/admin/access_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/access_view.js b/ambari-web/app/views/main/admin/access_view.js
new file mode 100644
index 0000000..12c0591
--- /dev/null
+++ b/ambari-web/app/views/main/admin/access_view.js
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF 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 License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.MainAdminAccessView = Em.View.extend({
+  templateName: require('templates/main/admin/access'),
+  didInsertElement: function() {
+    this.get('controller').loadData();
+  }
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/9d9e7048/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 894ed9e..f826403 100644
--- a/ambari-web/app/views/main/menu.js
+++ b/ambari-web/app/views/main/menu.js
@@ -39,7 +39,7 @@ App.MainMenuView = Em.CollectionView.extend({
 
     if (!App.get('isHadoop2Stack')) {
       result.push({ label:Em.I18n.t('menu.item.jobs'), routing:'apps'});
-    } else if(App.supports.jobs) {
+    } else if(App.supports.jobs && (App.db.getShowJobsForNonAdmin() || App.get('isAdmin'))) {
       result.push({ label:Em.I18n.t('menu.item.jobs'), routing:'jobs'});
     }