@@ -177,14 +177,35 @@ function totalDurationColor(totalGCTime, totalDuration) {
177177 return ( totalGCTime > GCTimePercent * totalDuration ) ? "white" : "black" ;
178178}
179179
180+ var sumOptionalColumns = [ 3 , 4 ] ;
181+ var execOptionalColumns = [ 5 , 6 ] ;
182+ var execDataTable ;
183+ var sumDataTable ;
184+
185+ function reselectCheckboxesBasedOnTaskTableState ( ) {
186+ var allChecked = true ;
187+ if ( typeof execDataTable !== "undefined" ) {
188+ for ( var k = 0 ; k < execOptionalColumns . length ; k ++ ) {
189+ if ( execDataTable . column ( execOptionalColumns [ k ] ) . visible ( ) ) {
190+ $ ( "[data-exec-col-idx=" + execOptionalColumns [ k ] + "]" ) . prop ( "checked" , true ) ;
191+ } else {
192+ allChecked = false ;
193+ }
194+ }
195+ }
196+ if ( allChecked ) {
197+ $ ( "#select-all-box" ) . prop ( "checked" , true ) ;
198+ }
199+ }
200+
180201$ ( document ) . ready ( function ( ) {
181202 $ . extend ( $ . fn . dataTable . defaults , {
182203 stateSave : true ,
183204 lengthMenu : [ [ 20 , 40 , 60 , 100 , - 1 ] , [ 20 , 40 , 60 , 100 , "All" ] ] ,
184205 pageLength : 20
185206 } ) ;
186207
187- executorsSummary = $ ( "#active-executors" ) ;
208+ var executorsSummary = $ ( "#active-executors" ) ;
188209
189210 getStandAloneppId ( function ( appId ) {
190211
@@ -444,9 +465,6 @@ $(document).ready(function () {
444465 else
445466 return ( formatBytes ( row . memoryMetrics . usedOnHeapStorageMemory , type ) + ' / ' +
446467 formatBytes ( row . memoryMetrics . totalOnHeapStorageMemory , type ) ) ;
447- } ,
448- "fnCreatedCell" : function ( nTd , sData , oData , iRow , iCol ) {
449- $ ( nTd ) . addClass ( 'on_heap_memory' )
450468 }
451469 } ,
452470 {
@@ -456,9 +474,6 @@ $(document).ready(function () {
456474 else
457475 return ( formatBytes ( row . memoryMetrics . usedOffHeapStorageMemory , type ) + ' / ' +
458476 formatBytes ( row . memoryMetrics . totalOffHeapStorageMemory , type ) ) ;
459- } ,
460- "fnCreatedCell" : function ( nTd , sData , oData , iRow , iCol ) {
461- $ ( nTd ) . addClass ( 'off_heap_memory' )
462477 }
463478 } ,
464479 { data : 'diskUsed' , render : formatBytes } ,
@@ -505,12 +520,16 @@ $(document).ready(function () {
505520 }
506521 }
507522 ] ,
508- "order" : [ [ 0 , "asc" ] ]
523+ "order" : [ [ 0 , "asc" ] ] ,
524+ "columnDefs" : [
525+ { "visible" : false , "targets" : 5 } ,
526+ { "visible" : false , "targets" : 6 }
527+ ]
509528 } ;
510-
511- var dt = $ ( selector ) . DataTable ( conf ) ;
512- dt . column ( 'executorLogsCol:name' ) . visible ( logsExist ( response ) ) ;
513- dt . column ( 'threadDumpCol:name' ) . visible ( getThreadDumpEnabled ( ) ) ;
529+
530+ execDataTable = $ ( selector ) . DataTable ( conf ) ;
531+ execDataTable . column ( 'executorLogsCol:name' ) . visible ( logsExist ( response ) ) ;
532+ execDataTable . column ( 'threadDumpCol:name' ) . visible ( getThreadDumpEnabled ( ) ) ;
514533 $ ( '#active-executors [data-toggle="tooltip"]' ) . tooltip ( ) ;
515534
516535 var sumSelector = "#summary-execs-table" ;
@@ -540,9 +559,6 @@ $(document).ready(function () {
540559 else
541560 return ( formatBytes ( row . allOnHeapMemoryUsed , type ) + ' / ' +
542561 formatBytes ( row . allOnHeapMaxMemory , type ) ) ;
543- } ,
544- "fnCreatedCell" : function ( nTd , sData , oData , iRow , iCol ) {
545- $ ( nTd ) . addClass ( 'on_heap_memory' )
546562 }
547563 } ,
548564 {
@@ -552,9 +568,6 @@ $(document).ready(function () {
552568 else
553569 return ( formatBytes ( row . allOffHeapMemoryUsed , type ) + ' / ' +
554570 formatBytes ( row . allOffHeapMaxMemory , type ) ) ;
555- } ,
556- "fnCreatedCell" : function ( nTd , sData , oData , iRow , iCol ) {
557- $ ( nTd ) . addClass ( 'off_heap_memory' )
558571 }
559572 } ,
560573 { data : 'allDiskUsed' , render : formatBytes } ,
@@ -597,13 +610,69 @@ $(document).ready(function () {
597610 ] ,
598611 "paging" : false ,
599612 "searching" : false ,
600- "info" : false
613+ "info" : false ,
614+ "columnDefs" : [
615+ { "visible" : false , "targets" : 3 } ,
616+ { "visible" : false , "targets" : 4 }
617+ ]
601618
602619 } ;
603620
604- $ ( sumSelector ) . DataTable ( sumConf ) ;
621+ sumDataTable = $ ( sumSelector ) . DataTable ( sumConf ) ;
605622 $ ( '#execSummary [data-toggle="tooltip"]' ) . tooltip ( ) ;
606-
623+
624+ $ ( "#showAdditionalMetrics" ) . append (
625+ "<div><a id='additionalMetrics'>" +
626+ "<span class='expand-input-rate-arrow arrow-closed' id='arrowtoggle-optional-metrics'></span>" +
627+ "Show Additional Metrics" +
628+ "</a></div>" +
629+ "<div class='container-fluid container-fluid-div' id='toggle-metrics' hidden>" +
630+ "<div><input type='checkbox' class='toggle-vis' id='select-all-box'>Select All</div>" +
631+ "<div id='on_heap_memory' class='on-heap-memory-checkbox-div'><input type='checkbox' class='toggle-vis' data-sum-col-idx='3' data-exec-col-idx='5'>On Heap Memory</div>" +
632+ "<div id='off_heap_memory' class='off-heap-memory-checkbox-div'><input type='checkbox' class='toggle-vis' data-sum-col-idx='4' data-exec-col-idx='6'>Off Heap Memory</div>" +
633+ "</div>" ) ;
634+
635+ reselectCheckboxesBasedOnTaskTableState ( ) ;
636+
637+ $ ( "#additionalMetrics" ) . click ( function ( ) {
638+ $ ( "#arrowtoggle-optional-metrics" ) . toggleClass ( "arrow-open arrow-closed" ) ;
639+ $ ( "#toggle-metrics" ) . toggle ( ) ;
640+ if ( window . localStorage ) {
641+ window . localStorage . setItem ( "arrowtoggle-optional-metrics-class" , $ ( "#arrowtoggle-optional-metrics" ) . attr ( 'class' ) ) ;
642+ }
643+ } ) ;
644+
645+ $ ( ".toggle-vis" ) . on ( "click" , function ( ) {
646+ var thisBox = $ ( this ) ;
647+ if ( thisBox . is ( "#select-all-box" ) ) {
648+ var sumColumn = sumDataTable . columns ( sumOptionalColumns ) ;
649+ var execColumn = execDataTable . columns ( execOptionalColumns ) ;
650+ if ( thisBox . is ( ":checked" ) ) {
651+ $ ( ".toggle-vis" ) . prop ( "checked" , true ) ;
652+ sumColumn . visible ( true ) ;
653+ execColumn . visible ( true ) ;
654+ } else {
655+ $ ( ".toggle-vis" ) . prop ( "checked" , false ) ;
656+ sumColumn . visible ( false ) ;
657+ execColumn . visible ( false ) ;
658+ }
659+ } else {
660+ var execColIdx = thisBox . attr ( "data-exec-col-idx" ) ;
661+ var execCol = execDataTable . column ( execColIdx ) ;
662+ execCol . visible ( ! execCol . visible ( ) ) ;
663+ var sumColIdx = thisBox . attr ( "data-sum-col-idx" ) ;
664+ var sumCol = sumDataTable . column ( sumColIdx ) ;
665+ sumCol . visible ( ! sumCol . visible ( ) ) ;
666+ }
667+ } ) ;
668+
669+ if ( window . localStorage ) {
670+ if ( window . localStorage . getItem ( "arrowtoggle-optional-metrics-class" ) != null &&
671+ window . localStorage . getItem ( "arrowtoggle-optional-metrics-class" ) . includes ( "arrow-open" ) ) {
672+ $ ( "#arrowtoggle-optional-metrics" ) . toggleClass ( "arrow-open arrow-closed" ) ;
673+ $ ( "#toggle-metrics" ) . toggle ( ) ;
674+ }
675+ }
607676 } ) ;
608677 } ) ;
609678 } ) ;
0 commit comments