User delete option added

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

Branch: refs/heads/4.1.0-test
Commit: 8a75e1e5e1ed99585cc891ae427238dcbdd7aae4
Parents: e2ef87a
Author: Dakshika Jayathilaka <[email protected]>
Authored: Thu Dec 11 08:07:13 2014 +0530
Committer: Dakshika Jayathilaka <[email protected]>
Committed: Thu Dec 11 08:07:13 2014 +0530

----------------------------------------------------------------------
 .../controllers/users/users_requests.jag        |  3 +-
 .../themes/theme0/partials/users_form.hbs       | 77 +++++++++++++++++---
 2 files changed, 68 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/8a75e1e5/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 b5c6c9e..a4eec80 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
@@ -31,9 +31,10 @@ include('/controllers/login/validator.jag');
 try {
     if(formtype == 'users'){
         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));
     }
 
 }catch(e){

http://git-wip-us.apache.org/repos/asf/stratos/blob/8a75e1e5/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 c2c4317..697a48a 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
@@ -74,8 +74,21 @@
                         </div>
                         <h2>{{userName}} </h2>
 
-                        <div class="toggle-menu-description">{{role}}
+                        <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>
+                        </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>
+                            </div>
                         </div>
+                        {{/ifCond}}
                     </div>
                 {{/each}}
                 {{#each content_body.sections.tenantInfoBean}}
@@ -126,17 +139,59 @@
                 // Get an array of errors from the validator
                 var errors = editor.validate();
                 //       var indicator = 
document.getElementById('valid_indicator');
+            });
+
+        {{else}}
+            $('.general-table .grid-group-item').hover(function () {
+                if($(this).hasClass('grid-group-item')) {
+                    $(this).find('.bottom-bar').stop().animate({bottom: 
'37px'}, 'slow');
+                }
+            }, function () {
+                if($(this).hasClass('grid-group-item')) {
+                    $(this).find('.bottom-bar').stop().animate({bottom: 
'-32px'}, 'slow');
+                }
+            });
 
-//        // Not valid
-//        if(errors.length) {
-//            indicator.className = 'label alert';
-//            indicator.textContent = 'not valid';
-//        }
-//        // Valid
-//        else {
-//            indicator.className = 'label success';
-//            indicator.textContent = 'valid';
-//        }
+            $('.general-table').on('click', '.hover-details', function (event) 
{
+                var payload =$(this).attr("data-user");
+                noty({
+                    layout: 'bottomRight',
+                    type: 'warning',
+                    text: 'Are you sure you want to delete user 
'+$(this).attr("data-user"),
+                    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 },
+                                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 () {
+
+                             });
+
+                        }
+                        },
+                        {addClass: 'btn btn-danger', text: 'No', onClick: 
function($noty) {
+                            $noty.close();
+                        }
+                        }
+                    ]
+                });
             });
         {{/if}}
 

Reply via email to