1616 * limitations under the License.
1717 */
1818
19- import { DecimalPipe , NgForOf , NgIf } from '@angular/common' ;
20- import { ChangeDetectionStrategy , Component , ElementRef , EventEmitter , Input , Output } from '@angular/core' ;
19+ import { DecimalPipe , NgForOf , NgIf , isPlatformBrowser } from '@angular/common' ;
20+ import {
21+ AfterViewInit ,
22+ ChangeDetectionStrategy ,
23+ ChangeDetectorRef ,
24+ Component ,
25+ ElementRef ,
26+ EventEmitter ,
27+ Inject ,
28+ Input ,
29+ OnDestroy ,
30+ Output ,
31+ PLATFORM_ID
32+ } from '@angular/core' ;
2133
2234import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe' ;
2335import { HumanizeDatePipe } from '@flink-runtime-web/components/humanize-date.pipe' ;
@@ -63,7 +75,9 @@ const rescaleTimeout = 2500;
6375 NzBadgeModule
6476 ]
6577} )
66- export class JobOverviewListComponent {
78+ export class JobOverviewListComponent implements AfterViewInit , OnDestroy {
79+ private static readonly END_TIME_MIN_WIDTH = 200 ; // Minimum space for End Time column
80+
6781 public readonly trackById = ( _ : number , node : NodesItemCorrect ) : string => node . id ;
6882 public readonly webRescaleEnabled = this . statusService . configuration . features [ 'web-rescale' ] ;
6983
@@ -79,6 +93,8 @@ export class JobOverviewListComponent {
7993
8094 public innerNodes : NodesItemCorrect [ ] = [ ] ;
8195 public left = 390 ;
96+ public dynamicResizeMin = 390 ;
97+ public tableScrollX = 0 ;
8298
8399 public desiredParallelism = new Map < string , number > ( ) ;
84100
@@ -104,7 +120,58 @@ export class JobOverviewListComponent {
104120 return this . innerNodes ;
105121 }
106122
107- constructor ( public readonly elementRef : ElementRef , private readonly statusService : StatusService ) { }
123+ constructor (
124+ public readonly elementRef : ElementRef ,
125+ private readonly statusService : StatusService ,
126+ @Inject ( PLATFORM_ID ) private platformId : object ,
127+ private readonly cdr : ChangeDetectorRef
128+ ) { }
129+
130+ public ngAfterViewInit ( ) : void {
131+ if ( isPlatformBrowser ( this . platformId ) ) {
132+ setTimeout ( ( ) => this . updateLeftBasedOnScreenSize ( ) , 0 ) ;
133+
134+ window . addEventListener ( 'resize' , this . handleWindowResize ) ;
135+ }
136+ }
137+
138+ public ngOnDestroy ( ) : void {
139+ if ( isPlatformBrowser ( this . platformId ) ) {
140+ window . removeEventListener ( 'resize' , this . handleWindowResize ) ;
141+ }
142+ }
143+
144+ private readonly handleWindowResize = ( ) : void => {
145+ this . updateLeftBasedOnScreenSize ( ) ;
146+ } ;
147+
148+ /**
149+ * Initialize table dimensions
150+ */
151+ private updateLeftBasedOnScreenSize ( ) : void {
152+ this . left = 390 ;
153+ this . dynamicResizeMin = 390 ;
154+
155+ const tableHeaders = this . elementRef . nativeElement . querySelectorAll ( 'thead th' ) ;
156+ let fixedColumnsWidth = 0 ;
157+ let foundRightColumn = false ;
158+
159+ tableHeaders . forEach ( ( th : HTMLElement , index : number ) => {
160+ if ( index > 0 && ! foundRightColumn ) {
161+ if ( th . hasAttribute ( 'nzright' ) ) {
162+ foundRightColumn = true ;
163+ } else {
164+ const width = th . getAttribute ( 'nzWidth' ) ;
165+ if ( width ) {
166+ fixedColumnsWidth += parseInt ( width , 10 ) ;
167+ }
168+ }
169+ }
170+ } ) ;
171+
172+ this . tableScrollX = this . left + fixedColumnsWidth + JobOverviewListComponent . END_TIME_MIN_WIDTH ;
173+ this . cdr . detectChanges ( ) ;
174+ }
108175
109176 public clickNode ( node : NodesItemCorrect ) : void {
110177 this . nodeClick . emit ( node ) ;
0 commit comments