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>