From 3460300ab30a19c54fd27f16d914aa07f5c63d04 Mon Sep 17 00:00:00 2001
From: Janis Streib <me@janis-streib.de>
Date: Wed, 26 Aug 2020 15:38:55 +0200
Subject: [PATCH] ADD: create macauth clients

---
 frontend/src/views/macauth/MACAuth.vue | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/frontend/src/views/macauth/MACAuth.vue b/frontend/src/views/macauth/MACAuth.vue
index 7f8ecd912..3773948f3 100644
--- a/frontend/src/views/macauth/MACAuth.vue
+++ b/frontend/src/views/macauth/MACAuth.vue
@@ -51,7 +51,7 @@
               <template v-slot:head(buttons)>
                 <b-button block variant="outline-success"
                           :id="'button-create-client-' +  bcd.name"
-                          @click="createClient">
+                          @click="createClient(bcd)">
                   <font-awesome-icon :icon="['fas', 'plus']"/>
                 </b-button>
                 <b-tooltip :target="'button-create-client-' +  bcd.name" triggers="hover"
@@ -96,6 +96,10 @@
           </b-collapse>
         </b-card>
       </template>
+      <DBEditor object_fq_name="macauth.client" :object_function="db_editor_object_function"
+                modal_id="dbeditor_macauth" :old_data="db_editor_old_data" :presets="db_editor_presets"
+                :non_optionals_order="['bcd_name', 'mac_addr', 'description']"
+      ></DBEditor>
     </Loading>
   </div>
 </template>
@@ -104,12 +108,16 @@
 import Loading from "../../components/Loading"
 import MACAuth from "@/api-services/macauth.service"
 import ApiUtil from '@/util/apiutil'
+import DBEditor from "@/components/DBEditor";
 
 export default {
   name: 'macauth',
-  components: {Loading},
+  components: {DBEditor, Loading},
   data() {
     return {
+      db_editor_object_function: 'create',
+      db_editor_old_data: {},
+      db_editor_presets: {},
       bcds: null,
       clients_by_bcd: null,
       macauth_fields: [
@@ -133,12 +141,12 @@ export default {
         },
         {
           key: 'last_login_node',
-          label: 'Letzer Login Node',
+          label: 'Letzer Login-Node',
           sortable: true
         },
         {
           key: 'last_login_port',
-          label: 'Letzer Login Port',
+          label: 'Letzer Login-Port',
           sortable: true
         },
         'buttons'
@@ -177,8 +185,11 @@ export default {
       }
       return new Date(Date.parse(value)).toLocaleString('de-DE')
     },
-    createClient() {
-      alert('TODO: DBEditor create new client')
+    createClient(bcd) {
+      this.db_editor_function = 'create'
+      this.db_editor_old_data = {}
+      this.db_editor_presets = {'bcd_name': bcd.name}
+      this.$root.$emit('bv::show::modal', 'dbeditor_macauth')
     },
     editClient() {
       alert('TODO: DBEditor edit client')
@@ -198,4 +209,4 @@ export default {
 .fullwidth .btn {
   flex: 1
 }
-</style>
\ No newline at end of file
+</style>
-- 
GitLab