mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Add support for $__range_s (#12883)
Fixes #12882 Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
This commit is contained in:
committed by
Torkel Ödegaard
parent
1f88bfd2bc
commit
48364f0111
@@ -489,9 +489,11 @@ export class PrometheusDatasource {
|
||||
getRangeScopedVars() {
|
||||
let range = this.timeSrv.timeRange();
|
||||
let msRange = range.to.diff(range.from);
|
||||
let sRange = Math.round(msRange / 1000);
|
||||
let regularRange = kbn.secondsToHms(msRange / 1000);
|
||||
return {
|
||||
__range_ms: { text: msRange, value: msRange },
|
||||
__range_s: { text: sRange, value: sRange },
|
||||
__range: { text: regularRange, value: regularRange },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -321,8 +321,10 @@ describe('PrometheusDatasource', () => {
|
||||
it('should have the correct range and range_ms', () => {
|
||||
let range = ctx.templateSrvMock.replace.mock.calls[0][1].__range;
|
||||
let rangeMs = ctx.templateSrvMock.replace.mock.calls[0][1].__range_ms;
|
||||
let rangeS = ctx.templateSrvMock.replace.mock.calls[0][1].__range_s;
|
||||
expect(range).toEqual({ text: '21s', value: '21s' });
|
||||
expect(rangeMs).toEqual({ text: 21031, value: 21031 });
|
||||
expect(rangeS).toEqual({ text: 21, value: 21 });
|
||||
});
|
||||
|
||||
it('should pass the default interval value', () => {
|
||||
|
||||
Reference in New Issue
Block a user