Skip to content

Commit c5d1a67

Browse files
committed
feat(apm): update feature
1 parent ab55df3 commit c5d1a67

11 files changed

+102
-7
lines changed

src/app/apm/collection/collection.component.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,19 @@
5252
<mat-card-header>
5353
<mat-card-title>性能分析</mat-card-title>
5454
</mat-card-header>
55-
<mat-card-content>content</mat-card-content>
55+
<mat-card-content class="chart-container">
56+
<ngx-charts-bar-vertical
57+
*ngIf="dataChart?.length"
58+
[results]="dataChart"
59+
[gradient]="gradient"
60+
[xAxis]="showXAxis"
61+
[yAxis]="showYAxis"
62+
[legend]="showLegend"
63+
[showXAxisLabel]="showXAxisLabel"
64+
[showYAxisLabel]="showYAxisLabel"
65+
>
66+
</ngx-charts-bar-vertical>
67+
</mat-card-content>
5668
</mat-card>
5769

5870
<stbui-search

src/app/apm/collection/collection.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@
2020
table {
2121
width: 100%;
2222
}
23+
24+
.chart-container {
25+
min-height: 400px;
26+
}

src/app/apm/collection/collection.component.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@ export class CollectionComponent implements OnInit {
4343
count = 0;
4444
duration = '0';
4545

46+
// chart
47+
dataChart: any = [];
48+
49+
showXAxis = true;
50+
showYAxis = true;
51+
gradient = false;
52+
showLegend = false;
53+
showXAxisLabel = true;
54+
xAxisLabel = 'Country';
55+
showYAxisLabel = true;
56+
yAxisLabel = 'Population';
57+
58+
colorScheme = {
59+
domain: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA']
60+
};
61+
4662
constructor(private service: CollectionService, private datePipe: DatePipe) {}
4763

4864
ngOnInit() {
@@ -67,7 +83,16 @@ export class CollectionComponent implements OnInit {
6783
return observableOf([]);
6884
})
6985
)
70-
.subscribe(data => (this.dataSource = data));
86+
.subscribe(data => {
87+
this.dataSource = data;
88+
89+
data.map(d => {
90+
this.dataChart.push({
91+
name: this.datePipe.transform(d.create_time,'yyyy-MM-dd hh:mm:ss'),
92+
value: d.duration
93+
});
94+
});
95+
});
7196

7297
this.service.getCount().subscribe(res => {
7398
this.body_size = res.data.body_size;

src/app/apm/collection/collection.module.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { NgModule } from '@angular/core';
22
import { CommonModule, DatePipe } from '@angular/common';
33
import { HttpClientModule } from '@angular/common/http';
4+
import { NgxChartsModule } from '@swimlane/ngx-charts';
5+
46
import { SharedModule } from '../../shared/shared.module';
57
import { SearchModule } from '../../component/search';
68
import { WidgetModule } from '../../component/widget';
@@ -14,6 +16,7 @@ import { DetailComponent } from './detail/detail.component';
1416
CommonModule,
1517
SharedModule,
1618
HttpClientModule,
19+
NgxChartsModule,
1720
SearchModule,
1821
WidgetModule
1922
],

src/app/apm/layout/layout.component.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@
44
<stbui-navigation [navigationModel]="navigationModel"></stbui-navigation>
55
</mat-sidenav>
66

7-
<div class="sidenav-container">
8-
<div class="main-container"><router-outlet></router-outlet></div>
9-
</div>
7+
<mat-sidenav-content> <router-outlet></router-outlet> </mat-sidenav-content>
108
</mat-sidenav-container>

src/app/apm/layout/layout.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Subscription } from 'rxjs';
33
import { NavigationService } from './navigation.service';
44

55
@Component({
6-
selector: 'app-layout',
6+
selector: 'apm-layout',
77
templateUrl: './layout.component.html',
88
styleUrls: ['./layout.component.scss']
99
})

src/app/apm/layout/navigation.model.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ export class NavigationModel {
5757
title: '应用告警',
5858
type: 'item',
5959
icon: 'alarm',
60+
badge: {
61+
title: '10',
62+
bg: '#ff4081',
63+
fg: '#fff'
64+
},
6065
url: '/apm/alarm'
6166
},
6267
{
@@ -65,7 +70,7 @@ export class NavigationModel {
6570
type: 'item',
6671
icon: 'laptop',
6772
url: '/apm/manage'
68-
},
73+
}
6974
];
7075
}
7176
}

src/app/apm/performance/performance.component.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,50 @@
113113
<mat-card-header>
114114
<mat-card-title>浏览器分类统计</mat-card-title>
115115
</mat-card-header>
116+
<mat-card-content class="chart-container">
117+
<ngx-charts-pie-chart
118+
*ngIf="dataBrowserChart?.length"
119+
[results]="dataBrowserChart"
120+
[legend]="showLegend"
121+
[labels]="showLabels"
122+
[doughnut]="doughnut"
123+
>
124+
</ngx-charts-pie-chart>
125+
</mat-card-content>
116126
</mat-card>
117127
</div>
118128
<div fxFlex.gt-xs="33.33" fxFlex.lt-md="50" fxFlex.lt-sm="100">
119129
<mat-card>
120130
<mat-card-header>
121131
<mat-card-title>系统分类统计</mat-card-title>
122132
</mat-card-header>
133+
<mat-card-content class="chart-container">
134+
<ngx-charts-pie-chart
135+
*ngIf="dataBrowserChart?.length"
136+
[results]="dataBrowserChart"
137+
[legend]="showLegend"
138+
[labels]="showLabels"
139+
[doughnut]="doughnut"
140+
>
141+
</ngx-charts-pie-chart>
142+
</mat-card-content>
123143
</mat-card>
124144
</div>
125145
<div fxFlex.gt-xs="33.33" fxFlex.lt-md="50" fxFlex.lt-sm="100">
126146
<mat-card>
127147
<mat-card-header>
128148
<mat-card-title>地理位置分类统计</mat-card-title>
129149
</mat-card-header>
150+
<mat-card-content class="chart-container">
151+
<ngx-charts-pie-chart
152+
*ngIf="dataBrowserChart?.length"
153+
[results]="dataBrowserChart"
154+
[legend]="showLegend"
155+
[labels]="showLabels"
156+
[doughnut]="doughnut"
157+
>
158+
</ngx-charts-pie-chart>
159+
</mat-card-content>
130160
</mat-card>
131161
</div>
132162
</div>

src/app/apm/performance/performance.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@
1111
table {
1212
width: 100%;
1313
}
14+
15+
.chart-container {
16+
min-height: 400px;
17+
}

src/app/apm/performance/performance.component.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ export class PerformanceComponent implements OnInit {
5454
tcp_time = 0;
5555
white_time = 9.153846153846153;
5656

57+
// chart
58+
dataBrowserChart = [];
59+
// options
60+
showLegend = false;
61+
// pie
62+
showLabels = false;
63+
doughnut = false;
64+
5765
constructor(private service: PerformanceService, private router: Router) {}
5866

5967
ngOnInit() {
@@ -78,6 +86,9 @@ export class PerformanceComponent implements OnInit {
7886
})
7987
)
8088
.subscribe(data => (this.dataSource = data));
89+
90+
this.dataBrowserChart.push({ name: 'Chrome', value: 13 });
91+
this.dataBrowserChart.push({ name: 'IE', value: 1 });
8192
}
8293

8394
onRowClicked(row) {

0 commit comments

Comments
 (0)