Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support advanced settings #68

Merged
merged 5 commits into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions gantt-chart/public/components/options_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@ export function OptionsEditor({ aggs, stateParams, setValue }: VisOptionsProps<G
<EuiSpacer size="s" />

<EuiFormRow label="Color">
<EuiColorPicker
color={stateParams.colors}
onChange={(e) => setValue('colors', e)}
/>
<EuiColorPicker color={stateParams.colors} onChange={(e) => setValue('colors', e)} />
</EuiFormRow>
</EuiPanel>
);
Expand Down
22 changes: 20 additions & 2 deletions gantt-chart/public/gantt_request_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
import { IUiSettingsClient } from 'opensearch-dashboards/public';
import { IndexPattern } from 'src/plugins/data/public';
import { VisParams } from 'src/plugins/visualizations/public';
import { buildOpenSearchQuery, Filter, Query, TimeRange, getTime } from '../../../src/plugins/data/common';
import {
buildOpenSearchQuery,
Filter,
getTime,
OpenSearchQueryConfig,
Query,
TimeRange,
} from '../../../src/plugins/data/common';
import { GanttVisDependencies } from './plugin';

interface GanttRequestHandlerDeps {
Expand All @@ -22,7 +29,18 @@ const constructRequest = (
uiSettings: IUiSettingsClient,
{ timeRange, filters, query, index, visParams }: GanttRequestHandlerDeps
) => {
const DSL = buildOpenSearchQuery(index, query, filters);
let DSL;
try {
const config: OpenSearchQueryConfig = {
allowLeadingWildcards: uiSettings.get('query:allowLeadingWildcards'),
queryStringOptions: uiSettings.get('query:queryString:options'),
ignoreFilterIfFieldNotInIndex: uiSettings.get('courier:ignoreFilterIfFieldNotInIndex'),
};
DSL = buildOpenSearchQuery(index, query, filters, config);
} catch (error) {
DSL = buildOpenSearchQuery(index, query, filters);
}

const request: any = {
index: index.title,
size: visParams.size,
Expand Down
24 changes: 10 additions & 14 deletions gantt-chart/public/gantt_vis_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { Vis, PersistedState } from 'src/plugins/visualizations/public';
import { IAggConfigs } from 'src/plugins/data/public';
import { PersistedState, Vis } from 'src/plugins/visualizations/public';
import { GanttChart } from './components/gantt_chart';
import { GanttChartEditor } from './components/gantt_chart_editor';
import { GanttVisDependencies } from './plugin';
import { OptionsEditor } from './components/options_editor';
import { getGanttRequestHandler } from './gantt_request_handler';
import { GanttVisDependencies } from './plugin';

export interface SearchResponse {
_index: string;
Expand Down Expand Up @@ -77,19 +77,15 @@ export interface GanttSuccessResponse {
total: number;
}

const getGanttResponseHandler = () => async ({
total,
hits,
}: {
total: number;
hits: SearchResponse[];
}) => {
const responseData: GanttSuccessResponse = {
total,
source: hits.map((hit) => hit._source),
const getGanttResponseHandler =
() =>
async ({ total, hits }: { total: number; hits: SearchResponse[] }) => {
const responseData: GanttSuccessResponse = {
total,
source: hits.map((hit) => hit._source),
};
return responseData;
};
return responseData;
};

export function getGanttVisDefinition(dependencies: GanttVisDependencies) {
const ganttRequestHandler = getGanttRequestHandler(dependencies);
Expand Down
11 changes: 9 additions & 2 deletions gantt-chart/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { CoreSetup, Plugin, CoreStart, IUiSettingsClient, HttpSetup } from 'opensearch-dashboards/public';
import {
CoreSetup,
CoreStart,
HttpSetup,
IUiSettingsClient,
Plugin,
} from 'opensearch-dashboards/public';
import { VisualizationsSetup } from '../../../src/plugins/visualizations/public';
import { getGanttVisDefinition } from './gantt_vis_type';

Expand All @@ -17,7 +23,8 @@ export interface GanttVisDependencies extends Partial<CoreStart> {
}

export class CustomVisualizationsPublicPlugin
implements Plugin<CustomVisualizationsSetup, CustomVisualizationsStart> {
implements Plugin<CustomVisualizationsSetup, CustomVisualizationsStart>
{
public setup(core: CoreSetup, setupDeps: SetupDependencies) {
const dependencies: GanttVisDependencies = {
uiSettings: core.uiSettings,
Expand Down