Commit d7227a61 authored by gj4210's avatar gj4210 👽
Browse files

UPD: Unified api requests for sub- & mainaccount tokens & roles

finally changed as is_own now works

ADD: Checkbox to copy roles when creating subaccounts
parent 7c9199e8
Pipeline #74005 passed with stages
in 6 minutes and 10 seconds
import TransactionService from './transaction.service'
export default {
list(config, login_name) {
list(config) {
let ta = [
// TODO: Main and Subaccounts should be put-togetherable
{"name": "cntl.mgr.list", "old": {"login_name_list": [login_name]}}, // Main Account
{"name": "cntl.mgr.list", "old": {"parent_login_name": login_name}}, // Subaccounts
{"name": "cntl.wapi_auth.list", "join": {"0": "cntl.wapi_auth.fkey_cntl_wapi_auth_mgr"}}, // Main Accounts (Session-) Tokens TODO: API doesn't return these for some reason
{"name": "cntl.wapi_auth.list", "join": {"1": "cntl.wapi_auth.fkey_cntl_wapi_auth_mgr"}}, // Subaccount Tokens
{"name": "cntl.mgr2role.list", "join": {"0": "cntl.wapi_auth.fkey_cntl_wapi_auth_mgr"}}, // Main Account Roles
{"name": "cntl.mgr2role.list", "join": {"1": "cntl.wapi_auth.fkey_cntl_wapi_auth_mgr"}} // Subaccount Roles
{"name": "cntl.mgr.list", "old": {"is_own": true}}, // Accounts
{"name": "cntl.wapi_auth.list", "join": {"0": "cntl.wapi_auth.fkey_cntl_wapi_auth_mgr"}}, // Tokens
{"name": "cntl.mgr2role.list", "join": {"0": "cntl.wapi_auth.fkey_cntl_wapi_auth_mgr"}}, // Roles
]
return TransactionService.execute(config, ta);
}
......
......@@ -11,13 +11,17 @@
placeholder="Beschreibung eingeben"
/>
</b-form-group>
<b-form-group label="Rolle:" label-for="input-account-create-role">
<b-form-select
id="input-account-create-role"
v-model="test_role"
:options="test_roles"
/>
</b-form-group>
<template v-if="roles_by_account != null && roles_by_account[$store.state.user.login_name] != null">
<b-form-group label="Rollen" label-for="input-account-create-do-copy-roles">
<b-form-checkbox id="input-account-create-do-copy-roles"
v-model="new_account.do_copy_roles">
Parent-Rollen übernehmen
</b-form-checkbox>
</b-form-group>
<template v-if="!new_account.do_copy_roles">
TODO: Rollen zuweisen <!-- TODO: look to the left-->
</template>
</template>
</b-form>
<template v-slot:modal-footer="{cancel}">
<b-button variant="outline-secondary" @click="cancel">
......@@ -56,13 +60,6 @@
placeholder="Beschreibung eingeben"
/>
</b-form-group>
<b-form-group label="Rolle:" label-for="input-account-edit-role">
<b-form-select
id="input-account-edit-role"
v-model="test_role"
:options="test_roles"
/>
</b-form-group>
</b-form>
<template v-slot:modal-footer="{cancel}">
<b-alert id="alert-edit-account" v-model="show_modal_alert"
......@@ -222,29 +219,32 @@
<p class="text-muted">Beschreibung</p>
</b-col>
<b-col>
<h5 class="mb-0">
<template
v-for="role in roles_by_account[account.login_name].slice(0, max_role_badge_count)">
<b-badge
:key="'role-badge-' + role.mgr_login_name + '-' + role.role_fq_name"
:id="account.login_name + '-role-badge-' + role.mgr_login_name + '-' + role.role_fq_name"
:style="{background: role.role_fq_name.toHSL({lit: [30, 40]})}"
class="mr-1 mb-1">{{role.system.toUpperCase()}}<br>{{role.role}}
</b-badge>
<b-popover
:key="'role-badge-tooltip' + role.mgr_login_name + '-' + role.role_fq_name"
:target="account.login_name + '-role-badge-' + role.mgr_login_name + '-' + role.role_fq_name"
triggers="hover"
placement="bottom">
<b-table :fields="permission_list_fields"
:items="role.contained_permissions"
sticky-header/>
</b-popover>
</template>
</h5>
<h6 v-if="roles_by_account[account.login_name].length > max_role_badge_count">
+ {{roles_by_account[account.login_name].length - max_role_badge_count}} Weitere
</h6>
<template v-if="roles_by_account[account.login_name] != null">
<h5 class="mb-0">
<template
v-for="role in roles_by_account[account.login_name].slice(0, max_role_badge_count)">
<b-button
:key="'role-badge-' + role.mgr_login_name + '-' + role.role_fq_name"
:id="account.login_name + '-role-badge-' + role.mgr_login_name + '-' + role.role_fq_name"
:style="{background: role.role_fq_name.toHSL({lit: [30, 40]}), border: 'none'}"
class="mr-1 mb-1 badge">{{role.system.toUpperCase()}}<br>{{role.role}}
</b-button>
<b-popover
:key="'role-badge-tooltip' + role.mgr_login_name + '-' + role.role_fq_name"
:target="account.login_name + '-role-badge-' + role.mgr_login_name + '-' + role.role_fq_name"
triggers="click blur"
placement="bottom">
<b-table :fields="permission_list_fields"
:items="role.contained_permissions"
sticky-header/>
</b-popover>
</template>
</h5>
<h6 v-if="roles_by_account[account.login_name].length > max_role_badge_count">
+ {{roles_by_account[account.login_name].length - max_role_badge_count}} Weitere
</h6>
</template>
<h6 v-else>Keine Rollen zugewiesen</h6>
<p class="text-muted">Rollen</p>
</b-col>
<b-col lg="1">
......@@ -323,15 +323,6 @@
components: {DateTimePicker},
data() {
return {
// TODO: remove test/wip data aka implement role management
test_role: 'NetVS Overlord',
test_roles: [
'NetVS Overlord',
'Dungeon Master',
'HiWi-Goblin',
'Guest',
'Individuell'
],
tokens_by_account: null,
roles_by_account: null,
accounts: null,
......@@ -339,7 +330,8 @@
parent_login_name: null,
description: '',
login_name: '',
expiration_date: null
expiration_date: null,
do_copy_roles: true
},
new_token: {
description: '',
......@@ -417,9 +409,12 @@
methods: {
fetchData() {
AccountTokenService.list(this.$store.state.netdb_axios_config, this.$store.state.user.login_name).then((response) => {
this.tokens_by_account = ApiUtil.dict_of_lists_by_value_of_array(this.formatExpiredTokens(response.data[2].concat(response.data[3])), 'login_name')
this.roles_by_account = ApiUtil.dict_of_lists_by_value_of_array(this.formatContainedPermissions(response.data[4].concat(response.data[5])), 'mgr_login_name')
this.accounts = response.data[0].concat(response.data[1])
this.accounts = response.data[0]
this.accounts.sort((a, b) => {
return a.parent_login_name == null ? -1 : b.parent_login_name == null ? 1 : 0
})
this.tokens_by_account = ApiUtil.dict_of_lists_by_value_of_array(this.formatExpiredTokens(response.data[1]), 'login_name')
this.roles_by_account = ApiUtil.dict_of_lists_by_value_of_array(this.formatContainedPermissions(response.data[2]), 'mgr_login_name')
})
},
showModalEditAccount(account) {
......@@ -448,6 +443,7 @@
this.new_account.description = ''
this.new_account.login_name = ''
this.new_account.expiration_date = null
this.new_account.do_copy_roles = true
},
resetTokenData() {
this.new_token.description = ''
......@@ -460,7 +456,7 @@
description_new: this.new_account.description,
allow_data_manipulation_new: true,
login_name_new: null,
do_copy_roles_new: true
do_copy_roles_new: this.new_account.do_copy_roles
}).then(() => {
this.$bvModal.hide('modal-create-account')
this.fetchData()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment