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

Side by Side Diff: appengine/swarming/elements/res/imp/botlist/bot-list-data.html

Issue 2276373002: Remove the rest of iron-ajax from bot-list-data (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@make-tasklist
Patch Set: Created 4 years, 3 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
OLDNEW
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 in an HTML Import-able file that contains the definition 6 This in an HTML Import-able file that contains the definition
7 of the following elements: 7 of the following elements:
8 8
9 <bot-list-data> 9 <bot-list-data>
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 This is dimensions, then bot properties, then elements from bot.state. 53 This is dimensions, then bot properties, then elements from bot.state.
54 54
55 Methods: 55 Methods:
56 signIn(): Force a signin of the user using OAuth. This happens 56 signIn(): Force a signin of the user using OAuth. This happens
57 automatically when auth_headers is set. 57 automatically when auth_headers is set.
58 58
59 Events: 59 Events:
60 None. 60 None.
61 --> 61 -->
62 62
63 <link rel="import" href="/res/imp/bower_components/iron-ajax/iron-ajax.html">
64
65 <link rel="import" href="bot-list-shared-behavior.html"> 63 <link rel="import" href="bot-list-shared-behavior.html">
66 64
67 <dom-module id="bot-list-data"> 65 <dom-module id="bot-list-data">
68 <template>
69 <iron-ajax id="botlist"
70 url="/_ah/api/swarming/v1/bots/list"
71 headers="[[auth_headers]]"
72 params="[[query_params]]"
73 handle-as="json"
74 last-response="{{_list}}"
75 loading="{{_busy1}}">
76 </iron-ajax>
77 66
78 <iron-ajax id="dimensions"
79 url="/_ah/api/swarming/v1/bots/dimensions"
80 headers="[[auth_headers]]"
81 handle-as="json"
82 last-response="{{_dimensions}}"
83 loading="{{_busy2}}">
84 </iron-ajax>
85
86 <iron-ajax id="fleet"
87 url="/_ah/api/swarming/v1/bots/count"
88 headers="[[auth_headers]]"
89 handle-as="json"
90 last-response="{{_count}}"
91 loading="{{_busy3}}">
92 </iron-ajax>
93 </template>
94 <script> 67 <script>
95 (function(){ 68 (function(){
96 var BLACKLIST_DIMENSIONS = ["quarantined", "error"]; 69 var BLACKLIST_DIMENSIONS = ["quarantined", "error"];
97 70
98 Polymer({ 71 Polymer({
99 is: 'bot-list-data', 72 is: 'bot-list-data',
100 73
101 behaviors: [ 74 behaviors: [
102 SwarmingBehaviors.BotListBehavior, 75 SwarmingBehaviors.BotListBehavior,
103 ], 76 ],
104 77
105 properties: { 78 properties: {
106 // inputs 79 // inputs
107 auth_headers: { 80 auth_headers: {
108 type: Object, 81 type: Object,
109 observer: "signIn", 82 observer: "signIn",
110 }, 83 },
111 query_params: { 84 query_params: {
112 type: Object, 85 type: Object,
86 observer: "_request",
113 }, 87 },
114 88
115 //outputs 89 //outputs
116 bots: { 90 bots: {
117 type: Array, 91 type: Array,
118 computed: "_bots(_list)", 92 computed: "_bots(_list)",
119 notify: true, 93 notify: true,
120 }, 94 },
121 busy: { 95 busy: {
122 type: Boolean, 96 type: Boolean,
(...skipping 16 matching lines...) Expand all
139 notify: true, 113 notify: true,
140 }, 114 },
141 primary_arr: { 115 primary_arr: {
142 type: Array, 116 type: Array,
143 //BOT_PROPERTIES is inherited from BotListBehavior 117 //BOT_PROPERTIES is inherited from BotListBehavior
144 computed: "_primaryArr(dimensions, BOT_PROPERTIES)", 118 computed: "_primaryArr(dimensions, BOT_PROPERTIES)",
145 notify: true, 119 notify: true,
146 }, 120 },
147 121
148 // private 122 // private
123 _busy1: {
124 type: Boolean,
125 value: false
126 },
127 _busy2: {
128 type: Boolean,
129 value: false
130 },
131 _busy3: {
132 type: Boolean,
133 value: false
134 },
149 _count: { 135 _count: {
150 type: Object, 136 type: Object,
151 }, 137 },
152 _dimensions: { 138 _dimensions: {
153 type: Object, 139 type: Object,
154 }, 140 },
155 _list: { 141 _list: {
156 type: Object, 142 type: Object,
157 }, 143 },
158 }, 144 },
159 145
160 signIn: function(){ 146 signIn: function(){
161 // Auto on iron-ajax means to automatically re-make the request if 147 this._getJsonAsync("_count", "/_ah/api/swarming/v1/bots/count",
162 // the url or the query params change. Auto does not trigger if the 148 "_busy2", this.auth_headers);
163 // [auth] headers change, so we wait until the user is signed in 149 this._getJsonAsync("_dimensions","/_ah/api/swarming/v1/bots/dimensions",
164 // before making any requests. 150 "_busy3", this.auth_headers);
165 this.$.botlist.auto = true; 151
166 this.$.dimensions.auto = true; 152 this._request();
167 this.$.fleet.auto = true;
168 }, 153 },
169 154
170 _bots: function(){ 155 _bots: function(){
171 if (!this._list || !this._list.items) { 156 if (!this._list || !this._list.items) {
172 return []; 157 return [];
173 } 158 }
174 // Do any preprocessing here 159 // Do any preprocessing here
175 this._list.items.forEach(function(bot){ 160 this._list.items.forEach(function(bot){
176 // Parse the state, which is a JSON string. This contains a lot of 161 // Parse the state, which is a JSON string. This contains a lot of
177 // interesting information like details about the devices attached. 162 // interesting information like details about the devices attached.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // Create custom filter options 263 // Create custom filter options
279 pMap["disk_space"] = []; 264 pMap["disk_space"] = [];
280 pMap["task"] = ["busy", "idle"]; 265 pMap["task"] = ["busy", "idle"];
281 pMap["status"] = ["alive", "dead", "quarantined"]; 266 pMap["status"] = ["alive", "dead", "quarantined"];
282 267
283 // No need to sort any of this, bot-filters sorts secondary items 268 // No need to sort any of this, bot-filters sorts secondary items
284 // automatically, especially when the user types a query. 269 // automatically, especially when the user types a query.
285 return pMap; 270 return pMap;
286 }, 271 },
287 272
273 _request: function() {
274 // wait until the user has logged in and the filters have loaded before requesting this to avoid double or even triple requests.
275 if (!this.auth_headers || !this.query_params) {
276 return;
277 }
278 this._getJsonAsync("_list", "/_ah/api/swarming/v1/bots/list",
279 "_busy1", this.auth_headers, this.query_params);
280 },
281
288 }); 282 });
289 })(); 283 })();
290 </script> 284 </script>
291 </dom-module> 285 </dom-module>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698