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

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

Issue 2778773002: Fix device summary when state not fully formed (Closed)
Patch Set: Fix device summary when state not fully formed: 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/build/elements.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
1 <!-- 1 <!--
2 This in an HTML Import-able file that contains the definition 2 This in an HTML Import-able file that contains the definition
3 of the following elements: 3 of the following elements:
4 4
5 <device-summary> 5 <device-summary>
6 6
7 Usage: 7 Usage:
8 8
9 <device-summary></device-summary> 9 <device-summary></device-summary>
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 _getDevices() { 94 _getDevices() {
95 var arr = []; 95 var arr = [];
96 if (!this.state || !this.state.devices) { 96 if (!this.state || !this.state.devices) {
97 return arr; 97 return arr;
98 } 98 }
99 for (var id in this.state.devices) { 99 for (var id in this.state.devices) {
100 if (this.state.devices.hasOwnProperty(id)) { 100 if (this.state.devices.hasOwnProperty(id)) {
101 var d = this.state.devices[id]; 101 var d = this.state.devices[id];
102 var device = { 102 var device = {
103 id: id, 103 id: id,
104 battery: d.battery.level, 104 state: d.state || "???",
105 state: d.state,
106 }; 105 };
106 device.battery = (d.battery && d.battery.level) || "???"
107 var count = 0; 107 var count = 0;
108 var totalTemp = 0; 108 var totalTemp = 0;
109 d.temp = d.temp || [];
109 for (var t in d.temp) { 110 for (var t in d.temp) {
110 totalTemp += parseFloat(d.temp[t]); 111 totalTemp += parseFloat(d.temp[t]);
111 count++; 112 count++;
112 } 113 }
113 // Report the average temperature of all sensors. 114 // Report the average temperature of all sensors.
114 if (count) { 115 if (count) {
115 device.temp = (totalTemp/count).toFixed(1); 116 device.temp = (totalTemp/count).toFixed(1);
117 } else {
118 device.temp == "???";
116 } 119 }
117 arr.push(device); 120 arr.push(device);
118 } 121 }
119 } 122 }
120 return arr; 123 return arr;
121 } 124 }
122 }); 125 });
123 </script> 126 </script>
124 </dom-module> 127 </dom-module>
OLDNEW
« no previous file with comments | « appengine/swarming/ui/build/elements.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698