mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-04-03 14:37:29 +02:00
Add API call for frontend to fetch list of valid roles from backend
- only relevant for admin config (addUser, editRole) - admin only (double-checked)
This commit is contained in:
@@ -8,6 +8,15 @@
|
||||
let message = {msg: '', color: '#d63384'}
|
||||
let displayMessage = false
|
||||
|
||||
export let roles = []
|
||||
let roleLabel = {
|
||||
api: 'API',
|
||||
user: 'User',
|
||||
manager: 'Manager',
|
||||
support: 'Support',
|
||||
admin: 'Admin'
|
||||
}
|
||||
|
||||
async function handleAddRole() {
|
||||
const username = document.querySelector('#role-username').value
|
||||
const role = document.querySelector('#role-select').value
|
||||
@@ -86,11 +95,9 @@
|
||||
<input type="text" class="form-control" placeholder="username" id="role-username"/>
|
||||
<select class="form-select" id="role-select">
|
||||
<option selected value="">Role...</option>
|
||||
<option value="user">User</option>
|
||||
<option value="manager">Manager</option>
|
||||
<option value="support">Support</option>
|
||||
<option value="admin">Admin</option>
|
||||
<option value="api">API</option>
|
||||
{#each roles as role}
|
||||
<option value={role}>{roleLabel[role]}</option>
|
||||
{/each}
|
||||
</select>
|
||||
<!-- PreventDefault on Sveltestrap-Button more complex to achieve than just use good ol' html button -->
|
||||
<!-- see: https://stackoverflow.com/questions/69630422/svelte-how-to-use-event-modifiers-in-my-own-components -->
|
||||
|
||||
Reference in New Issue
Block a user