Skip to content

Commit a88f694

Browse files
pbr0ck3rbillmurrin
authored andcommitted
add options to show/hide search buttons when creating a widget (#32)
* add options to show/hide search buttons when creating a widget * fixed typo * also add options to remove open in new window button and exclude from query button * made defaults true not false
1 parent eb708fb commit a88f694

File tree

5 files changed

+107
-22
lines changed

5 files changed

+107
-22
lines changed

src/web/components/FieldQuickValuesPlus.jsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const FieldQuickValuesPlus = React.createClass({
3535
dropdownIsOpen: false,
3636
loaded: false,
3737
data: [],
38-
defaults: {top_values: 5, sort_order: "descending", table_size: 25, show_pie_chart: true, show_data_table: true},
39-
quickValuesOptions: {top_values: 5, sort_order: "descending", table_size: 25, show_pie_chart: true, show_data_table: true}
38+
defaults: {top_values: 5, sort_order: "descending", table_size: 25, show_pie_chart: true, show_data_table: true, display_add_to_search_button: true, display_remove_from_search_button: true, display_exclude_from_query_button: true, display_get_term_reply_in_new_window_button: true},
39+
quickValuesOptions: {top_values: 5, sort_order: "descending", table_size: 25, show_pie_chart: true, show_data_table: true, display_add_to_search_button: true, display_remove_from_search_button: true, display_exclude_from_query_button: true, display_get_term_reply_in_new_window_button: true}
4040
};
4141
},
4242
style: style,
@@ -46,7 +46,7 @@ const FieldQuickValuesPlus = React.createClass({
4646
componentWillMount() {
4747
if (this.state.debug) console.log("In componentWillMount");
4848
this.setState({ dropdownIsOpen: false });
49-
this.setState({quickValuesOptions: {top_values: 5, sort_order: "descending", table_size: 25, show_pie_chart: true, show_data_table: true}});
49+
this.setState({quickValuesOptions: {top_values: 5, sort_order: "descending", table_size: 25, show_pie_chart: true, show_data_table: true, display_add_to_search_button: true, display_remove_from_search_button: true, display_exclude_from_query_button: true, display_get_term_reply_in_new_window_button: true}});
5050
},
5151

5252
componentDidMount() {
@@ -125,7 +125,12 @@ const FieldQuickValuesPlus = React.createClass({
125125
sort_order: this.state.configuration['org.graylog.plugins.quickvaluesplus.QuickValuesPlusPluginConfiguration'].sort_order,
126126
table_size: this.state.configuration['org.graylog.plugins.quickvaluesplus.QuickValuesPlusPluginConfiguration'].table_size,
127127
show_pie_chart: true,
128-
show_data_table: true
128+
show_data_table: true,
129+
display_add_to_search_button: true,
130+
display_remove_from_search_button: true,
131+
display_exclude_from_query_button: true,
132+
display_get_term_reply_in_new_window_button: true
133+
129134
},
130135
loaded: true,
131136
});
@@ -148,7 +153,12 @@ const FieldQuickValuesPlus = React.createClass({
148153
sort_order: this.state.defaults.sort_order,
149154
table_size: this.state.defaults.table_size,
150155
show_pie_chart: true,
151-
show_data_table: true
156+
show_data_table: true,
157+
display_add_to_search_button: true,
158+
display_remove_from_search_button: true,
159+
display_exclude_from_query_button: true,
160+
display_get_term_reply_in_new_window_button: true
161+
152162
},
153163
});
154164
}
@@ -233,8 +243,8 @@ const FieldQuickValuesPlus = React.createClass({
233243
data={this.state.data}
234244
horizontal
235245
displayAddToSearchButton
236-
displayRemoveFromSearchButton
237-
displayAnalysisInformation/>
246+
displayRemoveFromSearchButton={this.state.quickValuesOptions.display_remove_from_search_button}
247+
displayAnalysisInformation={this.state.quickValuesOptions.display_remove_from_search_button}/>
238248
);
239249
}
240250

@@ -266,4 +276,4 @@ const FieldQuickValuesPlus = React.createClass({
266276
},
267277
});
268278

269-
export default FieldQuickValuesPlus;
279+
export default FieldQuickValuesPlus;

src/web/components/QuickValuesPlusVisualization.jsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ const QuickValuesPlusVisualization = React.createClass({
3030
height: PropTypes.any,
3131
horizontal: PropTypes.bool,
3232
displayAnalysisInformation: PropTypes.bool,
33-
displayAddToSearchButton: PropTypes.bool,
34-
displayRemoveFromSearchButton: PropTypes.bool,
3533
},
3634
getInitialState() {
3735
this.filters = [];
@@ -308,21 +306,21 @@ const QuickValuesPlusVisualization = React.createClass({
308306
(d) => NumberUtils.formatNumber(d.count),
309307
];
310308

311-
if (this.props.displayAddToSearchButton) {
309+
if (this.props.config.display_add_to_search_button == true ) {
312310
columns.push((d) => this._getAddToSearchButton(d.term));
313311
}
314312

315-
if (this.props.displayRemoveFromSearchButton) {
313+
if (this.props.config.display_remove_from_search_button == true) {
316314
columns.push((d) => this._getRemoveFromSearchButton(d.term));
317315
}
318316

319317
if (this.props.config.dashboardID) {
320-
if (this.isPermitted(this.state.currentUser.permissions, [`dashboards:edit:${this.props.config.dashboardID}`])) {
318+
if (this.isPermitted(this.state.currentUser.permissions, [`dashboards:edit:${this.props.config.dashboardID}`]) && this.props.config.display_exclude_from_query_button) {
321319
columns.push((d) => this._getExcludeFromQueryButton(d.term));
322320
}
323321
}
324322

325-
if (this.props.config.field) {
323+
if (this.props.config.field && this.props.config.display_get_term_reply_in_new_window_button) {
326324
columns.push((d) => {
327325
//Properly format strings containing spaces, backslashes and colons.
328326
let escTerm = this.escape(`${d.term}`);
@@ -607,14 +605,15 @@ const QuickValuesPlusVisualization = React.createClass({
607605
<th style={{ width: '50%' }}>Value</th>
608606
<th style={{ alignItems: 'center' }}>%</th>
609607
<th style={{ alignItems: 'center' }}>#</th>
610-
{this.props.displayAddToSearchButton &&
608+
{this.props.config.display_add_to_search_button &&
611609
<th style={{ width: 30 }}>&nbsp;</th>
612610
}
613-
{this.props.displayRemoveFromSearchButton &&
611+
{this.props.config.display_remove_from_search_button &&
614612
<th style={{ width: 30 }}>&nbsp;</th>
615613
}
616-
{excludeQueryButton}
617-
{this.props.config.field &&
614+
{this.props.config.display_exclude_from_query_button &&
615+
excludeQueryButton}
616+
{(this.props.config.field && this.props.config.display_get_term_reply_in_new_window_button) &&
618617
<th style={{ width: 28 }}>&nbsp;</th>
619618
}
620619
</tr>
@@ -629,4 +628,4 @@ const QuickValuesPlusVisualization = React.createClass({
629628
},
630629
});
631630

632-
export default QuickValuesPlusVisualization;
631+
export default QuickValuesPlusVisualization;

src/web/components/QuickValuesPlusWidgetCreateConfiguration.jsx

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {PropTypes} from 'react';
1+
import React, {PropTypes} from 'react';
22
import { Input } from 'components/bootstrap';
33

44
const QuickValuesPlusWidgetCreateConfiguration = React.createClass({
@@ -14,6 +14,10 @@ const QuickValuesPlusWidgetCreateConfiguration = React.createClass({
1414
sort_order: 'descending',
1515
show_pie_chart: true,
1616
show_data_table: true,
17+
display_add_to_search_button: true,
18+
display_remove_from_search_button: true,
19+
display_exclude_from_query_button: true,
20+
display_get_term_reply_in_new_window_button: true,
1721
};
1822
},
1923

@@ -38,7 +42,7 @@ const QuickValuesPlusWidgetCreateConfiguration = React.createClass({
3842
onChange={this.props.onChange}
3943
help="Modify the number of results in the table."/>
4044

41-
<label for="quickvaluesplus-sort-order-descending" class="control-label"><span>Sort Order</span></label>
45+
<label for="quickvaluesplus-sort-order-descending" className="control-label"><span>Sort Order</span></label>
4246
<div className="radio">
4347
<label>
4448
<input key="dataSortOrderDesc" id="quickvaluesplus-sort-order-descending" type="radio" name="sort_order" value="descending"
@@ -73,6 +77,42 @@ const QuickValuesPlusWidgetCreateConfiguration = React.createClass({
7377
checked={this.props.config.show_data_table}
7478
onChange={this.props.onChange}
7579
help="Include a table with quantitative information." />
80+
81+
<Input key="displayAddToSearchButton"
82+
type="checkbox"
83+
id="quickvaluesplus-display-add-to-search-button"
84+
name="display_add_to_search_button"
85+
label="Display Add to Search Button"
86+
checked={this.props.config.display_add_to_search_button}
87+
onChange={this.props.onChange}
88+
help="Column containing a add to search button." />
89+
90+
<Input key="displayRemoveFromSearchButton"
91+
type="checkbox"
92+
id="quickvaluesplus-display-remove-from-search-button"
93+
name="display_remove_from_search_button"
94+
label="Display Remove From Search Button"
95+
checked={this.props.config.display_remove_from_search_button}
96+
onChange={this.props.onChange}
97+
help="Column containing a remove from search button." />
98+
99+
<Input key="displayExludeFromQueryButton"
100+
type="checkbox"
101+
id="quickvaluesplus-display-exclude-from-query-button"
102+
name="display_exclude_from_query_button"
103+
label="Display Exclude From Query Button"
104+
checked={this.props.config.display_exclude_from_query_button}
105+
onChange={this.props.onChange}
106+
help="Column containing a exclude from Query button." />
107+
108+
<Input key="displayGetTermReplyInNewWindowButton"
109+
type="checkbox"
110+
id="quickvaluesplus-display-get-term-reply-in-new-window-button"
111+
name="display_get_term_reply_in_new_window_button"
112+
label="Display Get Term Reply In New Window Button"
113+
checked={this.props.config.display_get_term_reply_in_new_window_button}
114+
onChange={this.props.onChange}
115+
help="Column containing a get term reply in new window button." />
76116
</fieldset>
77117
);
78118
},

src/web/components/QuickValuesPlusWidgetEditConfiguration.jsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,42 @@ const QuickValuesPlusWidgetEditConfiguration = React.createClass({
7575
defaultChecked={this.props.config.show_data_table}
7676
onChange={this.props.onChange}
7777
help="Include a table with quantitative information."/>
78+
79+
<Input key="displayAddToSearchButton"
80+
type="checkbox"
81+
id="quickvaluesplus-display-add-to-search-button"
82+
name="display_add_to_search_button"
83+
label="Display Add to Search Button"
84+
checked={this.props.config.display_add_to_search_button}
85+
onChange={this.props.onChange}
86+
help="Column containing a add to search button." />
87+
88+
<Input key="displayRemoveFromSearchButton"
89+
type="checkbox"
90+
id="quickvaluesplus-display-remove-from-search-button"
91+
name="display_remove_from_search_button"
92+
label="Display Remove From Search Button"
93+
checked={this.props.config.display_remove_from_search_button}
94+
onChange={this.props.onChange}
95+
help="Column containing a remove from search button." />
96+
97+
<Input key="displayExludeFromQueryButton"
98+
type="checkbox"
99+
id="quickvaluesplus-display-exclude-from-query-button"
100+
name="display_exclude_from_query_button"
101+
label="Display Exclude From Query Button"
102+
checked={this.props.config.display_exclude_from_query_button}
103+
onChange={this.props.onChange}
104+
help="Column containing a exclude from Query button." />
105+
106+
<Input key="displayGetTermReplyInNewWindowButton"
107+
type="checkbox"
108+
id="quickvaluesplus-display-get-term-reply-in-new-window-button"
109+
name="display_get_term_reply_in_new_window_button"
110+
label="Display Get Term Reply In New Window Button"
111+
checked={this.props.config.display_get_term_reply_in_new_window_button}
112+
onChange={this.props.onChange}
113+
help="Column containing a get term reply in new window button." />
78114
</fieldset>
79115
);
80116
},

src/web/stores/QuickValuesPlusStore.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ export const QuickValuesPlusStore = Reflux.createStore({
5050

5151
QuickValuesPlusActions.getQuickValues.promise(promise);
5252
},
53-
});
53+
});

0 commit comments

Comments
 (0)