Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Side by Side Diff: appengine/swarming/ui/res/imp/botpage/device-summary.html

Issue 2768893002: Add device-summary to bot-page (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/swarming/ui/res/imp/botpage/bot-page.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!--
2 This in an HTML Import-able file that contains the definition
3 of the following elements:
4
5 <device-summary>
6
7 Usage:
8
9 <device-summary></device-summary>
10
11 Shows a summary of Android devices, given the state variable from a bot.
12 It assumes that all the devices attached to one machine are the same type.
13
14 Properties:
15 state: A state Object, as sent by the server. For bots with Android devices,
16 this is expected include at least the following fields:
17 {
18 devices:{
19 [id]:{
20 battery: {
21 level: Integer
22 },
23 state: String,
24 temp: {
25 [sensor_name]: Float
26 }
27 },
28 [id]:{
29 // same as above
30 },
31 }
32 }
33
34
35 Methods:
36 None.
37
38 Events:
39 None.
40 -->
41
42 <link rel="import" href="/res/imp/common/single-page-style.html">
43
44 <dom-module id="device-summary">
45 <template>
46 <style include="single-page-style">
47 :host {
48 display: block;
49 }
50 </style>
51
52 <template is="dom-if" if="[[_devices.length]]">
53
54 <span class="title">Android Devices</span>
55
56 <table>
57 <thead>
58 <tr>
59 <th>ID</th>
60 <th>Battery</th>
61 <th>Avg Temp. (°C)</th>
62 <th>State</th>
63 </tr>
64 </thead>
65 <tbody>
66 <template is="dom-repeat" items="[[_devices]]" as="device">
67 <tr>
68 <td>[[device.id]]</td>
69 <td>[[device.battery]]</td>
70 <td>[[device.temp]]</td>
71 <td>[[device.state]]</td>
72 </tr>
73 </template>
74 </tbody>
75 </table>
76 </template>
77
78
79 </template>
80 <script>
81 Polymer({
82 is: 'device-summary',
83
84 properties: {
85 state: {
86 type: Object,
87 },
88
stephana 2017/03/23 15:04:46 Nit: no empty line between properties.
kjlubick 2017/03/23 15:26:21 done.
89 _devices: {
90 type: Array,
91 computed: "_getDevices(state.*)",
92 },
93 },
94
95 _getDevices() {
96 var arr = [];
97 if (!this.state || !this.state.devices) {
98 return arr;
99 }
100 for (var id in this.state.devices) {
stephana 2017/03/23 15:04:46 It's probably not an issue in this case, but in ge
kjlubick 2017/03/23 15:26:21 Done.
101 var d = this.state.devices[id];
102 var device = {
103 id: id,
104 battery: d.battery.level,
105 state: d.state,
106 };
107 var count = 0;
108 var totalTemp = 0;
109 for (var t in d.temp) {
110 totalTemp += parseFloat(d.temp[t]);
111 count++;
112 }
113 // Report the average temperature of all sensors.
114 if (count) {
115 device.temp = (totalTemp/count).toFixed(1);
116 }
117
118 arr.push(device);
119 }
120 return arr;
121 }
122 });
123 </script>
124 </dom-module>
OLDNEW
« no previous file with comments | « appengine/swarming/ui/res/imp/botpage/bot-page.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698