Skip to content

Commit

Permalink
change to add per-layer inbound and outbound data field selectors. Al…
Browse files Browse the repository at this point in the history
…so label fields from multiple queries.
  • Loading branch information
jkafader-esnet committed Mar 10, 2022
1 parent 1962cf3 commit 6e4e0e6
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 23 deletions.
9 changes: 6 additions & 3 deletions src/MapPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export class MapPanel extends Component<Props> {
var fieldsL1 = {
srcField: options.srcFieldL1,
dstField: options.dstFieldL1,
valField: options.valFieldL1,
inboundValueField: options.inboundValueFieldL1,
outboundValueField: options.outboundValueFieldL1,
endpointId: options.endpointIdL1,
};
var colorsL2 = {
Expand All @@ -79,7 +80,8 @@ export class MapPanel extends Component<Props> {
var fieldsL2 = {
srcField: options.srcFieldL2,
dstField: options.dstFieldL2,
valField: options.valFieldL2,
inboundValueField: options.inboundValueFieldL2,
outboundValueField: options.outboundValueFieldL2,
endpointId: options.endpointIdL2,
};
var colorsL3 = {
Expand All @@ -89,7 +91,8 @@ export class MapPanel extends Component<Props> {
var fieldsL3 = {
srcField: options.srcFieldL3,
dstField: options.dstFieldL3,
valField: options.valFieldL3,
inboundValueField: options.inboundValueFieldL3,
outboundValueField: options.outboundValueFieldL3,
endpointId: options.endpointIdL3,
};
var parsedDataL1 = {};
Expand Down
117 changes: 100 additions & 17 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,11 @@ plugin.setPanelOptions((builder) => {
const options: any[] = [];
if (context && context.data) {
for (const frame of context.data) {
const frameName = frame.refId;
for (const field of frame.fields) {
const name = getFieldDisplayName(field, frame, context.data);
const value = name;
options.push({ value, label: name });
options.push({ value, label: '[' + frameName + '] ' + name });
}
}
}
Expand All @@ -350,22 +351,48 @@ plugin.setPanelOptions((builder) => {
},
});
builder.addSelect({
path: 'valFieldL1',
name: 'Layer 1 Value Field',
description: 'Select the field to use for data values',
path: 'inboundValueFieldL1',
name: 'Layer 1 Inbound Value Field',
description: 'Select the field to use for A-Z traffic values',
showIf: layer1Bool(true),
category: FieldsCategory,
settings: {
allowCustomValue: false,
options: [],
getOptions: async (context: FieldOverrideContext) => {
const options: any[] = [];
if (context && context.data) {
for (const frame of context.data) {
const frameName = frame.refId;
for (const field of frame.fields) {
const name = getFieldDisplayName(field, frame, context.data);
const value = name;
options.push({ value, label: '[' + frameName + '] ' + name });
}
}
}
return Promise.resolve(options);
},
},
});
builder.addSelect({
path: 'outboundValueFieldL1',
name: 'Layer 1 Outbound Value Field',
description: 'Select the field to use for Z-A traffic values',
showIf: layer1Bool(true),
category: FieldsCategory,
settings: {
allowCustomValue: false,
options: [],
getOptions: async (context: FieldOverrideContext) => {
const options: any[] = [];
if (context && context.data) {
for (const frame of context.data) {
const frameName = frame.refId;
for (const field of frame.fields) {
const name = getFieldDisplayName(field, frame, context.data);
const value = name;
options.push({ value, label: name });
options.push({ value, label: '[' + frameName + '] ' + name });
}
}
}
Expand All @@ -386,10 +413,11 @@ plugin.setPanelOptions((builder) => {
const options: any[] = [];
if (context && context.data) {
for (const frame of context.data) {
const frameName = frame.refId;
for (const field of frame.fields) {
const name = getFieldDisplayName(field, frame, context.data);
const value = name;
options.push({ value, label: name });
options.push({ value, label: '[' + frameName + '] ' + name });
}
}
}
Expand All @@ -410,10 +438,11 @@ plugin.setPanelOptions((builder) => {
const options: any[] = [];
if (context && context.data) {
for (const frame of context.data) {
const frameName = frame.refId;
for (const field of frame.fields) {
const name = getFieldDisplayName(field, frame, context.data);
const value = name;
options.push({ value, label: name });
options.push({ value, label: '[' + frameName + '] ' + name });
}
}
}
Expand All @@ -422,9 +451,9 @@ plugin.setPanelOptions((builder) => {
},
});
builder.addSelect({
path: 'valFieldL2',
name: 'Layer 2 Value Field',
description: 'Select the field to use for data values',
path: 'inboundValueFieldL2',
name: 'Layer 2 Inbound Value Field',
description: 'Select the field to use for A-Z traffic values',
showIf: layer2Bool(true),
category: FieldsCategory,
settings: {
Expand All @@ -434,10 +463,36 @@ plugin.setPanelOptions((builder) => {
const options: any[] = [];
if (context && context.data) {
for (const frame of context.data) {
const frameName = frame.refId;
for (const field of frame.fields) {
const name = getFieldDisplayName(field, frame, context.data);
const value = name;
options.push({ value, label: name });
options.push({ value, label: '[' + frameName + '] ' + name });
}
}
}
return Promise.resolve(options);
},
},
});
builder.addSelect({
path: 'outboundValueFieldL2',
name: 'Layer 2 Outbound Value Field',
description: 'Select the field to use for Z-A traffic values',
showIf: layer2Bool(true),
category: FieldsCategory,
settings: {
allowCustomValue: false,
options: [],
getOptions: async (context: FieldOverrideContext) => {
const options: any[] = [];
if (context && context.data) {
for (const frame of context.data) {
const frameName = frame.refId;
for (const field of frame.fields) {
const name = getFieldDisplayName(field, frame, context.data);
const value = name;
options.push({ value, label: '[' + frameName + '] ' + name });
}
}
}
Expand All @@ -458,10 +513,11 @@ plugin.setPanelOptions((builder) => {
const options: any[] = [];
if (context && context.data) {
for (const frame of context.data) {
const frameName = frame.refId;
for (const field of frame.fields) {
const name = getFieldDisplayName(field, frame, context.data);
const value = name;
options.push({ value, label: name });
options.push({ value, label: '[' + frameName + '] ' + name });
}
}
}
Expand All @@ -482,10 +538,11 @@ plugin.setPanelOptions((builder) => {
const options: any[] = [];
if (context && context.data) {
for (const frame of context.data) {
const frameName = frame.refId;
for (const field of frame.fields) {
const name = getFieldDisplayName(field, frame, context.data);
const value = name;
options.push({ value, label: name });
options.push({ value, label: '[' + frameName + '] ' + name });
}
}
}
Expand All @@ -494,22 +551,48 @@ plugin.setPanelOptions((builder) => {
},
});
builder.addSelect({
path: 'valFieldL3',
name: 'Layer 3 Value Field',
description: 'Select the field to use for data values',
path: 'inboundValueFieldL3',
name: 'Layer 3 Inbound Value Field',
description: 'Select the field to use for A-Z traffic values',
showIf: layer3Bool(true),
category: FieldsCategory,
settings: {
allowCustomValue: false,
options: [],
getOptions: async (context: FieldOverrideContext) => {
const options: any[] = [];
if (context && context.data) {
for (const frame of context.data) {
const frameName = frame.refId;
for (const field of frame.fields) {
const name = getFieldDisplayName(field, frame, context.data);
const value = name;
options.push({ value, label: '[' + frameName + '] ' + name });
}
}
}
return Promise.resolve(options);
},
},
});
builder.addSelect({
path: 'outboundValueFieldL3',
name: 'Layer 3 Outbound Value Field',
description: 'Select the field to use for Z-A traffic values',
showIf: layer3Bool(true),
category: FieldsCategory,
settings: {
allowCustomValue: false,
options: [],
getOptions: async (context: FieldOverrideContext) => {
const options: any[] = [];
if (context && context.data) {
for (const frame of context.data) {
const frameName = frame.refId;
for (const field of frame.fields) {
const name = getFieldDisplayName(field, frame, context.data);
const value = name;
options.push({ value, label: name });
options.push({ value, label: '[' + frameName + '] ' + name });
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@ export interface MapOptions {
nodeHighlightL1: string;
srcFieldL1: string;
dstFieldL1: string;
valFieldL1: string;
inboundValueFieldL1: string;
outboundValueFieldL1: string;
endpointIdL1: string;
layer2: boolean;
mapjsonL2: string;
nodeHighlightL2: string;
srcFieldL2: string;
dstFieldL2: string;
valFieldL2: string;
inboundValueFieldL2: string;
outboundValueFieldL2: string;
endpointIdL2: string;
layer3: boolean;
mapjsonL3: string;
nodeHighlightL3: string;
srcFieldL3: string;
dstFieldL3: string;
valFieldL3: string;
inboundValueFieldL3: string;
outboundValueFieldL3: string;
endpointIdL3: string;
startLat: number;
startLng: number;
Expand Down

0 comments on commit 6e4e0e6

Please sign in to comment.