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

Side by Side Diff: appengine/swarming/ui/res/imp/common/common-behavior.html

Issue 2553563003: Link Swarming Tasklist and Botlist together (Closed)
Patch Set: Rebuild Created 4 years 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 It contains the definition of the following Behaviors: 6 It contains the definition of the following Behaviors:
7 7
8 SwarmingBehaviors.CommonBehavior 8 SwarmingBehaviors.CommonBehavior
9 9
10 To use it, include 10 To use it, include
(...skipping 12 matching lines...) Expand all
23 SwarmingBehaviors.CommonBehavior = { 23 SwarmingBehaviors.CommonBehavior = {
24 24
25 _botLink: function(bot_id) { 25 _botLink: function(bot_id) {
26 if (!bot_id) { 26 if (!bot_id) {
27 return undefined; 27 return undefined;
28 } 28 }
29 return "/bot?id=" + bot_id; 29 return "/bot?id=" + bot_id;
30 }, 30 },
31 31
32 // Create a link to a bot list with the preloaded filters and columns. 32 // Create a link to a bot list with the preloaded filters and columns.
33 // filters should be an array of {key:String, value:String} and 33 // filters - Array<Object> or Array<String>. If Array<Object>, Object
34 // columns should be an array of Strings. 34 // should be {key:String, value:String} or
35 // {key:String, value:Array<String>}. If Array<String>, the Strings
36 // should be valid filters (e.g. "foo:bar").
37 // columns - Array<String> , the the column names that should be shown.
35 _botListLink: function(filters, columns) { 38 _botListLink: function(filters, columns) {
36 filters = filters || []; 39 filters = filters || [];
37 columns = columns || []; 40 columns = columns || [];
38 var fArr = []; 41 var fArr = [];
39 filters.forEach(function(f){ 42 filters.forEach(function(f){
40 fArr.push(f.key + ":" + f.value); 43 if (f.key && f.value) {
44 if (Array.isArray(f.value)) {
45 f.value.forEach(function(v) {
46 fArr.push(f.key + ":" + v);
47 });
48 } else {
49 fArr.push(f.key + ":" + f.value);
50 }
51 } else {
52 fArr.push(f);
53 }
41 }); 54 });
42 var obj = { 55 var obj = {
43 f: fArr, 56 f: fArr,
44 c: columns, 57 c: columns,
45 } 58 }
46 return "/botlist?" + sk.query.fromParamSet(obj); 59 return "/botlist?" + sk.query.fromParamSet(obj);
47 }, 60 },
48 61
49 // Create a link to a bot in Google Cloud Console. Cloud console will try 62 // Create a link to a bot in Google Cloud Console. Cloud console will try
50 // to find the bot in the last project the user was logged in as, which 63 // to find the bot in the last project the user was logged in as, which
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // task abcefgh0 is the "canonical" task id. The first try has the id 188 // task abcefgh0 is the "canonical" task id. The first try has the id
176 // abcefgh1. If there is a second (transparent retry), it will be 189 // abcefgh1. If there is a second (transparent retry), it will be
177 // abcefgh2. We almost always want to link to the canonical one, 190 // abcefgh2. We almost always want to link to the canonical one,
178 // because the milo output (if any) will only be generated for 191 // because the milo output (if any) will only be generated for
179 // abcefgh0, not abcefgh1 or abcefgh2. 192 // abcefgh0, not abcefgh1 or abcefgh2.
180 taskId = taskId.substring(0, taskId.length - 1) + "0"; 193 taskId = taskId.substring(0, taskId.length - 1) + "0";
181 } 194 }
182 return "/task?id=" + taskId; 195 return "/task?id=" + taskId;
183 }, 196 },
184 197
198 // Create a link to a task list with the preloaded filters and columns.
199 // filters - Array<Object> or Array<String>. If Array<Object>, Object
200 // should be {key:String, value:String} or
201 // {key:String, value:Array<String>}. If Array<String>, the Strings
202 // should be valid filters (e.g. "foo:bar").
203 // columns - Array<String> , the the column names that should be shown.
204 _taskListLink: function(filters, columns) {
205 filters = filters || [];
206 columns = columns || [];
207 var fArr = [];
208 filters.forEach(function(f){
209 if (f.key && f.value) {
210 if (Array.isArray(f.value)) {
211 f.value.forEach(function(v) {
212 fArr.push(f.key + ":" + v);
213 });
214 } else {
215 fArr.push(f.key + ":" + f.value);
216 }
217 } else {
218 fArr.push(f);
219 }
220 });
221 var obj = {
222 f: fArr,
223 c: columns,
224 }
225 return "/tasklist?" + sk.query.fromParamSet(obj);
226 },
227
185 // _timeDiffApprox returns the approximate difference between now and 228 // _timeDiffApprox returns the approximate difference between now and
186 // the specified date. 229 // the specified date.
187 _timeDiffApprox: function(date){ 230 _timeDiffApprox: function(date){
188 if (!date) { 231 if (!date) {
189 return "eons"; 232 return "eons";
190 } 233 }
191 return sk.human.diffDate(date.getTime()); 234 return sk.human.diffDate(date.getTime());
192 }, 235 },
193 236
194 // timeDiffExact returns the exact difference between the two specified 237 // timeDiffExact returns the exact difference between the two specified
195 // dates. E.g. 2d 22h 22m 28s ago If a second date is not provided, 238 // dates. E.g. 2d 22h 22m 28s ago If a second date is not provided,
196 // now is used. 239 // now is used.
197 _timeDiffExact: function(first, second){ 240 _timeDiffExact: function(first, second){
198 if (!first) { 241 if (!first) {
199 return "eons"; 242 return "eons";
200 } 243 }
201 if (!second) { 244 if (!second) {
202 second = new Date(); 245 second = new Date();
203 } 246 }
204 return this._humanDuration((second.getTime() - first.getTime())/1000); 247 return this._humanDuration((second.getTime() - first.getTime())/1000);
205 }, 248 },
206 249
207 _truthy: function(a){ 250 _truthy: function(a){
208 return !!a; 251 return !!a;
209 } 252 }
210 }; 253 };
211 })(); 254 })();
212 </script> 255 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698