Skip to content

Commit

Permalink
gh-459 Fix: Analytics - Adding a second counter resets name in first …
Browse files Browse the repository at this point in the history
…graph

* Make the counter collection part of each `DashboardItem`
  • Loading branch information
ghillert committed Sep 15, 2017
1 parent bf75796 commit 42f95b8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ui/src/app/analytics/dashboard/dashboard.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<select #counterName="ngModel" name="counterName_{{item.id}}" [(ngModel)]="item.counter"
[compareWith]="compareCounter" required (ngModelChange)="onCounterNameChange(item)">
<option [ngValue]="undefined" disabled="disabled">Please select a counter...</option>
<option *ngFor="let counter of counters"
<option *ngFor="let counter of item.counters"
[ngValue]="counter">{{counter.name}}</option>
</select>
<span class="help-block" *ngIf="counterName.invalid && counterName.touched">Please select a counter.</span>
Expand Down
6 changes: 3 additions & 3 deletions ui/src/app/analytics/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { Counter } from './../model/counter.model';
export class DashboardComponent implements OnInit {

busy: Subscription;
public counters: Counter[] = [];

public get dashboardItems() {
return this.analyticsService.dashboardItems;
Expand Down Expand Up @@ -78,10 +77,11 @@ export class DashboardComponent implements OnInit {
* Retrieves metrics for specific type.
* @param {MetricType} metricType to retrieve.
*/
onMetricTypeChange(metricType: MetricType) {
onMetricTypeChange(metricType: MetricType, dashBoardItem: DashboardItem) {
console.log('Selected Metric Type:', metricType);
dashBoardItem.counters = [];
this.analyticsService.getStreamsForMetricType(metricType).subscribe(result => {
this.counters = result.items;
dashBoardItem.counters = result.items;
});
}

Expand Down
3 changes: 3 additions & 0 deletions ui/src/app/analytics/model/dashboard-item.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Serializable } from '../../shared/model';
import { MetricType } from './metric-type.model';
import { Counter } from './counter.model';
import { Page } from '../../shared/model';
import { Subscription } from 'rxjs/Subscription';

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

public counters: Counter[] = [];

constructor(
) { }

Expand Down

0 comments on commit 42f95b8

Please sign in to comment.