mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Added suport for timefilter/min/max in Vega urls (#124077)
This commit is contained in:
parent
39de549049
commit
2a552e8de6
3 changed files with 28 additions and 1 deletions
|
@ -351,6 +351,8 @@ a configuration option for changing the tooltip position and padding:
|
|||
*Vega* can load data from any URL. To enable, set `vis_type_vega.enableExternalUrls: true` in `kibana.yml`,
|
||||
then restart {kib}.
|
||||
|
||||
You can make the current time range part of the external as a millisecond timestamp by using the placeholders `%timefilter_min%` and `%timefilter_max%`, e.g. `http://example.com?min=%timefilter_min%`.
|
||||
|
||||
[float]
|
||||
[[vega-inspector]]
|
||||
====== Vega Inspector
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
import { cloneDeep } from 'lodash';
|
||||
import 'jest-canvas-mock';
|
||||
import { euiThemeVars } from '@kbn/ui-theme';
|
||||
import { TimeCache } from './time_cache';
|
||||
import { VegaParser } from './vega_parser';
|
||||
import { bypassExternalUrlCheck } from '../vega_view/vega_base_view';
|
||||
|
||||
|
@ -226,7 +227,12 @@ describe('VegaParser._resolveEsQueries', () => {
|
|||
},
|
||||
};
|
||||
};
|
||||
const vp = new VegaParser(spec, searchApiStub, 0, 0, mockGetServiceSettings);
|
||||
const tc = new (class extends TimeCache {
|
||||
getTimeBounds() {
|
||||
return { min: 123456, max: 654321 };
|
||||
}
|
||||
})();
|
||||
const vp = new VegaParser(spec, searchApiStub, tc, 0, mockGetServiceSettings);
|
||||
await vp._resolveDataUrls();
|
||||
|
||||
expect(vp.spec).toEqual(expected);
|
||||
|
@ -265,6 +271,20 @@ describe('VegaParser._resolveEsQueries', () => {
|
|||
{ data: { url: bypassExternalUrlCheck('url1') } }
|
||||
)
|
||||
);
|
||||
test(
|
||||
'timefilter_min',
|
||||
check(
|
||||
{ data: { url: 'http://example.com?min=%timefilter_min%' } },
|
||||
{ data: { url: 'http://example.com?min=123456' } }
|
||||
)
|
||||
);
|
||||
test(
|
||||
'timefilter_max',
|
||||
check(
|
||||
{ data: { url: 'http://example.com?min=%timefilter_max%' } },
|
||||
{ data: { url: 'http://example.com?min=654321' } }
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
describe('VegaParser.parseSchema', () => {
|
||||
|
|
|
@ -676,6 +676,11 @@ The URL is an identifier only. Kibana and your browser will never access this UR
|
|||
);
|
||||
}
|
||||
onFind(obj as Data);
|
||||
} else if (key === 'data' && typeof obj.url === 'string') {
|
||||
const bounds = this.timeCache.getTimeBounds();
|
||||
obj.url = obj.url
|
||||
.replaceAll('%timefilter_min%', bounds.min.toString())
|
||||
.replaceAll('%timefilter_max%', bounds.max.toString());
|
||||
} else {
|
||||
for (const k of Object.keys(obj)) {
|
||||
this._findObjectDataUrls(obj[k], onFind, k);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue