Updated Branches:
  refs/heads/master ec878b343 -> a7109affe

pushing fixes done by Chanaka Jayasena. STRATOS-365. used git am --signoff 
failed hence using apply option for this patch


Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/a7109aff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/a7109aff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/a7109aff

Branch: refs/heads/master
Commit: a7109affee8064cc7bc9b2b76482700275f36565
Parents: ec878b3
Author: Pradeep Fernando <[email protected]>
Authored: Fri Jan 17 12:18:54 2014 +0530
Committer: Pradeep Fernando <[email protected]>
Committed: Fri Jan 17 12:18:54 2014 +0530

----------------------------------------------------------------------
 .../console/themes/theme1/partials/header.hbs   | 12 ++++--
 .../console/themes/theme1/renderers/index.js    |  6 +--
 .../console/themes/theme1/theme.js              | 43 ++++++++++++++++----
 3 files changed, 47 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/a7109aff/components/org.apache.stratos.manager.console/console/themes/theme1/partials/header.hbs
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/themes/theme1/partials/header.hbs
 
b/components/org.apache.stratos.manager.console/console/themes/theme1/partials/header.hbs
index 3ad7353..23f5082 100644
--- 
a/components/org.apache.stratos.manager.console/console/themes/theme1/partials/header.hbs
+++ 
b/components/org.apache.stratos.manager.console/console/themes/theme1/partials/header.hbs
@@ -1,3 +1,4 @@
+
 {{#if login}}
         <div class="top-blue-strip"></div>
         <div class="login-logo-section"><a  href="{{url "/"}}"><img src="{{url 
"/themes/theme1/ui/img/logo-login.png"}}"/></a></div>
@@ -15,14 +16,19 @@
         <div class="container">
             <div class="row">
                 <div class="col-lg-3">
+                    {{#ifAllowed "tenant-mgt"}}
+                        can tenant-mgt
+                    {{else}}
+                        can't tenant-mgt
+                    {{/ifAllowed}}
                     <a class="navbar-brand" href="{{url "/"}}"><img src="{{url 
"/themes/theme1/ui/img/logo-inside.png"}}"/></a>
                  </div>
                  <div class="col-lg-9 custom-nav">
                     <ul class="pull-left">
                         <!-- li {{#if dashboard}} class="active" {{/if}}><a 
href="{{url "/"}}"><i class="fa fa-dashboard"></i> 
<span><br>Dashboard</span></a></li -->
                         <li {{#if my_cartridges}} class="active" {{/if}}><a 
href="{{url "/"}}"><i class="fa fa-tasks"></i>  <span><br>My 
Cartridges</span></a></li>
-                        <li {{#if configure_stratos}} class="active" 
{{/if}}><a href="{{url "/partition_deployments.jag"}}"><i class="fa 
fa-cogs"></i> <span><br>Configure Stratos</span></a></li>
-                        <li {{#if tenant_mgt}} class="active" {{/if}}><a 
href="{{url "/tenant_management.jag"}}"><i class="fa fa-user"></i> 
<span><br>Tenant Mgt</span></a></li>
+                        {{#isAllowed "edit"}}<li {{#if configure_stratos}} 
class="active" {{/if}}><a href="{{url "/partition_deployments.jag"}}"><i 
class="fa fa-cogs"></i> <span><br>Configure 
Stratos</span></a></li>{{/isAllowed}}
+                        {{#isAllowed "tenant-mgt"}}<li {{#if tenant_mgt}} 
class="active" {{/if}}><a href="{{url "/tenant_management.jag"}}"><i class="fa 
fa-user"></i> <span><br>Tenant Mgt</span></a></li>{{/isAllowed}}
                      </ul>
                      <ul class="pull-right">
                      <li class="dropdown">
@@ -95,7 +101,7 @@
                                         <a href="{{url 
"/cartridge_deployments.jag" }}">Cartridge Deployments</a>
                                     {{/if}}
                                 </li>
-                                <li {{#if mt_service_deployments}} 
class="active" {{/if}}>
+                                <li {{#if mt_service_deployments}} 
class="active" {{/if}} style="display:none">
                                     {{#if config_status.first_use}}
                                         <span>Multi-Tenant Service 
Deployments</span>
                                     {{else}}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/a7109aff/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/index.js
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/index.js
 
b/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/index.js
index 37b30dc..3540c30 100644
--- 
a/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/index.js
+++ 
b/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/index.js
@@ -1,6 +1,6 @@
 var render = function (theme, data, meta, require) {
       // Re-create the data structure of the cartridges.
-    var log = new Log();
+
     var cartridges_old = data.mycartridges.cartridge;
     var cartridges_new = [
         {
@@ -17,7 +17,6 @@ var render = function (theme, data, meta, require) {
                 }
             }
             cartridgesToPush.push(cartridges_old[i]);
-            log.info(cartridges_old[i]);
         } else {
             cartridgesToPush = null;
             for (var j = 0; j < cartridges_new.length; j++) {
@@ -32,7 +31,8 @@ var render = function (theme, data, meta, require) {
             }
         }
     }
-    log.info(cartridges_new);
+    var log = new Log();
+    log.info(meta.request.permissions);
 
     theme('index', {
         body: [

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/a7109aff/components/org.apache.stratos.manager.console/console/themes/theme1/theme.js
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/themes/theme1/theme.js 
b/components/org.apache.stratos.manager.console/console/themes/theme1/theme.js
index 2744cae..fb992ea 100644
--- 
a/components/org.apache.stratos.manager.console/console/themes/theme1/theme.js
+++ 
b/components/org.apache.stratos.manager.console/console/themes/theme1/theme.js
@@ -3,14 +3,41 @@
 var engine = require('caramel').engine('handlebars', (function () {
     return {
         partials: function (Handlebars) {
-            Handlebars.registerHelper("ifCon", function(conditional, options) {
-              if (options.hash.desired === options.hash.type) {
-                options.fn(this);
-              } else {
-                options.inverse(this);
+            var theme = caramel.theme();
+            var partials = function (file) {
+                (function register(prefix, file) {
+                    var i, length, name, files;
+                    if (file.isDirectory()) {
+                        files = file.listFiles();
+                        length = files.length;
+                        for (i = 0; i < length; i++) {
+                            file = files[i];
+                            register(prefix ? prefix + '.' + file.getName() : 
file.getName(), file);
+                        }
+                    } else {
+                        name = file.getName();
+                        if (name.substring(name.length - 4) !== '.hbs') {
+                            return;
+                        }
+                        file.open('r');
+                        Handlebars.registerPartial(prefix.substring(0, 
prefix.length - 4), file.readAll());
+                        file.close();
+                    }
+                })('', file);
+            };
+            //TODO : we don't need to register all partials in the themes dir.
+            //Rather register only not overridden partials
+            partials(new File(theme.__proto__.resolve.call(theme, 
'partials')));
+            partials(new File(theme.resolve('partials')));
+
+            Handlebars.registerHelper('isAllowed', function(action, options) {
+              if(caramel.meta().request.permissions != undefined && 
caramel.meta().request.permissions[action]) {
+                return options.fn(this);
               }
+              return options.inverse(this);
             });
-            /*
+
+
             Handlebars.registerHelper('ifCond', function (v1, operator, v2, 
options) {
 
                 switch (operator) {
@@ -30,7 +57,7 @@ var engine = require('caramel').engine('handlebars', 
(function () {
                         return options.inverse(this);
                 }
             });
-            */
+
         }
     }
-}));
\ No newline at end of file
+}()));
\ No newline at end of file

Reply via email to