Fix: Do not show ping if not up

pull/4264/head
Nelson Chan 5 months ago
parent bdfdcdb84c
commit 4ab1a03cb9
No known key found for this signature in database

@ -20,7 +20,7 @@
import { BarController, BarElement, Chart, Filler, LinearScale, LineController, LineElement, PointElement, TimeScale, Tooltip } from "chart.js"; import { BarController, BarElement, Chart, Filler, LinearScale, LineController, LineElement, PointElement, TimeScale, Tooltip } from "chart.js";
import "chartjs-adapter-dayjs-4"; import "chartjs-adapter-dayjs-4";
import { Line } from "vue-chartjs"; import { Line } from "vue-chartjs";
import { DOWN, PENDING, MAINTENANCE } from "../util.ts"; import { UP, DOWN, PENDING, MAINTENANCE } from "../util.ts";
Chart.register(LineController, BarController, LineElement, PointElement, TimeScale, BarElement, LinearScale, Tooltip, Filler); Chart.register(LineController, BarController, LineElement, PointElement, TimeScale, BarElement, LinearScale, Tooltip, Filler);
@ -39,7 +39,7 @@ export default {
loading: false, loading: false,
// Configurable filtering on top of the returned data // Configurable filtering on top of the returned data
chartPeriodHrs: 0, chartPeriodHrs: "0",
chartPeriodOptions: { chartPeriodOptions: {
0: this.$t("recent"), 0: this.$t("recent"),
@ -168,7 +168,7 @@ export default {
const x = this.$root.datetime(beat.time); const x = this.$root.datetime(beat.time);
pingData.push({ pingData.push({
x, x,
y: beat.ping, y: beat.status === UP ? beat.ping : null,
}); });
downData.push({ downData.push({
x, x,
@ -221,20 +221,18 @@ export default {
const x = this.$root.unixToDateTime(datapoint.timestamp); const x = this.$root.unixToDateTime(datapoint.timestamp);
// Show ping values if it was up in this period // Show ping values if it was up in this period
if (datapoint.up > 0) { avgPingData.push({
avgPingData.push({ x,
x, y: datapoint.up > 0 ? datapoint.avgPing : null,
y: datapoint.avgPing, });
}); minPingData.push({
minPingData.push({ x,
x, y: datapoint.up > 0 ? datapoint.minPing : null,
y: datapoint.minPing, });
}); maxPingData.push({
maxPingData.push({ x,
x, y: datapoint.up > 0 ? datapoint.maxPing : null,
y: datapoint.maxPing, });
});
}
downData.push({ downData.push({
x, x,
@ -328,6 +326,10 @@ export default {
// Load chart period from storage if saved // Load chart period from storage if saved
let period = this.$root.storage()[`chart-period-${this.monitorId}`]; let period = this.$root.storage()[`chart-period-${this.monitorId}`];
if (period != null) { if (period != null) {
// Has this ever been not a string?
if (typeof period !== "string") {
period = period.toString();
}
this.chartPeriodHrs = period; this.chartPeriodHrs = period;
} }
}, },

Loading…
Cancel
Save