From 87e382c61272e351b04715c960d485f863b7e594 Mon Sep 17 00:00:00 2001 From: ulrich <not disclosed> Date: Sat, 24 Dec 2016 15:30:33 +0000 Subject: [PATCH] Rollen in Arbeit --- web/ui/ui.js | 82 +++++++++++++++++++++++++++++++--------- 1 files changed, 63 insertions(+), 19 deletions(-) diff --git a/web/ui/ui.js b/web/ui/ui.js index d24b7a8..7782450 100644 --- a/web/ui/ui.js +++ b/web/ui/ui.js @@ -5,7 +5,8 @@ $('#nutzerLoeschen').click(um_del_user); $('#nutzerNeu').click(um_new_user); $('#nutzerLoeschen').prop( "disabled", true ); - + um_clear_user_form(); + um_apicall_get_user_list(); } /* ----- user functions ------ */ @@ -16,13 +17,23 @@ if(user.pw != kww) { alert('Kennworte stimmen nicht ueberein.'); } else { - alert('user-save ' + user.id); - um_apicall(self.serialisieren(user)); + //alert('user-save ' + user.id); + um_apicall_create_user(self.serialisieren(user)); } } -function um_del_user(user_name) { - alert('delete user ' + user_name); +function um_del_user() { + var users = []; + $('#nutzerliste :selected').each(function(i, selected){ + users[i] = $(selected).text(); + }); + + //alert('delete user ' + users[0]); + var antwort = confirm("Wollen Sie den Nutzer " + users[0] + " loeschen?"); + if (antwort == true) { + var user = new User(users[0], '-', '-', '-', '-'); + um_apicall_del_user(self.serialisieren(user)); + } } function um_new_user() { @@ -32,9 +43,14 @@ /* ----------- ui interaction ------------ */ function um_user_list_click() { - //var user_name = 'noch aus liste ermitteln..'; - //alert('user list click, user: ' + user_name); - um_get_user_list(); + $('#nutzerLoeschen').prop( "disabled", false ); + /* + var users = []; + $('#nutzerliste :selected').each(function(i, selected){ + users[i] = $(selected).text(); + }); + */ + //alert(users[0]); } @@ -48,33 +64,41 @@ } function um_show_user_list(resp) { + $("#nutzerliste").empty(); var users = resp.List[0]; - for(var i = 0; i < users.List.length; i++) { + for(var i = 1; i < users.List.length; i++) { var user = users.List[i]; $("#nutzerliste").append('<option value=' + user.String + '>' + user.String + '</option>'); } + $('#nutzerLoeschen').prop( "disabled", true ); //var user1 = users.List[1]; //var username = user1.String; //alert(username); - //$("#nutzerliste").append('<option value=' + UpdateItem + '>' + UpdateItem + '</option>'); +} + +function um_clear_user_form() { + $('#anmeldename').val(''); + $('#kennwort').val(''); + $('#kennwortw').val(''); } /* ---- api calls ----- */ -function um_apicall(obj) { - var c = 'de.uhilger.um.api.UserMgr'; +function um_apicall_create_user(user) { var m = 'createUser'; - var u = '../api?c=' + c + '&m=' + m; + var u = '../svc/' + m; $.ajax({ url: u, data: { - p: obj + p: user }, type: "POST", dataType : "html", - //success: function( resp ) { + success: function( resp ) { //$('#fehler').html('Antwort: ' + resp); - //}, + um_apicall_get_user_list(); + um_clear_user_form(); + }, error: function( xhr, status, errorThrown ) { $('#fehler').html("Error: " + errorThrown + " Status: " + status); }, @@ -84,8 +108,29 @@ }); } -function um_get_user_list() { - var c = 'de.uhilger.um.api.UserMgr'; +function um_apicall_del_user(user) { + var m = 'deleteUser'; + var u = '../svc/' + m; + $.ajax({ + url: u, + data: { + p: user + }, + type: "POST", + dataType : "html", + success: function( resp ) { + um_apicall_get_user_list(); + }, + error: function( xhr, status, errorThrown ) { + $('#fehler').html("Error: " + errorThrown + " Status: " + status); + }, + complete: function( xhr, status ) { + //alert( "The request is complete!" ); + } + }); +} + +function um_apicall_get_user_list() { var m = 'getUserNameList'; var u = '../svc/' + m; $.ajax({ @@ -93,7 +138,6 @@ type: "GET", dataType : "json", success: function( resp ) { - //$('#fehler').html('Antwort: ' + resp); um_show_user_list(resp); }, error: function( xhr, status, errorThrown ) { -- Gitblit v1.9.3