Skip to content

Commit

Permalink
[FLINK-14270][web] Support to display more metrics at once (apache#10689
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Yadong Xie authored Feb 7, 2020
1 parent f08ac8b commit 8a95253
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { combineLatest, Subject } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { JobService } from 'services';
import { trigger, animate, style, transition } from '@angular/animations';
import { JobChartService } from 'share/customize/job-chart/job-chart.service';

@Component({
selector: 'flink-job-overview-drawer',
Expand Down Expand Up @@ -62,16 +63,23 @@ export class JobOverviewDrawerComponent implements OnInit, OnDestroy {
closeDrawer() {
if (this.fullScreen) {
this.fullScreen = false;
this.jobChartService.resize();
} else {
this.router.navigate(['../../'], { relativeTo: this.activatedRoute }).then();
}
}

fullDrawer() {
this.fullScreen = true;
this.jobChartService.resize();
}

constructor(private activatedRoute: ActivatedRoute, private router: Router, private jobService: JobService) {}
constructor(
private activatedRoute: ActivatedRoute,
private router: Router,
private jobService: JobService,
private jobChartService: JobChartService
) {}

ngOnInit() {
const nodeId$ = this.activatedRoute.params.pipe(map(item => item.vertexId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class ResizeComponent implements OnInit, OnDestroy {
return innerOffsetTop;
};
const offsetTop = getOffsetTop(this.baseElement.nativeElement);
const maxResize = 560;
const maxResize = 900;
let newTop = e.pageY - offsetTop;
if (newTop > maxResize) {
newTop = maxResize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<div class="chart">
<div class="title">
<div class="text">{{title}}</div>
<div class="text" [attr.title]="title">{{title}}</div>
<div class="operate">
<nz-button-group [nzSize]="'small'">
<button nz-button [nzType]="size === 'big' ? 'primary' : 'default'" (click)="resize('big')">Big</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
padding: 12px;
margin-bottom: 12px;
float: left;
width: 50%;
width: 33.33%;

&.big {
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ import {
} from '@angular/core';
import { Chart } from '@antv/g2';
import * as G2 from '@antv/g2';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { JobChartService } from 'share/customize/job-chart/job-chart.service';

@Component({
selector: 'flink-job-chart',
Expand All @@ -49,6 +52,7 @@ export class JobChartComponent implements AfterViewInit, OnDestroy {
chartInstance: Chart;
data: Array<{ time: number; value: number; type: string }> = [];
latestValue: number;
destroy$ = new Subject();

@HostBinding('class.big')
get isBig() {
Expand Down Expand Up @@ -89,7 +93,7 @@ export class JobChartComponent implements AfterViewInit, OnDestroy {
this.closed.emit(this.title);
}

constructor(private cdr: ChangeDetectorRef) {}
constructor(private cdr: ChangeDetectorRef, private jobChartService: JobChartService) {}

ngAfterViewInit() {
this.cdr.detach();
Expand Down Expand Up @@ -124,9 +128,18 @@ export class JobChartComponent implements AfterViewInit, OnDestroy {
}
});
this.chartInstance.render();
this.jobChartService.resize$.pipe(takeUntil(this.destroy$)).subscribe(() => {
if (this.chartInstance) {
setTimeout(() => {
this.chartInstance.forceFit();
});
}
});
}

ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
if (this.chartInstance) {
this.chartInstance.destroy();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';

@Injectable({ providedIn: 'root' })
export class JobChartService {
resize$ = new Subject();
resize() {
this.resize$.next();
}
}

0 comments on commit 8a95253

Please sign in to comment.