diff --git a/kibana-reports/public/components/main/main.tsx b/kibana-reports/public/components/main/main.tsx index 63e43bd8..95f4316a 100644 --- a/kibana-reports/public/components/main/main.tsx +++ b/kibana-reports/public/components/main/main.tsx @@ -165,7 +165,7 @@ export function Main(props) { const pagination = { initialPageSize: 10, - pageSizeOptions: [8, 10, 13], + pageSizeOptions: [5, 10, 20], }; useEffect(() => { diff --git a/kibana-reports/public/components/report_definitions/report_trigger/report_trigger.tsx b/kibana-reports/public/components/report_definitions/report_trigger/report_trigger.tsx index 4cefe5fd..91faf228 100644 --- a/kibana-reports/public/components/report_definitions/report_trigger/report_trigger.tsx +++ b/kibana-reports/public/components/report_definitions/report_trigger/report_trigger.tsx @@ -562,7 +562,7 @@ export function ReportTrigger(props: ReportTriggerProps) { reportDefinitionRequest.trigger.trigger_params.enabled = true; } if (!('enabled' in reportDefinitionRequest.trigger.trigger_params)) { - reportDefinitionRequest.trigger.trigger_params.enabled = false; + reportDefinitionRequest.trigger.trigger_params.enabled = true; } } }); diff --git a/kibana-reports/server/backend/opendistro-es-reports-plugin.ts b/kibana-reports/server/backend/opendistro-es-reports-plugin.ts index 69c684e1..f238a40d 100644 --- a/kibana-reports/server/backend/opendistro-es-reports-plugin.ts +++ b/kibana-reports/server/backend/opendistro-es-reports-plugin.ts @@ -76,13 +76,14 @@ export default function (Client: any, config: any, components: any) { esReports.getReports = clientAction({ url: { fmt: `${ES_REPORTS_API.LIST_REPORT_INSTANCES}`, - //TODO: wrong format error thrown even required = false, need to figure it out the correct setting to make it truly optional - // req: { - // fromIndex: { - // type: 'string', - // required: false, - // }, - // }, + params: { + fromIndex: { + type: 'number', + }, + maxItems: { + type: 'number', + }, + }, }, method: 'GET', }); @@ -128,13 +129,14 @@ export default function (Client: any, config: any, components: any) { esReports.getReportDefinitions = clientAction({ url: { fmt: `${ES_REPORTS_API.LIST_REPORT_DEFINITIONS}`, - //TODO: wrong format error thrown even required = false, need to figure it out the correct setting to make it truly optional - // req: { - // fromIndex: { - // type: 'string', - // required: false, - // }, - // }, + params: { + fromIndex: { + type: 'number', + }, + maxItems: { + type: 'number', + }, + }, }, method: 'GET', }); diff --git a/kibana-reports/server/routes/report.ts b/kibana-reports/server/routes/report.ts index 178d4eb4..39544e30 100644 --- a/kibana-reports/server/routes/report.ts +++ b/kibana-reports/server/routes/report.ts @@ -25,7 +25,7 @@ import { API_PREFIX } from '../../common'; import { createReport } from './lib/createReport'; import { reportSchema } from '../model'; import { errorResponse } from './utils/helpers'; -import { DELIVERY_TYPE } from './utils/constants'; +import { DEFAULT_MAX_SIZE, DELIVERY_TYPE } from './utils/constants'; import { backendToUiReport, backendToUiReportsList, @@ -206,10 +206,8 @@ export default function (router: IRouter) { path: `${API_PREFIX}/reports`, validate: { query: schema.object({ - size: schema.maybe(schema.string()), - sortField: schema.maybe(schema.string()), - sortDirection: schema.maybe(schema.string()), - fromIndex: schema.maybe(schema.string()), + fromIndex: schema.maybe(schema.number()), + maxItems: schema.maybe(schema.number()), }), }, }, @@ -218,11 +216,9 @@ export default function (router: IRouter) { request, response ): Promise> => { - const { fromIndex } = request.query as { - size: string; - sortField: string; - sortDirection: string; - fromIndex: string; + const { fromIndex, maxItems } = request.query as { + fromIndex: number; + maxItems: number; }; try { @@ -230,11 +226,11 @@ export default function (router: IRouter) { const esReportsClient: ILegacyScopedClusterClient = context.reporting_plugin.esReportsClient.asScoped( request ); - const esResp = await esReportsClient.callAsCurrentUser( 'es_reports.getReports', { fromIndex: fromIndex, + maxItems: maxItems || DEFAULT_MAX_SIZE, } ); diff --git a/kibana-reports/server/routes/reportDefinition.ts b/kibana-reports/server/routes/reportDefinition.ts index a78e1038..285f08bf 100644 --- a/kibana-reports/server/routes/reportDefinition.ts +++ b/kibana-reports/server/routes/reportDefinition.ts @@ -29,6 +29,7 @@ import { backendToUiReportDefinitionsList, } from './utils/converters/backendToUi'; import { updateReportDefinition } from './lib/updateReportDefinition'; +import { DEFAULT_MAX_SIZE } from './utils/constants'; export default function (router: IRouter) { // Create report Definition @@ -137,10 +138,8 @@ export default function (router: IRouter) { path: `${API_PREFIX}/reportDefinitions`, validate: { query: schema.object({ - size: schema.maybe(schema.string()), - sortField: schema.maybe(schema.string()), - sortDirection: schema.maybe(schema.string()), - fromIndex: schema.maybe(schema.string()), + fromIndex: schema.maybe(schema.number()), + maxItems: schema.maybe(schema.number()), }), }, }, @@ -149,11 +148,9 @@ export default function (router: IRouter) { request, response ): Promise> => { - const { fromIndex } = request.query as { - size: string; - sortField: string; - sortDirection: string; - fromIndex: string; + const { fromIndex, maxItems } = request.query as { + fromIndex: number; + maxItems: number; }; try { @@ -166,6 +163,7 @@ export default function (router: IRouter) { 'es_reports.getReportDefinitions', { fromIndex: fromIndex, + maxItems: maxItems || DEFAULT_MAX_SIZE, } );