diff --git a/x-pack/plugins/ml/public/application/explorer/explorer_constants.ts b/x-pack/plugins/ml/public/application/explorer/explorer_constants.ts index 32b51bee64f86d..21e13cb029d69e 100644 --- a/x-pack/plugins/ml/public/application/explorer/explorer_constants.ts +++ b/x-pack/plugins/ml/public/application/explorer/explorer_constants.ts @@ -67,3 +67,8 @@ export const VIEW_BY_JOB_LABEL = i18n.translate('xpack.ml.explorer.jobIdLabel', * aggregations on influencers values. */ export const ANOMALY_SWIM_LANE_HARD_LIMIT = 1000; + +/** + * Default page size fot the anomaly swim lane. + */ +export const SWIM_LANE_DEFAULT_PAGE_SIZE = 10; diff --git a/x-pack/plugins/ml/public/application/explorer/reducers/explorer_reducer/state.ts b/x-pack/plugins/ml/public/application/explorer/reducers/explorer_reducer/state.ts index cf51c2b364045b..892b46467345b3 100644 --- a/x-pack/plugins/ml/public/application/explorer/reducers/explorer_reducer/state.ts +++ b/x-pack/plugins/ml/public/application/explorer/reducers/explorer_reducer/state.ts @@ -21,6 +21,7 @@ import { SwimlaneData, ViewBySwimLaneData, } from '../../explorer_utils'; +import { SWIM_LANE_DEFAULT_PAGE_SIZE } from '../../explorer_constants'; export interface ExplorerState { annotationsData: any[]; @@ -94,7 +95,7 @@ export function getExplorerDefaultState(): ExplorerState { viewBySwimlaneDataLoading: false, viewBySwimlaneFieldName: undefined, viewBySwimlaneOptions: [], - viewByPerPage: 10, + viewByPerPage: SWIM_LANE_DEFAULT_PAGE_SIZE, viewByFromPage: 1, swimlaneLimit: undefined, }; diff --git a/x-pack/plugins/ml/public/application/services/results_service/results_service.js b/x-pack/plugins/ml/public/application/services/results_service/results_service.js index 1231cefdef6211..3ecf2b471c7245 100644 --- a/x-pack/plugins/ml/public/application/services/results_service/results_service.js +++ b/x-pack/plugins/ml/public/application/services/results_service/results_service.js @@ -590,7 +590,7 @@ export function resultsServiceProvider(mlApiServices) { influencerFieldValues: { terms: { field: 'influencer_field_value', - size: maxResults || 1, + size: !!maxResults ? maxResults : ANOMALY_SWIM_LANE_HARD_LIMIT, order: { maxAnomalyScore: 'desc', }, diff --git a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/swimlane_input_resolver.ts b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/swimlane_input_resolver.ts index a23d02fffeb327..9ed6f88150f68d 100644 --- a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/swimlane_input_resolver.ts +++ b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/swimlane_input_resolver.ts @@ -28,6 +28,7 @@ import { import { MlStartDependencies } from '../../plugin'; import { ANOMALY_SWIM_LANE_HARD_LIMIT, + SWIM_LANE_DEFAULT_PAGE_SIZE, SWIMLANE_TYPE, SwimlaneType, } from '../../application/explorer/explorer_constants'; @@ -53,8 +54,6 @@ function getJobsObservable( ); } -export const EMBEDDABLE_DEFAULT_PER_PAGE = 10; - export function useSwimlaneInputResolver( embeddableInput: Observable, onInputChange: (output: Partial) => void, @@ -102,7 +101,7 @@ export function useSwimlaneInputResolver( startWith(undefined), // no need to emit when the initial value has been set distinctUntilChanged( - (prev, curr) => prev === undefined && curr === EMBEDDABLE_DEFAULT_PER_PAGE + (prev, curr) => prev === undefined && curr === SWIM_LANE_DEFAULT_PAGE_SIZE ) ), refresh.pipe(startWith(null)), @@ -154,7 +153,7 @@ export function useSwimlaneInputResolver( if (overallSwimlaneData && swimlaneTypeInput === SWIMLANE_TYPE.VIEW_BY) { if (perPageFromState === undefined) { // set initial pagination from the input or default one - setPerPage(perPageInput ?? EMBEDDABLE_DEFAULT_PER_PAGE); + setPerPage(perPageInput ?? SWIM_LANE_DEFAULT_PAGE_SIZE); } if (viewMode === ViewMode.EDIT && perPageFromState !== perPageInput) { @@ -171,7 +170,7 @@ export function useSwimlaneInputResolver( isViewBySwimLaneData(swimlaneData) ? swimlaneData.cardinality : ANOMALY_SWIM_LANE_HARD_LIMIT, - perPageFromState ?? perPageInput ?? EMBEDDABLE_DEFAULT_PER_PAGE, + perPageFromState ?? perPageInput ?? SWIM_LANE_DEFAULT_PAGE_SIZE, fromPageInput, swimlaneContainerWidth, appliedFilters @@ -224,7 +223,7 @@ export function useSwimlaneInputResolver( return [ swimlaneType, swimlaneData, - perPage ?? EMBEDDABLE_DEFAULT_PER_PAGE, + perPage ?? SWIM_LANE_DEFAULT_PAGE_SIZE, setPerPage, timeBuckets, isLoading,