| | |
| | | self.vorlagen = new Vorlagen(); |
| | | var dlg = document.querySelector(".dialog"); |
| | | dlg.style.flexBasis = '0em'; |
| | | document.querySelector('#nutzer-neu-btn').addEventListener('click', self.nutzer_neu_dialog_zeigen); |
| | | document.querySelector('#top-neu-btn').addEventListener('click', self.nutzer_neu_dialog_zeigen); |
| | | document.querySelector('.west').style.flexBasis = '0em'; |
| | | document.querySelector('.ost').style.flexBasis = '0em'; |
| | | self.get_login(); |
| | |
| | | /* Rollen erteilen und entziehen */ |
| | | |
| | | this.rollen_zeigen = function(nutzerId) { |
| | | var topBtn = document.querySelector('#top-neu-btn'); |
| | | topBtn.removeEventListener('click', self.nutzer_neu_dialog_zeigen); |
| | | topBtn.addEventListener('click', self.rolle_neu_dialog_zeigen); |
| | | topBtn.title = "Neue Rolle"; |
| | | |
| | | var m = 'getUserRoleNames'; |
| | | var u = '../svc/' + m + '?p=' + nutzerId; |
| | | self.http_get(u, function (antwort) { |
| | |
| | | |
| | | this.grant_role_klick = function(event) { |
| | | self.alter_role(event, 'grantRole', function(roleId) { |
| | | self.add_role_to_user_roles(roleId); |
| | | }); |
| | | }; |
| | | |
| | | this.add_role_to_user_roles = function(roleId) { |
| | | var btn = document.createElement("button"); |
| | | btn.type = "button"; |
| | | btn.classList.add("granted-role-btn"); |
| | | btn.id = roleId; |
| | | btn.textContent = roleId; |
| | | document.querySelector('.rollen-behaelter').appendChild(btn); |
| | | }); |
| | | }; |
| | | |
| | | this.revoke_role_klick = function(event) { |
| | |
| | | var target = event.target; |
| | | var nutzerId = document.querySelector("#nutzer-id").textContent; |
| | | var roleId = target.textContent; |
| | | var u = '../svc/' + method; |
| | | var data = "p=" + self.serialisieren(new UserRole(nutzerId, roleId)); |
| | | self.http_post(u, data, function (antwort) { |
| | | updateCallback(roleId); |
| | | }); |
| | | self.alter_role_call(method, nutzerId, roleId, updateCallback); |
| | | }; |
| | | |
| | | |
| | | this.rolle_neu_dialog_zeigen = function () { |
| | | self.dialog_zeigen('data/tpl/dlg-rolle-neu.tpl', '', function(){ |
| | | var btn = document.getElementById('rolle-speichern-btn'); |
| | | if(btn !== null) { |
| | | btn.addEventListener('click', function() { |
| | | var nutzerId = document.querySelector("#nutzer-id").textContent; |
| | | var rolle = document.getElementById('rollen-id').value; |
| | | self.alter_role_call('grantRole', nutzerId, rolle, function(roleId) { |
| | | self.add_role_to_user_roles(roleId); |
| | | self.dialog_schliessen(); |
| | | }); |
| | | }); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | /* Funktionen aus App-Vorlage */ |
| | | |
| | |
| | | }); |
| | | }; |
| | | |
| | | this.alter_role_call = function(method, nutzerId, roleId, updateCallback) { |
| | | var u = '../svc/' + method; |
| | | var data = "p=" + self.serialisieren(new UserRole(nutzerId, roleId)); |
| | | self.http_post(u, data, function (antwort) { |
| | | updateCallback(roleId); |
| | | }); |
| | | }; |
| | | |
| | | /* -------- An- und Abmelden ------------- */ |
| | | |
| | | this.get_login = function() { |