| OLD | NEW |
| (Empty) | |
| 1 <!-- |
| 2 This in an HTML Import-able file that contains the definition |
| 3 of the following elements: |
| 4 |
| 5 <bot-list-summary> |
| 6 |
| 7 |
| 8 Usage: |
| 9 |
| 10 <bot-list-summary></bot-list-summary> |
| 11 |
| 12 This element summarizes and displays the results of the current query. |
| 13 |
| 14 Properties: |
| 15 filtered_bots: Array<Object>, The bot list that is currently being shown |
| 16 (after filtering). The alive, dead, etc bots in this will be counted up |
| 17 for the summary. See bot-list-data for a description of this data type. |
| 18 fleet: Object, counts of all bots in the fleet. Contains "alive", "busy", |
| 19 "idle", "dead", and "quarantined". |
| 20 Methods: |
| 21 None. |
| 22 |
| 23 Events: |
| 24 None. |
| 25 --> |
| 26 |
| 27 |
| 28 <link rel="import" href="/res/imp/common/swarming-app.html"> |
| 29 |
| 30 <link rel="import" href="bot-list-shared.html"> |
| 31 |
| 32 <dom-module id="bot-list-summary"> |
| 33 <template> |
| 34 <style include="swarming-app-style"> |
| 35 :host { |
| 36 display: block; |
| 37 border-left: 1px solid black; |
| 38 padding: 5px 5px; |
| 39 font-family: sans-serif; |
| 40 } |
| 41 .header { |
| 42 font-size: 1.2em; |
| 43 font-weight: bold; |
| 44 } |
| 45 .right { |
| 46 text-align: right; |
| 47 } |
| 48 .left { |
| 49 text-align: left; |
| 50 } |
| 51 </style> |
| 52 |
| 53 <div class="header">Fleet</div> |
| 54 <!-- TODO(kjlubick) Once url params have been implemented, have these |
| 55 properly link to the botlist with the given features preloaded.--> |
| 56 <table> |
| 57 <tr> |
| 58 <td class="right"><a href="/newui/botlist?alive">Alive</a>:</td> |
| 59 <td class="left">[[fleet.alive]]</td> |
| 60 </tr> |
| 61 <tr> |
| 62 <td class="right"><a href="/newui/botlist?busy">Busy</a>:</td> |
| 63 <td class="left">[[fleet.busy]]</td> |
| 64 </tr> |
| 65 <tr> |
| 66 <td class="right"><a href="/newui/botlist?idle">Idle</a>:</td> |
| 67 <td class="left">[[fleet.idle]]</td> |
| 68 </tr> |
| 69 <tr> |
| 70 <td class="right"><a href="/newui/botlist?dead">Dead</a>:</td> |
| 71 <td class="left">[[fleet.dead]]</td> |
| 72 </tr> |
| 73 <tr> |
| 74 <td class="right"><a href="/newui/botlist?quaren">Quarantined</a>:</td> |
| 75 <td class="left">[[fleet.quarantined]]</td> |
| 76 </tr> |
| 77 </table> |
| 78 |
| 79 <div class="header">Displayed</div> |
| 80 <table> |
| 81 <tr> |
| 82 <td class="right"><a href="/newui/botlist?alive2">Alive</a>:</td> |
| 83 <td class="left">[[_currently_showing.alive]]</td> |
| 84 </tr> |
| 85 <tr> |
| 86 <td class="right"><a href="/newui/botlist?busy2">Busy</a>:</td> |
| 87 <td class="left">[[_currently_showing.busy]]</td> |
| 88 </tr> |
| 89 <tr> |
| 90 <td class="right"><a href="/newui/botlist?idle2">Idle</a>:</td> |
| 91 <td class="left">[[_currently_showing.idle]]</td> |
| 92 </tr> |
| 93 <tr> |
| 94 <td class="right"><a href="/newui/botlist?dead2">Dead</a>:</td> |
| 95 <td class="left">[[_currently_showing.dead]]</td> |
| 96 </tr> |
| 97 <tr> |
| 98 <td class="right"><a href="/newui/botlist?quaren2">Quarantined</a>:</td> |
| 99 <td class="left">[[_currently_showing.quarantined]]</td> |
| 100 </tr> |
| 101 </table> |
| 102 |
| 103 </template> |
| 104 <script> |
| 105 Polymer({ |
| 106 is: 'bot-list-summary', |
| 107 |
| 108 behaviors: [SwarmingBehaviors.BotListBehavior], |
| 109 |
| 110 properties: { |
| 111 filtered_bots: { |
| 112 type: Array, |
| 113 }, |
| 114 fleet: { |
| 115 type: Object, |
| 116 }, |
| 117 |
| 118 _currently_showing: { |
| 119 type: Object, |
| 120 value: function() { |
| 121 return { |
| 122 alive: -1, |
| 123 busy: -1, |
| 124 idle: -1, |
| 125 dead: -1, |
| 126 quarantined: -1, |
| 127 }; |
| 128 }, |
| 129 }, |
| 130 }, |
| 131 |
| 132 // Do this because Array changes in Polymer don't always trigger normal |
| 133 // property observers |
| 134 observers: ["_recount(filtered_bots.*)"], |
| 135 |
| 136 _recount: function() { |
| 137 var curr = { |
| 138 alive: 0, |
| 139 busy: 0, |
| 140 idle: 0, |
| 141 dead: 0, |
| 142 quarantined: 0, |
| 143 }; |
| 144 if (!this.filtered_bots) { |
| 145 return curr; |
| 146 } |
| 147 this.filtered_bots.forEach(function(bot) { |
| 148 if (this._taskId(bot) === "idle") { |
| 149 curr.idle++; |
| 150 } else { |
| 151 curr.busy++; |
| 152 } |
| 153 if (bot.quarantined) { |
| 154 curr.quarantined++; |
| 155 } |
| 156 if (bot.is_dead) { |
| 157 curr.dead++; |
| 158 } else { |
| 159 curr.alive++; |
| 160 } |
| 161 }.bind(this)); |
| 162 this.set("_currently_showing", curr); |
| 163 } |
| 164 }); |
| 165 </script> |
| 166 </dom-module> |
| OLD | NEW |