You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2014/11/11 12:28:54 UTC

[6/8] stratos git commit: cleanup user mgt related JSON-schema and improve UX

cleanup user mgt related JSON-schema and improve UX


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

Branch: refs/heads/master
Commit: fbe6afaba24dc92ba50511382f0ddce5398b443f
Parents: 560ebbd
Author: Dakshika Jayathilaka <si...@gmail.com>
Authored: Tue Nov 11 16:13:30 2014 +0530
Committer: Dakshika Jayathilaka <si...@gmail.com>
Committed: Tue Nov 11 16:13:30 2014 +0530

----------------------------------------------------------------------
 .../forms/default/users/tenants.json            |  10 +-
 .../controllers/forms/default/users/users.json  |  12 +-
 .../controllers/forms/form_generator.jag        | 134 -------------------
 .../controllers/forms/schema/users/tenants.json |  42 +++---
 .../console/controllers/menu/menu.json          |   2 +-
 .../themes/theme0/partials/users_form.hbs       |  17 +--
 6 files changed, 43 insertions(+), 174 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/fbe6afab/components/org.apache.stratos.manager.console/console/controllers/forms/default/users/tenants.json
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager.console/console/controllers/forms/default/users/tenants.json b/components/org.apache.stratos.manager.console/console/controllers/forms/default/users/tenants.json
index 7fb7080..c787d5f 100644
--- a/components/org.apache.stratos.manager.console/console/controllers/forms/default/users/tenants.json
+++ b/components/org.apache.stratos.manager.console/console/controllers/forms/default/users/tenants.json
@@ -1,9 +1,9 @@
 {
-    "admin":"admin",
-    "firstname":"Frank",
-    "lastname":"Myers",
+    "admin":"AdminUserName",
+    "firstname":"FirstName",
+    "lastname":"LastName",
     "adminPassword":"admin123",
-    "tenantDomain":"frank.com",
-    "email":"foo@bar.com",
+    "tenantDomain":"apache.org",
+    "email":"user@apache.org",
     "active":"true"
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbe6afab/components/org.apache.stratos.manager.console/console/controllers/forms/default/users/users.json
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager.console/console/controllers/forms/default/users/users.json b/components/org.apache.stratos.manager.console/console/controllers/forms/default/users/users.json
index 92a607b..df28139 100644
--- a/components/org.apache.stratos.manager.console/console/controllers/forms/default/users/users.json
+++ b/components/org.apache.stratos.manager.console/console/controllers/forms/default/users/users.json
@@ -1,9 +1,9 @@
 {
-    "userName":"lasindu",
-    "credential":"lasindu",
+    "userName":"UserName",
+    "credential":"Password",
     "role":"Internal/user",
-    "firstName":"Lasindu",
-    "lastName":"Charith",
-    "email":"lasindu@wso2.com",
-    "profileName":"null"
+    "firstName":"FirstName",
+    "lastName":"LastName",
+    "email":"user@apache.org",
+    "profileName":"profilename"
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbe6afab/components/org.apache.stratos.manager.console/console/controllers/forms/form_generator.jag
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager.console/console/controllers/forms/form_generator.jag b/components/org.apache.stratos.manager.console/console/controllers/forms/form_generator.jag
deleted file mode 100644
index 6e2acfd..0000000
--- a/components/org.apache.stratos.manager.console/console/controllers/forms/form_generator.jag
+++ /dev/null
@@ -1,134 +0,0 @@
-<%
-var outputHtml,path,i= "";
-/**
- * UI generation logic
- */
-
-/**
- * Function to generate HTML for the form
- * @param  {JSON} jsonSpec JSON description of the form
- * @return {String}        Formatted HTML ready to be inserted into the template
- */
-function traverse(jsonSpec, path) {
-
-    for (specNumber in jsonSpec) {
-        var spec = jsonSpec[specNumber];
-
-        if (typeof(spec.value)==="object") {
-            if (spec.type === 'name_object') {
-                path += spec.name + '.';
-			    outputHtml += generateSectionHtml(spec.label,spec.name, spec.value);
-		    }else if(spec.type === 'name_array'){
-                i=-1;
-                path += spec.name ;
-		        outputHtml += generateSectionHtml(spec.label,spec.name, spec.value);
-		    }else if(spec.type === 'object'){
-                ++i;
-                path += '.'+ i + '.';
-            }
-
-            traverse(spec.value, path);
-
-            if (spec.type === 'name_object') {
-                path = path.replace(spec.name+'.', '');
-			    outputHtml += "</div></div></div>";
-		    }else if(spec.type === 'name_array'){
-                path = path.replace(spec.name, '');
-                i=0;
-		        outputHtml += "</div></div></div>";
-		    }else if(spec.type === 'object'){
-                path = path.replace('.'+ i + '.', '');
-		        outputHtml += "<hr>";
-		    }
-
-        }else{
-            if (spec.type === 'field') {
-                path += spec.name+'.';
-
-                outputHtml += generateFieldHtml(spec.label,spec.placeholder, spec.name, spec.value, path);
-                path = path.replace(spec.name+'.', '');
-		    }
-        }
-    }
-
-     return outputHtml;
-
-}
-
-
-
-/**
- * Function to generate the html for a text field in the form
- * @param  {String} label       Label to be put in the form
- * @param  {String} placeholder Placeholder for the field
- * @param  {String} fieldName   Name of the field
- * @return {String}             Formatted HTML ready to be inserted in the template
- */
-function generateFieldHtml (label, placeholder, fieldName, value, path) {
-    log.info(path);
-    var labelHtml = "<label class='formlabel'>" + label + "</label>";
-    var inputHtml = "<input type='text' placeholder='" + placeholder + "' id='" +
-                    fieldName + "' class='form-control' value='"+value+"' data-path='"+
-                    path+"'>";
-    return labelHtml + inputHtml;
-}
-
-/**
- * @param myParam1
- * @param myParam2
- */
-function generateSectionHtml(label, name, content){
-    var outputHtml = "";
-    outputHtml += "<div class='panel-group subform' id='" + name + "'>";
-    outputHtml += "<div class='panel panel-default'>";
-    outputHtml += "<div class='panel-heading'>";
-    outputHtml += "<h4 class='panel-title'><a class='togglelink' data-toggle='collapse' data-parent='" + name + "' href='#" + name + "panel'>" + label + "</a></h4>";
-    outputHtml += "</div>";
-    outputHtml += "<div class='panel-collapse collapse' id='" + name + "panel'>";
-    return outputHtml;
-}
-
-
-var outputJSON = "";
-/**
- * Function to generate JSON for the form
- * @param  {JSON} jsonSpec JSON description of the form
- * @return {String}        Formatted JSON ready to be inserted into the editor box
- */
-function generateJSON(jsonSpec){
-
-    for (specNumber in jsonSpec) {
-        var spec = jsonSpec[specNumber];
-        if (typeof(spec.value)==="object") {
-
-            if(spec.type === 'name_object'){
-                outputJSON += '"'+ spec.name + '":';
-                outputJSON += "{";
-            }else if(spec.type === 'name_array'){
-                outputJSON += '"'+ spec.name + '":';
-                outputJSON += "[";
-		    }else if(spec.type == 'object'){
-		        outputJSON += "{";
-		    }
-
-            generateJSON(spec.value);
-
-            if(spec.type === 'name_object'){
-                outputJSON += "},";
-            }else if(spec.type === 'name_array'){
-                outputJSON += "],";
-		    }else if(spec.type == 'object'){
-		        outputJSON += "},";
-		    }
-        }else{
-            if (spec.type === 'field') {
-                    outputJSON += '"'+spec.name + '":"'+ spec.value + '",';
-            }
-        }
-
-    }
-
-    return outputJSON;
-}
-
-%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbe6afab/components/org.apache.stratos.manager.console/console/controllers/forms/schema/users/tenants.json
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager.console/console/controllers/forms/schema/users/tenants.json b/components/org.apache.stratos.manager.console/console/controllers/forms/schema/users/tenants.json
index 945c482..d8b07ee 100644
--- a/components/org.apache.stratos.manager.console/console/controllers/forms/schema/users/tenants.json
+++ b/components/org.apache.stratos.manager.console/console/controllers/forms/schema/users/tenants.json
@@ -4,48 +4,60 @@
     "id": "root",
     "title": "Tenant",
     "name": "Tenant",
-    "required":false,
+    "options": {
+        "disable_properties": true,
+        "disable_collapse": true
+    },
+    "required":["admin","adminPassword","email", "firstname", "lastname", "tenantDomain"],
     "properties":{
-        "active": {
+        "admin": {
             "type":"string",
-            "id": "root/active",
-            "default": "true",
-            "required":false
+            "id": "root/admin",
+            "default": "admin",
+            "title": "Admin user name",
+            "name": "Admin user name"
         },
         "adminPassword": {
             "type":"string",
             "id": "root/adminPassword",
             "default": "admin123",
-            "required":false
-        },
-        "admin": {
-            "type":"string",
-            "id": "root/admin",
-            "default": "admin",
-            "required":false
+            "title": "Admin user password",
+            "name": "Admin user password"
         },
         "email": {
             "type":"string",
             "id": "root/email",
             "default": "foo@bar.com",
-            "required":false
+            "title": "Admin email",
+            "name": "Admin email"
         },
         "firstname": {
             "type":"string",
             "id": "root/firstname",
             "default": "Frank",
-            "required":false
+            "title": "First name",
+            "name": "First name"
         },
         "lastname": {
             "type":"string",
             "id": "root/lastname",
             "default": "Myers",
-            "required":false
+            "title": "Last name",
+            "name": "Last name"
         },
         "tenantDomain": {
             "type":"string",
             "id": "root/tenantDomain",
             "default": "frank.com",
+            "title": "Tenant domain",
+            "name": "Tenant domain"
+        },
+        "active": {
+            "type":"boolean",
+            "id": "root/active",
+            "default": "true",
+            "title": "Active",
+            "name": "Active",
             "required":false
         }
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbe6afab/components/org.apache.stratos.manager.console/console/controllers/menu/menu.json
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager.console/console/controllers/menu/menu.json b/components/org.apache.stratos.manager.console/console/controllers/menu/menu.json
index dd4961f..7cc4d1f 100644
--- a/components/org.apache.stratos.manager.console/console/controllers/menu/menu.json
+++ b/components/org.apache.stratos.manager.console/console/controllers/menu/menu.json
@@ -92,7 +92,7 @@
                     "title": "Manage Users",
                     "icon": "fa-user",
                     "permissionPaths": ["/permission", "/permission/admin"],
-                    "description": "Manage users."
+                    "description": "Manage current tenant users."
                 },
                 {
                     "link": "users/tenants/",

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbe6afab/components/org.apache.stratos.manager.console/console/themes/theme0/partials/users_form.hbs
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/users_form.hbs b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/users_form.hbs
index 3c55119..40678a5 100644
--- a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/users_form.hbs
+++ b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/users_form.hbs
@@ -15,7 +15,7 @@
                     <div class='container text-center form-toolbar'>
                         <div class='col-md-5'></div>
                         <div class='col-md-7 '>
-                            <button class='btn btn-info btn-lg pull-right' type='button' id='deploy' data-form=''> Add </button>
+                            <button class='btn btn-info btn-lg pull-right' type='button' id='deploy' data-form=''> Add {{formContext}}</button>
                             <button class='btn btn-default btn-lg pull-right button-gap' type='button' onclick='window.location.replace(document.referrer)'> Cancel
                             </button>
                         </div>
@@ -54,14 +54,14 @@
                         </div>
                     </div>
                     <div class="col-md-7 col-sm-3 text-right">
-                        <a type="button" class="btn btn-primary btn-lg" href="new/">Add New</a>
+                        <a type="button" class="btn btn-primary btn-lg" href="new/">Add new {{formContext}}</a>
                     </div>
                 </div>
             {{else}}
                 <div class="row no-item row-overide">
                     <div class="row title">
                         <h2>No {{formTitle}} found..</h2>
-                        <a type="button" class="btn btn-primary btn-lg" href="new/">Add New {{formTitle}}</a>
+                        <a type="button" class="btn btn-primary btn-lg" href="new/">Add new {{formTitle}}</a>
                     </div>
                 </div>
             {{/if}}
@@ -74,12 +74,8 @@
                         </div>
                         <h2>{{userName}} </h2>
 
-                        <div class="toggle-menu-description">Define partitions/partition groups to be used in
-                            autoscaling and deployment policies.
+                        <div class="toggle-menu-description">{{role}}
                         </div>
-                        <!--<div class="toggle-menu-button">
-                            <button type="button" class="btn btn-primary" >Remove</button>
-                        </div>-->
                     </div>
                 {{/each}}
                 {{#each content_body.sections.tenantInfoBean}}
@@ -90,9 +86,6 @@
                         <h2>{{tenantDomain}} </h2>
 
                         <div class="toggle-menu-description">{{email}} - {{createdDate}} </div>
-                        <!--<div class="toggle-menu-button">
-                            <button type="button" class="btn btn-primary" >Remove</button>
-                        </div>-->
                     </div>
                 {{/each}}
             </div>
@@ -132,7 +125,6 @@
             editor.on('change', function () {
                 // Get an array of errors from the validator
                 var errors = editor.validate();
-                console.log(errors);
                 //       var indicator = document.getElementById('valid_indicator');
 
 //        // Not valid
@@ -174,7 +166,6 @@
                     .always(function () {
                         btn.html('Add '+formtype);
                     });
-            console.log(payload);
         });//end of deploy button trigger
 
     });