Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 42f95b8

Browse files
committed
gh-459 Fix: Analytics - Adding a second counter resets name in first graph
* Make the counter collection part of each `DashboardItem`
1 parent bf75796 commit 42f95b8

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

ui/src/app/analytics/dashboard/dashboard.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<select #counterName="ngModel" name="counterName_{{item.id}}" [(ngModel)]="item.counter"
2828
[compareWith]="compareCounter" required (ngModelChange)="onCounterNameChange(item)">
2929
<option [ngValue]="undefined" disabled="disabled">Please select a counter...</option>
30-
<option *ngFor="let counter of counters"
30+
<option *ngFor="let counter of item.counters"
3131
[ngValue]="counter">{{counter.name}}</option>
3232
</select>
3333
<span class="help-block" *ngIf="counterName.invalid && counterName.touched">Please select a counter.</span>

ui/src/app/analytics/dashboard/dashboard.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { Counter } from './../model/counter.model';
1818
export class DashboardComponent implements OnInit {
1919

2020
busy: Subscription;
21-
public counters: Counter[] = [];
2221

2322
public get dashboardItems() {
2423
return this.analyticsService.dashboardItems;
@@ -78,10 +77,11 @@ export class DashboardComponent implements OnInit {
7877
* Retrieves metrics for specific type.
7978
* @param {MetricType} metricType to retrieve.
8079
*/
81-
onMetricTypeChange(metricType: MetricType) {
80+
onMetricTypeChange(metricType: MetricType, dashBoardItem: DashboardItem) {
8281
console.log('Selected Metric Type:', metricType);
82+
dashBoardItem.counters = [];
8383
this.analyticsService.getStreamsForMetricType(metricType).subscribe(result => {
84-
this.counters = result.items;
84+
dashBoardItem.counters = result.items;
8585
});
8686
}
8787

ui/src/app/analytics/model/dashboard-item.model.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Serializable } from '../../shared/model';
22
import { MetricType } from './metric-type.model';
33
import { Counter } from './counter.model';
4+
import { Page } from '../../shared/model';
45
import { Subscription } from 'rxjs/Subscription';
56

67
/**
@@ -20,6 +21,8 @@ export class DashboardItem implements Serializable<DashboardItem> {
2021
public chartHeight = 140;
2122
public barSize = 2;
2223

24+
public counters: Counter[] = [];
25+
2326
constructor(
2427
) { }
2528

0 commit comments

Comments
 (0)