Skip to content

Commit eb708fb

Browse files
committed
31-fix-quick-values-changing-colors
1 parent 4c457fe commit eb708fb

File tree

2 files changed

+70
-11
lines changed

2 files changed

+70
-11
lines changed

src/web/components/FieldQuickValuesPlus.jsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,17 @@ const FieldQuickValuesPlus = React.createClass({
129129
},
130130
loaded: true,
131131
});
132-
this.refs.thedash.refs.widgetModal.setState({
133-
config: {
134-
top_values: this.state.configuration['org.graylog.plugins.quickvaluesplus.QuickValuesPlusPluginConfiguration'].top_values,
135-
sort_order: this.state.configuration['org.graylog.plugins.quickvaluesplus.QuickValuesPlusPluginConfiguration'].sort_order,
136-
table_size: this.state.configuration['org.graylog.plugins.quickvaluesplus.QuickValuesPlusPluginConfiguration'].table_size,
137-
show_pie_chart: true,
138-
show_data_table: true
139-
}
140-
});
132+
if (this.refs.thedash !== undefined) {
133+
this.refs.thedash.refs.widgetModal.setState({
134+
config: {
135+
top_values: this.state.configuration['org.graylog.plugins.quickvaluesplus.QuickValuesPlusPluginConfiguration'].top_values,
136+
sort_order: this.state.configuration['org.graylog.plugins.quickvaluesplus.QuickValuesPlusPluginConfiguration'].sort_order,
137+
table_size: this.state.configuration['org.graylog.plugins.quickvaluesplus.QuickValuesPlusPluginConfiguration'].table_size,
138+
show_pie_chart: true,
139+
show_data_table: true
140+
}
141+
});
142+
}
141143
} else {
142144
if (this.state.debug) console.log("Global config not loaded. QVP Options using internal default values.");
143145
this.setState({

src/web/components/QuickValuesPlusVisualization.jsx

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const QuickValuesPlusVisualization = React.createClass({
4545
this.topValues = 5;
4646
this.dimension = this.quickValuesData.dimension((d) => d.term);
4747
this.group = this.dimension.group().reduceSum((d) => d.count);
48+
this.currentConfig = {};
4849

4950
return {
5051
total: undefined,
@@ -59,9 +60,37 @@ const QuickValuesPlusVisualization = React.createClass({
5960
} else {
6061
this.sortOrder = d3.ascending;
6162
}
63+
64+
if (this.props.config.dashboardID) {
65+
this.setState({
66+
currentConfig: {
67+
dashboardID: this.props.config.dashboardID,
68+
field: this.props.config.field,
69+
query: this.props.config.query,
70+
show_data_table: this.props.config.show_data_table,
71+
show_pie_chart: this.props.config.show_pie_chart,
72+
sort_order: this.props.config.sort_order,
73+
stream_id: this.props.config.stream_id,
74+
table_size: this.props.config.table_size,
75+
timerange: this.props.config.timerange,
76+
top_values: this.props.config.top_values,
77+
}
78+
});
79+
} else {
80+
this.setState({currentConfig: {
81+
show_data_table: this.props.config.show_data_table,
82+
show_pie_chart: this.props.config.show_pie_chart,
83+
sort_order: this.props.config.sort_order,
84+
table_size: this.props.config.table_size,
85+
top_values: this.props.config.top_values,
86+
}
87+
});
88+
}
89+
6290
this.tableChanged = false;
6391
this.tableSize = this.props.config.table_size;
6492
this.topValues = this.props.config.top_values;
93+
6594
this._resizeVisualization(this.props.width, this.props.height, this.props.config.show_data_table);
6695
this._formatProps(this.props);
6796
this._renderDataTable();
@@ -83,10 +112,38 @@ const QuickValuesPlusVisualization = React.createClass({
83112
this.tableChanged = true;
84113
this.tableSize = nextProps.config.table_size;
85114
this.topValues = nextProps.config.top_values;
115+
86116
this._resizeVisualization(nextProps.width, nextProps.height, nextProps.config.show_data_table);
87117
this._formatProps(nextProps);
88-
this._renderDataTable();
89-
this._renderPieChart();
118+
119+
if (!deepEqual(this.state.currentConfig, nextProps.config)) {
120+
if (this.props.config.dashboardID) {
121+
this.setState({currentConfig: {
122+
dashboardID: nextProps.config.dashboardID,
123+
field: nextProps.config.field,
124+
query: nextProps.config.query,
125+
show_data_table: nextProps.config.show_data_table,
126+
show_pie_chart: nextProps.config.show_pie_chart,
127+
sort_order: nextProps.config.sort_order,
128+
stream_id: nextProps.config.stream_id,
129+
table_size: nextProps.config.table_size,
130+
timerange: nextProps.config.timerange,
131+
top_values: nextProps.config.top_values,
132+
}
133+
});
134+
} else {
135+
this.setState({currentConfig: {
136+
show_data_table: nextProps.config.show_data_table,
137+
show_pie_chart: nextProps.config.show_pie_chart,
138+
sort_order: nextProps.config.sort_order,
139+
table_size: nextProps.config.table_size,
140+
top_values: nextProps.config.top_values,
141+
}
142+
});
143+
}
144+
this._renderDataTable();
145+
this._renderPieChart();
146+
}
90147
},
91148
NUMBER_OF_TOP_VALUES: 10,
92149
DEFAULT_PIE_CHART_SIZE: 200,

0 commit comments

Comments
 (0)