Repository: stratos
Updated Branches:
  refs/heads/master 958a3100a -> 36acb117d


Tenant delete, activate, deactivate added


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

Branch: refs/heads/master
Commit: 36acb117d7aed5a01babbd90ed39b2eaeb4b63aa
Parents: 958a310
Author: Dakshika Jayathilaka <[email protected]>
Authored: Sun Jan 25 16:19:24 2015 +0530
Committer: Imesh Gunaratne <[email protected]>
Committed: Sun Jan 25 19:54:08 2015 +0530

----------------------------------------------------------------------
 .../console/controllers/rest/rest_calls.jag     |   6 +-
 .../controllers/users/users_requests.jag        |  10 +-
 .../console/themes/theme0/css/custom.css        |   3 +-
 .../themes/theme0/partials/users_form.hbs       | 106 ++++++++++++++++---
 4 files changed, 107 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/36acb117/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag
 
b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag
index 731ce8c..740957c 100644
--- 
a/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag
+++ 
b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag
@@ -36,15 +36,15 @@ RESTCalls = new function(){
     };
 
     this.activateTenant = function(tenantDomain){
-        return this.send("POST","/tenant/activate/" + tenantDomain,{});
+        return this.send("PUT","/tenants/activate/" + tenantDomain,{});
     };
 
     this.deactivateTenant = function(tenantDomain){
-        return this.send("POST","/tenant/deactivate/" + tenantDomain,{});
+        return this.send("PUT","/tenants/deactivate/" + tenantDomain,{});
     };
 
     this.deleteTenant = function(tenantDomain){
-        return this.send("DELETE","/tenant/" + tenantDomain,{});
+        return this.send("DELETE","/tenants/" + tenantDomain,{});
     };
 
     this.deleteUser = function(userName){

http://git-wip-us.apache.org/repos/asf/stratos/blob/36acb117/components/org.apache.stratos.manager.console/console/controllers/users/users_requests.jag
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/controllers/users/users_requests.jag
 
b/components/org.apache.stratos.manager.console/console/controllers/users/users_requests.jag
index a4eec80..70c43f8 100644
--- 
a/components/org.apache.stratos.manager.console/console/controllers/users/users_requests.jag
+++ 
b/components/org.apache.stratos.manager.console/console/controllers/users/users_requests.jag
@@ -33,8 +33,14 @@ try {
         formSubmit = util.RESTCalls.addUser(JSON.parse(formPayload));
     }else if(formtype == 'tenants'){
         formSubmit = util.RESTCalls.addTenant(JSON.parse(formPayload));
-    }else if(formtype == 'deleteusers'){
-        formSubmit = util.RESTCalls.deleteUser(JSON.parse(formPayload));
+    }else if(formtype == 'user-delete'){
+        formSubmit = util.RESTCalls.deleteUser(formPayload);
+    }else if(formtype == 'tenant-delete'){
+        formSubmit = util.RESTCalls.deleteTenant(formPayload);
+    }else if(formtype == 'tenant-activate'){
+    formSubmit = util.RESTCalls.activateTenant(formPayload);
+    }else if(formtype == 'tenant-deactivate'){
+    formSubmit = util.RESTCalls.deactivateTenant(formPayload);
     }
 
 }catch(e){

http://git-wip-us.apache.org/repos/asf/stratos/blob/36acb117/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css
 
b/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css
index 5e99274..e03e39b 100644
--- 
a/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css
+++ 
b/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css
@@ -192,6 +192,7 @@ a.btn:hover {
     margin-top: 0.7em;
 }
 
-button.hover-unsubscribe, button.hover-details, 
button.hover-delete,button.hover-delete-group, button.hover-undeploy{
+button.hover-unsubscribe, button.hover-details, 
button.hover-delete,button.hover-delete-group, button.b-top,
+button.hover-undeploy{
     margin-top: .7em;
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/36acb117/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 7ec038e..e45e4a4 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
@@ -78,14 +78,14 @@
                             <div class="toggle-menu-description">{{role}}</div>
                             {{#ifCond userName "!=" "admin"}}
                             <div class="list-button" style="display: none;">
-                                <button class="btn btn-danger btn-lg 
hover-details" type="button" id="details_list_{{id}}"
-                                        data-user="{{userName}}" > Delete
+                                <button class="btn btn-danger btn-lg 
hover-delete" type="button"
+                                        id="{{userName}}" 
data-formtype="user-delete"> Delete
                                 </button>
                             </div>
                             <div class="bottom-bar-wrapper">
                                 <div class="bottom-bar">
-                                    <button class="btn btn-danger btn-lg 
hover-details" type="button" id="details_{{id}}"
-                                            data-user="{{userName}}" > Delete
+                                    <button class="btn btn-danger btn-lg  
hover-delete" type="button"
+                                            id="{{userName}}" 
data-formtype="user-delete"> Delete
                                     </button>
                                 </div>
                             </div>
@@ -102,6 +102,35 @@
                             <h2>{{tenantDomain}} </h2>
 
                             <div class="toggle-menu-description">{{email}} - 
{{#UnixConvert createdDate}}{{/UnixConvert}} </div>
+                            <div class="list-button" style="display: none;">
+                                <button class="btn btn-danger btn-lg 
hover-delete b-top" type="button"
+                                        id="{{tenantDomain}}" 
data-formtype="tenant-delete"> Delete</button>
+                                {{#if active}}
+                                    <button class="btn btn-warning btn-lg 
hover-active b-top" type="button" id="{{tenantDomain}}"
+                                            data-formtype="tenant-deactivate" 
> Deactivate
+                                    </button>
+                                {{else}}
+                                    <button class="btn btn-info btn-lg 
hover-active b-top" type="button" id="{{tenantDomain}}"
+                                            data-formtype="tenant-activate" > 
Activate
+                                    </button>
+                                {{/if}}
+
+                            </div>
+                            <div class="bottom-bar-wrapper">
+                                <div class="bottom-bar">
+                                    <button class="btn btn-danger btn-lg 
hover-delete b-top" type="button"
+                                            id="{{tenantDomain}}" 
data-formtype="tenant-delete"> Delete</button>
+                                    {{#if active}}
+                                        <button class="btn btn-warning btn-lg 
hover-active b-top" type="button" id="{{tenantDomain}}"
+                                                
data-formtype="tenant-deactivate" > Deactivate
+                                        </button>
+                                    {{else}}
+                                        <button class="btn btn-info btn-lg 
hover-active b-top" type="button" id="{{tenantDomain}}"
+                                                
data-formtype="tenant-activate" > Activate
+                                        </button>
+                                    {{/if}}
+                                </div>
+                            </div>
                         </div>
                     {{/each}}
                 {{/ifCond}}
@@ -177,22 +206,25 @@
                 }
             });
 
-            $('.general-table').on('click', '.hover-details', function (event) 
{
-                var payload =$(this).attr("data-user");
+            //use to handle user and tenant delete actions
+            $('.general-table').on('click', '.hover-delete', function (event) {
+
+                var payload =$(this).attr("id");
+                var formtype = $(this).attr("data-formtype");
+                var configType = '{{formtype}}';
                 noty({
                     layout: 'bottomRight',
                     type: 'warning',
-                    text: 'Are you sure you want to delete user 
'+$(this).attr("data-user"),
+                    text: 'Are you sure you want to delete '+configType+': 
<strong>'+$(this).attr("id") + "</strong> ?",
                     buttons: [
                         {addClass: 'btn btn-primary', text: 'Yes', onClick: 
function($noty) {
-                            var formtype = 'deleteusers';
                             $noty.close();
 
                             $.ajax({
                                 type: "POST",
                                 url: caramel.context + 
"/controllers/users/users_requests.jag",
                                 dataType: 'json',
-                                data: { "formPayload": 
JSON.stringify(payload), "formtype": formtype },
+                                data: { "formPayload": payload, "formtype": 
formtype },
                                 success: function (data) {
                                     if (data.status == 'error') {
                                         var n = noty({text: data.message, 
layout: 'bottomRight', type: 'error'});
@@ -202,13 +234,63 @@
                                         var n = noty({text: data.message, 
layout: 'bottomRight', type: 'success'});
                                         window.setTimeout(function(){
                                             location.reload();
-                                        }, 1500);
+                                        }, 1000);
                                     }
+                                }
+                            }).always(function () {
+
+                            });
+
+                        }
+                        },
+                        {addClass: 'btn btn-danger', text: 'No', onClick: 
function($noty) {
+                            $noty.close();
+                        }
+                        }
+                    ]
+                });
+            });
+
+            //use to handle tenant
+            $('.general-table').on('click', '.hover-active', function (event) {
 
+                var payload =$(this).attr("id");
+                var formtype = $(this).attr("data-formtype");
+                var configType = '{{formtype}}';
+                var text ='';
+                if(formtype == 'tenant-activate'){
+                    text = 'activate ';
+                }else{
+                    text = 'deactivate ';
+                }
+                noty({
+                    layout: 'bottomRight',
+                    type: 'warning',
+                    text: 'Are you sure you want to  ' + text +configType+': 
<strong>'+$(this).attr("id") + "</strong> ?",
+                    buttons: [
+                        {addClass: 'btn btn-primary', text: 'Yes', onClick: 
function($noty) {
+                            $noty.close();
+
+                            $.ajax({
+                                type: "POST",
+                                url: caramel.context + 
"/controllers/users/users_requests.jag",
+                                dataType: 'json',
+                                data: { "formPayload": payload, "formtype": 
formtype },
+                                success: function (data) {
+                                    if (data.status == 'error') {
+                                        var n = noty({text: data.message, 
layout: 'bottomRight', type: 'error'});
+                                    } else if (data.status == 'warning') {
+                                        var n = noty({text: data.message, 
layout: 'bottomRight', type: 'warning'});
+                                    } else {
+                                        var n = noty({text: data.message, 
layout: 'bottomRight', type: 'success'});
+                                        window.setTimeout(function(){
+                                            location.reload();
+                                        }, 1000);
+                                    }
                                 }
-                                }).always(function () {
+                            }).always(function () {
 
-                             });
+                            });
 
                         }
                         },

Reply via email to