From b061a8a302c2055f9680bb0029210a64087d43bf Mon Sep 17 00:00:00 2001 From: Issif Date: Tue, 24 May 2022 19:33:01 +0200 Subject: [PATCH] fix missing timelines Signed-off-by: Issif --- frontend/src/App.vue | 6 +++--- frontend/src/components/charts/timeline.vue | 16 ++++++---------- frontend/src/main.js | 2 +- internal/events/add.go | 2 +- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 9ce0cae..4dfeb43 100755 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -45,16 +45,16 @@ export default { return { pages: [ { - href: 'dashboard', + href: '/dashboard', router: true, title: 'Dashboard', }, { - href: 'events', + href: '/events', router: true, title: 'Events', }, { - href: 'info', + href: '/info', router: true, title: 'Info', }, diff --git a/frontend/src/components/charts/timeline.vue b/frontend/src/components/charts/timeline.vue index b2778c0..df59433 100644 --- a/frontend/src/components/charts/timeline.vue +++ b/frontend/src/components/charts/timeline.vue @@ -113,24 +113,21 @@ export default { return; } if (l === undefined) { - l = results[0].time; + l = dayjs().toISOString(); } let unit = ''; let delta = ''; let oldest = 60; switch (this.filters.since) { - case '1min': - this.chartData.options.scales.x.time.unit = 'millisecond'; - unit = 'second'; delta = 1; oldest = 60; break; case '5min': this.chartData.options.scales.x.time.unit = 'second'; - unit = 'second'; delta = 10; oldest = 300; break; + unit = 'second'; delta = 5; oldest = 300; break; case '15min': this.chartData.options.scales.x.time.unit = 'second'; unit = 'second'; delta = 25; oldest = 1500; break; case '30min': this.chartData.options.scales.x.time.unit = 'minute'; - unit = 'second'; delta = 45; oldest = 3000; break; + unit = 'second'; delta = 48; oldest = 3000; break; case '1h': this.chartData.options.scales.x.time.unit = 'minute'; unit = 'minute'; delta = 1; oldest = 60; break; @@ -188,15 +185,13 @@ export default { } if (this.stats[f] === undefined) { this.stats[f] = { - last: l, count: 0, - data: [{ x: dayjs().toISOString(), y: 0 }], + data: [{ x: dayjs().add(delta, unit).toISOString(), y: 0 }], }; } this.stats[f].count += 1; if (dayjs(value.time) .isBefore(dayjs(l).subtract(delta, unit))) { - l = value.time; Object.keys(this.stats).forEach((key) => { this.stats[key].data.push({ x: l, @@ -204,6 +199,7 @@ export default { }); this.stats[key].count = 0; }); + l = value.time; this.stats[f].count = 0; } }); @@ -217,7 +213,7 @@ export default { let i = 0; Object.keys(this.stats).forEach((key) => { this.stats[key].data.push({ - x: dayjs().subtract(oldest, unit).toISOString(), + x: dayjs().subtract(oldest - delta, unit).toISOString(), y: 0, }); let bgc = ''; diff --git a/frontend/src/main.js b/frontend/src/main.js index 89a7bc3..5e6f3ad 100755 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -13,7 +13,7 @@ const capitalize = function capitalize(value) { const formatDate = function formatDate(value) { if (!value) return ''; - return moment(String(value)).format('YYYY/MM/DD hh:mm:ss:SSS'); + return moment(String(value)).format('YYYY/MM/DD HH:mm:ss:SSS'); }; const opts = {}; diff --git a/internal/events/add.go b/internal/events/add.go index 910198e..97c969d 100644 --- a/internal/events/add.go +++ b/internal/events/add.go @@ -18,7 +18,7 @@ func Add(e *models.Event) error { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } - utils.WriteLog("info", fmt.Sprintf("POST event 'event:%v'", e.Time.UnixNano()/1e3), false) + utils.WriteLog("info", fmt.Sprintf("NEW event 'event:%v'", e.Time.UnixNano()/1e3), false) go broadcast.GetBroadcast().BroadcastMessage()