DataLinks: Implement javascript callback (#19851)

This commit is contained in:
Ryan McKinley
2019-10-28 04:08:19 -07:00
committed by GitHub
parent 040801256f
commit 9e004b9211
5 changed files with 65 additions and 14 deletions

View File

@@ -156,11 +156,31 @@ export class LinkSrv implements LinkService {
const params: KeyValue = {};
const timeRangeUrl = toUrlParams(this.timeSrv.timeRangeForUrl());
let href = link.url;
if (link.onBuildUrl) {
href = link.onBuildUrl({
origin,
scopedVars,
});
}
let onClick: (e: any) => void = undefined;
if (link.onClick) {
onClick = (e: any) => {
link.onClick({
origin,
scopedVars,
e,
});
};
}
const info: LinkModel<T> = {
href: link.url.replace(/\s|\n/g, ''),
href: href.replace(/\s|\n/g, ''),
title: this.templateSrv.replace(link.title || '', scopedVars),
target: link.targetBlank ? '_blank' : '_self',
origin,
onClick,
};
this.templateSrv.fillVariableValuesForUrl(params, scopedVars);