forked from grafana.jool/grafana-jool
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
672 B
19 lines
672 B
import { TimeRange } from '@grafana/data';
|
|
|
|
function roundMsToMin(milliseconds: number): number {
|
|
return roundSecToMin(milliseconds / 1000);
|
|
}
|
|
|
|
function roundSecToMin(seconds: number): number {
|
|
return Math.floor(seconds / 60);
|
|
}
|
|
|
|
export function shouldRefreshLabels(range?: TimeRange, prevRange?: TimeRange): boolean {
|
|
if (range && prevRange) {
|
|
const sameMinuteFrom = roundMsToMin(range.from.valueOf()) === roundMsToMin(prevRange.from.valueOf());
|
|
const sameMinuteTo = roundMsToMin(range.to.valueOf()) === roundMsToMin(prevRange.to.valueOf());
|
|
// If both are same, don't need to refresh
|
|
return !(sameMinuteFrom && sameMinuteTo);
|
|
}
|
|
return false;
|
|
}
|
|
|