summaryrefslogtreecommitdiffstats
path: root/webapp/src/components/GroupModuleClientList.vue
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/src/components/GroupModuleClientList.vue')
-rw-r--r--webapp/src/components/GroupModuleClientList.vue160
1 files changed, 120 insertions, 40 deletions
diff --git a/webapp/src/components/GroupModuleClientList.vue b/webapp/src/components/GroupModuleClientList.vue
index a1036aa..c491b63 100644
--- a/webapp/src/components/GroupModuleClientList.vue
+++ b/webapp/src/components/GroupModuleClientList.vue
@@ -1,65 +1,140 @@
<i18n>
{
"en": {
+ "id": "ID",
+ "name": "Name",
+ "ip": "IP Address",
+ "mac": "MAC Address",
+ "uuid": "UUID",
+ "removeClients": "Remove one client | Remove {0} clients",
+ "addClients": "Add clients",
+ "deleteClients": "Delete one client | Delete {0} clients",
+ "createClient": "Create client"
},
"de": {
+ "id": "ID",
+ "name": "Name",
+ "ip": "IP Adresse",
+ "mac": "MAC Adresse",
+ "uuid": "UUID",
+ "removeClients": "Entferne einen Clienten | Entferne {0} Clienten",
+ "addClients": "Füge Clienten hinzu",
+ "deleteClients": "Lösche einen Clienten | Lösche {0} Clienten",
+ "createClient": "Client erstellen"
}
}
</i18n>
<template>
- <v-data-table stlye="width: 100px"
- :headers="headers"
- :items="clients"
- item-key="id"
- hide-actions
- select-all
- v-model="selected"
- >
- <template slot="items" slot-scope="props">
- <tr @click="props.selected = !props.selected">
- <td class="narrow-td">
- <v-checkbox
- color="primary"
- v-model="props.selected"
- hide-details
- @click.native.stop
- ></v-checkbox>
- </td>
- <td class="narrow-td">{{ props.item.id }}</td>
- <td>{{ props.item.name }}</td>
- <td>{{ props.item.ip }}</td>
- <td>{{ props.item.mac }}</td>
- <td>{{ props.item.uuid }}</td>
- <td class="narrow-td">
- <v-btn icon @click.stop><v-icon color="primary">edit</v-icon></v-btn>
- </td>
- </tr>
- </template>
- </v-data-table>
+ <div>
+ <v-card>
+ <v-card-title v-if="clients.length > 10">
+ <component-table-actions :pagination.sync="pagination" :search.sync="search" :item-count="clients.length" />
+ </v-card-title>
+ <v-divider></v-divider>
+ <v-data-table
+ :headers="headers"
+ :items="clients"
+ item-key="id"
+ select-all
+ hide-actions
+ v-model="selected"
+ :search="search"
+ :pagination.sync="pagination"
+ >
+ <template slot="items" slot-scope="props">
+ <tr @click.stop="props.selected = !props.selected" @dblclick="loadClient(props.item.id)">
+ <td class="narrow-td">
+ <v-checkbox
+ color="primary"
+ v-model="props.selected"
+ hide-details
+ @click.native.stop
+ @dblclick.native.stop
+ ></v-checkbox>
+ </td>
+ <td class="narrow-td">{{ props.item.id }}</td>
+ <td>{{ props.item.name }}</td>
+ <td>{{ props.item.ip }}</td>
+ <td>{{ props.item.mac }}</td>
+ <td>{{ props.item.uuid }}</td>
+ <td class="narrow-td">
+ <v-btn class="next-arrow" icon @click="loadClient(props.item.id)"><v-icon>keyboard_arrow_right</v-icon></v-btn>
+ </td>
+ </tr>
+ </template>
+ </v-data-table>
+ </v-card>
+ <div v-if="tabIndex === 0" class="text-xs-right">
+ <v-btn flat color="error" @click="deleteSelected" :disabled="selected.length === 0">
+ <v-icon left>delete</v-icon>{{ $tc('deleteClients', selected.length, [selected.length]) }}
+ </v-btn>
+ <v-btn flat color="success" @click="newClient"><v-icon left>create</v-icon>{{ $t('createClient') }}</v-btn>
+ </div>
+ <div v-else class="text-xs-right">
+ <v-btn flat color="error" @click="removeSelected" :disabled="selected.length === 0">
+ <v-icon left>remove_circle_outline</v-icon>{{ $tc('removeClients', selected.length, [selected.length]) }}
+ </v-btn>
+ <v-btn flat color="success" @click="addExisting"><v-icon left>add_circle_outline</v-icon>{{ $t('addClients') }}</v-btn>
+ </div>
+ </div>
</template>
<script>
+import ComponentTableActions from '@/components/ComponentTableActions'
+import { mapState, mapMutations } from 'vuex'
export default {
name: 'GroupModuleClientList',
- props: ['tabIndex'],
+ props: ['tabIndex', 'groupId', 'clients'],
+ components: {
+ ComponentTableActions
+ },
data () {
return {
- headers: [
- { text: 'ID', value: 'id' },
- { text: 'Name', value: 'name' },
- { text: 'IP Address', value: 'ip' },
- { text: 'MAC Address', value: 'mac' },
- { text: 'UUID', value: 'uuid' },
- { sortable: false }
- ],
- selected: []
+ selected: [],
+ search: '',
+ pagination: {}
}
},
computed: {
+ ...mapState('groups', ['showAll']),
+ headers () {
+ return [
+ { text: this.$t('id'), value: 'id' },
+ { text: this.$t('name'), value: 'name' },
+ { text: this.$t('ip'), value: 'ip' },
+ { text: this.$t('mac'), value: 'mac' },
+ { text: this.$t('uuid'), value: 'uuid' },
+ { sortable: false }
+ ]
+ }
+ },
+ watch: {
+ showAll (value) {
+ if (!value) this.search = ''
+ },
clients () {
- return this.$store.state.groups.groupChain[this.tabIndex].clients
+ this.selected = []
+ }
+ },
+ methods: {
+ ...mapMutations('groups', ['setActiveTab', 'setTab', 'setDialog']),
+ loadClient (id) {
+ this.$store.dispatch('groups/loadClient', { id, tabIndex: this.tabIndex + 1, switchTab: true })
+ },
+ newClient () {
+ this.setTab({ index: 1, item: { tabType: 'client' } })
+ this.setActiveTab(1)
+ },
+ deleteSelected () {
+ this.setDialog({ show: true, info: { action: 'delete', type: 'client', selected: this.selected } })
+ },
+ removeSelected () {
+ this.setDialog({ show: true, info: { action: 'remove', type: 'client', selected: this.selected, tabIndex: this.tabIndex } })
+ },
+ addExisting () {
+ this.setDialog({ show: true, info: { action: 'add', type: 'client', selected: this.selected, tabIndex: this.tabIndex } })
}
}
}
@@ -70,4 +145,9 @@ export default {
.narrow-td {
width: 10px;
}
+
+.next-arrow {
+ margin-left: 20px;
+ margin-right: -10px;
+}
</style>