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

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

Issue 2696613007: Add the ability to filter by time to task list. (Closed)
Patch Set: Add lots of docs and rework setDate Created 3 years, 10 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
« no previous file with comments | « appengine/swarming/ui/res/imp/tasklist/task-list-demo.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!-- 1 <!--
2 This in an HTML Import-able file that contains the definition 2 This in an HTML Import-able file that contains the definition
3 of the following elements: 3 of the following elements:
4 4
5 <task-list-summary> 5 <task-list-summary>
6 6
7 Usage: 7 Usage:
8 8
9 <task-list-summary></task-list-summary> 9 <task-list-summary></task-list-summary>
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 <table> 70 <table>
71 <thead> 71 <thead>
72 <th class="header right" colspan=2>Selected</th> 72 <th class="header right" colspan=2>Selected</th>
73 </thead> 73 </thead>
74 <tr> 74 <tr>
75 <td class="right"> 75 <td class="right">
76 Displayed: 76 Displayed:
77 </td> 77 </td>
78 <td class="left">[[num_tasks]]</td> 78 <td class="left">[[num_tasks]]</td>
79 </tr> 79 </tr>
80 <tr title="By default, these counts are from the last 24 hours"> 80 <tr title="These counts reflect the time period selected">
81 <td class="right" > 81 <td class="right" >
82 Total: 82 Total:
83 </td> 83 </td>
84 <td class="left">[[_selected_exact.count]]</td> 84 <td class="left">[[_selected_exact.count]]</td>
85 </tr> 85 </tr>
86 <template is="dom-repeat" items="[[_selected_summary]]" as="item" inde x-as="idx"> 86 <template is="dom-repeat" items="[[_selected_summary]]" as="item" inde x-as="idx">
87 <tr title="By default, these counts are from the last 24 hours"> 87 <tr title="These counts reflect the time period selected">
88 <td class="right"> 88 <td class="right">
89 <a href$="[[_makeURL(item.name,'true',columns.*,sort)]]">[[item. human]]</a>: 89 <a href$="[[_makeURL(item.name,'true',columns.*,sort,count_param s.*)]]">[[item.human]]</a>:
90 </td> 90 </td>
91 <td class="left">[[_idx(_selected_counts, idx, _selected_counts.*) ]]</td> 91 <td class="left">[[_idx(_selected_counts, idx, _selected_counts.*) ]]</td>
92 </tr> 92 </tr>
93 </template> 93 </template>
94 </table> 94 </table>
95 </div> 95 </div>
96 96
97 <div class="left column"> 97 <div class="left column">
98 <table> 98 <table>
99 <thead> 99 <thead>
100 <!-- TODO(kjlubick) when user can update time, use the human readabl e value instead of 12h-->
101 <th class="header right" colspan=2>All Tasks in last 24h</th> 100 <th class="header right" colspan=2>All Tasks in last 24h</th>
102 </thead> 101 </thead>
103 <template is="dom-repeat" items="[[_all_summary]]" as="item" index-as= "idx"> 102 <template is="dom-repeat" items="[[_all_summary]]" as="item" index-as= "idx">
104 <tr title="By default, this is the last 24 hours"> 103 <tr title="These counts are all from the last 24 hours">
105 <td class="right"> 104 <td class="right">
106 <a href$="[[_makeURL(item.name,'',columns.*,sort)]]">[[item.huma n]]</a>: 105 <a href$="[[_makeURL(item.name,'',columns.*,sort)]]">[[item.huma n]]</a>:
107 </td> 106 </td>
108 <td class="left">[[_idx(_all_counts, idx, _all_counts.*)]]</td> 107 <td class="left">[[_idx(_all_counts, idx, _all_counts.*)]]</td>
109 </tr> 108 </tr>
110 </template> 109 </template>
111 </table> 110 </table>
112 </div> 111 </div>
113 112
114 </div> 113 </div>
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 _idx: function(obj, idx) { 234 _idx: function(obj, idx) {
236 return obj && obj[idx] && obj[idx].count; 235 return obj && obj[idx] && obj[idx].count;
237 }, 236 },
238 237
239 // Recount all the task counts. This will make use of _getJsonAsyncArr bec ause 238 // Recount all the task counts. This will make use of _getJsonAsyncArr bec ause
240 // the results will be generated in a dom-repeat. 239 // the results will be generated in a dom-repeat.
241 _recountEverything: function() { 240 _recountEverything: function() {
242 if (!this.auth_headers || !this.count_params) { 241 if (!this.auth_headers || !this.count_params) {
243 return; 242 return;
244 } 243 }
244 // We round 24 hours ago down to the nearest minute to mirror what
245 // the UI can select. Additionally, this may allow for easier
246 // server-side caching.
247 var now = new Date();
248 now.setSeconds(0);
249 now.setMilliseconds(0);
245 // convert to seconds because API uses seconds. 250 // convert to seconds because API uses seconds.
246 var now = (new Date()).getTime()/1000; 251 var last24hrs = now.getTime()/1000 - 24 * 60 * 60;
247 var last2Days = now - 24 * 60 * 60;
248
249 // TODO(kjlubick): Once users can specify their own times, respect those limits here.
250 252
251 var queryObj = { 253 var queryObj = {
252 start: [last2Days], 254 start: [last24hrs],
253 }; 255 };
254 256 // ALL_TASKS summary is always the last 24 hours
255 for (var i = 0; i < ALL_TASKS_SUMMARY.length; i++) { 257 for (var i = 0; i < ALL_TASKS_SUMMARY.length; i++) {
256 if (this._all_counts.length < ALL_TASKS_SUMMARY.length) { 258 if (this._all_counts.length < ALL_TASKS_SUMMARY.length) {
257 this.push("_all_counts", {}); 259 this.push("_all_counts", {});
258 } 260 }
259 queryObj.state = [ALL_TASKS_SUMMARY[i].name]; 261 queryObj.state = [ALL_TASKS_SUMMARY[i].name];
260 this._getJsonAsyncArr(i, "_all_counts","/api/swarming/v1/tasks/count", "_busyArr1", 262 this._getJsonAsyncArr(i, "_all_counts","/api/swarming/v1/tasks/count", "_busyArr1",
261 this.auth_headers, queryObj); 263 this.auth_headers, queryObj);
262 } 264 }
263 265
264 queryObj = JSON.parse(JSON.stringify(this.count_params)); 266 queryObj = JSON.parse(JSON.stringify(this.count_params));
265 queryObj.start = [last2Days];
266 this._getJsonAsync("_selected_exact","/api/swarming/v1/tasks/count","_bu sy3", 267 this._getJsonAsync("_selected_exact","/api/swarming/v1/tasks/count","_bu sy3",
267 this.auth_headers, queryObj); 268 this.auth_headers, queryObj);
268 269
269 for (var j = 0; j < SELECTED_TASKS_SUMMARY.length; j++) { 270 for (var j = 0; j < SELECTED_TASKS_SUMMARY.length; j++) {
270 if (this._selected_counts.length < SELECTED_TASKS_SUMMARY.length) { 271 if (this._selected_counts.length < SELECTED_TASKS_SUMMARY.length) {
271 this.push("_selected_counts", {}); 272 this.push("_selected_counts", {});
272 } 273 }
273 queryObj.state = [SELECTED_TASKS_SUMMARY[j].name]; 274 queryObj.state = [SELECTED_TASKS_SUMMARY[j].name];
274 this._getJsonAsyncArr(j, "_selected_counts","/api/swarming/v1/tasks/co unt","_busyArr2", 275 this._getJsonAsyncArr(j, "_selected_counts","/api/swarming/v1/tasks/co unt","_busyArr2",
275 this.auth_headers, queryObj); 276 this.auth_headers, queryObj);
276 } 277 }
277 }, 278 },
278 279
279 // _makeURL creates a task-list url that keeps the columns and sort requir ements the same 280 // _makeURL creates a task-list url that keeps the columns and sort requir ements the same
280 // while changing which state is represented. The preserveOthers signifies if other 281 // while changing which state is represented. The preserveOthers signifies if other
281 // filtering parameters (e.g. tags) should be kept as well. 282 // filtering parameters (e.g. tags) should be kept as well.
282 _makeURL: function(state, preserveOthers) { 283 _makeURL: function(state, preserveOthers) {
283 var fstr = "state:"+state; 284 var fstr = "state:"+state;
284 if (preserveOthers) { 285 var cp = this.count_params;
285 var fstr = encodeURIComponent(fstr);
286 var url = window.location.href;
287 if (url.indexOf(fstr+"&") !== -1) {
288 // The state filter is already on the list.
289 return undefined;
290 }
291 if (url.indexOf("f=state") === -1) {
292 return url + "&f=" + fstr;
293 }
294 // Things can't be in multiple states at once - so replace it.
295 // %3A is url encoded colon (:)
296 return url.replace(/f=state%3A[A-Z_]+/, `f=state%3A${fstr}`);
297 }
298 var params = { 286 var params = {
299 s: [this.sort], 287 s: [this.sort],
300 c: this.columns, 288 c: this.columns,
289 f: [],
290 }
291 if (cp.start && cp.start[0]) {
292 // timestamps gleaned from count_params are in seconds, so we convert back to ms.
293 params.st = [cp.start[0] + "000"];
294 }
295 if (cp.end && cp.end[0]) {
296 // timestamps gleaned from count_params are in seconds, so we convert back to ms.
297 params.et = [cp.end[0] + "000"];
298 } else {
299 params.n = [true];
301 } 300 }
302 if (state) { 301 if (state) {
303 params["f"] = [fstr]; 302 params.f.push(fstr);
303 }
304 if (preserveOthers && cp.tags) {
305 cp.tags.forEach(function(t){
306 params.f.push(t);
307 });
308 }
309 if (!preserveOthers) {
310 params.n = [true];
304 } 311 }
305 312
306 return window.location.href.split('?')[0] + '?' + sk.query.fromParamSet( params); 313 return window.location.href.split('?')[0] + '?' + sk.query.fromParamSet( params);
307 }, 314 },
308 315
309 }); 316 });
310 })(); 317 })();
311 </script> 318 </script>
312 </dom-module> 319 </dom-module>
OLDNEW
« no previous file with comments | « appengine/swarming/ui/res/imp/tasklist/task-list-demo.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698