Skip to content

Commit

Permalink
Merge branch 'end-to-end-tests' of github.com:esnet/grafana-esnet-net…
Browse files Browse the repository at this point in the history
…workmap-panel into end-to-end-tests
  • Loading branch information
sanchezelton committed Nov 12, 2024
2 parents 2096da6 + 9329cfb commit e71a9f4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 32 deletions.
13 changes: 4 additions & 9 deletions src/MapPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { Component } from 'react';
import { PanelProps, createTheme, getValueFormat, DataFrameView, sortDataFrame, getTimeField, EventBus } from '@grafana/data';
import type { GrafanaTheme2 } from '@grafana/data';
import { PanelProps, createTheme, getValueFormat, DataFrameView, sortDataFrame, getTimeField } from '@grafana/data';
import { MapOptions } from './types';
import { sanitizeTopology } from './components/lib/topologyTools';
import './components/MapCanvas.component.js';
Expand All @@ -12,8 +11,6 @@ import { signals } from "./signals.js"
export interface MapPanelProps extends PanelProps<MapOptions> {
fieldConfig: any;
options: MapOptions;
eventBus: EventBus;
theme: GrafanaTheme2;
}

export function toDataFrames(data){
Expand All @@ -34,7 +31,7 @@ export class MapPanel extends Component<MapPanelProps> {
mapCanvas: any;
lastOptions: any;
lastTopology: any;
theme: GrafanaTheme2;
theme: any;
mapjsonCache: any;
subscriptionHandle: any;
variableChangeHandle: any;
Expand Down Expand Up @@ -201,16 +198,15 @@ export class MapPanel extends Component<MapPanelProps> {
}
// snapshot the current options. If they're not the same as the last options, update them.
let currOptions = JSON.parse(JSON.stringify(options));

if (Array.isArray(thresholds)) {
thresholds.forEach((layerThresholds, layerIdx)=>{
const currLayerNodeThresholds = options?.layers?.[layerIdx].nodeThresholds;
if(JSON.stringify(layerThresholds) !== JSON.stringify(currLayerNodeThresholds)){
setPath(currOptions, `layers[${layerIdx}].nodeThresholds`, layerThresholds);
}
});
}

return currOptions;
} return currOptions;
}

updateMap(forceRefresh?) {
Expand Down Expand Up @@ -306,7 +302,6 @@ export class MapPanel extends Component<MapPanelProps> {
this.mapCanvas.current.setTrafficFormat(formatter);
this.mapCanvas.current.setTraffic(trafficData);
}

componentDidMount() {
let { eventBus, options, replaceVariables, fieldConfig } = this.props;
options = JSON.parse(JSON.stringify(options));
Expand Down
14 changes: 0 additions & 14 deletions src/components/hoc/withThemeWrapper.tsx

This file was deleted.

9 changes: 8 additions & 1 deletion src/components/lib/esmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ function renderEdges(g, data, ref, layerId) {
var layerClass = ' l'+layerId;
return 'edge edge-az edge-az-' + name + connections + layerClass;
})
.attr('text', function (d) {
return d.AZname;
})
.attr('pointer-events', 'stroke')
.on('mousedown', function(event, d){
event.stopPropagation();
Expand Down Expand Up @@ -193,6 +196,9 @@ function renderEdges(g, data, ref, layerId) {
var layerClass = ' l'+layerId;
return 'edge edge-za edge-za-' + name + connections + layerClass;
})
.attr('text', function (d) {
return d.ZAname;
})
.attr('pointer-events', 'stroke')
.on('mousedown', function(event, d){
event.stopPropagation();
Expand Down Expand Up @@ -997,6 +1003,7 @@ export class EsMap {
}
this.mapCanvas.listen(signals.SELECTION_CLEARED, clearSelection);

// function nudge(latOrLng, amount){
const nudge = (latOrLng, amount) => {
if (this.lastInteractedType === null || this.lastInteractedObject === null) return;
if (this.lastInteractedType === "nodes") {
Expand Down Expand Up @@ -1041,7 +1048,7 @@ export class EsMap {
default:
break;
}
});
})
}

destroy(){
Expand Down
10 changes: 2 additions & 8 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { standardEditorsRegistry, FieldConfigProperty, PanelPlugin, FieldOverrideContext, getFieldDisplayName } from '@grafana/data';
import type { PanelProps } from '@grafana/data';
import { MapOptions } from './types';
import { MapPanel } from './MapPanel';
import { CustomTextArea } from './components/CustomTextArea';
Expand All @@ -17,19 +16,14 @@ import {
defaultCustomEdgeTooltip,
defaultCustomNodeTooltip
} from "./options";
import { ComponentType } from 'react';

const customEditors = {
"CoordinateButton": CoordinateButton,
"CustomTextArea": CustomTextArea,
"ViewportCoordinateButton": ViewportCoordinateButton
}

const DEFAULT_LAYER_OPTIONS = {
color: "gray"
}

export const plugin = new PanelPlugin<MapOptions>(MapPanel as unknown as ComponentType<PanelProps<MapOptions>>);
export const plugin = new PanelPlugin<MapOptions>(MapPanel);

function checkBools(settings: object) {
return (config: MapOptions) => {
Expand Down Expand Up @@ -132,7 +126,7 @@ let layerOptions = {
category: "Layer ${i+1}: Basic Options",
showIf: { "topologySource": ["autodetect", "json"], "layers[${i}].visible": true},
description: 'The default color for nodes and links on Layer ${i+1}',
defaultValue: DEFAULT_LAYER_OPTIONS.color,
defaultValue: 'grey',
},
"layers[${i}].mapjson": {
name: 'Layer ${i+1} Map data (json)',
Expand Down

0 comments on commit e71a9f4

Please sign in to comment.