This repository was archived by the owner on Jun 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathApp.vue
134 lines (133 loc) · 3.29 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<script>
import axios from 'axios'
import Datasource from './components/ServerDatasource.vue'
export default {
name: 'app',
components: {
Datasource
},
mounted () {
this.getSource()
},
render (h) {
return (
<div id="app">
<h2 class="text-center mb3">Vue Datasource</h2>
<datasource source={this.information} total={this.total} limits={this.limits} actions={this.actions} columns={this.columns} on-change={this.change}></datasource>
</div>
)
},
data () {
return {
information: [],
columns: [
{
name: 'Id',
key: 'id',
order: true
},
{
name: 'First Name',
key: 'first_name',
order: true
},
{
name: 'Last Name',
key: 'last_name',
render: (value, row) => {
return <strong><i>Epic</i> {value} <img src={row.avatar} width="20" /></strong>
}
}
],
actions: [
{
text: 'Edit',
icon: 'glyphicon glyphicon-pencil',
class: 'btn-primary',
show (selectedRow) {
if (selectedRow) {
return (selectedRow.row.id === 1)
} else {
return true
}
},
event (e, row) {
console.warn('Are you clicked me?', e)
if (row === null) {
console.info('Ups.. data not found :(')
} else {
console.info('Yeeei, I found this :)', JSON.stringify(row))
}
}
},
{
text: 'Delete',
icon: 'glyphicon glyphicon-trash',
class: 'btn-danger',
show (selectedRow) {
return true
},
event (e, row) {
console.warn('Are you clicked me?', e)
if (row === null) {
console.info('Ups.. data not found :(')
} else {
console.info('Yeeei, I found this :)', JSON.stringify(row))
}
}
},
{
text: 'Show',
icon: 'glyphicon glyphicon-eye-open',
class: 'btn-info',
show (selectedRow) {
return true
},
event (e, row) {
console.warn('Are you clicked me?', e)
if (row === null) {
console.info('Ups.. data not found :(')
} else {
console.info('Yeeei, I found this :)', JSON.stringify(row))
}
}
}
],
limits: [3, 5, 10, 15, 20],
page: 1,
perpage: 10,
pagination: {},
search: '',
total: 0
}
},
methods: {
getSource () {
axios.get(`https://reqres.in/api/users?per_page=${this.perpage}&page=${this.page}`).then((response) => {
this.information = response.data.data
this.total = response.data.total
})
},
change (value) {
this.page = value.page
this.perpage = value.perpage
this.getSource()
},
searching (value) {
this.search = value
this.getSource()
}
}
}
</script>
<style scoped>
@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500,700');
@import "./assets/app.css";
#app {
font-family: 'Roboto' !important;
margin: 150px 0;
}
.mb3 {
margin-bottom: 30px;
}
</style>