| 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 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-page> | 9 <task-page> |
| 10 | 10 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 <table class="task-info" hidden$="[[_not(_task_exists)]]"> | 204 <table class="task-info" hidden$="[[_not(_task_exists)]]"> |
| 205 <tbody> | 205 <tbody> |
| 206 <tr> | 206 <tr> |
| 207 <td>Name</td> | 207 <td>Name</td> |
| 208 <td>[[_request.name]]</td> | 208 <td>[[_request.name]]</td> |
| 209 </tr> | 209 </tr> |
| 210 <tr> | 210 <tr> |
| 211 <td>State</td> | 211 <td>State</td> |
| 212 <td class$="[[_stateClass(_result)]]">[[state(_result)]]</td> | 212 <td class$="[[_stateClass(_result)]]">[[state(_result)]]</td> |
| 213 </tr> | 213 </tr> |
| 214 <template is="dom-if" if="[[_eq(_result.state,'PENDING')]]"> | 214 |
| 215 <tr> | 215 <tr> |
| 216 <td><b>Why Pending?</b></td> | |
| 217 <td> | 216 <td> |
| 218 <span class$="[[_it(_other_pending.count)]]">[[_otherPendi
ng(_other_pending)]]</span> | 217 <template is="dom-if" if="[[_eq(_result.state,'PENDING')]]
"> |
| 219 similar pending tasks, | 218 <b>Why Pending?</b> |
| 219 </template> |
| 220 <template is="dom-if" if="[[_neq(_result.state,'PENDING')]
]"> |
| 221 Similar Load |
| 222 </template> |
| 223 </td> |
| 224 <td> |
| 225 <span class$="[[_it(_other_pending.count)]]">[[_other_pend
ing.count]]</span> |
| 226 <a |
| 227 title="The list of pending tasks that matches the list o
f dimensions" |
| 228 href$='[[_taskListLink(_request.properties.dimensions,""
,"state:PENDING")]]'>similar pending tasks</a>, |
| 220 <span class$="[[_it(_other_running.count)]]">[[_other_runn
ing.count]]</span> | 229 <span class$="[[_it(_other_running.count)]]">[[_other_runn
ing.count]]</span> |
| 221 similar running tasks | 230 <a |
| 231 title="The list of running tasks that matches the list o
f dimensions" |
| 232 href$='[[_taskListLink(_request.properties.dimensions,""
,"state:RUNNING")]]'>similar running tasks</a> |
| 222 </td> | 233 </td> |
| 223 </tr> | 234 </tr> |
| 224 </template> | 235 |
| 225 <tr> | 236 <tr> |
| 226 <td>Fleet Capacity</td> | 237 <td>Fleet Capacity</td> |
| 227 <td> | 238 <td> |
| 228 <span class$="[[_it(_bots_count.count)]]">[[_bots_count.coun
t]]</span> | 239 <span class$="[[_it(_bots_count.count)]]">[[_bots_count.coun
t]]</span> |
| 229 <a | 240 <a |
| 230 title="The list of bots that matches the list of dimensi
ons" | 241 title="The list of bots that matches the list of dimensi
ons" |
| 231 href$="[[_botListLink(_request.properties.dimensions)]]"
>bots</a> | 242 href$="[[_botListLink(_request.properties.dimensions)]]"
>bots</a> |
| 232 can run this task | 243 can run this task |
| 233 (<span class$="[[_it(_bots_count.dead)]]">[[_bots_count.dead
]]</span> | 244 (<span class$="[[_it(_bots_count.dead)]]">[[_bots_count.dead
]]</span> |
| 234 dead, | 245 dead, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 <template is="dom-if" if="[[_request.parent_task_id]]"> | 324 <template is="dom-if" if="[[_request.parent_task_id]]"> |
| 314 <tr> | 325 <tr> |
| 315 <td>Parent Task</td> | 326 <td>Parent Task</td> |
| 316 <td> | 327 <td> |
| 317 <a href$="[[_taskLink(_request.parent_task_id)]]">[[_reque
st.parent_task_id]]</a> | 328 <a href$="[[_taskLink(_request.parent_task_id)]]">[[_reque
st.parent_task_id]]</a> |
| 318 </td> | 329 </td> |
| 319 </tr> | 330 </tr> |
| 320 </template> | 331 </template> |
| 321 <tr> | 332 <tr> |
| 322 <td rowspan$="[[_rowspan(_request.properties.dimensions)]]"> | 333 <td rowspan$="[[_rowspan(_request.properties.dimensions)]]"> |
| 334 Dimensions <br/> |
| 323 <a | 335 <a |
| 324 title="The list of bots that matches the list of dimensi
ons" | 336 title="The list of bots that matches the list of dimensi
ons" |
| 325 href$="[[_botListLink(_request.properties.dimensions)]]"
> | 337 href$="[[_botListLink(_request.properties.dimensions)]]"
>Bots</a> |
| 326 Requested Dimensions | 338 <a |
| 327 </a> | 339 title="The list of tasks that matches the list of dimens
ions" |
| 340 href$="[[_taskListLink(_request.properties.dimensions)]]
">Tasks</a> |
| 328 </td> | 341 </td> |
| 329 </tr> | 342 </tr> |
| 330 <template is="dom-repeat" items="{{_request.properties.dimension
s}}" as="dimension"> | 343 <template is="dom-repeat" items="{{_request.properties.dimension
s}}" as="dimension"> |
| 331 <tr> | 344 <tr> |
| 332 <td><b>[[dimension.key]]:</b> [[_alias(dimension)]]</td> | 345 <td><b>[[dimension.key]]:</b> [[_alias(dimension)]]</td> |
| 333 </tr> | 346 </tr> |
| 334 </template> | 347 </template> |
| 335 <tr> | 348 <tr> |
| 336 <td>Isolated Inputs</td> | 349 <td>Isolated Inputs</td> |
| 337 <td> | 350 <td> |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 }, | 727 }, |
| 715 _server_details: { | 728 _server_details: { |
| 716 type: Object, | 729 type: Object, |
| 717 }, | 730 }, |
| 718 _stdout: { | 731 _stdout: { |
| 719 type: String, | 732 type: String, |
| 720 } | 733 } |
| 721 }, | 734 }, |
| 722 | 735 |
| 723 observers: [ | 736 observers: [ |
| 724 "_whyPending(_request,_result,_auth_headers)"], | 737 "_similarLoad(_request,_result,_auth_headers)"], |
| 725 | 738 |
| 726 _alias: function(dim) { | 739 _alias: function(dim) { |
| 727 var values = dim.value; | 740 var values = dim.value; |
| 728 if (!Array.isArray(values)) { | 741 if (!Array.isArray(values)) { |
| 729 values = [values]; | 742 values = [values]; |
| 730 } | 743 } |
| 731 if (swarming.alias.has(dim.key)) { | 744 if (swarming.alias.has(dim.key)) { |
| 732 values.forEach(function(v, i){ | 745 values.forEach(function(v, i){ |
| 733 values[i] = swarming.alias.apply(v, dim.key); | 746 values[i] = swarming.alias.apply(v, dim.key); |
| 734 }); | 747 }); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 }, | 895 }, |
| 883 | 896 |
| 884 // makes text italic unless it's numbers (i.e. when loading) | 897 // makes text italic unless it's numbers (i.e. when loading) |
| 885 _it: function(s) { | 898 _it: function(s) { |
| 886 if (!s || (s[0] === "<")) { | 899 if (!s || (s[0] === "<")) { |
| 887 return "italic"; | 900 return "italic"; |
| 888 } | 901 } |
| 889 return ""; | 902 return ""; |
| 890 }, | 903 }, |
| 891 | 904 |
| 905 _neq: function(a,b) { |
| 906 return a !== b; |
| 907 }, |
| 908 |
| 892 _noMilo: function(result) { | 909 _noMilo: function(result) { |
| 893 return !(this._tag(result, "allow_milo") || this._tag(result, "luci_proj
ect")); | 910 return !(this._tag(result, "allow_milo") || this._tag(result, "luci_proj
ect")); |
| 894 }, | 911 }, |
| 895 | 912 |
| 896 _otherPending: function(other_pending) { | |
| 897 if (other_pending && other_pending.count > 0) { | |
| 898 // subtract 1 from this count, because that's this task. | |
| 899 return other_pending.count - 1; | |
| 900 } | |
| 901 return "<counting>"; | |
| 902 }, | |
| 903 | |
| 904 _pending: function(result) { | 913 _pending: function(result) { |
| 905 if (!result.created_ts) { | 914 if (!result.created_ts) { |
| 906 return ""; | 915 return ""; |
| 907 } | 916 } |
| 908 var end = result.started_ts || result.abandoned_ts || new Date(); | 917 var end = result.started_ts || result.abandoned_ts || new Date(); |
| 909 // In the case of deduplicated tasks, started_ts comes before the task. | 918 // In the case of deduplicated tasks, started_ts comes before the task. |
| 910 if (end <= result.created_ts) { | 919 if (end <= result.created_ts) { |
| 911 return "0s"; | 920 return "0s"; |
| 912 } | 921 } |
| 913 return this._timeDiffExact(result.created_ts, end); | 922 return this._timeDiffExact(result.created_ts, end); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 }, | 1034 }, |
| 1026 | 1035 |
| 1027 _wasPickedUp: function(result) { | 1036 _wasPickedUp: function(result) { |
| 1028 return result && result.state !== this.PENDING && result.state !== this.
CANCELED && result.state != this.EXPIRED; | 1037 return result && result.state !== this.PENDING && result.state !== this.
CANCELED && result.state != this.EXPIRED; |
| 1029 }, | 1038 }, |
| 1030 | 1039 |
| 1031 _wasNotPickedUp: function(result) { | 1040 _wasNotPickedUp: function(result) { |
| 1032 return result && !this._wasPickedUp(result); | 1041 return result && !this._wasPickedUp(result); |
| 1033 }, | 1042 }, |
| 1034 | 1043 |
| 1035 _whyPending: function() { | 1044 _similarLoad: function() { |
| 1036 if (!this._request || !this._result || !this._auth_headers) { | 1045 if (!this._request || !this._result || !this._auth_headers) { |
| 1037 return; | 1046 return; |
| 1038 } | 1047 } |
| 1039 var result = this._result; | 1048 var result = this._result; |
| 1040 var request = this._request; | 1049 var request = this._request; |
| 1041 var botCountParams = { | 1050 var botCountParams = { |
| 1042 dimensions: [] | 1051 dimensions: [] |
| 1043 }; | 1052 }; |
| 1044 var dims = (request.properties && request.properties.dimensions) || []; | 1053 var dims = (request.properties && request.properties.dimensions) || []; |
| 1045 dims.forEach(function(d){ | 1054 dims.forEach(function(d){ |
| 1046 botCountParams.dimensions.push(`${d.key}:${d.value}`); | 1055 botCountParams.dimensions.push(`${d.key}:${d.value}`); |
| 1047 }); | 1056 }); |
| 1048 this._getJsonAsync("_bots_count", "/api/swarming/v1/bots/count", "_busyB
otCount", this._auth_headers, botCountParams); | 1057 this._getJsonAsync("_bots_count", "/api/swarming/v1/bots/count", "_busyB
otCount", this._auth_headers, botCountParams); |
| 1049 | 1058 |
| 1050 if (result && result.state === "PENDING") { | 1059 var start = new Date(); |
| 1051 var start = new Date(); | 1060 start.setSeconds(0); |
| 1052 start.setSeconds(0); | 1061 // go back 24 hours, rounded to the nearest minute for better caching. |
| 1053 // go back 24 hours, rounded to the nearest minute for better caching. | 1062 start = "" + (start.getTime() - 24*60*60*1000); |
| 1054 start = "" + (start.getTime() - 24*60*60*1000); | 1063 // convert to seconds, because that's what the API expects. |
| 1055 // convert to seconds, because that's what the API expects. | 1064 start = start.substring(0, start.length-3); |
| 1056 start = start.substring(0, start.length-3); | |
| 1057 | 1065 |
| 1058 var taskCountParams = { | 1066 var taskCountParams = { |
| 1059 start: [start], | 1067 start: [start], |
| 1060 state: ["RUNNING"], | 1068 state: ["RUNNING"], |
| 1061 tags: botCountParams.dimensions, | 1069 tags: botCountParams.dimensions, |
| 1062 }; | 1070 }; |
| 1063 | 1071 |
| 1064 this._getJsonAsync("_other_running", "/api/swarming/v1/tasks/count", "
_busyRunningCount", this._auth_headers, taskCountParams); | 1072 this._getJsonAsync("_other_running", "/api/swarming/v1/tasks/count", "_b
usyRunningCount", this._auth_headers, taskCountParams); |
| 1065 // change running to pending | 1073 // change running to pending |
| 1066 taskCountParams.state = ["PENDING"]; | 1074 taskCountParams.state = ["PENDING"]; |
| 1067 this._getJsonAsync("_other_pending", "/api/swarming/v1/tasks/count", "
_busyPendingCount", this._auth_headers, taskCountParams); | 1075 this._getJsonAsync("_other_pending", "/api/swarming/v1/tasks/count", "_b
usyPendingCount", this._auth_headers, taskCountParams); |
| 1068 } | |
| 1069 } | 1076 } |
| 1070 }); | 1077 }); |
| 1071 })(); | 1078 })(); |
| 1072 </script> | 1079 </script> |
| 1073 </dom-module> | 1080 </dom-module> |
| OLD | NEW |