From e03a3e19101730173a6858a8401c70024a0e3b62 Mon Sep 17 00:00:00 2001
From: ulrich <not disclosed>
Date: Tue, 27 Dec 2016 13:16:49 +0000
Subject: [PATCH] Rolle entziehen

---
 web/ui/ui.js |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/web/ui/ui.js b/web/ui/ui.js
index 1a76637..af818d5 100644
--- a/web/ui/ui.js
+++ b/web/ui/ui.js
@@ -9,6 +9,7 @@
   $('#nutzerRolleEntziehen').prop( "disabled", true );
   $('#rolleErteilen').prop( "disabled", true );
   $('#rolleErteilen').click(um_grant_role);
+  $('#nutzerRolleEntziehen').click(um_revoke_role);
   $('#neueRolle').click(um_new_role);
   $('#rollen').click(um_role_list_click);
   $('#nutzerrollen').click(um_user_role_list_click);
@@ -72,6 +73,14 @@
   }
 }
 
+function um_revoke_role() {
+  var userId = um_get_first_selected_user_id();
+  var roleId = um_get_first_selected_userrole_id();
+  if(roleId !== 'none' && userId !== 'none') {
+    um_apicall_revoke_role(userId, roleId);
+  }
+}
+
 /* ----------- ui interaction ------------ */
 
 function um_user_list_click() {
@@ -131,6 +140,18 @@
   var roleId = 'none';
   var roleIds = [];
   $('#rollen :selected').each(function(i, selected){
+    roleIds[i] = $(selected).text();
+  });
+  if(roleIds.length > 0) {
+    roleId = roleIds[0];
+  }
+  return roleId;
+}
+
+function um_get_first_selected_userrole_id() {
+  var roleId = 'none';
+  var roleIds = [];
+  $('#nutzerrollen :selected').each(function(i, selected){
     roleIds[i] = $(selected).text();
   });
   if(roleIds.length > 0) {
@@ -255,6 +276,29 @@
   });
 }
 
+function um_apicall_revoke_role(userId, roleName) {
+  var m = 'revokeRole';
+  var u = '../svc/' + m;
+  $.ajax({
+    url: u,
+    data: {
+      p1: userId,
+      p2: roleName
+    },
+    type: "POST",
+    dataType : "html",
+    success: function( resp ) {
+      um_apicall_get_user_roles(userId);
+    },
+    error: function( xhr, status, errorThrown ) {
+      $('#fehler').html("Error: " + errorThrown + " Status: " + status);
+    },
+    complete: function( xhr, status ) {
+      //alert( "The request is complete!" );
+    }
+  });
+}
+
 //public List getUserRoleNames(String userId)
 function um_apicall_get_user_roles(userId) {
   var m = 'getUserRoleNames';

--
Gitblit v1.9.3