@@ -16,6 +16,7 @@ import {
1616 DatafeedWithStats ,
1717 CombinedJobWithStats ,
1818} from '../../../common/types/anomaly_detection_jobs' ;
19+ import { GLOBAL_CALENDAR } from '../../../common/constants/calendars' ;
1920import { datafeedsProvider , MlDatafeedsResponse , MlDatafeedsStatsResponse } from './datafeeds' ;
2021import { jobAuditMessagesProvider } from '../job_audit_messages' ;
2122import { resultsServiceProvider } from '../results_service' ;
@@ -227,6 +228,8 @@ export function jobsProvider(callAsCurrentUser: APICaller) {
227228 const groups : { [ jobId : string ] : string [ ] } = { } ;
228229 const datafeeds : { [ id : string ] : DatafeedWithStats } = { } ;
229230 const calendarsByJobId : { [ jobId : string ] : string [ ] } = { } ;
231+ const globalCalendars : string [ ] = [ ] ;
232+
230233 const requests : [
231234 Promise < MlJobsResponse > ,
232235 Promise < MlJobsStatsResponse > ,
@@ -298,7 +301,9 @@ export function jobsProvider(callAsCurrentUser: APICaller) {
298301 if ( calendarResults ) {
299302 calendarResults . forEach ( cal => {
300303 cal . job_ids . forEach ( id => {
301- if ( groups [ id ] ) {
304+ if ( id === GLOBAL_CALENDAR ) {
305+ globalCalendars . push ( cal . calendar_id ) ;
306+ } else if ( groups [ id ] ) {
302307 groups [ id ] . forEach ( jId => {
303308 if ( calendarsByJobId [ jId ] !== undefined ) {
304309 calendarsByJobId [ jId ] . push ( cal . calendar_id ) ;
@@ -325,8 +330,12 @@ export function jobsProvider(callAsCurrentUser: APICaller) {
325330 jobResults . jobs . forEach ( job => {
326331 const tempJob = job as CombinedJobWithStats ;
327332
328- if ( calendarsByJobId [ tempJob . job_id ] . length ) {
329- tempJob . calendars = calendarsByJobId [ tempJob . job_id ] ;
333+ const calendars : string [ ] = [
334+ ...( calendarsByJobId [ tempJob . job_id ] || [ ] ) ,
335+ ...( globalCalendars || [ ] ) ,
336+ ] ;
337+ if ( calendars . length ) {
338+ tempJob . calendars = calendars ;
330339 }
331340
332341 if ( jobStatsResults && jobStatsResults . jobs ) {
0 commit comments