1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html">
<link rel="import" href="../imports/lodash.html">
<!--
tf-run-generator is a plumbing component that takes in a url to load runs from, and
produces the following upward-bindable properties:
outRunToScalars: Maps from run name (string) to an array of scalar tags (strings).
outRunToHistograms: Maps from run name (string) to an array of histogram tags (strings).
outRunToImages: Maps from run name (string) to an array of image tags (strings).
-->
<dom-module id="tf-run-generator">
<template>
<iron-ajax
id="ajax"
auto
url="[[url]]"
handle-as="json"
debounce="300"
on-response="_setResponse"
verbose=true
>
</iron-ajax>
</template>
<script>
Polymer({
is: "tf-run-generator",
properties: {
url: String,
_runToTag: {
type: Object,
readOnly: true,
},
outRunToScalars: {
// {[runName: string]: string[]}
// the names of scalar tags.
type: Object,
computed: "_scalars(_runToTag.*)",
notify: true,
},
outRunToHistograms: {
// {[runName: string]: string[]}
// the names of histogram tags.
type: Object,
computed: "_histograms(_runToTag.*)",
notify: true,
},
outRunToCompressedHistograms: {
// {[runName: string]: string[]}
// the names of histogram tags.
type: Object,
computed: "_compressedHistograms(_runToTag.*)",
notify: true,
},
outRunToImages: {
// {[runName: string]: string[]}
// the names of image tags.
type: Object,
computed: "_images(_runToTag.*)",
notify: true,
},
outRunsWithGraph: {
// ["run1", "run2", ...]
// array of run names that have an associated graph definition.
type: Array,
computed: "_graphs(_runToTag.*)",
notify: true
}
},
_scalars: function(_runToTag) {
return _.mapValues(_runToTag.base, "scalars");
},
_histograms: function(_runToTag) {
return _.mapValues(_runToTag.base, "histograms");
},
_compressedHistograms: function(_runToTag) {
return _.mapValues(_runToTag.base, "compressedHistograms");
},
_images: function(_runToTag) {
return _.mapValues(_runToTag.base, "images");
},
_graphs: function(_runToTag) {
var runsWithGraph = [];
_.each(_runToTag.base, function(runInfo, runName) {
if (runInfo.graph === true) {
runsWithGraph.push(runName);
}
});
return runsWithGraph;
},
_setResponse: function(event) {
this._set_runToTag(event.detail.response);
}
});
</script>
</dom-module>
|