|
7 | 7 | Field, |
8 | 8 | MetricFindValue, |
9 | 9 | getDefaultTimeRange, |
| 10 | + FieldType, |
10 | 11 | } from '@grafana/data'; |
11 | 12 | import { DataSourceWithBackend, getTemplateSrv } from '@grafana/runtime'; |
12 | 13 |
|
@@ -113,14 +114,20 @@ export class DataSource extends DataSourceWithBackend<HaystackQuery, HaystackDat |
113 | 114 | } |
114 | 115 |
|
115 | 116 | let fieldVals = field.values.map((value) => { |
116 | | - if (value.startsWith('@')) { |
117 | | - // Detect ref using @ prefix, and adjust value to just the Ref |
118 | | - let spaceIndex = value.indexOf(' '); |
119 | | - let id = value.substring(0, spaceIndex); |
120 | | - return { text: value, value: id }; |
121 | | - } else { |
122 | | - // Otherwise, just use the value directly |
123 | | - return { text: value, value: value }; |
| 117 | + switch (field.type) { |
| 118 | + case FieldType.string: |
| 119 | + if (value.startsWith('@')) { |
| 120 | + // Detect ref using @ prefix, and adjust value to just the Ref |
| 121 | + let spaceIndex = value.indexOf(' '); |
| 122 | + let id = value.substring(0, spaceIndex); |
| 123 | + let dis = value.substring(spaceIndex + 2, value.length - 1); |
| 124 | + return { text: dis, value: id }; |
| 125 | + } else { |
| 126 | + // Otherwise, just use the value directly |
| 127 | + return { text: value, value: value }; |
| 128 | + } |
| 129 | + default: |
| 130 | + return { text: value, value: value }; |
124 | 131 | } |
125 | 132 | }); |
126 | 133 | return acc.concat(fieldVals); |
|
0 commit comments