2016-04-28 20:50:03 -04:00
|
|
|
import {StringMapWrapper} from '@angular/facade';
|
2015-05-27 17:57:54 -04:00
|
|
|
import {Validator} from './validator';
|
|
|
|
import {Metric} from './metric';
|
|
|
|
import {Options} from './common_options';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SampleDescription merges all available descriptions about a sample
|
|
|
|
*/
|
|
|
|
export class SampleDescription {
|
|
|
|
// TODO(tbosch): use static values when our transpiler supports them
|
2016-06-02 20:30:40 -04:00
|
|
|
static get PROVIDERS(): any[] { return _PROVIDERS; }
|
2015-10-02 19:47:54 -04:00
|
|
|
description: {[key: string]: any};
|
2015-05-27 17:57:54 -04:00
|
|
|
|
2016-04-12 12:40:37 -04:00
|
|
|
constructor(public id: string, descriptions: Array<{[key: string]: any}>,
|
|
|
|
public metrics: {[key: string]: any}) {
|
2015-05-27 17:57:54 -04:00
|
|
|
this.description = {};
|
2015-10-07 12:09:43 -04:00
|
|
|
descriptions.forEach(description => {
|
2015-05-27 17:57:54 -04:00
|
|
|
StringMapWrapper.forEach(description, (value, prop) => this.description[prop] = value);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
toJson() { return {'id': this.id, 'description': this.description, 'metrics': this.metrics}; }
|
|
|
|
}
|
|
|
|
|
2016-04-12 12:40:37 -04:00
|
|
|
var _PROVIDERS = [
|
2016-06-02 20:30:40 -04:00
|
|
|
{
|
|
|
|
provide: SampleDescription,
|
|
|
|
useFactory: (metric, id, forceGc, userAgent, validator, defaultDesc, userDesc) =>
|
2016-04-12 12:40:37 -04:00
|
|
|
new SampleDescription(id,
|
|
|
|
[
|
|
|
|
{'forceGc': forceGc, 'userAgent': userAgent},
|
|
|
|
validator.describe(),
|
|
|
|
defaultDesc,
|
|
|
|
userDesc
|
|
|
|
],
|
|
|
|
metric.describe()),
|
2016-06-02 20:30:40 -04:00
|
|
|
deps: [
|
|
|
|
Metric,
|
|
|
|
Options.SAMPLE_ID,
|
|
|
|
Options.FORCE_GC,
|
|
|
|
Options.USER_AGENT,
|
|
|
|
Validator,
|
|
|
|
Options.DEFAULT_DESCRIPTION,
|
|
|
|
Options.SAMPLE_DESCRIPTION
|
|
|
|
]
|
|
|
|
}
|
2016-04-12 12:40:37 -04:00
|
|
|
];
|