From 4752614c0105b864d00e97179b4b77ccbad89e2d Mon Sep 17 00:00:00 2001
From: Jannik Schönartz
Date: Wed, 16 Oct 2019 19:16:14 +0000
Subject: [webapp/clients] Add the choice to select backends when deleting
 clients

 [group/clients]
Checkbox list of the clients in the permanently delete dialog

[server/backendhelper]
Only deletes from the selected backends (array with backendids)
---
 webapp/src/components/GroupModuleDialog.vue | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

(limited to 'webapp/src/components/GroupModuleDialog.vue')

diff --git a/webapp/src/components/GroupModuleDialog.vue b/webapp/src/components/GroupModuleDialog.vue
index e9bb65d..41b98b5 100644
--- a/webapp/src/components/GroupModuleDialog.vue
+++ b/webapp/src/components/GroupModuleDialog.vue
@@ -45,7 +45,8 @@
     "name": "Name",
     "description": "Description",
     "ip": "IP Address",
-    "wake": "Wake up"
+    "wake": "Wake up",
+    "deleteInBackends": "Select the backends, where the clients will get deleted:"
   },
   "de": {
     "title": {
@@ -92,7 +93,8 @@
     "name": "Name",
     "description": "Beschreibung",
     "ip": "IP Adresse",
-    "wake": "Aufwecken"
+    "wake": "Aufwecken",
+    "deleteInBackends": "Wähle die Backends, aus denen die Clients gelöscht werden:"
   }
 }
 </i18n>
@@ -138,6 +140,19 @@
           >
             <div slot-scope="{ item }">[{{ item.id }}] {{ item.name }}</div>
           </RecycleScroller>
+          <div v-if="action === 'delete' && dialog.info.type === 'client'">
+            <div class="select-backends">{{ $t('deleteInBackends') }}</div>
+            <template v-for="backend in backends">
+              <v-checkbox
+                :label="backend.name"
+                v-model="backend.selected"
+                :key="backend.id"
+                :value="backend.selected"
+                color="primary"
+                hide-details
+              ></v-checkbox>
+            </template>
+          </div>
         </div>
       </v-card-text>
 
@@ -183,6 +198,7 @@ export default {
   },
   computed: {
     ...mapState('groups', ['dialog', 'tabChain']),
+    ...mapState('backends', ['backends']),
     headers () {
       const lastColumn = this.dialog.info.type === 'client' ? 'ip' : 'description'
       return [
@@ -227,6 +243,7 @@ export default {
           if (this.dialog.info.action === 'select') this.selected = this.dialog.info.selected
           else this.selected = []
           if (this.$refs.cardtext) this.$nextTick(() => this.$refs.cardtext.dispatchEvent(new Event('scroll')))
+          if (this.dialog.info.type === 'client') this.$store.dispatch('backends/loadData')
         }
       }
     }
@@ -262,6 +279,7 @@ export default {
         })
       }
       if (this.action === 'add') data.selected = this.selected
+      if (this.action === 'delete') data.backends = this.backends
       this.$store.dispatch('groups/' + actionMap[this.action][this.dialog.info.type], data)
       this.setDialog({ show: false })
     },
@@ -297,4 +315,7 @@ export default {
 .selected-list {
   padding: 30px;
 }
+.select-backends {
+  margin-top: 20px;
+}
 </style>
-- 
cgit v1.2.3-55-g7522

