import React from 'react' import Influx from 'react-influx' import {ifcat} from '../../libs/utils' import EntryStore from '../../stores/EntryStore' import Dispatcher from '../../dispatchers/Dispatcher' import Spinner from 'react-spinkit' import AceEditor from 'react-ace'; import brace from 'brace' import 'brace/mode/json'; import 'brace/theme/monokai'; export default class Header extends Influx.Component { constructor(...args) { super(...args); this.state = {search: {}, searchEnabled: false}; this.search = {}; } getListeners() { return [ [EntryStore, EntryStore.Events.UPDATED, this._onEntryStoreUpdated] ] } _onEntryStoreUpdated() { const search = {query: EntryStore.getSearchQuery(), options: EntryStore.getSearchOptions()}; this.setState({search, searchEnabled: true}); this.search = JSON.stringify(search); } _handleChange(key, data) { if (!this.state.searchEnabled) { return; } try { this.setState({search: {...this.state.search, [key]: JSON.parse(data)}}) } catch (e) { console.error(e); } } _handleSearch() { try { const {query,options} = this.state.search; Dispatcher.emit(Dispatcher.Events.REQUEST_ENTRY_SEARCH, query, options, true); } catch (e) { console.error(e); } } render() { return (