Skip to content

Commit 7e23d91

Browse files
author
mbrill-nt
committed
Fixed default values for options, removed dummy_graph.ts
1 parent c86d059 commit 7e23d91

File tree

10 files changed

+120
-198
lines changed

10 files changed

+120
-198
lines changed

src/dummy_graph.ts

Lines changed: 0 additions & 164 deletions
This file was deleted.

src/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { PanelPlugin } from '@grafana/data';
22
import { PanelSettings } from './types';
33

44
import { ServiceDependencyGraphPanelController } from './panel/ServiceDependencyGraphPanelController';
5-
import { optionsBuilder } from './options/options';
5+
import { optionsBuilder } from './options/Options';
66

77
export const plugin = new PanelPlugin<PanelSettings>(ServiceDependencyGraphPanelController).setPanelOptions(
88
optionsBuilder

src/options/DefaultSettings.tsx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { PanelSettings} from '../types';
2+
3+
export const DefaultSettings: PanelSettings = {
4+
animate: true,
5+
6+
dataMapping: {
7+
sourceComponentPrefix: 'origin_',
8+
targetComponentPrefix: 'target_',
9+
10+
responseTimeColumn: 'response-time',
11+
requestRateColumn: 'request-rate',
12+
errorRateColumn: 'error-rate',
13+
responseTimeOutgoingColumn: 'response-time-out',
14+
requestRateOutgoingColumn: 'request-rate-out',
15+
errorRateOutgoingColumn: 'error-rate-out',
16+
17+
extOrigin: 'external_origin',
18+
extTarget: 'external_target',
19+
type: 'type',
20+
21+
baselineRtUpper: 'threshold',
22+
23+
showDummyData: false,
24+
},
25+
26+
sumTimings: {value: true},
27+
filterEmptyConnections: {value: true},
28+
showDebugInformation: {value: false},
29+
showConnectionStats: {value: true},
30+
showBaselines: {value: false},
31+
32+
style: {
33+
healthyColor: 'rgb(87, 148, 242)',
34+
dangerColor: 'rgb(196, 22, 42)',
35+
unknownColor: 'rgb(123, 123, 138)',
36+
},
37+
38+
serviceIcons: [
39+
{
40+
pattern: 'java',
41+
filename: 'java'
42+
},
43+
{
44+
pattern: 'spok|star trek',
45+
filename: 'star_trek'
46+
},
47+
],
48+
49+
externalIcons: [
50+
{
51+
pattern: 'web',
52+
filename: 'web'
53+
},
54+
{
55+
pattern: 'jms',
56+
filename: 'message'
57+
},
58+
{
59+
pattern: 'jdbc',
60+
filename: 'database'
61+
},
62+
{
63+
pattern: 'http',
64+
filename: 'http'
65+
}
66+
],
67+
68+
drillDownLink: "",
69+
}

src/options/TypeAheadTextfield/TypeaheadTextfield.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ interface State {
2222
export class TypeaheadTextField extends React.PureComponent<Props, State> {
2323
constructor(props: Props | Readonly<Props>) {
2424
super(props);
25+
26+
var value = props.value;
27+
if(value === undefined) {
28+
value = props.item.defaultValue;
29+
}
2530
this.state = {
2631
...props,
32+
value: value,
2733
suggestions: [],
2834
};
2935
}
@@ -90,7 +96,7 @@ export class TypeaheadTextField extends React.PureComponent<Props, State> {
9096
render() {
9197
var value = this.props.value;
9298
if (value === undefined) {
93-
value = '';
99+
value = this.props.item.defaultValue;
94100
}
95101

96102
const suggestions = this.getSuggestions(value);

src/options/dummyDataSwitch/DummyDataSwitch.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ interface State {
2121
export class DummyDataSwitch extends React.PureComponent<Props, State> {
2222
constructor(props: Props | Readonly<Props>) {
2323
super(props);
24+
25+
var dataMapping = this.props.context.options.dataMapping;
26+
if(dataMapping === undefined) {
27+
dataMapping = this.props.item.defaultValue;
28+
}
2429
this.state = {
25-
dataMapping: this.props.context.options.dataMapping,
30+
dataMapping: dataMapping,
2631
...props,
2732
};
2833
}
@@ -48,7 +53,6 @@ export class DummyDataSwitch extends React.PureComponent<Props, State> {
4853
onChange = (event: any) => {
4954
var dataMapping = this.props.context.options.dataMapping;
5055
var newValue = !dataMapping.showDummyData;
51-
5256
dataMapping = this.state.dataMapping;
5357

5458
if (newValue) {

src/options/externalIconMapping/ExternalIconMapping.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class ExternalIconMapping extends React.PureComponent<Props, Props> {
4545

4646
render() {
4747
if (!this.state.value || this.state.value === undefined) {
48-
this.state.context.options.externalIcons = [{ pattern: 'my-type', filename: 'default' }];
48+
this.state.context.options.externalIcons = this.state.item.defaultValue;
4949
}
5050
var optionsList: JSX.Element[] = [];
5151
for (const image of this.getExternalIcons()) {

src/options/genericDataSwitch/GenericDataSwitch.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import React from 'react';
2-
import { StandardEditorProps } from '@grafana/data';
32
import { Switch } from '@grafana/ui';
43
import { IntSwitch } from 'types';
54

5+
interface StandardEditorProps {
6+
item: any,
7+
value: IntSwitch,
8+
onChange: any,
9+
context: any,
10+
}
11+
612
function onChangeOverride(value: IntSwitch, onChange: any, item: any) {
713
value.value = !value.value;
814
onChange.call(item.path, value);
915
}
1016

1117
export const GenericDataSwitch: React.FC<StandardEditorProps> = ({item, value, onChange, context}) => {
1218
if(context.options[item.path] === undefined){
13-
context.options[item.path] = {value: false}
19+
context.options[item.path] = item.defaultValue;
1420
}
1521

1622
return (

0 commit comments

Comments
 (0)