|
@@ -166,7 +166,7 @@ export class Explore extends React.Component<any, IExploreState> {
|
|
|
supportsTable,
|
|
supportsTable,
|
|
|
datasourceLoading: false,
|
|
datasourceLoading: false,
|
|
|
},
|
|
},
|
|
|
- () => datasourceError === null && this.handleSubmit()
|
|
|
|
|
|
|
+ () => datasourceError === null && this.onSubmit()
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -174,7 +174,7 @@ export class Explore extends React.Component<any, IExploreState> {
|
|
|
this.el = el;
|
|
this.el = el;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- handleAddQueryRow = index => {
|
|
|
|
|
|
|
+ onAddQueryRow = index => {
|
|
|
const { queries } = this.state;
|
|
const { queries } = this.state;
|
|
|
const nextQueries = [
|
|
const nextQueries = [
|
|
|
...queries.slice(0, index + 1),
|
|
...queries.slice(0, index + 1),
|
|
@@ -184,7 +184,7 @@ export class Explore extends React.Component<any, IExploreState> {
|
|
|
this.setState({ queries: nextQueries });
|
|
this.setState({ queries: nextQueries });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- handleChangeDatasource = async option => {
|
|
|
|
|
|
|
+ onChangeDatasource = async option => {
|
|
|
this.setState({
|
|
this.setState({
|
|
|
datasource: null,
|
|
datasource: null,
|
|
|
datasourceError: null,
|
|
datasourceError: null,
|
|
@@ -197,10 +197,10 @@ export class Explore extends React.Component<any, IExploreState> {
|
|
|
this.setDatasource(datasource);
|
|
this.setDatasource(datasource);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- handleChangeQuery = (value, index) => {
|
|
|
|
|
|
|
+ onChangeQuery = (value: string, index: number, override?: boolean) => {
|
|
|
const { queries } = this.state;
|
|
const { queries } = this.state;
|
|
|
const prevQuery = queries[index];
|
|
const prevQuery = queries[index];
|
|
|
- const edited = prevQuery.query !== value;
|
|
|
|
|
|
|
+ const edited = override ? false : prevQuery.query !== value;
|
|
|
const nextQuery = {
|
|
const nextQuery = {
|
|
|
...queries[index],
|
|
...queries[index],
|
|
|
edited,
|
|
edited,
|
|
@@ -211,50 +211,71 @@ export class Explore extends React.Component<any, IExploreState> {
|
|
|
this.setState({ queries: nextQueries });
|
|
this.setState({ queries: nextQueries });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- handleChangeTime = nextRange => {
|
|
|
|
|
|
|
+ onChangeTime = nextRange => {
|
|
|
const range = {
|
|
const range = {
|
|
|
from: nextRange.from,
|
|
from: nextRange.from,
|
|
|
to: nextRange.to,
|
|
to: nextRange.to,
|
|
|
};
|
|
};
|
|
|
- this.setState({ range }, () => this.handleSubmit());
|
|
|
|
|
|
|
+ this.setState({ range }, () => this.onSubmit());
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- handleClickCloseSplit = () => {
|
|
|
|
|
|
|
+ onClickClear = () => {
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ graphResult: null,
|
|
|
|
|
+ logsResult: null,
|
|
|
|
|
+ queries: ensureQueries(),
|
|
|
|
|
+ tableResult: null,
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ onClickCloseSplit = () => {
|
|
|
const { onChangeSplit } = this.props;
|
|
const { onChangeSplit } = this.props;
|
|
|
if (onChangeSplit) {
|
|
if (onChangeSplit) {
|
|
|
onChangeSplit(false);
|
|
onChangeSplit(false);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- handleClickGraphButton = () => {
|
|
|
|
|
|
|
+ onClickGraphButton = () => {
|
|
|
this.setState(state => ({ showingGraph: !state.showingGraph }));
|
|
this.setState(state => ({ showingGraph: !state.showingGraph }));
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- handleClickLogsButton = () => {
|
|
|
|
|
|
|
+ onClickLogsButton = () => {
|
|
|
this.setState(state => ({ showingLogs: !state.showingLogs }));
|
|
this.setState(state => ({ showingLogs: !state.showingLogs }));
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- handleClickSplit = () => {
|
|
|
|
|
|
|
+ onClickSplit = () => {
|
|
|
const { onChangeSplit } = this.props;
|
|
const { onChangeSplit } = this.props;
|
|
|
if (onChangeSplit) {
|
|
if (onChangeSplit) {
|
|
|
onChangeSplit(true, this.state);
|
|
onChangeSplit(true, this.state);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- handleClickTableButton = () => {
|
|
|
|
|
|
|
+ onClickTableButton = () => {
|
|
|
this.setState(state => ({ showingTable: !state.showingTable }));
|
|
this.setState(state => ({ showingTable: !state.showingTable }));
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- handleRemoveQueryRow = index => {
|
|
|
|
|
|
|
+ onClickTableCell = (columnKey: string, rowValue: string) => {
|
|
|
|
|
+ const { datasource, queries } = this.state;
|
|
|
|
|
+ if (datasource && datasource.modifyQuery) {
|
|
|
|
|
+ const nextQueries = queries.map(q => ({
|
|
|
|
|
+ ...q,
|
|
|
|
|
+ edited: false,
|
|
|
|
|
+ query: datasource.modifyQuery(q.query, { addFilter: { key: columnKey, value: rowValue } }),
|
|
|
|
|
+ }));
|
|
|
|
|
+ this.setState({ queries: nextQueries }, () => this.onSubmit());
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ onRemoveQueryRow = index => {
|
|
|
const { queries } = this.state;
|
|
const { queries } = this.state;
|
|
|
if (queries.length <= 1) {
|
|
if (queries.length <= 1) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
const nextQueries = [...queries.slice(0, index), ...queries.slice(index + 1)];
|
|
const nextQueries = [...queries.slice(0, index), ...queries.slice(index + 1)];
|
|
|
- this.setState({ queries: nextQueries }, () => this.handleSubmit());
|
|
|
|
|
|
|
+ this.setState({ queries: nextQueries }, () => this.onSubmit());
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- handleSubmit = () => {
|
|
|
|
|
|
|
+ onSubmit = () => {
|
|
|
const { showingLogs, showingGraph, showingTable, supportsGraph, supportsLogs, supportsTable } = this.state;
|
|
const { showingLogs, showingGraph, showingTable, supportsGraph, supportsLogs, supportsTable } = this.state;
|
|
|
if (showingTable && supportsTable) {
|
|
if (showingTable && supportsTable) {
|
|
|
this.runTableQuery();
|
|
this.runTableQuery();
|
|
@@ -267,27 +288,6 @@ export class Explore extends React.Component<any, IExploreState> {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- onClickClear = () => {
|
|
|
|
|
- this.setState({
|
|
|
|
|
- graphResult: null,
|
|
|
|
|
- logsResult: null,
|
|
|
|
|
- queries: ensureQueries(),
|
|
|
|
|
- tableResult: null,
|
|
|
|
|
- });
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- onClickTableCell = (columnKey: string, rowValue: string) => {
|
|
|
|
|
- const { datasource, queries } = this.state;
|
|
|
|
|
- if (datasource && datasource.modifyQuery) {
|
|
|
|
|
- const nextQueries = queries.map(q => ({
|
|
|
|
|
- ...q,
|
|
|
|
|
- edited: false,
|
|
|
|
|
- query: datasource.modifyQuery(q.query, { addFilter: { key: columnKey, value: rowValue } }),
|
|
|
|
|
- }));
|
|
|
|
|
- this.setState({ queries: nextQueries }, () => this.handleSubmit());
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
onQuerySuccess(datasourceId: string, queries: any[]): void {
|
|
onQuerySuccess(datasourceId: string, queries: any[]): void {
|
|
|
// save queries to history
|
|
// save queries to history
|
|
|
let { datasource, history } = this.state;
|
|
let { datasource, history } = this.state;
|
|
@@ -450,7 +450,7 @@ export class Explore extends React.Component<any, IExploreState> {
|
|
|
</div>
|
|
</div>
|
|
|
) : (
|
|
) : (
|
|
|
<div className="navbar-buttons explore-first-button">
|
|
<div className="navbar-buttons explore-first-button">
|
|
|
- <button className="btn navbar-button" onClick={this.handleClickCloseSplit}>
|
|
|
|
|
|
|
+ <button className="btn navbar-button" onClick={this.onClickCloseSplit}>
|
|
|
Close Split
|
|
Close Split
|
|
|
</button>
|
|
</button>
|
|
|
</div>
|
|
</div>
|
|
@@ -460,7 +460,7 @@ export class Explore extends React.Component<any, IExploreState> {
|
|
|
<Select
|
|
<Select
|
|
|
className="datasource-picker"
|
|
className="datasource-picker"
|
|
|
clearable={false}
|
|
clearable={false}
|
|
|
- onChange={this.handleChangeDatasource}
|
|
|
|
|
|
|
+ onChange={this.onChangeDatasource}
|
|
|
options={datasources}
|
|
options={datasources}
|
|
|
placeholder="Loading datasources..."
|
|
placeholder="Loading datasources..."
|
|
|
value={selectedDatasource}
|
|
value={selectedDatasource}
|
|
@@ -470,19 +470,19 @@ export class Explore extends React.Component<any, IExploreState> {
|
|
|
<div className="navbar__spacer" />
|
|
<div className="navbar__spacer" />
|
|
|
{position === 'left' && !split ? (
|
|
{position === 'left' && !split ? (
|
|
|
<div className="navbar-buttons">
|
|
<div className="navbar-buttons">
|
|
|
- <button className="btn navbar-button" onClick={this.handleClickSplit}>
|
|
|
|
|
|
|
+ <button className="btn navbar-button" onClick={this.onClickSplit}>
|
|
|
Split
|
|
Split
|
|
|
</button>
|
|
</button>
|
|
|
</div>
|
|
</div>
|
|
|
) : null}
|
|
) : null}
|
|
|
- <TimePicker range={range} onChangeTime={this.handleChangeTime} />
|
|
|
|
|
|
|
+ <TimePicker range={range} onChangeTime={this.onChangeTime} />
|
|
|
<div className="navbar-buttons">
|
|
<div className="navbar-buttons">
|
|
|
<button className="btn navbar-button navbar-button--no-icon" onClick={this.onClickClear}>
|
|
<button className="btn navbar-button navbar-button--no-icon" onClick={this.onClickClear}>
|
|
|
Clear All
|
|
Clear All
|
|
|
</button>
|
|
</button>
|
|
|
</div>
|
|
</div>
|
|
|
<div className="navbar-buttons relative">
|
|
<div className="navbar-buttons relative">
|
|
|
- <button className="btn navbar-button--primary" onClick={this.handleSubmit}>
|
|
|
|
|
|
|
+ <button className="btn navbar-button--primary" onClick={this.onSubmit}>
|
|
|
Run Query <i className="fa fa-level-down run-icon" />
|
|
Run Query <i className="fa fa-level-down run-icon" />
|
|
|
</button>
|
|
</button>
|
|
|
{loading || latency ? <ElapsedTime time={latency} className="text-info" /> : null}
|
|
{loading || latency ? <ElapsedTime time={latency} className="text-info" /> : null}
|
|
@@ -505,26 +505,26 @@ export class Explore extends React.Component<any, IExploreState> {
|
|
|
history={history}
|
|
history={history}
|
|
|
queries={queries}
|
|
queries={queries}
|
|
|
request={this.request}
|
|
request={this.request}
|
|
|
- onAddQueryRow={this.handleAddQueryRow}
|
|
|
|
|
- onChangeQuery={this.handleChangeQuery}
|
|
|
|
|
- onExecuteQuery={this.handleSubmit}
|
|
|
|
|
- onRemoveQueryRow={this.handleRemoveQueryRow}
|
|
|
|
|
|
|
+ onAddQueryRow={this.onAddQueryRow}
|
|
|
|
|
+ onChangeQuery={this.onChangeQuery}
|
|
|
|
|
+ onExecuteQuery={this.onSubmit}
|
|
|
|
|
+ onRemoveQueryRow={this.onRemoveQueryRow}
|
|
|
/>
|
|
/>
|
|
|
{queryError && !loading ? <div className="text-warning m-a-2">{queryError}</div> : null}
|
|
{queryError && !loading ? <div className="text-warning m-a-2">{queryError}</div> : null}
|
|
|
|
|
|
|
|
<div className="result-options">
|
|
<div className="result-options">
|
|
|
{supportsGraph ? (
|
|
{supportsGraph ? (
|
|
|
- <button className={`btn navbar-button ${graphButtonActive}`} onClick={this.handleClickGraphButton}>
|
|
|
|
|
|
|
+ <button className={`btn navbar-button ${graphButtonActive}`} onClick={this.onClickGraphButton}>
|
|
|
Graph
|
|
Graph
|
|
|
</button>
|
|
</button>
|
|
|
) : null}
|
|
) : null}
|
|
|
{supportsTable ? (
|
|
{supportsTable ? (
|
|
|
- <button className={`btn navbar-button ${tableButtonActive}`} onClick={this.handleClickTableButton}>
|
|
|
|
|
|
|
+ <button className={`btn navbar-button ${tableButtonActive}`} onClick={this.onClickTableButton}>
|
|
|
Table
|
|
Table
|
|
|
</button>
|
|
</button>
|
|
|
) : null}
|
|
) : null}
|
|
|
{supportsLogs ? (
|
|
{supportsLogs ? (
|
|
|
- <button className={`btn navbar-button ${logsButtonActive}`} onClick={this.handleClickLogsButton}>
|
|
|
|
|
|
|
+ <button className={`btn navbar-button ${logsButtonActive}`} onClick={this.onClickLogsButton}>
|
|
|
Logs
|
|
Logs
|
|
|
</button>
|
|
</button>
|
|
|
) : null}
|
|
) : null}
|