Groups.vue 9.17 KB
Newer Older
janis.streib's avatar
janis.streib committed
1
2
3
<template>
  <div class="oe-overview">
    <h1>Gruppen</h1>
janis.streib's avatar
janis.streib committed
4
    <p>
janis.streib's avatar
janis.streib committed
5
      Gruppen werden Broadcastdomains (BCDs) und Domains (FQDNs), sowie Konten zugeordnet.
6
      Diese Zuordnungen regeln, wer auf welche Domains und welche Bereiche zugreifen kann.
janis.streib's avatar
janis.streib committed
7
8
      OE-Betreuer können diese Gruppen administrieren.
      <br/>
janis.streib's avatar
FMT    
janis.streib committed
9
10
      Durch Untergruppen wird es ermöglicht,
      <b-link to="/user/tokens">Unterkonten</b-link>
11
12
      auf einen Teil der Zuordnungen der Gruppen des Hauptkontos einzuschränken.
      So kann eine höhere Sicherheit Ihrer API-Anwendungen erzielt werden.
janis.streib's avatar
janis.streib committed
13
14
    </p>
    <hr/>
janis.streib's avatar
janis.streib committed
15
    <Loading :data="[groups]">
janis.streib's avatar
janis.streib committed
16
17
18
19
20
21
22
23
      <b-button style="margin-bottom: 20px" block variant="outline-success"
                id="button-create-group" @click="createSubgroup('')">
        <font-awesome-icon :icon="['fas', 'plus']"/>
      </b-button>
      <b-tooltip target="button-create-group" triggers="hover"
                 variant="success" placement="bottom">
        Neue Gruppe anlegen
      </b-tooltip>
janis.streib's avatar
janis.streib committed
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
      <Paginator :items="groups" items_per_page="15">
        <template v-slot:item="data">
          <GroupCard
            v-bind:key="data.item.name"
            :mgrs="mgrs"
            :group=data.item
            :groups="groups"
            :create-bcd2-group="createBCD2Group"
            :create-fqdn2-group="createFQDN2Group"
            :create-mgr2-group="createMgr2Group"
            :create-subgroup="createSubgroup"
            :delete-bcd-item="deleteBCDItem"
            :delete-mgr-item="deleteMgrItem"
            :delete-fqdn-item="deleteFQDNItem"
            :edit-fqdn2-group="editFQDN2Group"
            :subgroups="groups_by_parent[data.item.name]"
            :fqdn2grp="fqdn2grp"
            :bcds2grp="bcds2grp"
            :mgrs2grp="mgrs2grp"
            :delete-group="deleteGroup"
            :edit-group="editGroup"
janis.streib's avatar
janis.streib committed
45
            :show-e-v-log="showEvLog"
janis.streib's avatar
janis.streib committed
46
47
48
49
          >
          </GroupCard>
        </template>
      </Paginator>
50
51
52
53
      <div v-if="!groups || groups.length === 0"
           class="font-italic text-center mb-3">
        Keine Gruppen vorhanden
      </div>
janis.streib's avatar
janis.streib committed
54
    </Loading>
janis.streib's avatar
janis.streib committed
55
    <DBEditor modal_id="assign_to_group" :object_function="db_editor_function"
janis.streib's avatar
janis.streib committed
56
              :object_fq_name="db_editor_object_fq_name"
janis.streib's avatar
janis.streib committed
57
              :presets="db_editor_presets"
janis.streib's avatar
janis.streib committed
58
              :non_optionals_order="db_editor_non_optionals_order"
janis.streib's avatar
janis.streib committed
59
              :object_title="db_editor_object_fq_name != null?db_editor_object_fq_name[db_editor_object_fq_name]:''"
janis.streib's avatar
janis.streib committed
60
61
              :old_data="db_editor_old_data">
    </DBEditor>
janis.streib's avatar
janis.streib committed
62
63
    <EVLogViewer v-if="evlogGroup" modal_id="groups-evlog"
                 :title="'Gruppe: ' + evlogGroup.name" ref_obj_fq="cntl.group" refobj_id_field="name" :refobj_id_value="evlogGroup.name"></EVLogViewer>
janis.streib's avatar
janis.streib committed
64
65
66
67
68
69
70
  </div>
</template>

<script>
import GroupService from '@/api-services/groups.service'
import Loading from '@/components/Loading'
import apiutil from '@/util/apiutil'
janis.streib's avatar
janis.streib committed
71
72
import transactionutil from '@/util/transactionutil'
import Mgr2GroupService from '@/api-services.gen/cntl.mgr2group'
janis.streib's avatar
janis.streib committed
73
74
import BCD2GroupService from '@/api-services.gen/nd.bcd2group'
import FQDN2GroupService from '@/api-services.gen/dns.fqdn2group'
janis.streib's avatar
janis.streib committed
75
import GenGroupService from '@/api-services.gen/cntl.group'
janis.streib's avatar
janis.streib committed
76
import DBEditor from '@/components/DBEditor'
janis.streib's avatar
janis.streib committed
77
import GroupCard from '@/components/GroupCard'
janis.streib's avatar
janis.streib committed
78
import Paginator from '@/components/Paginator'
janis.streib's avatar
janis.streib committed
79
import EVLogViewer from '@/components/EVLogViewer'
janis.streib's avatar
janis.streib committed
80
81
82

export default {
  name: 'Groups',
janis.streib's avatar
janis.streib committed
83
  components: {EVLogViewer, Paginator, GroupCard, DBEditor, Loading},
janis.streib's avatar
janis.streib committed
84
85
86
  data() {
    return {
      mgrs: null,
janis.streib's avatar
janis.streib committed
87
      evlogGroup: null,
janis.streib's avatar
janis.streib committed
88
      db_editor_presets: {},
janis.streib's avatar
janis.streib committed
89
90
      db_editor_object_fq_name: null,
      db_editor_function: 'create',
janis.streib's avatar
janis.streib committed
91
92
93
      default_order: ['group_name', 'parent_name', 'description', 'do_copy_assignments', 'mgr_login_name', 'bcd_name', 'fqdn_value'],
      group_create_order: ['name', 'description', 'ou_short_name'],
      db_editor_non_optionals_order: ['group_name', 'parent_name', 'description', 'do_copy_assignments', 'mgr_login_name', 'bcd_name', 'fqdn_value'],
janis.streib's avatar
janis.streib committed
94
95
96
97
98
99
      db_editor_old_data: {},
      db_editor_object_title: {
        'cntl.mgr2group': 'Konto-zu-Gruppen-Zuordnung',
        'nd.bcd2group': 'BCD-zu-Gruppen-Zuordnung',
        'dns.fqdn2group': 'Domain-zu-Gruppen-Zuordnung'
      },
janis.streib's avatar
janis.streib committed
100
101
102
103
104
      mgrs2grp: null,
      bcds2grp: null,
      fqdn2grp: null,
      groups: null,
      ous: null,
janis.streib's avatar
janis.streib committed
105
      groups_by_parent: null
janis.streib's avatar
janis.streib committed
106
107
108
109
110
111
    }
  },
  methods: {
    async refresh() {
      this.groups = this.mgrs2ou = this.ous = null
      const res = (await GroupService.list(this.$store.state.netdb_axios_config, true)).data
janis.streib's avatar
janis.streib committed
112
      this.groups = res[0].filter(group => !group.is_sub_group)
janis.streib's avatar
janis.streib committed
113
114
115
      this.bcds2grp = apiutil.dict_of_lists_by_value_of_array(res[2], 'group_name')
      this.mgrs2grp = apiutil.dict_of_lists_by_value_of_array(res[1], 'group_name')
      this.fqdn2grp = apiutil.dict_of_lists_by_value_of_array(res[3], 'group_name')
116
117
118
      this.mgrs = apiutil.dict_by_value_of_array(res[4], 'login_name')
      const subgroups = res[0].filter(group => group.is_sub_group)
      this.groups_by_parent = apiutil.dict_of_lists_by_value_of_array(subgroups, 'parent_name')
janis.streib's avatar
janis.streib committed
119
120
      this.bcds = apiutil.dict_by_value_of_array(res[5], 'name')
    },
janis.streib's avatar
janis.streib committed
121
    deleteMgrItem(item) {
janis.streib's avatar
janis.streib committed
122
123
124
125
126
127
      const ta = transactionutil.generateDeleteElement('cntl.mgr2group', Mgr2GroupService.deleteParamsList(), item, item.mgr_login_name + ' aus Gruppe ' + item.group_name)
      this.$store.commit('addTransactionElement', ta)
      this.$emit('commited', ta)
      if (!this.isMobile() && !this.$store.state.show_sidebar) {
        this.$store.state.show_sidebar = true
      }
janis.streib's avatar
janis.streib committed
128
    },
janis.streib's avatar
janis.streib committed
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
    deleteBCDItem(item) {
      const ta = transactionutil.generateDeleteElement('nd.bcd2group', BCD2GroupService.deleteParamsList(), item, item.bcd_name + ' aus Gruppe ' + item.group_name)
      this.$store.commit('addTransactionElement', ta)
      this.$emit('commited', ta)
      if (!this.isMobile() && !this.$store.state.show_sidebar) {
        this.$store.state.show_sidebar = true
      }
    },
    deleteFQDNItem(item) {
      const ta = transactionutil.generateDeleteElement('dns.fqdn2group', FQDN2GroupService.deleteParamsList(), item, item.fqdn_value + ' aus Gruppe ' + item.group_name)
      this.$store.commit('addTransactionElement', ta)
      this.$emit('commited', ta)
      if (!this.isMobile() && !this.$store.state.show_sidebar) {
        this.$store.state.show_sidebar = true
      }
    },
janis.streib's avatar
janis.streib committed
145
146
147
148
149
150
151
152
    deleteGroup(item) {
      const ta = transactionutil.generateDeleteElement('cntl.group', GenGroupService.deleteParamsList(), item, 'Gruppe ' + item.name)
      this.$store.commit('addTransactionElement', ta)
      this.$emit('commited', ta)
      if (!this.isMobile() && !this.$store.state.show_sidebar) {
        this.$store.state.show_sidebar = true
      }
    },
janis.streib's avatar
janis.streib committed
153
154
155
156
157
    createSubgroup(parent_name) {
      this.db_editor_function = 'create'
      this.db_editor_old_data = {}
      this.db_editor_presets = {parent_name: parent_name}
      this.db_editor_object_fq_name = 'cntl.group'
janis.streib's avatar
janis.streib committed
158
      this.db_editor_non_optionals_order = this.default_order
janis.streib's avatar
janis.streib committed
159
      if (parent_name === '') {
janis.streib's avatar
janis.streib committed
160
161
        this.db_editor_non_optionals_order = this.group_create_order
      }
janis.streib's avatar
janis.streib committed
162
163
      this.$root.$emit('bv::show::modal', 'assign_to_group')
    },
janis.streib's avatar
janis.streib committed
164
165
166
167
168
169
    showEvLog(group) {
      this.evlogGroup = group
      this.$root.$nextTick(() => {
        this.$root.$emit('bv::show::modal', 'groups-evlog')
      })
    },
janis.streib's avatar
janis.streib committed
170
    createMgr2Group(group_name) {
janis.streib's avatar
janis.streib committed
171
172
      this.db_editor_function = 'create'
      this.db_editor_old_data = {}
janis.streib's avatar
janis.streib committed
173
      this.db_editor_presets = {group_name: group_name}
janis.streib's avatar
janis.streib committed
174
      this.db_editor_object_fq_name = 'cntl.mgr2group'
janis.streib's avatar
janis.streib committed
175
      this.db_editor_non_optionals_order = this.default_order
janis.streib's avatar
janis.streib committed
176
177
178
179
180
181
182
      this.$root.$emit('bv::show::modal', 'assign_to_group')
    },
    createBCD2Group(group_name) {
      this.db_editor_function = 'create'
      this.db_editor_old_data = {}
      this.db_editor_presets = {group_name: group_name}
      this.db_editor_object_fq_name = 'nd.bcd2group'
janis.streib's avatar
janis.streib committed
183
      this.db_editor_non_optionals_order = this.default_order
janis.streib's avatar
janis.streib committed
184
185
186
187
188
189
190
      this.$root.$emit('bv::show::modal', 'assign_to_group')
    },
    createFQDN2Group(group_name) {
      this.db_editor_function = 'create'
      this.db_editor_old_data = {}
      this.db_editor_presets = {group_name: group_name}
      this.db_editor_object_fq_name = 'dns.fqdn2group'
janis.streib's avatar
janis.streib committed
191
      this.db_editor_non_optionals_order = this.default_order
janis.streib's avatar
janis.streib committed
192
193
194
      this.$root.$emit('bv::show::modal', 'assign_to_group')
    },
    editFQDN2Group(item) {
janis.streib's avatar
janis.streib committed
195
      this.db_editor_function = 'update'
janis.streib's avatar
janis.streib committed
196
      this.db_editor_presets = item
janis.streib's avatar
janis.streib committed
197
198
      this.db_editor_old_data = item
      this.db_editor_object_fq_name = 'dns.fqdn2group'
janis.streib's avatar
janis.streib committed
199
      this.db_editor_non_optionals_order = this.default_order
janis.streib's avatar
janis.streib committed
200
      this.$root.$emit('bv::show::modal', 'assign_to_group')
janis.streib's avatar
janis.streib committed
201
202
203
204
    },
    editGroup(item) {
      window.console.debug(item)
      this.db_editor_function = 'update'
janis.streib's avatar
janis.streib committed
205
      this.db_editor_presets = item
janis.streib's avatar
janis.streib committed
206
207
      this.db_editor_old_data = item
      this.db_editor_object_fq_name = 'cntl.group'
janis.streib's avatar
janis.streib committed
208
209
210
211
212
      if (!item.is_sub_group) {
        this.db_editor_non_optionals_order = this.group_create_order
      } else {
        this.db_editor_non_optionals_order = this.default_order
      }
janis.streib's avatar
janis.streib committed
213
      this.$root.$emit('bv::show::modal', 'assign_to_group')
janis.streib's avatar
janis.streib committed
214
215
216
217
218
219
220
221
222
223
224
    }
  },
  async mounted() {
    await this.refresh()
  }
}
</script>

<style scoped>

</style>