mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DataLinks: Implement javascript callback (#19851)
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user