Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into data-cleanup/…
Browse files Browse the repository at this point in the history
…filter-messages
  • Loading branch information
Liza K committed Aug 2, 2021
2 parents 1d2e051 + c048f71 commit 8d24947
Show file tree
Hide file tree
Showing 55 changed files with 2,032 additions and 920 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

> Warning: This API is now obsolete.
>
> Import from the "<!-- -->@<!-- -->kbn/es-query" package directly instead. 8.0
>
> Import from the "<!-- -->@<!-- -->kbn/es-query" package directly instead. 8.0
<b>Signature:</b>

Expand Down
4 changes: 4 additions & 0 deletions docs/management/advanced-options.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@ Shows the Timelion tutorial to users when they first open the Timelion app.
Used for calculating automatic intervals in visualizations, this is the number
of buckets to try to represent.

[[timelion-legacyChartsLibrary]]`timelion:legacyChartsLibrary`::
Enables the legacy charts library for timelion charts in Visualize.


[float]
[[kibana-visualization-settings]]
==== Visualization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type ExistsFilter = Filter & {
* @public
*/
export const isExistsFilter = (filter: FieldFilter): filter is ExistsFilter =>
has(filter, 'exists')!;
has(filter, 'exists');

/**
* @internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import type { estypes } from '@elastic/elasticsearch';
import { get, isPlainObject } from 'lodash';
import { has, isPlainObject } from 'lodash';
import type { FieldFilter, Filter, FilterMeta } from './types';
import type { IndexPatternFieldBase, IndexPatternBase } from '../../es_query';
import { getConvertedValueForField } from './get_converted_value_for_field';
Expand Down Expand Up @@ -57,7 +57,7 @@ export const isPhraseFilter = (filter: FieldFilter): filter is PhraseFilter => {
* @public
*/
export const isScriptedPhraseFilter = (filter: FieldFilter): filter is PhraseFilter =>
Boolean(get(filter, 'script.script.params.value'));
has(filter, 'script.script.params.value');

/** @internal */
export const getPhraseFilterField = (filter: PhraseFilter) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-query/src/filters/helpers/meta_filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const isFilterPinned = (filter: Filter) => {
*
* @public
*/
export const isFilterDisabled = (filter: Filter): boolean => has(filter, 'meta.disabled');
export const isFilterDisabled = (filter: Filter): boolean => get(filter, 'meta.disabled', false);

/**
*
Expand Down
1 change: 1 addition & 0 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export class DocLinksService {
indexManagement: `${ELASTICSEARCH_DOCS}index-mgmt.html`,
kibanaSearchSettings: `${KIBANA_DOCS}advanced-options.html#kibana-search-settings`,
visualizationSettings: `${KIBANA_DOCS}advanced-options.html#kibana-visualization-settings`,
timelionSettings: `${KIBANA_DOCS}advanced-options.html#kibana-timelion-settings`,
},
ml: {
guide: `${ELASTIC_WEBSITE_URL}guide/en/machine-learning/${DOC_LINK_VERSION}/index.html`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { mountWithIntl } from '@kbn/test/jest';
import { TableHeader } from './table_header';
import { findTestSubject } from '@elastic/eui/lib/test';
import { SortOrder } from './helpers';
import { IndexPattern, IFieldType } from '../../../../../kibana_services';
import { IndexPattern, IndexPatternField } from '../../../../../kibana_services';

function getMockIndexPattern() {
return ({
Expand All @@ -29,7 +29,7 @@ function getMockIndexPattern() {
aggregatable: false,
searchable: true,
sortable: true,
} as IFieldType;
} as IndexPatternField;
} else {
return {
name,
Expand All @@ -38,7 +38,7 @@ function getMockIndexPattern() {
aggregatable: false,
searchable: true,
sortable: false,
} as IFieldType;
} as IndexPatternField;
}
},
} as unknown) as IndexPattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
Query,
TimeRange,
Filter,
IFieldType,
IndexPatternField,
IndexPattern,
ISearchSource,
} from '../../../../data/common';
Expand Down Expand Up @@ -50,7 +50,7 @@ export interface SearchProps extends Partial<DiscoverGridProps> {
sharedItemTitle?: string;
inspectorAdapters?: Adapters;

filter?: (field: IFieldType, value: string[], operator: string) => void;
filter?: (field: IndexPatternField, value: string[], operator: string) => void;
hits?: ElasticSearchHit[];
totalHitCount?: number;
onMoveColumn?: (column: string, index: number) => void;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/discover/public/kibana_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export {
IIndexPattern,
IndexPattern,
indexPatterns,
IFieldType,
IndexPatternField,
ISearchSource,
EsQuerySortValue,
SortDirection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
type: 'text',
_meta: { description: 'Non-default value of setting.' },
},
'timelion:legacyChartsLibrary': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'timelion:target_buckets': {
type: 'long',
_meta: { description: 'Non-default value of setting.' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface UsageStats {
'visualization:tileMap:maxPrecision': number;
'csv:separator': string;
'visualization:tileMap:WMSdefaults': string;
'timelion:legacyChartsLibrary': boolean;
'timelion:target_buckets': number;
'timelion:max_buckets': number;
'timelion:es.timefield': string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { OverlayStart, HttpStart, IBasePath } from 'src/core/public';
import {
IndexPatternsContract,
IIndexPattern,
IndexPattern,
DataPublicPluginStart,
} from '../../../../../data/public';
import {
Expand Down Expand Up @@ -86,7 +86,7 @@ export interface FlyoutState {
error?: string;
file?: File;
importCount: number;
indexPatterns?: IIndexPattern[];
indexPatterns?: IndexPattern[];
importMode: ImportMode;
loadingMessage?: string;
isLegacyFile: boolean;
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7258,6 +7258,12 @@
"description": "Non-default value of setting."
}
},
"timelion:legacyChartsLibrary": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
},
"timelion:target_buckets": {
"type": "long",
"_meta": {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/timelion/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
registerListenEventListener,
watchMultiDecorator,
} from '../../kibana_legacy/public';
import { getTimezone } from '../../vis_type_timelion/public';
import { _LEGACY_ as visTypeTimelion } from '../../vis_type_timelion/public';
import { initCellsDirective } from './directives/cells/cells';
import { initFullscreenDirective } from './directives/fullscreen/fullscreen';
import { initFixedElementDirective } from './directives/fixed_element';
Expand Down Expand Up @@ -144,7 +144,7 @@ export function initTimelionApp(app, deps) {
$scope.updatedSheets = [];

const savedVisualizations = deps.plugins.visualizations.savedVisualizationsLoader;
const timezone = getTimezone(deps.core.uiSettings);
const timezone = visTypeTimelion.getTimezone(deps.core.uiSettings);

const defaultExpression = '.es(*)';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import _ from 'lodash';
import { parseTimelionExpressionAsync } from '../../../vis_type_timelion/public';
import { _LEGACY_ as visTypeTimelion } from '../../../vis_type_timelion/public';

export const SUGGESTION_TYPE = {
ARGUMENTS: 'arguments',
Expand Down Expand Up @@ -180,7 +180,7 @@ async function extractSuggestionsFromParsedResult(

export async function suggest(expression, functionList, cursorPosition, argValueSuggestions) {
try {
const result = await parseTimelionExpressionAsync(expression);
const result = await visTypeTimelion.parseTimelionExpressionAsync(expression);
return await extractSuggestionsFromParsedResult(
result,
cursorPosition,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/timelion/public/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
// styles for timelion visualization are lazy loaded only while a vis is opened
// this will duplicate styles only if both Timelion app and timelion visualization are loaded
// could be left here as it is since the Timelion app is deprecated
@import '../../vis_type_timelion/public/components/timelion_vis.scss';
@import '../../vis_type_timelion/public/legacy/timelion_vis.scss';
18 changes: 6 additions & 12 deletions src/plugins/timelion/public/panels/timechart/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ import $ from 'jquery';
import moment from 'moment-timezone';
// @ts-ignore
import observeResize from '../../lib/observe_resize';
import {
calculateInterval,
DEFAULT_TIME_FORMAT,
tickFormatters,
xaxisFormatterProvider,
generateTicksProvider,
} from '../../../../vis_type_timelion/public';
import { _LEGACY_ as visTypeTimelion } from '../../../../vis_type_timelion/public';
import { TimelionVisualizationDependencies } from '../../application';

const DEBOUNCE_DELAY = 50;
Expand All @@ -37,9 +31,9 @@ export function timechartFn(dependencies: TimelionVisualizationDependencies) {
help: 'Draw a timeseries chart',
render($scope: any, $elem: any) {
const template = '<div class="chart-top-title"></div><div class="chart-canvas"></div>';
const formatters = tickFormatters() as any;
const getxAxisFormatter = xaxisFormatterProvider(uiSettings);
const generateTicks = generateTicksProvider();
const formatters = visTypeTimelion.tickFormatters() as any;
const getxAxisFormatter = visTypeTimelion.xaxisFormatterProvider(uiSettings);
const generateTicks = visTypeTimelion.generateTicksProvider();

// TODO: I wonder if we should supply our own moment that sets this every time?
// could just use angular's injection to provide a moment service?
Expand Down Expand Up @@ -226,7 +220,7 @@ export function timechartFn(dependencies: TimelionVisualizationDependencies) {
if (legendCaption) {
legendCaption.text(
moment(pos.x).format(
_.get(dataset, '[0]._global.legend.timeFormat', DEFAULT_TIME_FORMAT)
_.get(dataset, '[0]._global.legend.timeFormat', visTypeTimelion.DEFAULT_TIME_FORMAT)
)
);
}
Expand Down Expand Up @@ -289,7 +283,7 @@ export function timechartFn(dependencies: TimelionVisualizationDependencies) {

// Get the X-axis tick format
const time = timefilter.timefilter.getBounds() as any;
const interval = calculateInterval(
const interval = visTypeTimelion.calculateInterval(
time.min.valueOf(),
time.max.valueOf(),
uiSettings.get('timelion:target_buckets') || 200,
Expand Down
18 changes: 18 additions & 0 deletions src/plugins/vis_type_timelion/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export const UI_SETTINGS = {
LEGACY_CHARTS_LIBRARY: 'timelion:legacyChartsLibrary',
ES_TIMEFIELD: 'timelion:es.timefield',
DEFAULT_INDEX: 'timelion:es.default_index',
TARGET_BUCKETS: 'timelion:target_buckets',
MAX_BUCKETS: 'timelion:max_buckets',
MIN_INTERVAL: 'timelion:min_interval',
GRAPHITE_URL: 'timelion:graphite.url',
QUANDL_KEY: 'timelion:quandl.key',
};
33 changes: 33 additions & 0 deletions src/plugins/vis_type_timelion/common/vis_data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export interface VisSeries {
yaxis?: number;
label: string;
lines?: {
show?: boolean;
lineWidth?: number;
fill?: number;
steps?: number;
};
points?: {
show?: boolean;
symbol?: 'cross' | 'x' | 'circle' | 'square' | 'diamond' | 'plus' | 'triangle';
fillColor?: string;
fill?: number;
radius?: number;
lineWidth?: number;
};
bars: {
lineWidth?: number;
fill?: number;
};
color?: string;
data: Array<Array<number | null>>;
stack: boolean;
}
2 changes: 1 addition & 1 deletion src/plugins/vis_type_timelion/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"kibanaVersion": "kibana",
"server": true,
"ui": true,
"requiredPlugins": ["visualizations", "data", "expressions"],
"requiredPlugins": ["visualizations", "data", "expressions", "charts"],
"requiredBundles": ["kibanaUtils", "kibanaReact", "visDefaultEditor"],
"owner": {
"name": "Kibana App",
Expand Down
62 changes: 62 additions & 0 deletions src/plugins/vis_type_timelion/public/components/series/area.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React from 'react';
import { AreaSeries, ScaleType, CurveType, AreaSeriesStyle, PointShape } from '@elastic/charts';
import type { VisSeries } from '../../../common/vis_data';

interface AreaSeriesComponentProps {
index: number;
visData: VisSeries;
groupId: string;
}

const isShowLines = (lines: VisSeries['lines'], points: VisSeries['points']) =>
lines?.show ? true : points?.show ? false : true;

const getAreaSeriesStyle = ({ color, lines, points }: AreaSeriesComponentProps['visData']) =>
({
line: {
opacity: isShowLines(lines, points) ? 1 : 0,
stroke: color,
strokeWidth: lines?.lineWidth !== undefined ? Number(lines.lineWidth) : 3,
visible: isShowLines(lines, points),
},
area: {
fill: color,
opacity: lines?.fill ?? 0,
visible: lines?.show ?? points?.show ?? true,
},
point: {
fill: points?.fillColor ?? color,
opacity: points?.lineWidth !== undefined ? (points.fill || 1) * 10 : 10,
radius: points?.radius ?? 3,
stroke: color,
strokeWidth: points?.lineWidth ?? 2,
visible: points?.show ?? false,
shape: points?.symbol === 'cross' ? PointShape.X : points?.symbol,
},
curve: lines?.steps ? CurveType.CURVE_STEP : CurveType.LINEAR,
} as AreaSeriesStyle);

export const AreaSeriesComponent = ({ index, groupId, visData }: AreaSeriesComponentProps) => (
<AreaSeries
id={index + visData.label}
groupId={groupId}
name={visData.label}
xScaleType={ScaleType.Time}
yScaleType={ScaleType.Linear}
xAccessor={0}
yAccessors={[1]}
data={visData.data}
sortIndex={index}
color={visData.color}
stackAccessors={visData.stack ? [0] : undefined}
areaSeriesStyle={getAreaSeriesStyle(visData)}
/>
);
Loading

0 comments on commit 8d24947

Please sign in to comment.