Web-console: prevent unnecessary loading of disabled data sources (#7804)

* prevent loading disabled datasources

* prevent double loading

* remove complexity

* rename function

* remove space
This commit is contained in:
mcbrewster 2019-06-01 02:08:34 -07:00 committed by Clint Wylie
parent 55af692b56
commit 21d3d0cde8
1 changed files with 13 additions and 3 deletions

View File

@ -151,8 +151,11 @@ export class DatasourcesView extends React.Component<DatasourcesViewProps, Datas
const seen = countBy(datasources, (x: any) => x.datasource); const seen = countBy(datasources, (x: any) => x.datasource);
const disabledResp = await axios.get('/druid/coordinator/v1/metadata/datasources?includeDisabled'); let disabled: string [] = [];
const disabled: string[] = disabledResp.data.filter((d: string) => !seen[d]); if (this.state.showDisabled) {
const disabledResp = await axios.get('/druid/coordinator/v1/metadata/datasources?includeDisabled' );
disabled = disabledResp.data.filter((d: string) => !seen[d]);
}
const rulesResp = await axios.get('/druid/coordinator/v1/rules'); const rulesResp = await axios.get('/druid/coordinator/v1/rules');
const rules = rulesResp.data; const rules = rulesResp.data;
@ -395,6 +398,13 @@ GROUP BY 1`);
}); });
} }
private toggleDisabled(showDisabled: boolean) {
if (!showDisabled) {
this.datasourceQueryManager.rerunLastQuery();
}
this.setState({showDisabled: !showDisabled});
}
getDatasourceActions(datasource: string, disabled: boolean): BasicAction[] { getDatasourceActions(datasource: string, disabled: boolean): BasicAction[] {
const { goToSql } = this.props; const { goToSql } = this.props;
@ -657,7 +667,7 @@ GROUP BY 1`);
<Switch <Switch
checked={showDisabled} checked={showDisabled}
label="Show disabled" label="Show disabled"
onChange={() => this.setState({ showDisabled: !showDisabled })} onChange={() => this.toggleDisabled(showDisabled)}
/> />
<TableColumnSelection <TableColumnSelection
columns={noSqlMode ? tableColumnsNoSql : tableColumns} columns={noSqlMode ? tableColumnsNoSql : tableColumns}