2015-02-18 09:04:02 -08:00
|
|
|
import { StringMapWrapper, ListWrapper, StringMap } from 'angular2/src/facade/collection';
|
2015-02-11 10:13:49 -08:00
|
|
|
import { bind, OpaqueToken } from 'angular2/di';
|
|
|
|
|
import { Validator } from './validator';
|
|
|
|
|
import { Metric } from './metric';
|
2015-03-06 17:34:27 -08:00
|
|
|
import { Options } from './common_options';
|
2015-02-11 10:13:49 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SampleDescription merges all available descriptions about a sample
|
|
|
|
|
*/
|
|
|
|
|
export class SampleDescription {
|
|
|
|
|
// TODO(tbosch): use static values when our transpiler supports them
|
|
|
|
|
static get BINDINGS() { return _BINDINGS; }
|
|
|
|
|
|
|
|
|
|
id:string;
|
2015-02-18 09:04:02 -08:00
|
|
|
description:StringMap;
|
|
|
|
|
metrics:StringMap;
|
2015-02-11 10:13:49 -08:00
|
|
|
|
2015-02-18 09:04:02 -08:00
|
|
|
constructor(id, descriptions:List<StringMap>, metrics:StringMap) {
|
2015-02-11 10:13:49 -08:00
|
|
|
this.id = id;
|
|
|
|
|
this.metrics = metrics;
|
|
|
|
|
this.description = {};
|
|
|
|
|
ListWrapper.forEach(descriptions, (description) => {
|
|
|
|
|
StringMapWrapper.forEach(description, (value, prop) => this.description[prop] = value );
|
|
|
|
|
});
|
|
|
|
|
}
|
2015-03-06 11:46:33 -08:00
|
|
|
|
|
|
|
|
toJson() {
|
|
|
|
|
return {
|
|
|
|
|
'id': this.id,
|
|
|
|
|
'description': this.description,
|
|
|
|
|
'metrics': this.metrics
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-02-11 10:13:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var _BINDINGS = [
|
|
|
|
|
bind(SampleDescription).toFactory(
|
2015-02-20 13:32:54 -08:00
|
|
|
(metric, id, forceGc, userAgent, validator, defaultDesc, userDesc) => new SampleDescription(id,
|
2015-02-11 10:13:49 -08:00
|
|
|
[
|
2015-02-20 13:32:54 -08:00
|
|
|
{'forceGc': forceGc, 'userAgent': userAgent},
|
2015-02-11 10:13:49 -08:00
|
|
|
validator.describe(),
|
|
|
|
|
defaultDesc,
|
|
|
|
|
userDesc
|
|
|
|
|
],
|
|
|
|
|
metric.describe()),
|
2015-02-20 13:32:54 -08:00
|
|
|
[
|
|
|
|
|
Metric, Options.SAMPLE_ID, Options.FORCE_GC, Options.USER_AGENT,
|
|
|
|
|
Validator, Options.DEFAULT_DESCRIPTION, Options.SAMPLE_DESCRIPTION
|
|
|
|
|
]
|
2015-03-06 17:34:27 -08:00
|
|
|
)
|
2015-02-11 10:13:49 -08:00
|
|
|
];
|