Commit 61aeedd2 authored by Janis Streib's avatar Janis Streib 🦉
Browse files

UPD: refactored ou view

parent 2c2b4520
Pipeline #152811 passed with stages
in 5 minutes and 56 seconds
<template>
<b-card no-body :key="'card-account-' + ou.short_name" class="mb-4 shadow">
<template v-slot:header>
<b-row>
<b-col>
<h4>
{{ ou.name }} ({{ ou.short_name }})
</h4>
<p class="text-muted">Organisationseinheit</p>
</b-col>
<b-col lg="2">
<b-button-group class="d-flex">
<b-button variant="outline-secondary" :id="'show-evlog-ou-' + ou.short_name"
@click="show_ev_log(ou)">
<font-awesome-icon icon="history"></font-awesome-icon>
</b-button>
<b-tooltip :target="'show-evlog-ou-' + ou.short_name" triggers="hover"
variant="secondary" placement="bottom">
Eventlog
</b-tooltip>
</b-button-group>
</b-col>
</b-row>
</template>
<b-button block squared variant="outline-secondary" v-b-toggle="ou.short_name + '-collapse'">
OE-Betreuer
<b-badge pill v-if="ou_mgrs">{{
ou_mgrs.length
}}
</b-badge>
<b-badge pill v-else>0</b-badge>
<br/>
<font-awesome-icon class="collapse-icon" :icon="['fas','chevron-down']"/>
</b-button>
<b-collapse :id="ou.short_name + '-collapse'">
<b-table :items="ou_mgrs" :fields="ou_list_fields">
<template v-slot:cell(first_name)="data">
{{ mgrs_by_login_name[data.item.mgr_login_name].first_name }}
</template>
<template v-slot:cell(last_name)="data">
{{ mgrs_by_login_name[data.item.mgr_login_name].last_name }}
</template>
<template v-slot:cell(email)="data">
<b-link :href="'mailto:'+mgrs_by_login_name[data.item.mgr_login_name].email">
{{ mgrs_by_login_name[data.item.mgr_login_name].email }}
</b-link>
</template>
<template v-slot:head(actions)>
<b-button @click="create_mgr_assignment(ou.short_name)" block variant="outline-success"
:id="'button-assign-mgr-' + ou.short_name">
<font-awesome-icon :icon="['fas', 'plus']"/>
</b-button>
<b-tooltip :target="'button-assign-mgr-' + ou.short_name" triggers="hover"
variant="success" placement="left">
Neuen Account zuordnen
</b-tooltip>
</template>
<template v-slot:cell(actions)="data">
<b-button-group class="d-flex">
<b-button @click="delete_mgr_assignment(data.item)" variant="outline-danger"
:id="'button-unassign-mgr-' + data.item.bcd_name">
<font-awesome-icon :icon="['fas', 'unlink']"></font-awesome-icon>
</b-button>
<b-tooltip :target="'button-unassign-mgr-' + data.item.bcd_name" triggers="hover"
variant="danger" placement="left">
Zuweisung aufheben
</b-tooltip>
</b-button-group>
</template>
</b-table>
</b-collapse>
<b-button block squared variant="outline-secondary"
v-b-toggle="ou.short_name + '-collapse-domains'">
Domains
<b-badge pill v-if="ou_fqdns">{{
ou_fqdns.length
}}
</b-badge>
<b-badge pill v-else>0</b-badge>
<br/>
<font-awesome-icon class="collapse-icon" :icon="['fas','chevron-down']"/>
</b-button>
<b-collapse :id="ou.short_name + '-collapse-domains'">
<b-table :items="ou_fqdns" :fields="fqdn_list_fields">
<template v-slot:head(actions)>
<b-button block variant="outline-success"
:id="'button-assign-fqdn-' + ou.short_name"
@click="create_fqdn_assignment(ou.short_name)">
<font-awesome-icon :icon="['fas', 'plus']"/>
</b-button>
<b-tooltip :target="'button-assign-fqdn-' + ou.short_name" triggers="hover"
variant="success" placement="left">
Neue Domain zuordnen
</b-tooltip>
</template>
<template v-slot:cell(actions)="data">
<b-button-group class="d-flex">
<b-button @click="delete_fqdn_assignment(data.item)" variant="outline-danger"
:id="'button-unassign-fqdn-' + data.item.fqdn_value">
<font-awesome-icon :icon="['fas', 'unlink']"></font-awesome-icon>
</b-button>
<b-tooltip :target="'button-unassign-fqdn-' + data.item.fqdn_value" triggers="hover"
variant="danger" placement="bottom">
Zuweisung aufheben
</b-tooltip>
</b-button-group>
</template>
</b-table>
</b-collapse>
<b-button block squared variant="outline-secondary"
v-b-toggle="ou.short_name + '-collapse-bcds'">
Broadcastdomains (BCDs)
<b-badge pill v-if="ou_bcds">{{
ou_bcds.length
}}
</b-badge>
<b-badge pill v-else>0</b-badge>
<br/>
<font-awesome-icon class="collapse-icon" :icon="['fas','chevron-down']"/>
</b-button>
<b-collapse :id="ou.short_name + '-collapse-bcds'">
<b-table :items="ou_bcds" :fields="bcd_list_fields">
<template v-slot:cell(name)="item">
<b-link :to="'/dnsvs/bcds/' + item.item.name">{{ item.item.name }}</b-link>
</template>
</b-table>
</b-collapse>
</b-card>
</template>
<script>
export default {
name: 'OUCard',
data() {
return {
bcd_list_fields: [
{
key: 'name',
label: 'BCD',
sortable: true
},
{
key: 'description',
label: 'Beschreibung',
sortable: true
}
],
fqdn_list_fields: [
{
key: 'fqdn_value',
label: 'FQDN',
sortable: true
},
{
key: 'actions',
label: 'Aktionen',
sortable: false
}
],
ou_list_fields: [
{
key: 'mgr_login_name',
label: 'Login Name',
sortable: false
},
{
key: 'first_name',
label: 'Vorname',
sortable: false
},
{
key: 'last_name',
label: 'Nachname',
sortable: false
},
{
key: 'email',
label: 'E-Mail',
sortable: false
},
{
key: 'actions',
label: 'Aktionen',
sortable: false
}
]
}
},
props: {
ou: {
type: Object,
required: true
},
ou_bcds: {
type: Array,
required: true
},
ou_fqdns: {
type: Array,
required: true
},
ou_mgrs: {
type: Array,
required: true
},
mgrs_by_login_name: {
type: Object,
required: true
},
show_ev_log: {
type: Function,
required: true
},
delete_fqdn_assignment: {
type: Function,
required: true
},
create_fqdn_assignment: {
type: Function,
required: true
},
create_mgr_assignment: {
type: Function,
required: true
},
delete_mgr_assignment: {
type: Function,
required: true
}
}
}
</script>
<style scoped>
</style>
<template>
<div class="oe-overview">
<h1>Organisationseinheiten</h1>
<b-checkbox :value="true" :unchecked-value="false" v-model="only_own_oe" switch>Nur eigene Organisationseinheiten
<div class="ou-overview">
<h1 v-if="is_entry">Organisationseinheiten</h1>
<h1 v-else>{{ou.name}} <small class="text-muted">Organisationseinheit</small></h1>
<b-checkbox v-if="is_entry" :value="true" :unchecked-value="false" v-model="only_own_ou" switch>Nur eigene Organisationseinheiten
anzeigen
</b-checkbox>
<hr/>
<hr>
<h2 v-if="!is_entry">Untergeordnete Organisationseinheiten</h2>
<Loading :data="[ous, mgrs]">
<Paginator :items="ous" items_per_page="15">
<Paginator :items="ous" items_per_page="15" no_items_text="Keine Organisationseinheiten vorhanden">
<template v-slot:item="card_data">
<b-card no-body :key="'card-account-' + card_data.item.short_name" class="mb-4 shadow">
<template v-slot:header>
<b-row>
<b-col>
<h4>
{{ card_data.item.name }} ({{ card_data.item.short_name }})
</h4>
<p class="text-muted">Organisationseinheit</p>
</b-col>
<b-col lg="2">
<b-button-group class="d-flex">
<b-button variant="outline-secondary" :id="'show-evlog-ou-' + card_data.item.short_name"
@click="showEvLog(card_data.item)">
<font-awesome-icon icon="history"></font-awesome-icon>
</b-button>
<b-tooltip :target="'show-evlog-ou-' + card_data.item.short_name" triggers="hover"
variant="secondary" placement="bottom">
Eventlog
</b-tooltip>
</b-button-group>
</b-col>
</b-row>
</template>
<b-button block squared variant="outline-secondary" v-b-toggle="card_data.item.short_name + '-collapse'">
OE-Betreuer<br/>
<font-awesome-icon class="collapse-icon" :icon="['fas','chevron-down']"/>
</b-button>
<b-collapse :id="card_data.item.short_name + '-collapse'">
<b-table :items="mgrs2ou[card_data.item.short_name]" :fields="ou_list_fields">
<template v-slot:cell(first_name)="data">
{{ mgrs[data.item.mgr_login_name].first_name }}
</template>
<template v-slot:cell(last_name)="data">
{{ mgrs[data.item.mgr_login_name].last_name }}
</template>
<template v-slot:cell(email)="data">
<b-link :href="'mailto:'+mgrs[data.item.mgr_login_name].email">
{{ mgrs[data.item.mgr_login_name].email }}
</b-link>
</template>
<template v-slot:head(actions)>
<b-button @click="assign_mgr(card_data.item.short_name)" block variant="outline-success"
:id="'button-assign-mgr-' + card_data.item.short_name">
<font-awesome-icon :icon="['fas', 'plus']"/>
</b-button>
<b-tooltip :target="'button-assign-mgr-' + card_data.item.short_name" triggers="hover"
variant="success" placement="left">
Neuen Account zuordnen
</b-tooltip>
</template>
<template v-slot:cell(actions)="data">
<b-button-group class="d-flex">
<b-button @click="deleteMgrItem(data.item)" variant="outline-danger"
:id="'button-unassign-mgr-' + data.item.bcd_name">
<font-awesome-icon :icon="['fas', 'unlink']"></font-awesome-icon>
</b-button>
<b-tooltip :target="'button-unassign-mgr-' + data.item.bcd_name" triggers="hover"
variant="danger" placement="left">
Zuweisung aufheben
</b-tooltip>
</b-button-group>
</template>
</b-table>
</b-collapse>
<b-button block squared variant="outline-secondary"
v-b-toggle="card_data.item.short_name + '-collapse-domains'">
Domains
<b-badge pill v-if="fqdns2ou[card_data.item.short_name]">{{
fqdns2ou[card_data.item.short_name].length
}}
</b-badge>
<b-badge pill v-else>0</b-badge>
<br/>
<font-awesome-icon class="collapse-icon" :icon="['fas','chevron-down']"/>
</b-button>
<b-collapse :id="card_data.item.short_name + '-collapse-domains'">
<b-table :items="fqdns2ou[card_data.item.short_name]" :fields="fqdn_list_fields">
<template v-slot:head(actions)>
<b-button block variant="outline-success"
:id="'button-assign-fqdn-' + card_data.item.short_name"
@click="createFqdn2OU(card_data.item.short_name)">
<font-awesome-icon :icon="['fas', 'plus']"/>
</b-button>
<b-tooltip :target="'button-assign-fqdn-' + card_data.item.short_name" triggers="hover"
variant="success" placement="left">
Neue Domain zuordnen
</b-tooltip>
</template>
<template v-slot:cell(actions)="data">
<b-button-group class="d-flex">
<b-button @click="deleteFqdnItem(data.item)" variant="outline-danger"
:id="'button-unassign-fqdn-' + data.item.fqdn_value">
<font-awesome-icon :icon="['fas', 'unlink']"></font-awesome-icon>
</b-button>
<b-tooltip :target="'button-unassign-fqdn-' + data.item.fqdn_value" triggers="hover"
variant="danger" placement="bottom">
Zuweisung aufheben
</b-tooltip>
</b-button-group>
</template>
</b-table>
</b-collapse>
<b-button block squared variant="outline-secondary"
v-b-toggle="card_data.item.short_name + '-collapse-bcds'">
Broadcastdomains (BCDs)
<b-badge pill v-if="bcds2ou[card_data.item.short_name]">{{
bcds2ou[card_data.item.short_name].length
}}
</b-badge>
<b-badge pill v-else>0</b-badge>
<br/>
<font-awesome-icon class="collapse-icon" :icon="['fas','chevron-down']"/>
</b-button>
<b-collapse :id="card_data.item.short_name + '-collapse-bcds'">
<b-table :items="bcds2ou[card_data.item.short_name]" :fields="bcd_list_fields">
<template v-slot:cell(name)="item">
<b-link :to="'/dnsvs/bcds/' + item.item.name">{{item.item.name}}</b-link>
</template>
</b-table>
</b-collapse>
</b-card>
<OUCard :create_fqdn_assignment="create_fqdn_assignment"
:create_mgr_assignment="create_mgr_assignment"
:delete_fqdn_assignment="delete_fqdn_assignment"
:delete_mgr_assignment="delete_mgr_assignment"
:ou="card_data.item"
:mgrs_by_login_name="mgrs"
:ou_mgrs="mgrs2ou[card_data.item.short_name] || []"
:ou_fqdns="fqdns2ou[card_data.item.short_name] || []"
:ou_bcds="bcds2ou[card_data.item.short_name] || []"
:show_ev_log="show_ev_log"
>
</OUCard>
</template>
</Paginator>
<div v-if="!ous || ous.length === 0"
class="font-italic text-center mb-3">
Keine Organisationseinheiten vorhanden
</div>
</Loading>
<DBEditor modal_id="assign_user_to_oe" object_function="create" object_fq_name="cntl.mgr2ou"
:presets="db_editor_presets"
......@@ -144,102 +33,54 @@
:presets="db_editor_presets"
:non_optionals_order="['ou_short_name', 'fqdn_value']"
object_title="Domain-zu-Organisationseinheits-Zuordnung"></DBEditor>
<EVLogViewer v-if="evlogOu" modal_id="ou_evlog" ref_obj_fq="org.unit" refobj_id_field="short_name"
:refobj_id_value="evlogOu.short_name"
:title="'Organisationseinheit: ' + evlogOu.name"></EVLogViewer>
<EVLogViewer v-if="evlog_ou" modal_id="ou_evlog" ref_obj_fq="org.unit" refobj_id_field="short_name"
:refobj_id_value="evlog_ou.short_name"
:title="'Organisationseinheit: ' + evlog_ou.name"></EVLogViewer>
</div>
</template>
<script>
import OUService from '@/api-services/ou.service'
import Loading from '@/components/Loading'
import EVLogViewer from '@/components/EVLogViewer'
import Paginator from '@/components/Paginator'
import apiutil from '@/util/apiutil'
import DBEditor from '@/components/DBEditor'
import transactionutil from '@/util/transactionutil'
import Mgr2OuService from '@/api-services.gen/cntl.mgr2ou'
import FQDN2OuService from '@/api-services.gen/dns.fqdn2ou'
import OUCard from '@/components/OUCard'
import Paginator from '@/components/Paginator'
import Loading from '@/components/Loading'
import DBEditor from '@/components/DBEditor'
import EVLogViewer from '@/components/EVLogViewer'
export default {
name: 'OE',
components: {DBEditor, Loading, Paginator, EVLogViewer},
watch: {
only_own_oe: {
immediate: true,
async handler() {
await this.refresh()
}
}
},
name: 'OUOverview',
components: {EVLogViewer, DBEditor, Loading, Paginator, OUCard},
data() {
return {
evlogOu: null,
only_own_oe: true,
ou: {name: 'Foo Bar'}, // dummy var, contains current ou (if not is_entry)
is_entry: true, // dummy var
evlog_ou: null,
only_own_ou: true,
mgrs2ou: null,
bcds2ou: null,
fqdnss2ou: null,
fqdns2ou: null,
mgrs: null,
ous: null,
db_editor_presets: {},
bcd_list_fields: [
{
key: 'name',
label: 'BCD',
sortable: true
},
{
key: 'description',
label: 'Beschreibung',
sortable: true
}
],
fqdn_list_fields: [
{
key: 'fqdn_value',
label: 'FQDN',
sortable: true
},
{
key: 'actions',
label: 'Aktionen',
sortable: false
}
],
ou_list_fields: [
{
key: 'mgr_login_name',
label: 'Login Name',
sortable: false
},
{
key: 'first_name',
label: 'Vorname',
sortable: false
},
{
key: 'last_name',
label: 'Nachname',
sortable: false
},
{
key: 'email',
label: 'E-Mail',
sortable: false
},
{
key: 'actions',
label: 'Aktionen',
sortable: false
}
]
db_editor_presets: {}
}
},
watch: {
only_own_ou: {
immediate: true,
async handler() {
await this.refresh()
}
}
},
methods: {
async refresh() {
this.mgrs = this.mgrs2ou = this.ous = null
let res = null
if (this.only_own_oe) {
if (this.only_own_ou) {
res = (await OUService.listOwn(this.$store.state.netdb_axios_config)).data
this.mgrs2ou = apiutil.dict_of_lists_by_value_of_array(res[2], 'ou_short_name')
this.fqdns2ou = apiutil.dict_of_lists_by_value_of_array(res[4], 'ou_short_name')
......@@ -255,15 +96,15 @@ export default {
this.ous = res[0]
}
},
assign_mgr(oe) {
this.db_editor_presets = {ou_short_name: oe}
create_mgr_assignment(ou) {
this.db_editor_presets = {ou_short_name: ou}
this.$root.$emit('bv::show::modal', 'assign_user_to_oe')
},
createFqdn2OU(oe) {
this.db_editor_presets = {ou_short_name: oe}
create_fqdn_assignment(ou) {
this.db_editor_presets = {ou_short_name: ou}
this.$root.$emit('bv::show::modal', 'assign_fqdn_to_oe')
},
deleteMgrItem(item) {
delete_mgr_assignment(item) {
const ta = transactionutil.generateDeleteElement('cntl.mgr2ou', Mgr2OuService.deleteParamsList(), item, item.mgr_login_name + ' aus OE ' + item.ou_short_name)
this.$store.commit('addTransactionElement', ta)
this.$emit('commited', ta)
......@@ -271,7 +112,7 @@ export default {
this.$store.state.show_sidebar = true
}
},
deleteFqdnItem(item) {
delete_fqdn_assignment(item) {
const ta = transactionutil.generateDeleteElement('dns.fqdn2ou', FQDN2OuService.deleteParamsList(), item, item.fqdn_value + ' aus OE ' + item.ou_short_name)
this.$store.commit('addTransactionElement', ta)
this.$emit('commited', ta)
......@@ -279,8 +120,8 @@ export default {
this.$store.state.show_sidebar = true
}
},
showEvLog(ou) {
this.evlogOu = ou
show_ev_log(ou) {
this.evlog_ou = ou
this.$root.$nextTick(() => {
this.$root.$emit('bv::show::modal', 'ou_evlog')
})
......
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