diff --git a/src/components/SearchContainer/Tabs/PrebuiltQueriesDisplay.jsx b/src/components/SearchContainer/Tabs/PrebuiltQueriesDisplay.jsx index 5574ef66e..46ef0a325 100644 --- a/src/components/SearchContainer/Tabs/PrebuiltQueriesDisplay.jsx +++ b/src/components/SearchContainer/Tabs/PrebuiltQueriesDisplay.jsx @@ -1,10 +1,10 @@ import React, { Component } from 'react'; -import PrebuiltQueryNode from './PrebuiltQueryNode' +import PrebuiltQueryNode from './PrebuiltQueryNode'; import { If, Then, Else } from 'react-if'; -const { app } = require('electron').remote -var fs = require('fs') -var path = require('path') -var process = require('process') +const { app } = require('electron').remote; +var fs = require('fs'); +var path = require('path'); +var process = require('process'); var exec = require('child_process').exec; export default class PrebuiltQueriesDisplay extends Component { @@ -14,20 +14,52 @@ export default class PrebuiltQueriesDisplay extends Component { this.state = { queries: [], custom: [] - } + }; + } + + componentWillMount() { + $.ajax({ + url: path.join(app.getPath('userData'), '/customqueries.json'), + type: 'GET', + success: function (response) { + var x = JSON.parse(response); + var y = []; + + $.each(x.queries, function (index, el) { + y.push(el); + }); + + this.setState({ custom: y }); + }.bind(this) + }); + + $.ajax({ + url: 'src/components/SearchContainer/Tabs/PrebuiltQueries.json', + type: 'GET', + success: function (response) { + var x = JSON.parse(response); + var y = []; + + $.each(x.queries, function (index, el) { + y.push(el); + }); + + this.setState({ queries: y }); + }.bind(this) + }); } getCommandLine() { switch (process.platform) { case 'darwin' : return 'open'; - case 'win32' : return 'start'; - case 'win64' : return 'start'; + case 'win32' : return ''; + case 'win64' : return ''; default : return 'xdg-open'; } } editCustom(){ - exec(this.getCommandLine() + ' ' + path.join(app.getPath('userData'),'/customqueries.json')); + exec(this.getCommandLine() + ' "' + path.join(app.getPath('userData'),'/customqueries.json') + '"'); } refreshCustom(){ @@ -35,49 +67,19 @@ export default class PrebuiltQueriesDisplay extends Component { url: path.join(app.getPath('userData'),'/customqueries.json'), type: 'GET', success: function(response){ - var x = JSON.parse(response) - var y = [] + var x = JSON.parse(response); + var y = []; $.each(x.queries, function(index, el) { - y.push(el) + y.push(el); }); - this.setState({custom: y}) + this.setState({custom: y}); }.bind(this) - }) + }); } - componentWillMount() { - $.ajax({ - url: path.join(app.getPath('userData'),'/customqueries.json'), - type: 'GET', - success: function(response){ - var x = JSON.parse(response) - var y = [] - - $.each(x.queries, function(index, el) { - y.push(el) - }); - - this.setState({custom: y}) - }.bind(this) - }) - - $.ajax({ - url: 'src/components/SearchContainer/Tabs/PrebuiltQueries.json', - type: 'GET', - success: function(response){ - var x = JSON.parse(response) - var y = [] - - $.each(x.queries, function(index, el) { - y.push(el) - }); - - this.setState({queries: y}) - }.bind(this) - }) - } + render() { return ( @@ -87,21 +89,21 @@ export default class PrebuiltQueriesDisplay extends Component {
{this.state.queries.map(function(a){ - return + return ; })}

Custom Queries - - + +

- +
No user defined queries.
{() =>
{this.state.custom.map(function(a){ - return + return ; })}
}