Commit 1cf3bc54 by Jansa Jose

datatable in table page

parent 7a6385c9
...@@ -15,21 +15,15 @@ ...@@ -15,21 +15,15 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-sm-12 table-responsive"> <div class="col-sm-12 table-responsive">
<table aria-describedby="example1_info" role="grid" id="example1" class="table table-bordered table-striped dataTable"> <table id="example1" class="table table-bordered table-striped dataTable" cellspacing="0" width="100%">
<thead> <thead>
<tr role="row"> <tr role="row">
<th aria-label="Date: activate to sort column descending" aria-sort="ascending" style="width: 167px;" colspan="1" rowspan="1" aria-controls="example1" tabindex="0" class="sorting_asc">Date</th> <th>Date</th>
<th aria-label="Description: activate to sort column ascending" style="width: 207px;" colspan="1" rowspan="1" aria-controls="example1" tabindex="0" class="sorting">Description</th> <th>Description</th>
<th aria-label="Amount: activate to sort column ascending" style="width: 182px;" colspan="1" rowspan="1" aria-controls="example1" tabindex="0" class="sorting">Amount</th> <th>Amount</th>
</tr> </tr>
</thead> </thead>
<!-- <tbody v-if="transactions"> <tbody></tbody>
<tr class="even" role="row" v-for="trans in transactions" :key="trans">
<td class="sorting_1">{{trans.date}}</td>
<td>{{trans.description}}</td>
<td>{{trans.amount}}</td>
</tr>
</tbody> -->
</table> </table>
</div> </div>
</div> </div>
...@@ -51,17 +45,10 @@ require('datatables.net-bs') ...@@ -51,17 +45,10 @@ require('datatables.net-bs')
export default { export default {
name: 'Tables', name: 'Tables',
mounted() { data: {
this.getData() dataTable: null
this.loadDatatable()
this.access_token = localStorage.getItem('token')
}, },
methods: { methods: {
loadDatatable() {
this.$nextTick(() => {
$('#example1').DataTable()
})
},
getData() { getData() {
var params = {'client_id': config.clientId, 'client_secret': config.clientSecret, 'access_token': this.access_token} var params = {'client_id': config.clientId, 'client_secret': config.clientSecret, 'access_token': this.access_token}
var thisObj = this var thisObj = this
...@@ -84,6 +71,35 @@ export default { ...@@ -84,6 +71,35 @@ export default {
toggleLoading() { toggleLoading() {
this.loading = this.loading === '' ? 'loading' : '' this.loading = this.loading === '' ? 'loading' : ''
} }
},
mounted() {
let users = []
this.access_token = localStorage.getItem('token')
this.dataTable = $('#example1').DataTable({})
var params = {'client_id': config.clientId, 'client_secret': config.clientSecret, 'access_token': this.access_token}
var thisObj = this
api
.request('post', 'listTransactions', params)
.then(response => {
thisObj.toggleLoading()
var data = response.data
if (data.status === 'success') {
data.data.resources.forEach(item => {
users.push(item)
})
users.forEach(user => {
this.dataTable.row.add([
user.date,
user.description,
user.amount
]).draw(false)
})
}
})
.catch(() => {
thisObj.$store.commit('TOGGLE_LOADING')
thisObj.response = 'Server appears to be offline'
})
} }
} }
</script> </script>
......
...@@ -11,6 +11,10 @@ const routes = [ ...@@ -11,6 +11,10 @@ const routes = [
component: LoginView component: LoginView
}, },
{ {
path: '/login',
component: LoginView
},
{
path: '/signup', path: '/signup',
component: SignupView component: SignupView
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment