11<template >
2- <va-card :title =" $t('tables.serverSidePagination ')" >
2+ <va-card :title =" $t('Users ')" :key = " tableKey " > <!-- TODO should be update when something is deleted -- >
33 <va-data-table
44 :fields =" fields"
55 :data =" users"
6- :loading =" loading"
7- @page-selected =" readItems"
8- api-mode
6+ :per-page =" 10"
97 >
10- <template slot="avatar" slot-scope="props">
11- <img :src =" props.rowData.avatar" class =" data-table-server-pagination---avatar" >
8+ <template slot="actions" slot-scope="props">
9+
10+ <va-popover :message =" `${$t('tables.edit')} ${props.rowData.username}`" placement =" top" >
11+ <router-link :to =" { name: 'change group', params: {username} }" >
12+ <va-button flat small color =" gray" icon =" fa fa-pencil" />
13+ </router-link >
14+ </va-popover >
15+
16+ <va-popover :message =" `${$t('tables.delete')} ${props.rowData.username}`" placement =" top" >
17+ <va-button flat small color =" gray" icon =" fa fa-trash" v-on:click =" deleteUser(props.rowData.username)" />
18+ </va-popover >
1219 </template >
1320 </va-data-table >
1421 </va-card >
1522</template >
1623
1724<script >
25+
1826import axios from ' axios'
1927
2028export default {
2129 data () {
2230 return {
23- perPage: 3 ,
24- totalPages: 0 ,
2531 users: [],
26- loading : false ,
32+ tableKey : 1 ,
2733 }
2834 },
2935 computed: {
@@ -39,6 +45,9 @@ export default {
3945 }, {
4046 name: ' groups__name' ,
4147 title: ' groups' ,
48+ }, {
49+ name: ' __slot:actions' ,
50+ dataClass: ' text-right' ,
4251 }]
4352 },
4453 },
@@ -47,22 +56,23 @@ export default {
4756 },
4857 methods: {
4958 readItems () {
50- this .loading = true
51-
52- axios .get (' http://192.168.0.4:8000/en/api/users' )
59+ this .$http .get (' http://localhost:8000/en/api/users' )
5360 .then (response => {
54- this .users = response .data
55- this .loading = false
61+ this .users = response .data . data
62+ console . log ( this .users )
5663 })
5764 },
65+
66+ deleteUser : function (username ) {
67+ this .$http .post (' http://localhost:8000/en/api/users/delete' , { username: username })
68+
69+ alert (username + ' deleted' )
70+ this .readItems ()
71+ this .tableKey += 1
72+ },
5873 },
5974}
6075 </script >
6176
6277<style lang="scss">
63- .data-table-server-pagination---avatar {
64- width : 40px ;
65- height : 40px ;
66- border-radius : 50% ;
67- }
6878 </style >
0 commit comments