mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
LinkSrv: Add newlines so I can read code
This commit is contained in:
@@ -129,21 +129,26 @@ const getDataFrameVars = (dataFrames: DataFrame[]) => {
|
|||||||
let title: Field = undefined;
|
let title: Field = undefined;
|
||||||
const suggestions: VariableSuggestion[] = [];
|
const suggestions: VariableSuggestion[] = [];
|
||||||
const keys: KeyValue<true> = {};
|
const keys: KeyValue<true> = {};
|
||||||
|
|
||||||
for (const df of dataFrames) {
|
for (const df of dataFrames) {
|
||||||
for (const f of df.fields) {
|
for (const f of df.fields) {
|
||||||
if (keys[f.name]) {
|
if (keys[f.name]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
suggestions.push({
|
suggestions.push({
|
||||||
value: `__data.fields[${f.name}]`,
|
value: `__data.fields[${f.name}]`,
|
||||||
label: `${f.name}`,
|
label: `${f.name}`,
|
||||||
documentation: `Formatted value for ${f.name} on the same row`,
|
documentation: `Formatted value for ${f.name} on the same row`,
|
||||||
origin: VariableOrigin.Fields,
|
origin: VariableOrigin.Fields,
|
||||||
});
|
});
|
||||||
|
|
||||||
keys[f.name] = true;
|
keys[f.name] = true;
|
||||||
|
|
||||||
if (!numeric && f.type === FieldType.number) {
|
if (!numeric && f.type === FieldType.number) {
|
||||||
numeric = f;
|
numeric = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!title && f.config.title && f.config.title !== f.name) {
|
if (!title && f.config.title && f.config.title !== f.name) {
|
||||||
title = f;
|
title = f;
|
||||||
}
|
}
|
||||||
@@ -158,6 +163,7 @@ const getDataFrameVars = (dataFrames: DataFrame[]) => {
|
|||||||
origin: VariableOrigin.Fields,
|
origin: VariableOrigin.Fields,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numeric) {
|
if (numeric) {
|
||||||
suggestions.push({
|
suggestions.push({
|
||||||
value: `__data.fields[${numeric.name}].numeric`,
|
value: `__data.fields[${numeric.name}].numeric`,
|
||||||
@@ -172,6 +178,7 @@ const getDataFrameVars = (dataFrames: DataFrame[]) => {
|
|||||||
origin: VariableOrigin.Fields,
|
origin: VariableOrigin.Fields,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (title) {
|
if (title) {
|
||||||
suggestions.push({
|
suggestions.push({
|
||||||
value: `__data.fields[${title.config.title}]`,
|
value: `__data.fields[${title.config.title}]`,
|
||||||
@@ -180,6 +187,7 @@ const getDataFrameVars = (dataFrames: DataFrame[]) => {
|
|||||||
origin: VariableOrigin.Fields,
|
origin: VariableOrigin.Fields,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return suggestions;
|
return suggestions;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -264,6 +272,7 @@ export class LinkSrv implements LinkService {
|
|||||||
const timeRangeUrl = toUrlParams(this.timeSrv.timeRangeForUrl());
|
const timeRangeUrl = toUrlParams(this.timeSrv.timeRangeForUrl());
|
||||||
|
|
||||||
let href = link.url;
|
let href = link.url;
|
||||||
|
|
||||||
if (link.onBuildUrl) {
|
if (link.onBuildUrl) {
|
||||||
href = link.onBuildUrl({
|
href = link.onBuildUrl({
|
||||||
origin,
|
origin,
|
||||||
@@ -272,6 +281,7 @@ export class LinkSrv implements LinkService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let onClick: (e: any) => void = undefined;
|
let onClick: (e: any) => void = undefined;
|
||||||
|
|
||||||
if (link.onClick) {
|
if (link.onClick) {
|
||||||
onClick = (e: any) => {
|
onClick = (e: any) => {
|
||||||
link.onClick({
|
link.onClick({
|
||||||
@@ -289,9 +299,11 @@ export class LinkSrv implements LinkService {
|
|||||||
origin,
|
origin,
|
||||||
onClick,
|
onClick,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.templateSrv.fillVariableValuesForUrl(params, scopedVars);
|
this.templateSrv.fillVariableValuesForUrl(params, scopedVars);
|
||||||
|
|
||||||
const variablesQuery = toUrlParams(params);
|
const variablesQuery = toUrlParams(params);
|
||||||
|
|
||||||
info.href = this.templateSrv.replace(info.href, {
|
info.href = this.templateSrv.replace(info.href, {
|
||||||
...scopedVars,
|
...scopedVars,
|
||||||
[DataLinkBuiltInVars.keepTime]: {
|
[DataLinkBuiltInVars.keepTime]: {
|
||||||
@@ -303,7 +315,9 @@ export class LinkSrv implements LinkService {
|
|||||||
value: variablesQuery,
|
value: variablesQuery,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
info.href = getConfig().disableSanitizeHtml ? info.href : sanitizeUrl(info.href);
|
info.href = getConfig().disableSanitizeHtml ? info.href : sanitizeUrl(info.href);
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user