/
component.vue
82 lines (78 loc) · 2.36 KB
/
component.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
<template>
<div>
<h5>List</h5>
<div>
<button class="btn btn-success" id="add" type="button" @click="onAdd()">Add</button>
<button class="btn btn-info" id="start" type="button" v-if="showPerformanceButtonRef" @click="onStart()">
Performance
</button>
</div>
<table class="table" v-for="(element, index) in elementsRef" :key="index">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">ID</th>
<th scope="col">Title</th>
<th scope="col">Unit</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<tr v-for="(serie, index) in measuredSeriesRef" :key="index">
<td>{{ index + 1 }}</td>
<td>{{ serie.getId() }}</td>
<td>{{ serie.getTitle() }}</td>
<td>{{ serie.getUnit() }}</td>
<td>
<button class="btn btn-info" :id="'edit-' + index" type="button" @click="onEdit(serie)">
Edit
</button>
</td>
</tr>
</tbody>
</table>
<small>Duration: {{ durationRef }} ms</small>
</div>
</template>
<script>
import { ListSerieController } from './controller';
import CreateSerieComponent from '../create/component.vue';
import EditSerieComponent from '../edit/component.vue';
import { ref } from '@vue/composition-api';
import { MeasuredSerieModel } from '../../../models/measured-series.model';
export default {
setup() {
const $ctrl = new ListSerieController();
const elementsRef = ref($ctrl.elements);
const durationRef = ref($ctrl.duration);
const measuredSerieRef = ref($ctrl.measuredSerie);
const measuredSeriesRef = ref($ctrl.measuredSeries);
const showPerformanceButtonRef = ref($ctrl.showPerformanceButton);
const onAdd = () => {
$ctrl.add();
};
const onEdit = (measuredSerie) => {
$ctrl.edit(measuredSerie);
measuredSerieRef.value = $ctrl.measuredSerie;
};
const onStart = () => {
$ctrl.onStart();
};
$ctrl.renderView = () => {
elementsRef.value = $ctrl.elements;
durationRef.value = $ctrl.duration;
showPerformanceButtonRef.value = $ctrl.showPerformanceButton;
};
return {
elementsRef,
durationRef,
measuredSerieRef,
measuredSeriesRef,
showPerformanceButtonRef,
onAdd,
onStart,
onEdit,
};
},
};
</script>