Skip to content

Commit

Permalink
fix tooltip function and remove single viewer link for latlong
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 committed Jan 27, 2021
1 parent 423e12d commit bff94a7
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/ml/public/application/explorer/explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ export class Explorer extends React.Component {
const timefilter = getTimefilter();
const bounds = timefilter.getActiveBounds();
const selectedJobIds = Array.isArray(selectedJobs) ? selectedJobs.map((job) => job.id) : [];

return (
<ExplorerPage
jobSelectorProps={jobSelectorProps}
Expand Down Expand Up @@ -331,6 +330,7 @@ export class Explorer extends React.Component {
}
/>
)}

<AnomalyTimeline
explorerState={this.props.explorerState}
setSelectedCells={this.props.setSelectedCells}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React, { useState, useRef, useEffect } from 'react';
import uuid from 'uuid';
import React, { useMemo, useState, useRef, useEffect } from 'react';
import { htmlIdGenerator } from '@elastic/eui';
import {
EmbeddableFactory,
ErrorEmbeddable,
ViewMode,
isErrorEmbeddable,
ViewMode,
} from '../../../../../../../src/plugins/embeddable/public';
import {
MapEmbeddable,
MapEmbeddableInput,
MapEmbeddableOutput,
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../maps/public/embeddable';
import { Dictionary } from '../../../../common/types/common';
Expand All @@ -28,17 +30,22 @@ interface Props {

export function EmbeddedMapComponent({ seriesConfig, severity }: Props) {
const [embeddable, setEmbeddable] = useState<MapEmbeddable | ErrorEmbeddable | undefined>();
const id = useMemo(() => htmlIdGenerator()(), []);

const embeddableRoot: React.RefObject<HTMLDivElement> = useRef<HTMLDivElement>(null);
const layerList = useRef<LayerDescriptor[]>([]);
const {
services: { embeddable: embeddablePlugin, maps: mapsPlugin },
} = useMlKibana();

const factory = embeddablePlugin.getEmbeddableFactory(MAP_SAVED_OBJECT_TYPE);
const factory:
| EmbeddableFactory<MapEmbeddableInput, MapEmbeddableOutput, MapEmbeddable>
| undefined = embeddablePlugin
? embeddablePlugin.getEmbeddableFactory(MAP_SAVED_OBJECT_TYPE)
: undefined;

const input: MapEmbeddableInput = {
id: uuid.v4(),
id,
attributes: { title: '' },
filters: [],
hidePanelTitles: true,
Expand Down Expand Up @@ -83,7 +90,7 @@ export function EmbeddedMapComponent({ seriesConfig, severity }: Props) {
console.error('Map embeddable not found.');
return;
}
const embeddableObject: any = await factory.create({
const embeddableObject = await factory.create({
...input,
title: 'Explorer map',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { MlTooltipComponent } from '../../components/chart_tooltip';
import { withKibana } from '../../../../../../../src/plugins/kibana_react/public';
import { ML_APP_URL_GENERATOR } from '../../../../common/constants/ml_url_generator';
import { ML_JOB_AGGREGATION } from '../../../../common/constants/aggregation_types';
import { addItemToRecentlyAccessed } from '../../util/recently_accessed';
import { ExplorerChartsErrorCallOuts } from './explorer_charts_error_callouts';

Expand Down Expand Up @@ -58,7 +59,6 @@ function getChartId(series) {
function ExplorerChartContainer({
series,
severity,
showSingleMetricViewerLink,
tooManyBuckets,
wrapLabel,
mlUrlGenerator,
Expand All @@ -69,8 +69,8 @@ function ExplorerChartContainer({
useEffect(() => {
let isCancelled = false;
const generateLink = async () => {
const singleMetricViewerLink = await getExploreSeriesLink(mlUrlGenerator, series);
if (!isCancelled && showSingleMetricViewerLink === true) {
if (!isCancelled && series.functionDescription !== ML_JOB_AGGREGATION.LAT_LONG) {
const singleMetricViewerLink = await getExploreSeriesLink(mlUrlGenerator, series);
setExplorerSeriesLink(singleMetricViewerLink);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export function getDefaultChartsData() {
chartsPerRow: 1,
errorMessages: undefined,
seriesToPlot: [],
showSingleMetricViewerLink: true,
// default values, will update on every re-render
tooManyBuckets: false,
timeFieldName: 'timestamp',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from '../../../common/constants/search';
import { getEntityFieldList } from '../../../common/util/anomaly_utils';
import { extractErrorMessage } from '../../../common/util/errors';
import { ML_JOB_AGGREGATION } from '../../../common/constants/aggregation_types';
import {
isSourceDataChartableForDetector,
isModelPlotChartableForDetector,
Expand Down Expand Up @@ -511,7 +512,9 @@ export async function loadAnomaliesTableData(
const entityFields = getEntityFieldList(anomaly.source);
isChartable = isModelPlotEnabled(job, anomaly.detectorIndex, entityFields);
}
anomaly.isTimeSeriesViewRecord = isChartable;

anomaly.isTimeSeriesViewRecord =
isChartable && anomaly.source?.function !== ML_JOB_AGGREGATION.LAT_LONG;

if (mlJobService.customUrlsByJob[jobId] !== undefined) {
anomaly.customUrls = mlJobService.customUrlsByJob[jobId];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export function buildConfigFromDetector(job, detectorIndex) {
const config = {
jobId: job.job_id,
detectorIndex: detectorIndex,
metricFunction: mlFunctionToESAggregation(detector.function),
metricFunction:
detector.function === ML_JOB_AGGREGATION.LAT_LONG
? ML_JOB_AGGREGATION.LAT_LONG
: mlFunctionToESAggregation(detector.function),
timeField: job.data_description.time_field,
interval: job.analysis_config.bucket_span,
datafeedConfig: job.datafeed_config,
Expand Down

0 comments on commit bff94a7

Please sign in to comment.