Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!-- | 1 <!-- |
| 2 Copyright 2016 The LUCI Authors. All rights reserved. | 2 Copyright 2016 The LUCI Authors. All rights reserved. |
| 3 Use of this source code is governed under the Apache License, Version 2.0 | 3 Use of this source code is governed under the Apache License, Version 2.0 |
| 4 that can be found in the LICENSE file. | 4 that can be found in the LICENSE file. |
| 5 | 5 |
| 6 This file contains most of the logic needed to create a dynamic table. It is b roken up into two | 6 This file contains most of the logic needed to create a dynamic table. It is b roken up into two |
| 7 parts, a style dom-module called "dynamic-table-style" and a behavior called | 7 parts, a style dom-module called "dynamic-table-style" and a behavior called |
| 8 SwarmingBehaviors.DynamicTableBehavior. This behavior ties together filtering, sorting and column | 8 SwarmingBehaviors.DynamicTableBehavior. This behavior ties together filtering, sorting and column |
| 9 content. It also offers a few utilities to make creating the table easier. A c lient of these two | 9 content. It also offers a few utilities to make creating the table easier. A c lient of these two |
| 10 parts needs to create the templates to actually draw the <table>,<tr> and so o n. See | 10 parts needs to create the templates to actually draw the <table>,<tr> and so o n. See |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 _filteredSortedItems, Array<Object>, The list of items that should shown, af ter filtering and | 50 _filteredSortedItems, Array<Object>, The list of items that should shown, af ter filtering and |
| 51 sorting. | 51 sorting. |
| 52 _plainColumns, Array<String>, the list of columns with any special columns s tripped out. | 52 _plainColumns, Array<String>, the list of columns with any special columns s tripped out. |
| 53 | 53 |
| 54 This behavior provides the following methods: | 54 This behavior provides the following methods: |
| 55 _column(col, item): Return the text content of item for a column. | 55 _column(col, item): Return the text content of item for a column. |
| 56 _header(col): Return the header for a column, defaulting to the column name. | 56 _header(col): Return the header for a column, defaulting to the column name. |
| 57 _hide(col): Return a boolean based on whether to hide this column. | 57 _hide(col): Return a boolean based on whether to hide this column. |
| 58 _sortChange(event): Update the sorting based on an event created by sort-tog gle. | 58 _sortChange(event): Update the sorting based on an event created by sort-tog gle. |
| 59 --> | 59 --> |
| 60 | 60 <link rel="import" href="common-aliases.html"> |
| 61 <dom-module id="dynamic-table-style"> | 61 <dom-module id="dynamic-table-style"> |
| 62 <template> | 62 <template> |
| 63 <style> | 63 <style> |
| 64 table { | 64 table { |
| 65 border-collapse: collapse; | 65 border-collapse: collapse; |
| 66 margin-left: 5px; | 66 margin-left: 5px; |
| 67 } | 67 } |
| 68 td, th { | 68 td, th { |
| 69 border: 1px solid #DDD; | 69 border: 1px solid #DDD; |
| 70 padding: 5px; | 70 padding: 5px; |
| 71 } | 71 } |
| 72 th { | 72 th { |
| 73 position: relative; | 73 position: relative; |
| 74 } | 74 } |
| 75 sort-toggle { | 75 sort-toggle { |
| 76 position: absolute; | 76 position: absolute; |
| 77 right: 0; | 77 right: 0; |
| 78 top: 0.4em; | 78 top: 0.4em; |
| 79 } | 79 } |
| 80 </style> | 80 </style> |
| 81 | 81 |
| 82 </template> | 82 </template> |
| 83 </dom-module> | 83 </dom-module> |
| 84 | 84 |
| 85 <script> | 85 <script> |
| 86 window.SwarmingBehaviors = window.SwarmingBehaviors || {}; | |
| 87 (function(){ | 86 (function(){ |
| 88 // This behavior wraps up all the shared swarming functionality. | 87 // This behavior wraps up all the shared swarming functionality. |
| 89 SwarmingBehaviors.DynamicTableBehavior = { | 88 SwarmingBehaviors.DynamicTableBehavior = [SwarmingBehaviors.Aliases, { |
| 90 | 89 |
| 91 properties: { | 90 properties: { |
| 92 | 91 |
| 93 _columns: { | 92 _columns: { |
| 94 type: Array, | 93 type: Array, |
| 95 }, | 94 }, |
| 96 | 95 |
| 97 _filter: { | 96 _filter: { |
| 98 type: Function, | 97 type: Function, |
| 99 }, | 98 }, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 }, | 206 }, |
| 208 // _stripSpecial removes the special columns and sorts the remaining | 207 // _stripSpecial removes the special columns and sorts the remaining |
| 209 // columns so they always appear in the same order, regardless of | 208 // columns so they always appear in the same order, regardless of |
| 210 // the order they are added. | 209 // the order they are added. |
| 211 _stripSpecial: function(){ | 210 _stripSpecial: function(){ |
| 212 return this._columns.filter(function(c) { | 211 return this._columns.filter(function(c) { |
| 213 return this._specialColumns.indexOf(c) === -1; | 212 return this._specialColumns.indexOf(c) === -1; |
| 214 }.bind(this)).sort(); | 213 }.bind(this)).sort(); |
| 215 }, | 214 }, |
| 216 | 215 |
| 217 }; | 216 // Common columns shared between tasklist and botlist |
| 217 _commonColumns: function() { | |
| 218 // return a fresh object so all elements have their own copy | |
| 219 return { | |
| 220 android_devices: function(bot) { | |
| 221 var devs = this._attribute(bot, "android_devices", "0"); | |
| 222 if (this._verbose) { | |
| 223 return devs.join(" | ") + " devices available"; | |
| 224 } | |
| 225 // max() works on strings as long as they can be coerced to Number. | |
| 226 return Math.max(...devs) + " devices available"; | |
| 227 }, | |
| 228 device_type: function(bot) { | |
| 229 var dt = this._attribute(bot, "device_type", "none"); | |
| 230 dt = dt[0]; | |
| 231 var alias = this._androidAlias(dt); | |
| 232 if (alias === "unknown") { | |
| 233 return dt; | |
| 234 } | |
| 235 return this._applyAlias(dt, alias); | |
| 236 }, | |
| 237 gpu: function(bot){ | |
| 238 var gpus = this._attribute(bot, "gpu", "none"); | |
| 239 var verbose = [] | |
| 240 var named = []; | |
| 241 // non-verbose mode has only the top level GPU info "e.g. NVidia" | |
| 242 // which is found by looking for gpu ids w/o a colon. | |
| 243 gpus.forEach(function(g){ | |
| 244 var alias = this._gpuAlias(g); | |
| 245 if (alias === "unknown") { | |
| 246 verbose.push(g); | |
| 247 if (g.indexOf(":") === -1) { | |
| 248 named.push(g); | |
| 249 } | |
| 250 return; | |
| 251 } | |
| 252 verbose.push(this._applyAlias(g, alias)); | |
| 253 if (g.indexOf(":") === -1) { | |
| 254 named.push(this._applyAlias(g, alias)); | |
| 255 } | |
| 256 }.bind(this)) | |
| 257 if (this._verbose || !named.length) { | |
| 258 return verbose.join(" | "); | |
| 259 } | |
| 260 return named.join(" | "); | |
| 261 }, | |
| 262 pool: function(bot) { | |
| 263 var pool = this._attribute(bot, "pool"); | |
| 264 return pool.join(" | "); | |
| 265 }, | |
| 266 }; | |
| 267 }, | |
| 268 | |
|
jcgregorio
2016/08/23 13:07:44
One blank line here.
kjlubick
2016/08/23 17:43:19
Done.
| |
| 269 | |
| 270 }]; | |
| 218 })(); | 271 })(); |
| 219 </script> | 272 </script> |
| OLD | NEW |