opencode ergebnis V0.1
This commit is contained in:
1 parent
61d86a3d83
commit
7e498ebc3f
71 files changed
+28982
-46
No files matched your search
@@ -0,0 +1,78 @@
|
||||
const tenant = window.location.pathname.split('/')[1];
|
||||
const apiBase = `/${tenant}/admin/api`;
|
||||
|
||||
function changeRole(accountId, role) {
|
||||
fetch(`${apiBase}/accounts/${accountId}/role`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({role: role})
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (data.success) alert('Rolle geändert');
|
||||
});
|
||||
}
|
||||
|
||||
function openPasswordModal(accountId) {
|
||||
document.getElementById('pwdAccountId').value = accountId;
|
||||
document.getElementById('passwordModal').showModal();
|
||||
}
|
||||
|
||||
function closePasswordModal() {
|
||||
document.getElementById('passwordModal').close();
|
||||
document.getElementById('newPassword').value = '';
|
||||
}
|
||||
|
||||
function resetPassword() {
|
||||
const accountId = document.getElementById('pwdAccountId').value;
|
||||
const password = document.getElementById('newPassword').value;
|
||||
fetch(`${apiBase}/accounts/${accountId}/password`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({password: password})
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (data.success) {
|
||||
alert('Passwort zurückgesetzt');
|
||||
closePasswordModal();
|
||||
} else {
|
||||
alert(data.error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleteAccount(accountId) {
|
||||
if (!confirm('Account wirklich löschen?')) return;
|
||||
fetch(`${apiBase}/accounts/${accountId}`, {
|
||||
method: 'DELETE'
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (data.success) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function openCreateAccountModal() {
|
||||
document.getElementById('createAccountModal').showModal();
|
||||
}
|
||||
|
||||
function closeCreateAccountModal() {
|
||||
document.getElementById('createAccountModal').close();
|
||||
document.getElementById('newAccountName').value = '';
|
||||
document.getElementById('newAccountPassword').value = '';
|
||||
}
|
||||
|
||||
function createAccount() {
|
||||
const name = document.getElementById('newAccountName').value;
|
||||
const password = document.getElementById('newAccountPassword').value;
|
||||
const role = document.getElementById('newAccountRole').value;
|
||||
fetch(`${apiBase}/accounts`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({name, password, role})
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (data.success) {
|
||||
alert('Account angelegt');
|
||||
location.reload();
|
||||
} else {
|
||||
alert(data.error);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user