| | |
| | | JSON.parse(antwort), |
| | | function (html) { |
| | | document.querySelector("#nutzer").innerHTML = html; |
| | | document.querySelector("#nutzer-id").textContent = nutzerId; |
| | | document.querySelector("#nutzer-id").textContent = nutzerId; |
| | | self.addEvtListener('.granted-role-btn', 'click', self.revoke_role_klick); |
| | | var m = 'getRoleNamesGranted'; |
| | | var u = '../svc/' + m; |
| | | self.http_get(u, function (antwort2) { |
| | |
| | | JSON.parse(antwort2), |
| | | function (html) { |
| | | document.querySelector(".alle-rollen-behaelter").innerHTML = html; |
| | | document.querySelector('.zurueck-btn').addEventListener('click', function (e) { |
| | | self.get_user_list(); |
| | | }); |
| | | self.addEvtListener('.avl-role-btn', 'click', self.grant_role_klick); |
| | | }); |
| | | }); |
| | | }); |
| | | }); |
| | | }; |
| | | |
| | | this.grant_role_klick = function(event) { |
| | | self.alter_role(event, 'grantRole', 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) { |
| | | self.alter_role(event, 'revokeRole', function(roleId) { |
| | | var btn = document.querySelector("#" + roleId); |
| | | btn.parentNode.removeChild(btn); |
| | | }); |
| | | }; |
| | | |
| | | this.alter_role = function(event, method, updateCallback) { |
| | | 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); |
| | | }); |
| | | }; |
| | | |
| | | this.info_dialog_zeigen = function () { |
| | |
| | | function (h) { |
| | | var elem = document.getElementById('nutzer'); |
| | | elem.innerHTML = h; |
| | | |
| | | var absaetze = document.querySelectorAll('p.nutzer-liste-eintrag'); |
| | | var index; |
| | | for (index = 0; index < absaetze.length; index++) { |
| | | absaetze[index].addEventListener("click", self.nutzerliste_klick); |
| | | } |
| | | |
| | | self.addEvtListener('p.nutzer-liste-eintrag', 'click', self.nutzerliste_klick); |
| | | }); |
| | | }); |
| | | }; |
| | |
| | | this.serialisieren = function(obj) { |
| | | return '{"' + obj.constructor.name + '":' + JSON.stringify(obj) + '}'; |
| | | }; |
| | | |
| | | this.addEvtListener = function(selector, eventName, func) { |
| | | var elems = document.querySelectorAll(selector); |
| | | var index; |
| | | for (index = 0; index < elems.length; index++) { |
| | | elems[index].addEventListener(eventName, func); |
| | | } |
| | | }; |
| | | |
| | | } |
| | | |
| | |
| | | this.email = em; |
| | | } |
| | | |
| | | function UserRole(u, r) { |
| | | this.userId = u; |
| | | this.role = r; |
| | | } |