1
1
'use strict' ;
2
2
3
3
import oboe from 'oboe' ;
4
- import dataTableProcessing from 'datatables.net-plugins/api/processing()' ;
5
4
import { cssBadgeForState , capitalizeFirstLetter } from './utils.js'
6
5
7
6
window . fetch_table_data = fetch_table_data ;
8
7
window . create_datatable = create_datatable ;
9
8
window . set_cluster_id = set_cluster_id ;
10
9
window . set_filter_id = set_filter_id ;
11
10
12
- dataTableProcessing ( window , jQuery ) ;
13
-
14
11
var entityMap = {
15
12
'&' : '&' ,
16
13
'<' : '<' ,
@@ -336,3 +333,53 @@ function set_cluster_id(id) {
336
333
function reload_page ( ) {
337
334
window . location = '?' + get_request_params ( ) ;
338
335
}
336
+
337
+ const activeJobsConfig = $ ( '#active_jobs_config' ) [ 0 ] . dataset ;
338
+
339
+ var filter_id = activeJobsConfig . filterId ;
340
+ var cluster_id = activeJobsConfig . clusterId ;
341
+
342
+ if ( filter_id == "null" ) {
343
+ filter_id = localStorage . getItem ( 'jobfilter' ) || activeJobsConfig . defaultFilterId ;
344
+ }
345
+
346
+ if ( cluster_id == "null" ) {
347
+ cluster_id = localStorage . getItem ( 'jobcluster' ) || 'all' ;
348
+ }
349
+
350
+ var performance_tracking_enabled = false ;
351
+
352
+ function report_performance ( ) {
353
+ var marks = performance . getEntriesByType ( 'mark' ) ;
354
+ marks . forEach ( function ( entry ) {
355
+ console . log ( entry . startTime + "," + entry . name ) ;
356
+ } ) ;
357
+
358
+ // hack but only one mark for document ready, and rest are draw times
359
+ if ( marks . length > 1 ) {
360
+ console . log ( "version,documentReady,firstDraw,lastDraw" ) ;
361
+ console . log ( `${ activeJobsConfig . oodVersion } ,${ marks [ 0 ] . startTime } ,${ marks [ 1 ] . startTime } ,${ marks . slice ( - 1 ) [ 0 ] . startTime } ` ) ;
362
+ }
363
+ }
364
+
365
+ if ( activeJobsConfig . consoleLogPerformanceReport ) {
366
+ performance_tracking_enabled = true ;
367
+ performance . mark ( 'document ready - build table and make ajax request for jobs' ) ;
368
+ }
369
+
370
+ var table = create_datatable ( {
371
+ drawCallback : function ( settings ) {
372
+ // do a performance mark every time we draw the table (which happens when new records are downloaded)
373
+ if ( performance_tracking_enabled && settings . aoData . length > 0 ) {
374
+ performance . mark ( 'draw records - ' + settings . aoData . length ) ;
375
+ }
376
+ } , base_uri : activeJobsConfig . baseUri } ) ;
377
+
378
+ fetch_table_data ( table , {
379
+ doneCallback : function ( ) {
380
+ // generate report after done fetching records
381
+ if ( performance_tracking_enabled ) {
382
+ setTimeout ( report_performance , 2000 ) ;
383
+ }
384
+ } ,
385
+ base_uri : activeJobsConfig . baseUri } ) ;
0 commit comments