| | |
| | | $('#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 ------ */ |
| | |
| | | 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() { |
| | |
| | | /* ----------- ui interaction ------------ */ |
| | | |
| | | function um_user_list_click() { |
| | | var user_name = 'noch aus liste ermitteln..'; |
| | | alert('user list click, user: ' + user_name); |
| | | $('#nutzerLoeschen').prop( "disabled", false ); |
| | | /* |
| | | var users = []; |
| | | $('#nutzerliste :selected').each(function(i, selected){ |
| | | users[i] = $(selected).text(); |
| | | }); |
| | | */ |
| | | //alert(users[0]); |
| | | } |
| | | |
| | | |
| | |
| | | return user; |
| | | } |
| | | |
| | | function um_show_user_list(resp) { |
| | | $("#nutzerliste").empty(); |
| | | var users = resp.List[0]; |
| | | 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); |
| | | } |
| | | |
| | | 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); |
| | | }, |
| | | complete: function( xhr, status ) { |
| | | //alert( "The request is complete!" ); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | 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({ |
| | | url: u, |
| | | type: "GET", |
| | | dataType : "json", |
| | | success: function( resp ) { |
| | | um_show_user_list(resp); |
| | | }, |
| | | error: function( xhr, status, errorThrown ) { |
| | | $('#fehler').html("Error: " + errorThrown + " Status: " + status); |
| | | }, |