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

Side by Side Diff: appengine/swarming/elements/res/imp/tasklist/task-list.html

Issue 2338823002: Fix small glitches in bot-page and task-list (Closed) Base URL: git@github.com:luci/luci-py@master
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 <task-list> 9 <task-list>
10 10
11 task-list creats a dynamic table for viewing swarming tasks. Columns can be 11 task-list creats a dynamic table for viewing swarming tasks. Columns can be
12 dynamically filtered and it supports client-side filtering. 12 dynamically filtered and it supports client-side filtering.
13 13
14 This is a top-level element. 14 This is a top-level element.
15 15
16 Properties: 16 Properties:
17 client_id: String, Oauth 2.0 client id. It will be set by server-side 17 client_id: String, Oauth 2.0 client id. It will be set by server-side
18 template evaluation. 18 template evaluation.
19 19
20 Methods: 20 Methods:
21 None. 21 None.
22 22
23 Events: 23 Events:
24 None. 24 None.
25 --> 25 -->
26 26
27 <link rel="import" href="/res/imp/bower_components/iron-flex-layout/iron-flex-la yout-classes.html"> 27 <link rel="import" href="/res/imp/bower_components/iron-flex-layout/iron-flex-la yout-classes.html">
28 <link rel="import" href="/res/imp/bower_components/paper-button/paper-button.htm l"> 28 <link rel="import" href="/res/imp/bower_components/paper-button/paper-button.htm l">
29 <link rel="import" href="/res/imp/bower_components/paper-button/paper-button.htm l">
30 <link rel="import" href="/res/imp/bower_components/paper-dialog/paper-dialog.htm l">
29 <link rel="import" href="/res/imp/bower_components/polymer/polymer.html"> 31 <link rel="import" href="/res/imp/bower_components/polymer/polymer.html">
30 32
31 <link rel="import" href="/res/imp/common/dynamic-table-behavior.html"> 33 <link rel="import" href="/res/imp/common/dynamic-table-behavior.html">
32 <link rel="import" href="/res/imp/common/error-toast.html"> 34 <link rel="import" href="/res/imp/common/error-toast.html">
33 <link rel="import" href="/res/imp/common/sort-toggle.html"> 35 <link rel="import" href="/res/imp/common/sort-toggle.html">
34 <link rel="import" href="/res/imp/common/swarming-app.html"> 36 <link rel="import" href="/res/imp/common/swarming-app.html">
35 <link rel="import" href="/res/imp/common/url-param.html"> 37 <link rel="import" href="/res/imp/common/url-param.html">
36 38
37 <link rel="import" href="task-filters.html"> 39 <link rel="import" href="task-filters.html">
38 <link rel="import" href="task-list-data.html"> 40 <link rel="import" href="task-list-data.html">
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 <div hidden$="[[_not(_signed_in)]]"> 84 <div hidden$="[[_not(_signed_in)]]">
83 <task-list-data 85 <task-list-data
84 auth_headers="[[_auth_headers]]" 86 auth_headers="[[_auth_headers]]"
85 query_params="[[_query_params]]" 87 query_params="[[_query_params]]"
86 tasks="{{_items}}" 88 tasks="{{_items}}"
87 busy="{{_busy}}" 89 busy="{{_busy}}"
88 primary_map="{{_primary_map}}" 90 primary_map="{{_primary_map}}"
89 primary_arr="{{_primary_arr}}"> 91 primary_arr="{{_primary_arr}}">
90 </task-list-data> 92 </task-list-data>
91 93
92 <error-toast></error-toast>
93
94 <div class="horizontal layout"> 94 <div class="horizontal layout">
95 95
96 <task-filters 96 <task-filters
97 primary_map="[[_primary_map]]" 97 primary_map="[[_primary_map]]"
98 primary_arr="[[_primary_arr]]" 98 primary_arr="[[_primary_arr]]"
99 columns="{{_columns}}" 99 columns="{{_columns}}"
100 query_params="{{_query_params}}" 100 query_params="{{_query_params}}"
101 filter="{{_filter}}"> 101 filter="{{_filter}}">
102 </task-filters> 102 </task-filters>
103 103
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 href$="[[_taskLink(task.task_id)]]" 170 href$="[[_taskLink(task.task_id)]]"
171 target="_blank"> 171 target="_blank">
172 [[task.name]] 172 [[task.name]]
173 </a> 173 </a>
174 </td> 174 </td>
175 <td hidden$="[[_hide('state', _columns.*)]]"> 175 <td hidden$="[[_hide('state', _columns.*)]]">
176 [[_column('state', task)]] 176 [[_column('state', task)]]
177 <paper-button 177 <paper-button
178 raised 178 raised
179 hidden$="[[_cannotCancel(task,_permissions)]]" 179 hidden$="[[_cannotCancel(task,_permissions)]]"
180 on-tap="_cancelTask"> 180 on-tap="_promptCancel">
181 Cancel 181 Cancel
182 </paper-button> 182 </paper-button>
183 </td> 183 </td>
184 <td hidden$="[[_hide('deduped_from', _columns.*)]]"> 184 <td hidden$="[[_hide('deduped_from', _columns.*)]]">
185 <a 185 <a
186 class="center" 186 class="center"
187 href$="[[_taskLink(task.deduped_from)]]" 187 href$="[[_taskLink(task.deduped_from)]]"
188 target="_blank"> 188 target="_blank">
189 [[_column('deduped_from',task)]] 189 [[_column('deduped_from',task)]]
190 </a> 190 </a>
191 </td> 191 </td>
192 192
193 <template 193 <template
194 is="dom-repeat" 194 is="dom-repeat"
195 items="[[_plainColumns]]" 195 items="[[_plainColumns]]"
196 as="c"> 196 as="c">
197 <td hidden$="[[_hide(c)]]"> 197 <td hidden$="[[_hide(c)]]">
198 [[_column(c, task)]] 198 [[_column(c, task)]]
199 </td> 199 </td>
200 </template> 200 </template>
201 201
202 </tr> 202 </tr>
203 </template> <!--tasks_table repeat--> 203 </template> <!--tasks_table repeat-->
204 </tbody> 204 </tbody>
205 </table> 205 </table>
206 </div> 206 </div>
207 207
208 </swarming-app> 208 </swarming-app>
209 209
210 <paper-dialog id="prompt" modal on-iron-overlay-closed="_promptClosed">
211 <h2>Are you sure?</h2>
212 <div>Are you sure you want to [[_dialogPrompt]]?</div>
213 <div class="buttons">
214 <paper-button dialog-dismiss autofocus>No</paper-button>
215 <paper-button dialog-confirm>Yes</paper-button>
216 </div>
217 </paper-dialog>
218
219 <error-toast></error-toast>
220
210 </template> 221 </template>
211 <script> 222 <script>
212 (function(){ 223 (function(){
213 var specialColumns = ["deduped_from", "name", "state"]; 224 var specialColumns = ["deduped_from", "name", "state"];
214 225
215 // Given a time attribute like "abandoned_ts", humanTime returns a function 226 // Given a time attribute like "abandoned_ts", humanTime returns a function
216 // that returns the human-friendly version of that attribute. The human 227 // that returns the human-friendly version of that attribute. The human
217 // friendly time was created in task-list-data. 228 // friendly time was created in task-list-data.
218 function humanTime(attr) { 229 function humanTime(attr) {
219 return function(task) { 230 return function(task) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 is: 'task-list', 287 is: 'task-list',
277 behaviors: [ 288 behaviors: [
278 SwarmingBehaviors.DynamicTableBehavior, 289 SwarmingBehaviors.DynamicTableBehavior,
279 ], 290 ],
280 291
281 properties: { 292 properties: {
282 client_id: { 293 client_id: {
283 type: String, 294 type: String,
284 }, 295 },
285 296
297 // The task id to cancel if the prompt is accepted.
298 _toCancel: {
299 type: String,
300 },
301
286 // For dynamic table. 302 // For dynamic table.
287 _columnMap: { 303 _columnMap: {
288 type: Object, 304 type: Object,
289 value: function() { 305 value: function() {
290 var base = this._commonColumns(); 306 var base = this._commonColumns();
291 for (var attr in columnMap) { 307 for (var attr in columnMap) {
292 base[attr] = columnMap[attr]; 308 base[attr] = columnMap[attr];
293 } 309 }
294 return base; 310 return base;
295 }, 311 },
(...skipping 21 matching lines...) Expand all
317 return [retVal]; 333 return [retVal];
318 } 334 }
319 return retVal; 335 return retVal;
320 }, 336 },
321 337
322 _cannotCancel: function(task, permissions) { 338 _cannotCancel: function(task, permissions) {
323 return !(permissions && permissions.cancel_task && 339 return !(permissions && permissions.cancel_task &&
324 this._column("state", task) === "PENDING"); 340 this._column("state", task) === "PENDING");
325 }, 341 },
326 342
327 _cancelTask: function(e) { 343 _cancelTask: function() {
344 var url = "/_ah/api/swarming/v1/task/" + this._toCancel +"/cancel";
345 swarming.postWithToast(url, "Canceling task " + this._toCancel, this._au th_headers);
346 this.set("_toCancel", "");
347 },
348
349 _promptClosed: function(e) {
350 if (e.detail.confirmed) {
351 this._cancelTask();
352 }
353 },
354
355 _promptCancel: function(e) {
328 var task = e.model.task; 356 var task = e.model.task;
329 if (!task || !task.task_id) { 357 if (!task || !task.task_id) {
330 console.log("Missing task info", task); 358 console.log("Missing task info", task);
331 return 359 return
332 } 360 }
333 var id = task.task_id 361 this.set("_toCancel", task.task_id);
334 362 this.set("_dialogPrompt", 'cancel task "'+ task.name +'"');
335 var url = "/_ah/api/swarming/v1/task/" + id +"/cancel"; 363 this.$.prompt.open();
336 swarming.postWithToast(url, "Canceling task " + id, this._auth_headers);
337 }, 364 },
338 365
339 _tag: function(task, col) { 366 _tag: function(task, col) {
340 if (!task || !task.tagMap) { 367 if (!task || !task.tagMap) {
341 return undefined; 368 return undefined;
342 } 369 }
343 return task.tagMap[col]; 370 return task.tagMap[col];
344 }, 371 },
345 372
346 _taskLink: function(taskId) { 373 _taskLink: function(taskId) {
(...skipping 18 matching lines...) Expand all
365 if (state === "RUNNING" || state === "PENDING") { 392 if (state === "RUNNING" || state === "PENDING") {
366 return "pending"; 393 return "pending";
367 } 394 }
368 return ""; 395 return "";
369 } 396 }
370 397
371 }); 398 });
372 })(); 399 })();
373 </script> 400 </script>
374 </dom-module> 401 </dom-module>
OLDNEW
« no previous file with comments | « appengine/swarming/elements/res/imp/botpage/bot-page.html ('k') | appengine/swarming/elements/res/js/alias.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698