| 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 --> | 6 --> |
| 7 <!DOCTYPE html> | 7 <!DOCTYPE html> |
| 8 <html> | 8 <html> |
| 9 <head> | 9 <head> |
| 10 <title>task-page Demo</title> | 10 <title>task-page Demo</title> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 return function(request){ | 36 return function(request){ |
| 37 if (!request.requestHeaders.authorization) { | 37 if (!request.requestHeaders.authorization) { |
| 38 sinon.log("You must be logged in (check your Oauth?)"); | 38 sinon.log("You must be logged in (check your Oauth?)"); |
| 39 request.respond(403, {}, "You must be logged in (check your Oauth?)"); | 39 request.respond(403, {}, "You must be logged in (check your Oauth?)"); |
| 40 return; | 40 return; |
| 41 } | 41 } |
| 42 sinon.log("User authenticated :) "+ request.requestHeaders.authorization
); | 42 sinon.log("User authenticated :) "+ request.requestHeaders.authorization
); |
| 43 sinon.log("Bot Request: "+sinon.format(request)); | 43 sinon.log("Bot Request: "+sinon.format(request)); |
| 44 // If the user changes bot id, show them some of the other sample data. | 44 // If the user changes bot id, show them some of the other sample data. |
| 45 var idx = request.url.indexOf("f00"); | 45 var idx = request.url.indexOf("f00"); |
| 46 var item = 0; | 46 if (idx ===-1) { |
| 47 if (idx !=-1) { | 47 request.respond(404, {}, "Not found"); |
| 48 var name = request.url.substring(idx+1, idx+4); | 48 return; |
| 49 item = parseInt(name) || 0; | |
| 50 name = Math.max(name - 1, 0); | |
| 51 name = Math.min(name, arr.length-1); | |
| 52 } | 49 } |
| 50 idx = request.url.substring(idx+1, idx+4); |
| 51 idx = parseInt(idx) || 0; |
| 52 idx = Math.max(idx - 1, 0); |
| 53 idx = Math.min(idx, arr.length-1); |
| 53 | 54 |
| 54 request.respond(200, {"Content-Type":"application/json"}, JSON.stringify
(arr[name])); | 55 |
| 56 request.respond(200, {"Content-Type":"application/json"}, JSON.stringify
(arr[idx])); |
| 55 } | 57 } |
| 56 } | 58 } |
| 57 | 59 |
| 58 | 60 |
| 59 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/task\/abcdef\d+\/reque
st.*/, genResponse(requests)); | 61 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/task\/abcdef\d+\/reque
st.*/, genResponse(requests)); |
| 60 server.respondWith("GET", /^\/api\/swarming\/v1\/task\/abcdef\d+\/request.*/
, genResponse(requests)); | 62 server.respondWith("GET", /^\/api\/swarming\/v1\/task\/abcdef\d+\/request.*/
, genResponse(requests)); |
| 61 | 63 |
| 62 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/task\/abcdef\d+\/resul
t.*/, genResponse(results)); | 64 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/task\/abcdef\d+\/resul
t.*/, genResponse(results)); |
| 63 server.respondWith("GET", /^\/api\/swarming\/v1\/task\/abcdef\d+\/result.*/,
genResponse(results)); | 65 server.respondWith("GET", /^\/api\/swarming\/v1\/task\/abcdef\d+\/result.*/,
genResponse(results)); |
| 64 | 66 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 100 |
| 99 server.respondWith("POST", /^\/_ah\/api\/swarming\/v1\/tasks\/new/, newTask)
; | 101 server.respondWith("POST", /^\/_ah\/api\/swarming\/v1\/tasks\/new/, newTask)
; |
| 100 server.respondWith("POST", /^\/api\/swarming\/v1\/tasks\/new/, newTask); | 102 server.respondWith("POST", /^\/api\/swarming\/v1\/tasks\/new/, newTask); |
| 101 </script> | 103 </script> |
| 102 | 104 |
| 103 <link rel="import" href="task-page.html"> | 105 <link rel="import" href="task-page.html"> |
| 104 </head> | 106 </head> |
| 105 <body> | 107 <body> |
| 106 | 108 |
| 107 <task-page | 109 <task-page |
| 108 task_id="abcdef001" | 110 task_id="abcdef000" |
| 109 client_id="20770472288-t5smpbpjptka4nd888fv0ctd23ftba2o.apps.googleusercontent
.com"> | 111 client_id="20770472288-t5smpbpjptka4nd888fv0ctd23ftba2o.apps.googleusercontent
.com"> |
| 110 </task-page> | 112 </task-page> |
| 111 | 113 |
| 112 </body> | 114 </body> |
| 113 </html> | 115 </html> |
| OLD | NEW |