2019-08-28 01:50:43 -05:00
|
|
|
import { ContextMenuItem } from '../components/ContextMenu/ContextMenu';
|
|
|
|
import { LinkModelSupplier } from '@grafana/data';
|
|
|
|
|
|
|
|
export const DataLinkBuiltInVars = {
|
|
|
|
keepTime: '__url_time_range',
|
2019-09-13 09:38:21 -05:00
|
|
|
timeRangeFrom: '__from',
|
|
|
|
timeRangeTo: '__to',
|
2019-08-28 01:50:43 -05:00
|
|
|
includeVars: '__all_variables',
|
2019-09-13 09:38:21 -05:00
|
|
|
seriesName: '__series.name',
|
|
|
|
fieldName: '__field.name',
|
|
|
|
valueTime: '__value.time',
|
|
|
|
valueNumeric: '__value.numeric',
|
|
|
|
valueText: '__value.text',
|
|
|
|
valueRaw: '__value.raw',
|
|
|
|
// name of the calculation represented by the value
|
|
|
|
valueCalc: '__value.calc',
|
2019-08-28 01:50:43 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delays creating links until we need to open the ContextMenu
|
|
|
|
*/
|
|
|
|
export const linkModelToContextMenuItems: (links: LinkModelSupplier<any>) => ContextMenuItem[] = links => {
|
|
|
|
return links.getLinks().map(link => {
|
|
|
|
return {
|
|
|
|
label: link.title,
|
|
|
|
// TODO: rename to href
|
|
|
|
url: link.href,
|
|
|
|
target: link.target,
|
2020-04-12 15:20:02 -05:00
|
|
|
icon: `${link.target === '_self' ? 'link' : 'external-link-alt'}`,
|
2019-10-28 06:08:19 -05:00
|
|
|
onClick: link.onClick,
|
2019-08-28 01:50:43 -05:00
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|