| | |
| | | |
| | | function um_init() { |
| | | $('#user-form').hide(); |
| | | $('.user-save-btn').click(um_user_save); |
| | | $('#nutzerliste').click(um_user_list_click); |
| | | $('#nutzerLoeschen').click(um_del_user); |
| | |
| | | $('#nutzerLoeschen').prop( "disabled", true ); |
| | | $('#nutzerRolleEntziehen').prop( "disabled", true ); |
| | | $('#rolleErteilen').prop( "disabled", true ); |
| | | $('#rolleErteilen').click(um_grant_role); |
| | | $('#neueRolle').click(um_new_role); |
| | | $('#rollen').click(um_role_list_click); |
| | | $('#nutzerrollen').click(um_user_role_list_click); |
| | |
| | | } |
| | | } |
| | | |
| | | function um_grant_role() { |
| | | var roleIsNew = false; |
| | | var userId = um_get_first_selected_user_id(); |
| | | var roleId = um_get_first_selected_role_id(); |
| | | if(roleId !== 'none' && userId !== 'none') { |
| | | um_apicall_grant_role(userId, roleId, roleIsNew); |
| | | } |
| | | } |
| | | |
| | | /* ----------- ui interaction ------------ */ |
| | | |
| | | function um_user_list_click() { |
| | | $('#nutzerLoeschen').prop( "disabled", false ); |
| | | $('#rollen :selected').prop("selected", false); |
| | | var userId = um_get_first_selected_user_id(); |
| | | um_apicall_get_user_roles(userId); |
| | | } |
| | |
| | | return userId; |
| | | } |
| | | |
| | | function um_get_first_selected_role_id() { |
| | | var roleId = 'none'; |
| | | var roleIds = []; |
| | | $('#rollen :selected').each(function(i, selected){ |
| | | roleIds[i] = $(selected).text(); |
| | | }); |
| | | if(roleIds.length > 0) { |
| | | roleId = roleIds[0]; |
| | | } |
| | | return roleId; |
| | | } |
| | | |
| | | // {"List":[{"List":[{"String":"ROLE_NAME"},{"String":"testrolle1"}]}]} |
| | | function um_show_user_role_list(resp) { |
| | | $("#nutzerrollen").empty(); |
| | |
| | | //$('#neueRolle').prop( "disabled", true ); |
| | | $('#rolleErteilen').prop( "disabled", true ); |
| | | } |
| | | |
| | | /* ---- api calls ----- */ |
| | | |
| | | function um_apicall_create_user(user) { |