Skip to content

Commit

Permalink
Web console: Server context defaults (#16868)
Browse files Browse the repository at this point in the history
* add server defaults

* null is NULL

* r to d

* add test

* typo
  • Loading branch information
vogievetsky authored Aug 9, 2024
1 parent a7dd436 commit 483a03f
Show file tree
Hide file tree
Showing 18 changed files with 343 additions and 411 deletions.
2 changes: 1 addition & 1 deletion licenses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5085,7 +5085,7 @@ license_category: binary
module: web-console
license_name: Apache License version 2.0
copyright: Imply Data
version: 0.22.20
version: 0.22.21

---

Expand Down
3 changes: 1 addition & 2 deletions web-console/console-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@
*/

window.consoleConfig = {
exampleManifestsUrl: 'https://druid.apache.org/data/example-manifests-v2.tsv',
/* future configs may go here */
/* configs go here */
};
14 changes: 7 additions & 7 deletions web-console/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web-console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@blueprintjs/datetime2": "^2.3.7",
"@blueprintjs/icons": "^5.10.0",
"@blueprintjs/select": "^5.2.1",
"@druid-toolkit/query": "^0.22.20",
"@druid-toolkit/query": "^0.22.21",
"@druid-toolkit/visuals-core": "^0.3.3",
"@druid-toolkit/visuals-react": "^0.3.3",
"@fontsource/open-sans": "^5.0.28",
Expand Down
3 changes: 1 addition & 2 deletions web-console/src/components/header-bar/header-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ import './header-bar.scss';
const capabilitiesOverride = localStorageGetJson(LocalStorageKeys.CAPABILITIES_OVERRIDE);

export type HeaderActiveTab =
| null
| 'data-loader'
| 'streaming-data-loader'
| 'classic-batch-data-loader'
Expand Down Expand Up @@ -93,7 +92,7 @@ const DruidLogo = React.memo(function DruidLogo() {
});

export interface HeaderBarProps {
active: HeaderActiveTab;
active: HeaderActiveTab | null;
capabilities: Capabilities;
onUnrestrict(capabilities: Capabilities): void;
}
Expand Down
63 changes: 38 additions & 25 deletions web-console/src/console-application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import type { Filter } from 'react-table';

import type { HeaderActiveTab } from './components';
import { HeaderBar, Loader } from './components';
import type { DruidEngine, QueryWithContext } from './druid-models';
import type { DruidEngine, QueryContext, QueryWithContext } from './druid-models';
import { Capabilities, maybeGetClusterCapacity } from './helpers';
import { stringToTableFilters, tableFiltersToString } from './react-table';
import { AppToaster } from './singletons';
Expand All @@ -51,22 +51,32 @@ import './console-application.scss';

type FiltersRouteMatch = RouteComponentProps<{ filters?: string }>;

function changeHashWithFilter(slug: string, filters: Filter[]) {
function changeTabWithFilter(tab: HeaderActiveTab, filters: Filter[]) {
const filterString = tableFiltersToString(filters);
location.hash = slug + (filterString ? `/${filterString}` : '');
location.hash = tab + (filterString ? `/${filterString}` : '');
}

function viewFilterChange(slug: string) {
return (filters: Filter[]) => changeHashWithFilter(slug, filters);
function viewFilterChange(tab: HeaderActiveTab) {
return (filters: Filter[]) => changeTabWithFilter(tab, filters);
}

function pathWithFilter(slug: string) {
return [`/${slug}/:filters`, `/${slug}`];
function pathWithFilter(tab: HeaderActiveTab) {
return [`/${tab}/:filters`, `/${tab}`];
}

function switchTab(tab: HeaderActiveTab) {
location.hash = tab;
}

function switchToWorkbenchTab(tabId: string) {
location.hash = `workbench/${tabId}`;
}

export interface ConsoleApplicationProps {
defaultQueryContext?: Record<string, any>;
mandatoryQueryContext?: Record<string, any>;
baseQueryContext?: QueryContext;
defaultQueryContext?: QueryContext;
mandatoryQueryContext?: QueryContext;
serverQueryContext?: QueryContext;
}

export interface ConsoleApplicationState {
Expand Down Expand Up @@ -158,22 +168,22 @@ export class ConsoleApplication extends React.PureComponent<

private readonly goToStreamingDataLoader = (supervisorId?: string) => {
if (supervisorId) this.supervisorId = supervisorId;
location.hash = 'streaming-data-loader';
switchTab('streaming-data-loader');
this.resetInitialsWithDelay();
};

private readonly goToClassicBatchDataLoader = (taskId?: string) => {
if (taskId) this.taskId = taskId;
location.hash = 'classic-batch-data-loader';
switchTab('classic-batch-data-loader');
this.resetInitialsWithDelay();
};

private readonly goToDatasources = (datasource: string) => {
changeHashWithFilter('datasources', [{ id: 'datasource', value: `=${datasource}` }]);
changeTabWithFilter('datasources', [{ id: 'datasource', value: `=${datasource}` }]);
};

private readonly goToSegments = (datasource: string, onlyUnavailable = false) => {
changeHashWithFilter(
changeTabWithFilter(
'segments',
compact([
{ id: 'datasource', value: `=${datasource}` },
Expand All @@ -183,19 +193,19 @@ export class ConsoleApplication extends React.PureComponent<
};

private readonly goToSupervisor = (supervisorId: string) => {
changeHashWithFilter('supervisors', [{ id: 'supervisor_id', value: `=${supervisorId}` }]);
changeTabWithFilter('supervisors', [{ id: 'supervisor_id', value: `=${supervisorId}` }]);
};

private readonly goToTasksWithTaskId = (taskId: string) => {
changeHashWithFilter('tasks', [{ id: 'task_id', value: `=${taskId}` }]);
changeTabWithFilter('tasks', [{ id: 'task_id', value: `=${taskId}` }]);
};

private readonly goToTasksWithTaskGroupId = (taskGroupId: string) => {
changeHashWithFilter('tasks', [{ id: 'group_id', value: `=${taskGroupId}` }]);
changeTabWithFilter('tasks', [{ id: 'group_id', value: `=${taskGroupId}` }]);
};

private readonly goToTasksWithDatasource = (datasource: string, type?: string) => {
changeHashWithFilter(
changeTabWithFilter(
'tasks',
compact([
{ id: 'datasource', value: `=${datasource}` },
Expand All @@ -206,24 +216,24 @@ export class ConsoleApplication extends React.PureComponent<

private readonly openSupervisorSubmit = () => {
this.openSupervisorDialog = true;
location.hash = 'supervisors';
switchTab('supervisors');
this.resetInitialsWithDelay();
};

private readonly openTaskSubmit = () => {
this.openTaskDialog = true;
location.hash = 'tasks';
switchTab('tasks');
this.resetInitialsWithDelay();
};

private readonly goToQuery = (queryWithContext: QueryWithContext) => {
this.queryWithContext = queryWithContext;
location.hash = 'workbench';
switchTab('workbench');
this.resetInitialsWithDelay();
};

private readonly wrapInViewContainer = (
active: HeaderActiveTab,
active: HeaderActiveTab | null,
el: JSX.Element,
classType: 'normal' | 'narrow-pad' | 'thin' | 'thinner' = 'normal',
) => {
Expand Down Expand Up @@ -293,7 +303,8 @@ export class ConsoleApplication extends React.PureComponent<
};

private readonly wrappedWorkbenchView = (p: RouteComponentProps<{ tabId?: string }>) => {
const { defaultQueryContext, mandatoryQueryContext } = this.props;
const { defaultQueryContext, mandatoryQueryContext, baseQueryContext, serverQueryContext } =
this.props;
const { capabilities } = this.state;

const queryEngines: DruidEngine[] = ['native'];
Expand All @@ -309,12 +320,12 @@ export class ConsoleApplication extends React.PureComponent<
<WorkbenchView
capabilities={capabilities}
tabId={p.match.params.tabId}
onTabChange={newTabId => {
location.hash = `workbench/${newTabId}`;
}}
onTabChange={switchToWorkbenchTab}
initQueryWithContext={this.queryWithContext}
defaultQueryContext={defaultQueryContext}
mandatoryQueryContext={mandatoryQueryContext}
baseQueryContext={baseQueryContext}
serverQueryContext={serverQueryContext}
queryEngines={queryEngines}
allowExplain
goToTask={this.goToTasksWithTaskId}
Expand All @@ -325,6 +336,7 @@ export class ConsoleApplication extends React.PureComponent<
};

private readonly wrappedSqlDataLoaderView = () => {
const { serverQueryContext } = this.props;
const { capabilities } = this.state;
return this.wrapInViewContainer(
'sql-data-loader',
Expand All @@ -334,6 +346,7 @@ export class ConsoleApplication extends React.PureComponent<
goToTask={this.goToTasksWithTaskId}
goToTaskGroup={this.goToTasksWithTaskGroupId}
getClusterCapacity={maybeGetClusterCapacity}
serverQueryContext={serverQueryContext}
/>,
);
};
Expand Down
Loading

0 comments on commit 483a03f

Please sign in to comment.