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

[ML] Anomaly Explorer swim lane pagination #70063

Merged
merged 39 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8fa8bd1
[ML] use explorer service
darnautov Jun 25, 2020
2ac4e94
[ML] WIP pagination
darnautov Jun 26, 2020
96ebfb0
[ML] add to dashboard without the limit
darnautov Jun 26, 2020
483ee8a
[ML] WIP
darnautov Jun 27, 2020
9865ece
[ML] loading states
darnautov Jun 29, 2020
e5c6b4e
[ML] viewBySwimlaneDataLoading on field change
darnautov Jun 29, 2020
1750bf1
[ML] fix dashboard control
darnautov Jun 29, 2020
408c5d0
[ML] universal swim lane container, embeddable pagination
darnautov Jun 29, 2020
b54eb99
[ML] fix css issue
darnautov Jun 29, 2020
d1307bd
[ML] rename anomalyTimelineService
darnautov Jun 29, 2020
a6f7511
[ML] rename callback
darnautov Jun 29, 2020
5014202
[ML] rename container component
darnautov Jun 30, 2020
5d11936
[ML] empty state, increase pagination margin
darnautov Jun 30, 2020
6870fdc
[ML] check for loading
darnautov Jun 30, 2020
6128253
Merge remote-tracking branch 'upstream/master' into ML-68360-swimlane…
darnautov Jun 30, 2020
0d77650
[ML] fix i18n
darnautov Jun 30, 2020
79ffff0
[ML] fix unit test
darnautov Jun 30, 2020
9eb04c9
[ML] improve selected cells
darnautov Jun 30, 2020
e989297
[ML] fix overall selection with changing job selection
darnautov Jun 30, 2020
59548d0
[ML] required props for pagination component
darnautov Jun 30, 2020
9a9b719
[ML] move RESIZE_IGNORED_DIFF_PX
darnautov Jun 30, 2020
1d683bf
[ML] jest tests
darnautov Jul 1, 2020
69c5a44
[ML] add test subject
darnautov Jul 1, 2020
57e4cae
[ML] SWIM_LANE_DEFAULT_PAGE_SIZE
darnautov Jul 1, 2020
04bf4ca
[ML] change empty state styling
darnautov Jul 1, 2020
d1919b3
[ML] fix agg size for influencer filters
darnautov Jul 1, 2020
36c3530
[ML] remove debounce
darnautov Jul 1, 2020
0819795
[ML] SCSS variables, rename swim lane class
darnautov Jul 1, 2020
ba3b363
[ML] job selector using context
darnautov Jul 1, 2020
98526c4
[ML] set padding for embeddable panel
darnautov Jul 1, 2020
8ca948c
Merge remote-tracking branch 'upstream/master' into ML-68360-swimlane…
darnautov Jul 1, 2020
cda437d
[ML] adjust pagination styles
darnautov Jul 1, 2020
a44f125
Merge remote-tracking branch 'upstream/master' into ML-68360-swimlane…
darnautov Jul 2, 2020
e6fd3af
[ML] replace custom time range subject with timefilter
darnautov Jul 2, 2020
f8af4b0
[ML] change loading indicator to mono
darnautov Jul 2, 2020
1370083
[ML] use swim lane type constant
darnautov Jul 2, 2020
fd9e7d0
[ML] change context naming
darnautov Jul 2, 2020
b66ebb2
[ML] update jest snapshot
darnautov Jul 2, 2020
90336a1
[ML] fix tests
darnautov Jul 2, 2020
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
25 changes: 23 additions & 2 deletions x-pack/plugins/ml/public/application/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React, { FC } from 'react';
import ReactDOM from 'react-dom';

import { AppMountParameters, CoreStart } from 'kibana/public';
import { AppMountParameters, CoreStart, HttpStart } from 'kibana/public';

import { Storage } from '../../../../../src/plugins/kibana_utils/public';

Expand All @@ -17,6 +17,8 @@ import { setLicenseCache } from './license';
import { MlSetupDependencies, MlStartDependencies } from '../plugin';

import { MlRouter } from './routing';
import { mlApiServicesProvider } from './services/ml_api_service';
import { HttpService } from './services/http_service';

type MlDependencies = MlSetupDependencies & MlStartDependencies;

Expand All @@ -27,6 +29,23 @@ interface AppProps {

const localStorage = new Storage(window.localStorage);

/**
* Provides global services available across the entire ML app.
*/
export function getMlGlobalServices(httpStart: HttpStart) {
const httpService = new HttpService(httpStart);
return {
httpService,
mlApiServices: mlApiServicesProvider(httpService),
};
}

export interface MlServicesContext {
mlServices: MlGlobalServices;
}

export type MlGlobalServices = ReturnType<typeof getMlGlobalServices>;

const App: FC<AppProps> = ({ coreStart, deps }) => {
const pageDeps = {
indexPatterns: deps.data.indexPatterns,
Expand All @@ -47,7 +66,9 @@ const App: FC<AppProps> = ({ coreStart, deps }) => {
const I18nContext = coreStart.i18n.Context;
return (
<I18nContext>
<KibanaContextProvider services={services}>
<KibanaContextProvider
services={{ ...services, mlServices: getMlGlobalServices(coreStart.http) }}
>
<MlRouter pageDeps={pageDeps} />
</KibanaContextProvider>
</I18nContext>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
normalizeTimes,
} from './job_select_service_utils';
import { MlJobWithTimeRange } from '../../../../common/types/anomaly_detection_jobs';
import { ml } from '../../services/ml_api_service';
import { useMlKibana } from '../../contexts/kibana';
import { JobSelectionMaps } from './job_selector';

Expand Down Expand Up @@ -66,7 +65,10 @@ export const JobSelectorFlyout: FC<JobSelectorFlyoutProps> = ({
withTimeRangeSelector = true,
}) => {
const {
services: { notifications },
services: {
notifications,
mlServices: { mlApiServices },
},
} = useMlKibana();

const [newSelection, setNewSelection] = useState(selectedIds);
Expand Down Expand Up @@ -151,7 +153,7 @@ export const JobSelectorFlyout: FC<JobSelectorFlyoutProps> = ({

async function fetchJobs() {
try {
const resp = await ml.jobs.jobsWithTimerange(dateFormatTz);
const resp = await mlApiServices.jobs.jobsWithTimerange(dateFormatTz);
const normalizedJobs = normalizeTimes(resp.jobs, dateFormatTz, DEFAULT_GANTT_BAR_WIDTH);
const { groups: groupsWithTimerange, groupsMap } = getGroupsFromJobs(normalizedJobs);
setJobs(normalizedJobs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import { Subscription } from 'rxjs';
import { EuiSuperDatePicker, OnRefreshProps } from '@elastic/eui';
import { TimeRange, TimeHistoryContract } from 'src/plugins/data/public';

import {
mlTimefilterRefresh$,
mlTimefilterTimeChange$,
} from '../../../services/timefilter_refresh_service';
import { mlTimefilterRefresh$ } from '../../../services/timefilter_refresh_service';
import { useUrlState } from '../../../util/url_state';
import { useMlKibana } from '../../../contexts/kibana';

Expand Down Expand Up @@ -108,7 +105,6 @@ export const DatePickerWrapper: FC = () => {
timefilter.setTime(newTime);
setTime(newTime);
setRecentlyUsedRanges(getRecentlyUsedRanges());
mlTimefilterTimeChange$.next({ lastRefresh: Date.now(), timeRange: { start, end } });
}

function updateInterval({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ import {
import { SecurityPluginSetup } from '../../../../../security/public';
import { LicenseManagementUIPluginSetup } from '../../../../../license_management/public';
import { SharePluginStart } from '../../../../../../../src/plugins/share/public';
import { MlServicesContext } from '../../app';

interface StartPlugins {
data: DataPublicPluginStart;
security?: SecurityPluginSetup;
licenseManagement?: LicenseManagementUIPluginSetup;
share: SharePluginStart;
}
export type StartServices = CoreStart & StartPlugins & { kibanaVersion: string };
export type StartServices = CoreStart &
StartPlugins & { kibanaVersion: string } & MlServicesContext;
// eslint-disable-next-line react-hooks/rules-of-hooks
export const useMlKibana = () => useKibana<StartServices>();
export type MlKibanaReactContextValue = KibanaReactContextValue<StartServices>;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import React from 'react';
import { IndexPattern, IndexPatternsContract } from '../../../../../../../src/plugins/data/public';
import { SavedSearchSavedObject } from '../../../../common/types/kibana';
import { MlServicesContext } from '../../app';

export interface MlContextValue {
combinedQuery: any;
Expand Down Expand Up @@ -34,4 +35,4 @@ export type SavedSearchQuery = object;
// Multiple custom hooks can be created to access subsets of
// the overall context value if necessary too,
// see useCurrentIndexPattern() for example.
export const MlContext = React.createContext<Partial<MlContextValue>>({});
export const MlContext = React.createContext<Partial<MlContextValue & MlServicesContext>>({});
20 changes: 12 additions & 8 deletions x-pack/plugins/ml/public/application/explorer/_explorer.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$borderRadius: $euiBorderRadius / 2;

.ml-swimlane-selector {
visibility: hidden;
}
Expand Down Expand Up @@ -104,10 +106,9 @@

// SASSTODO: This entire selector needs to be rewritten.
// It looks extremely brittle with very specific sizing units
.ml-explorer-swimlane {
.mlExplorerSwimlane {
user-select: none;
padding: 0;
margin-bottom: $euiSizeS;

line.gridLine {
stroke: $euiBorderColor;
Expand Down Expand Up @@ -218,17 +219,20 @@
div.lane {
height: 30px;
darnautov marked this conversation as resolved.
Show resolved Hide resolved
border-bottom: 0px;
border-radius: 2px;
margin-top: -1px;
border-radius: $borderRadius;
white-space: nowrap;

&:not(:first-child) {
margin-top: -1px;
darnautov marked this conversation as resolved.
Show resolved Hide resolved
}

div.lane-label {
display: inline-block;
font-size: 13px;
font-size: $euiFontSizeXS;
height: 30px;
text-align: right;
vertical-align: middle;
border-radius: 2px;
border-radius: $borderRadius;
padding-right: 5px;
margin-right: 5px;
border: 1px solid transparent;
Expand Down Expand Up @@ -261,7 +265,7 @@
.sl-cell-inner-dragselect {
height: 26px;
margin: 1px;
border-radius: 2px;
border-radius: $borderRadius;
text-align: center;
}

Expand Down Expand Up @@ -293,7 +297,7 @@
.sl-cell-inner,
.sl-cell-inner-dragselect {
border: 2px solid $euiColorDarkShade;
border-radius: 2px;
border-radius: $borderRadius;
opacity: 1;
}
}
Expand Down
Loading