Skip to content

Commit 5a83061

Browse files
authored
[FLINK-39486][runtime-web] Adapt the size of the job-overview-list section based on screen size (#27978)
1 parent 9373256 commit 5a83061

3 files changed

Lines changed: 82 additions & 7 deletions

File tree

flink-runtime-web/web-dashboard/src/app/pages/job/overview/list/job-overview-list.component.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
class="no-border small"
2222
[nzSize]="'small'"
2323
[nzData]="nodes"
24-
[nzScroll]="{ x: 1360 + left + 'px' }"
24+
[nzScroll]="{ x: tableScrollX + 'px' }"
2525
[nzFrontPagination]="false"
2626
[nzShowPagination]="false"
2727
>
@@ -36,7 +36,7 @@
3636
<th [nzSortFn]="sortParallelismFn" nzWidth="100px">Parallelism</th>
3737
<th [nzSortFn]="sortStartTimeFn" nzWidth="150px">Start Time</th>
3838
<th [nzSortFn]="sortDurationFn" nzWidth="150px">Duration</th>
39-
<th [nzSortFn]="sortEndTimeFn" nzWidth="150px">End Time</th>
39+
<th [nzSortFn]="sortEndTimeFn">End Time</th>
4040
<th nzWidth="60px" nzRight>Tasks</th>
4141
<th *ngIf="webRescaleEnabled" nzWidth="80px" nzRight>Scale</th>
4242
</tr>
@@ -136,7 +136,11 @@
136136
</tr>
137137
</tbody>
138138
</nz-table>
139-
<flink-resize [(left)]="left" [baseElement]="elementRef" [resizeMin]="390"></flink-resize>
139+
<flink-resize
140+
[(left)]="left"
141+
[baseElement]="elementRef"
142+
[resizeMin]="dynamicResizeMin"
143+
></flink-resize>
140144
<ng-template #loadingTemplate>
141145
<span class="text-secondary">loading...</span>
142146
</ng-template>

flink-runtime-web/web-dashboard/src/app/pages/job/overview/list/job-overview-list.component.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
color: @text-color-secondary;
2727
font-size: @font-size-sm;
2828
}
29+
30+
::ng-deep .ant-table-wrapper {
31+
width: 100%;
32+
}
2933
}
3034

3135
.name {

flink-runtime-web/web-dashboard/src/app/pages/job/overview/list/job-overview-list.component.ts

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,20 @@
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

2234
import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
2335
import { 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

Comments
 (0)