index.php
2.02 KB
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
<?php
/**
* @var $this yii\web\View
* @var \common\models\Call[] $calls
*/
$this->title = 'My Yii Application';
?>
<div class="site-index">
<div class="jumbotron">
</div>
<div class="body-content">
<div id="app">
<div class="row">
<table class="bordered">
<thead>
<tr>
<th>ID</th>
<th>Company</th>
<th>Status</th>
<th>Duration</th>
</tr>
</thead>
<tbody>
<tr v-if="" v-for="call in calls">
<td>{{call.id}}</td>
<td>{{call.company}}</td>
<td>{{call.status}}</td>
<td>{{call.duration}}</td>
</tr>
</tbody>
</table>
<div class="row">
<div class="col s5 input-field">
<label for="search-company">Company</label>
<input v-model="search" id="search-company" type="text">
<button v-on:click="fetchSearch()" class="waves-effect waves-light btn">Search</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
new Vue({
el: '#app',
data: {
calls: null,
search: null
},
created: function() {
this.fetchData()
},
methods: {
fetchData: function() {
var self = this;
axios.get('/rest/calls')
.then(function(response) {
console.log(response.data);
self.calls = response.data;
});
},
fetchSearch: function() {
var self = this;
axios.get('/rest/calls/search?word=' + self.search)
.then(function(response) {
console.log(response.data);
self.calls = response.data;
});
}
}
})
</script>