-
diff --git a/web-app/src/app/routes/dashboard/dashboard.component.html b/web-app/src/app/routes/dashboard/dashboard.component.html
index 6c0231a..876a91b 100644
--- a/web-app/src/app/routes/dashboard/dashboard.component.html
+++ b/web-app/src/app/routes/dashboard/dashboard.component.html
@@ -1,13 +1,10 @@
-
-
+
diff --git a/web-app/src/app/routes/dashboard/dashboard.component.ts b/web-app/src/app/routes/dashboard/dashboard.component.ts
index b94cbae..1e836cd 100644
--- a/web-app/src/app/routes/dashboard/dashboard.component.ts
+++ b/web-app/src/app/routes/dashboard/dashboard.component.ts
@@ -4,6 +4,7 @@ import { I18NService } from '@core';
import { ALAIN_I18N_TOKEN } from '@delon/theme';
import { EChartsOption } from 'echarts';
import { NzMessageService } from 'ng-zorro-antd/message';
+import { fromEvent } from 'rxjs';
import { MonitorService } from '../../service/monitor.service';
@@ -26,24 +27,112 @@ export class DashboardComponent implements OnInit, OnDestroy {
appsCountLoading: boolean = true;
appsCountTableData: any[] = [];
appsCountEChartOption!: EChartsOption;
+ appsCountTheme!: EChartsOption;
+ echartsInstance!: any;
+ pageResize$!: any;
ngOnInit(): void {
this.appsCountLoading = true;
+ this.appsCountTheme = {
+ title: {
+ text: '监控总览',
+ subtext: '监控类型纳管数量分布',
+ left: 'center'
+ },
+ tooltip: {
+ trigger: 'item',
+ formatter: '{a}
{b} : {c}个监控 占比({d}%)'
+ },
+ legend: {
+ show: false,
+ itemWidth: 80,
+ itemHeight: 20,
+ right: 0,
+ orient: 'vertical'
+ },
+ calculable: true,
+ series: [
+ {
+ name: '总量',
+ type: 'pie',
+ selectedMode: 'single',
+ color: '#722ED1',
+ radius: [0, '30%'],
+ label: {
+ position: 'center',
+ fontSize: 15,
+ color: '#ffffff',
+ fontStyle: 'oblique',
+ formatter: '{a}:{c}'
+ },
+ labelLine: {
+ show: false
+ },
+ data: [{ value: 0, name: '监控总量' }]
+ },
+ {
+ name: '纳管数量分布',
+ type: 'pie',
+ radius: ['45%', '65%'],
+ labelLine: {
+ length: 30
+ },
+ label: {
+ formatter: '{a|{a}}{abg|}\n{hr|}\n {b|{b}:}{c} {per|{d}%} ',
+ backgroundColor: '#F6F8FC',
+ borderColor: '#8C8D8E',
+ borderWidth: 1,
+ borderRadius: 4,
+ rich: {
+ a: {
+ color: '#6E7079',
+ lineHeight: 22,
+ align: 'center'
+ },
+ hr: {
+ borderColor: '#8C8D8E',
+ width: '100%',
+ borderWidth: 1,
+ height: 0
+ },
+ b: {
+ color: '#4C5058',
+ fontSize: 14,
+ fontWeight: 'bold',
+ lineHeight: 33
+ },
+ per: {
+ color: '#fff',
+ backgroundColor: '#4C5058',
+ padding: [3, 4],
+ borderRadius: 4
+ }
+ }
+ }
+ }
+ ]
+ };
this.refresh();
this.appsCountLoading = false;
// https://stackoverflow.com/questions/43908009/why-is-setinterval-in-an-angular-service-only-firing-one-time
this.interval$ = setInterval(this.refresh.bind(this), 30000);
+ this.pageResize$ = fromEvent(window, 'resize').subscribe(event => {
+ this.resizeChart();
+ });
}
ngOnDestroy(): void {
clearInterval(this.interval$);
+ if (this.pageResize$) {
+ this.pageResize$.unsubscribe();
+ }
}
refresh(): void {
let dashboard$ = this.monitorSvc.getAppsMonitorSummary().subscribe(
message => {
dashboard$.unsubscribe();
- if (message.code === 0) {
+ if (message.code === 0 && message.data.apps != undefined) {
// {app:'linux',size: 12}
let apps: any[] = message.data.apps;
this.appsCountTableData = [];
@@ -57,88 +146,16 @@ export class DashboardComponent implements OnInit, OnDestroy {
name: appName,
value: app.size
});
- total = total + app.size ? app.size : 0;
+ total = total + (app.size ? app.size : 0);
});
-
- this.appsCountEChartOption = {
- title: {
- text: '监控总览',
- subtext: '监控类型纳管数量分布',
- left: 'center'
- },
- tooltip: {
- trigger: 'item',
- formatter: '{a}
{b} : {c}个监控 占比({d}%)'
- },
- legend: {
- itemWidth: 80,
- itemHeight: 20,
- right: 0,
- orient: 'vertical'
- },
- calculable: true,
- series: [
- {
- name: '总量',
- type: 'pie',
- selectedMode: 'single',
- color: '#722ED1',
- radius: [0, '30%'],
- label: {
- position: 'center',
- fontSize: 15,
- color: '#ffffff',
- fontStyle: 'oblique',
- formatter: '{a}:{c}'
- },
- labelLine: {
- show: false
- },
- data: [{ value: total, name: '监控总量' }]
- },
- {
- name: '纳管数量分布',
- type: 'pie',
- radius: ['45%', '65%'],
- labelLine: {
- length: 30
- },
- label: {
- formatter: '{a|{a}}{abg|}\n{hr|}\n {b|{b}:}{c} {per|{d}%} ',
- backgroundColor: '#F6F8FC',
- borderColor: '#8C8D8E',
- borderWidth: 1,
- borderRadius: 4,
- rich: {
- a: {
- color: '#6E7079',
- lineHeight: 22,
- align: 'center'
- },
- hr: {
- borderColor: '#8C8D8E',
- width: '100%',
- borderWidth: 1,
- height: 0
- },
- b: {
- color: '#4C5058',
- fontSize: 14,
- fontWeight: 'bold',
- lineHeight: 33
- },
- per: {
- color: '#fff',
- backgroundColor: '#4C5058',
- padding: [3, 4],
- borderRadius: 4
- }
- }
- },
- data: this.appsCountTableData
- }
- ]
- };
+ // @ts-ignore
+ this.appsCountTheme.series[0].data = [{ value: total, name: '监控总量' }];
+ // @ts-ignore
+ this.appsCountTheme.series[1].data = this.appsCountTableData;
+ this.appsCountEChartOption = this.appsCountTheme;
+ this.cdr.detectChanges();
+ } else {
+ this.appsCountEChartOption = this.appsCountTheme;
this.cdr.detectChanges();
}
},
@@ -157,4 +174,13 @@ export class DashboardComponent implements OnInit, OnDestroy {
}
}
}
+
+ onChartInit(ec: any) {
+ this.echartsInstance = ec;
+ }
+ resizeChart() {
+ if (this.echartsInstance) {
+ this.echartsInstance.resize();
+ }
+ }
}
diff --git a/web-app/src/app/routes/monitor/monitor-list/monitor-list.component.html b/web-app/src/app/routes/monitor/monitor-list/monitor-list.component.html
index 07d769d..8490e63 100644
--- a/web-app/src/app/routes/monitor/monitor-list/monitor-list.component.html
+++ b/web-app/src/app/routes/monitor/monitor-list/monitor-list.component.html
@@ -55,19 +55,19 @@
>
- |
- 监控名称 |
+ |
+ 监控名称 |
监控状态 |
监控Host |
监控类型 |
最新修改时间 |
- 操作 |
+ 操作 |
|
-
+ |
{{ data.name }}
@@ -102,7 +102,7 @@
|
{{ data.gmtUpdate ? data.gmtUpdate : data.gmtCreate }} |
-
+ |
diff --git a/web-app/src/environments/environment.ts b/web-app/src/environments/environment.ts
index 27ba195..7ba92bb 100644
--- a/web-app/src/environments/environment.ts
+++ b/web-app/src/environments/environment.ts
@@ -11,7 +11,7 @@ export const environment = {
production: false,
useHash: false,
api: {
- baseUrl: 'http://localhost:8080/',
+ baseUrl: 'http://localhost:1157/',
refreshTokenEnabled: true
},
modules: [DelonMockModule.forRoot({ data: MOCK_DATA })]
|