Adding date selector

This commit is contained in:
Axel 2021-12-23 16:42:48 +01:00
parent 4067a8448b
commit 3981724c86
2 changed files with 59 additions and 38 deletions

File diff suppressed because one or more lines are too long

View file

@ -8,6 +8,15 @@
<!-- <p class="context-menu"><img src="/img/menu.svg" width="40" /></p> -->
</h1>
Show:
<select
v-model="chart.days"
@change="refreshGraph"
>
<option value="7">7 days</option>
<option value="15">15 days</option>
<option value="30">30 days</option>
</select>
<h3>Uptime: past {{ chart.days }} days</h3>
<div id="chart">
<apexchart v-if="chart.render" type="bar" height="350" :options="chartOptions" :series="series"></apexchart>
@ -71,12 +80,6 @@
text: 'Loading...'
},
chartOptions: {
chart: {
type: 'bar',
height: 350,
stacked: true,
stackType: '100%'
},
responsive: [{
breakpoint: 480,
options: {
@ -113,18 +116,9 @@
default:
return 'unknown';
}
}
},
mounted: function() {
let task_id = this.$route.params.id ?? null
if (task_id != null) {
this.$http.post('/api/getTask/'+task_id, {
days: this.chart.days
})
.then(response => this.task = response.data)
.then(() => {
this.$http.post('/api/getTaskGraph/'+task_id, {
refreshGraph: function() {
this.$http.post('/api/getTaskGraph/'+this.task.id, {
days: this.chart.days
})
.then(response => {
@ -139,7 +133,22 @@
new_data_b.push(response.data[date]['down'])
}
this.chartOptions.xaxis.categories = xaxis;
this.chartOptions = {
xaxis: {
categories: xaxis,
labels: {
show: true,
rotate: -45,
rotateAlways: true,
}
},
chart: {
type: 'bar',
height: 300,
stacked: true,
stackType: '100%'
},
}
this.series = [{
name: 'UP',
data: new_data_a,
@ -153,6 +162,18 @@
this.chart.render = true
})
}
},
mounted: function() {
let task_id = this.$route.params.id ?? null
if (task_id != null) {
this.$http.post('/api/getTask/'+task_id, {
days: this.chart.days
})
.then(response => this.task = response.data)
.then(() => {
this.refreshGraph()
})
}
}