Fix graph zooming end date
This commit is contained in:
parent
80efccf6c5
commit
6349881dbd
1 changed files with 3 additions and 16 deletions
|
@ -449,7 +449,9 @@ export class VideoStatsComponent implements OnInit {
|
||||||
const { min, max } = chart.scales.x
|
const { min, max } = chart.scales.x
|
||||||
|
|
||||||
const startDate = rawData.data[min].date
|
const startDate = rawData.data[min].date
|
||||||
const endDate = this.buildZoomEndDate(rawData.groupInterval, rawData.data[max].date)
|
const endDate = max === rawData.data.length - 1
|
||||||
|
? (this.statsEndDate || new Date()).toISOString()
|
||||||
|
: rawData.data[max + 1].date
|
||||||
|
|
||||||
this.peertubeRouter.silentNavigate([], { startDate, endDate })
|
this.peertubeRouter.silentNavigate([], { startDate, endDate })
|
||||||
this.addAndSelectCustomDateFilter()
|
this.addAndSelectCustomDateFilter()
|
||||||
|
@ -605,19 +607,4 @@ export class VideoStatsComponent implements OnInit {
|
||||||
second: 'numeric'
|
second: 'numeric'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildZoomEndDate (groupInterval: string, last: string) {
|
|
||||||
const date = new Date(last)
|
|
||||||
|
|
||||||
// Remove parts of the date we don't need
|
|
||||||
if (groupInterval.endsWith(' day') || groupInterval.endsWith(' days')) {
|
|
||||||
date.setHours(23, 59, 59)
|
|
||||||
} else if (groupInterval.endsWith(' hour') || groupInterval.endsWith(' hours')) {
|
|
||||||
date.setMinutes(59, 59)
|
|
||||||
} else {
|
|
||||||
date.setSeconds(59)
|
|
||||||
}
|
|
||||||
|
|
||||||
return date.toISOString()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue