Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion app/lib/components/benchmark_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import 'package:http/http.dart' as http;
selector: 'benchmark-grid',
template: r'''
<div *ngIf="isLoading" style="position: fixed; top: 0; left: 0; z-index: 1000; background-color: #AAFFAA;">Loading...</div>
<div style="margin: 5px;">
<button id="toggleArchived" (click)="toggleArchived()">{{isShowArchived ? "Hide" : "Show"}} Archived</button>
</div>
<div *ngIf="benchmarks != null" class="card-container">
<benchmark-card
*ngFor="let benchmark of benchmarks"
Expand All @@ -31,6 +34,14 @@ class BenchmarkGrid implements OnInit, OnDestroy {
bool isLoading = true;
List<BenchmarkData> benchmarks;
Timer _reloadTimer;
bool _isShowArchived = false;

bool get isShowArchived => _isShowArchived;

void toggleArchived() {
_isShowArchived = !_isShowArchived;
reloadData();
}

@override
void ngOnInit() {
Expand All @@ -47,7 +58,9 @@ class BenchmarkGrid implements OnInit, OnDestroy {
isLoading = true;
Map<String, dynamic> statusJson = JSON.decode((await _httpClient.get('/api/get-benchmarks')).body);
GetBenchmarksResult result = GetBenchmarksResult.fromJson(statusJson);
benchmarks = result.benchmarks;
benchmarks = result.benchmarks
.where((BenchmarkData data) => !data.timeseries.timeseries.isArchived || _isShowArchived)
.toList();
isLoading = false;
}
}
Expand Down
2 changes: 2 additions & 0 deletions app/lib/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ class Timeseries extends Entity {
'Label': string(),
'Unit': string(),
'Goal': number(),
'Archived': boolean(),
}
);

Expand All @@ -267,6 +268,7 @@ class Timeseries extends Entity {
String get label => this['Label'];
String get unit => this['Unit'];
double get goal => this['Goal'];
bool get isArchived => this['Archived'];
}

class TimeseriesValue extends Entity {
Expand Down
17 changes: 13 additions & 4 deletions app/test/benchmark_grid_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void main() {
test('should show a grid', () async {
List<String> httpCalls = <String>[];

await bootstrap(BenchmarkGrid, [
var component = await bootstrap(BenchmarkGrid, [
provide(http.Client, useValue: new MockClient((http.Request request) async {
httpCalls.add(request.url.path);
return new http.Response(
Expand All @@ -45,23 +45,32 @@ void main() {
await new Future.delayed(Duration.ZERO);

expect(httpCalls, <String>['/api/get-benchmarks']);
expect(document.querySelectorAll('benchmark-card'),
hasLength(_testData['Benchmarks'].length));
expect(document.querySelectorAll('benchmark-card'), hasLength(5));

expect(component.instance.isShowArchived, isFalse);
document.body.querySelector('#toggleArchived').click();
expect(component.instance.isShowArchived, isTrue);

await new Future.delayed(Duration.ZERO);

expect(component.instance.benchmarks, hasLength(10));
expect(document.querySelectorAll('benchmark-card'), hasLength(10));
});
});
}

final math.Random _rnd = new math.Random(1234);

final _testData = {
'Benchmarks': new List.generate(5, (int i) => {
'Benchmarks': new List.generate(10, (int i) => {
'Timeseries': {
'Key': 'key$i',
'Timeseries': {
'ID': 'series$i',
'Label': 'Series $i',
'Unit': 'ms',
'Goal': i.toDouble(),
'Archived': i % 2 != 0, // make half of them archived
},
},
'Values': new List.generate(_rnd.nextInt(5), (int v) => {
Expand Down
3 changes: 3 additions & 0 deletions db/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ type Timeseries struct {
// The current goal we want to reach for this metric. As of today, all our metrics are smaller
// is better.
Goal float64
// Indicates that this series contains old data that's no longer interesting (e.g. it will be
// hidden from the UI).
Archived bool
}

// TimeseriesEntity contains storage data on a Timeseries.
Expand Down