Skip to content

Commit

Permalink
fix missing timelines
Browse files Browse the repository at this point in the history
Signed-off-by: Issif <[email protected]>
  • Loading branch information
Issif authored and poiana committed May 24, 2022
1 parent 3043dd2 commit b061a8a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
6 changes: 3 additions & 3 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand Down
16 changes: 6 additions & 10 deletions frontend/src/components/charts/timeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -188,22 +185,21 @@ 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,
y: this.stats[key].count,
});
this.stats[key].count = 0;
});
l = value.time;
this.stats[f].count = 0;
}
});
Expand All @@ -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 = '';
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down
2 changes: 1 addition & 1 deletion internal/events/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit b061a8a

Please sign in to comment.