44 * you may not use this file except in compliance with the Elastic License.
55 */
66
7- import * as Rx from 'rxjs' ;
7+ import { i18n } from '@kbn/i18n' ;
8+ import { I18nProvider } from '@kbn/i18n/react' ;
89import React from 'react' ;
910import ReactDOM from 'react-dom' ;
11+ import * as Rx from 'rxjs' ;
1012import { catchError , filter , map , mergeMap , takeUntil } from 'rxjs/operators' ;
11- import { i18n } from '@kbn/i18n' ;
13+ import {
14+ CoreSetup ,
15+ CoreStart ,
16+ NotificationsSetup ,
17+ Plugin ,
18+ PluginInitializerContext ,
19+ } from 'src/core/public' ;
1220import { ManagementSetup } from 'src/plugins/management/public' ;
13- import { CoreSetup , CoreStart , Plugin , PluginInitializerContext } from 'src/core/public' ;
14- import { I18nProvider } from '@kbn/i18n/react' ;
1521import { UiActionsSetup } from 'src/plugins/ui_actions/public' ;
16-
17- import { ReportListing } from './components/report_listing' ;
18- import { getGeneralErrorToast } from './components' ;
19-
20- import { ReportingNotifierStreamHandler as StreamHandler } from './lib/stream_handler' ;
21- import { ReportingAPIClient } from './lib/reporting_api_client' ;
22- import { GetCsvReportPanelAction } from './panel_actions/get_csv_panel_action' ;
23- import { csvReportingProvider } from './share_context_menu/register_csv_reporting' ;
24- import { reportingPDFPNGProvider } from './share_context_menu/register_pdf_png_reporting' ;
25-
26- import { LicensingPluginSetup } from '../../licensing/public' ;
22+ import { JobId , JobStatusBuckets } from '../' ;
2723import { CONTEXT_MENU_TRIGGER } from '../../../../src/plugins/embeddable/public' ;
28- import { SharePluginSetup } from '../../../../src/plugins/share/public' ;
29-
3024import {
3125 FeatureCatalogueCategory ,
3226 HomePublicPluginSetup ,
3327} from '../../../../src/plugins/home/public' ;
28+ import { SharePluginSetup } from '../../../../src/plugins/share/public' ;
29+ import { LicensingPluginSetup } from '../../licensing/public' ;
30+ import { ConfigType } from '../common/types' ;
31+ import { JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY } from '../constants' ;
32+ import { getGeneralErrorToast } from './components' ;
33+ import { ReportListing } from './components/report_listing' ;
34+ import { ReportingAPIClient } from './lib/reporting_api_client' ;
35+ import { ReportingNotifierStreamHandler as StreamHandler } from './lib/stream_handler' ;
36+ import { GetCsvReportPanelAction } from './panel_actions/get_csv_panel_action' ;
37+ import { csvReportingProvider } from './share_context_menu/register_csv_reporting' ;
38+ import { reportingPDFPNGProvider } from './share_context_menu/register_pdf_png_reporting' ;
3439
35- import {
36- JOB_COMPLETION_NOTIFICATIONS_POLLER_CONFIG ,
37- JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY ,
38- } from '../constants' ;
39-
40- import { JobId , JobStatusBuckets , NotificationsService } from '..' ;
41-
42- const {
43- jobCompletionNotifier : { interval : JOBS_REFRESH_INTERVAL } ,
44- } = JOB_COMPLETION_NOTIFICATIONS_POLLER_CONFIG ;
40+ export interface ClientConfigType {
41+ poll : ConfigType [ 'poll' ] ;
42+ }
4543
4644function getStored ( ) : JobId [ ] {
4745 const sessionValue = sessionStorage . getItem ( JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY ) ;
4846 return sessionValue ? JSON . parse ( sessionValue ) : [ ] ;
4947}
5048
5149function handleError (
52- notifications : NotificationsService ,
50+ notifications : NotificationsSetup ,
5351 err : Error
5452) : Rx . Observable < JobStatusBuckets > {
5553 notifications . toasts . addDanger (
@@ -64,18 +62,19 @@ function handleError(
6462 return Rx . of ( { completed : [ ] , failed : [ ] } ) ;
6563}
6664
67- export class ReportingPublicPlugin implements Plugin < any , any > {
65+ export class ReportingPublicPlugin implements Plugin < void , void > {
66+ private config : ClientConfigType ;
6867 private readonly stop$ = new Rx . ReplaySubject ( 1 ) ;
69-
7068 private readonly title = i18n . translate ( 'xpack.reporting.management.reportingTitle' , {
7169 defaultMessage : 'Reporting' ,
7270 } ) ;
73-
7471 private readonly breadcrumbText = i18n . translate ( 'xpack.reporting.breadcrumb' , {
7572 defaultMessage : 'Reporting' ,
7673 } ) ;
7774
78- constructor ( initializerContext : PluginInitializerContext ) { }
75+ constructor ( initializerContext : PluginInitializerContext ) {
76+ this . config = initializerContext . config . get < ClientConfigType > ( ) ;
77+ }
7978
8079 public setup (
8180 core : CoreSetup ,
@@ -130,6 +129,7 @@ export class ReportingPublicPlugin implements Plugin<any, any> {
130129 < ReportListing
131130 toasts = { toasts }
132131 license$ = { license$ }
132+ pollConfig = { this . config . poll }
133133 redirect = { start . application . navigateToApp }
134134 apiClient = { apiClient }
135135 />
@@ -163,8 +163,9 @@ export class ReportingPublicPlugin implements Plugin<any, any> {
163163 const { http, notifications } = core ;
164164 const apiClient = new ReportingAPIClient ( http ) ;
165165 const streamHandler = new StreamHandler ( notifications , apiClient ) ;
166+ const { interval } = this . config . poll . jobsRefresh ;
166167
167- Rx . timer ( 0 , JOBS_REFRESH_INTERVAL )
168+ Rx . timer ( 0 , interval )
168169 . pipe (
169170 takeUntil ( this . stop$ ) , // stop the interval when stop method is called
170171 map ( ( ) => getStored ( ) ) , // read all pending job IDs from session storage
0 commit comments