| 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>bot-page Demo</title> | 10 <title>bot-page Demo</title> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 var genResponse = function(arr) { | 33 var genResponse = function(arr) { |
| 34 return function(request){ | 34 return function(request){ |
| 35 if (!request.requestHeaders.authorization) { | 35 if (!request.requestHeaders.authorization) { |
| 36 sinon.log("You must be logged in (check your Oauth?)"); | 36 sinon.log("You must be logged in (check your Oauth?)"); |
| 37 request.respond(403, {}, "You must be logged in (check your Oauth?)"); | 37 request.respond(403, {}, "You must be logged in (check your Oauth?)"); |
| 38 return; | 38 return; |
| 39 } | 39 } |
| 40 sinon.log("User authenticated :) "+ request.requestHeaders.authorization
); | 40 sinon.log("User authenticated :) "+ request.requestHeaders.authorization
); |
| 41 sinon.log("Bot Request: "+sinon.format(request)); | 41 sinon.log("Bot Request: "+sinon.format(request)); |
| 42 // TODO(kjlubick)make this return a thing from the list | 42 // If the user changes bot id, show them some of the other sample data. |
| 43 request.respond(200, {"Content-Type":"application/json"}, JSON.stringify
(arr[0])); | 43 var idx = request.url.indexOf("-00"); |
| 44 var item = 0; |
| 45 if (idx !=-1) { |
| 46 var name = request.url.substring(idx+1, idx+4); |
| 47 item = parseInt(name) || 0; |
| 48 name = Math.max(name - 1, 0); |
| 49 name = Math.min(name, arr.length-1); |
| 50 } |
| 51 |
| 52 |
| 53 request.respond(200, {"Content-Type":"application/json"}, JSON.stringify
(arr[name])); |
| 44 } | 54 } |
| 45 } | 55 } |
| 46 | 56 |
| 47 | 57 |
| 48 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/bot\/test-bot-\d+\/get
.*/, genResponse(bots)); | 58 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/bot\/test-bot-\d+\/get
.*/, genResponse(bots)); |
| 49 server.respondWith("GET", /^\/api\/swarming\/v1\/bot\/test-bot-\d+\/get.*/,
genResponse(bots)); | 59 server.respondWith("GET", /^\/api\/swarming\/v1\/bot\/test-bot-\d+\/get.*/,
genResponse(bots)); |
| 50 | 60 |
| 51 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/bot\/test-bot-\d+\/eve
nts.*/, genResponse(events)); | 61 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/bot\/test-bot-\d+\/eve
nts.*/, genResponse(events)); |
| 52 server.respondWith("GET", /^\/api\/swarming\/v1\/bot\/test-bot-\d+\/events.*
/, genResponse(events)); | 62 server.respondWith("GET", /^\/api\/swarming\/v1\/bot\/test-bot-\d+\/events.*
/, genResponse(events)); |
| 53 | 63 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 74 <body> | 84 <body> |
| 75 | 85 |
| 76 <bot-page | 86 <bot-page |
| 77 bot_id="test-bot-001" | 87 bot_id="test-bot-001" |
| 78 client_id="20770472288-t5smpbpjptka4nd888fv0ctd23ftba2o.apps.googleusercontent
.com" | 88 client_id="20770472288-t5smpbpjptka4nd888fv0ctd23ftba2o.apps.googleusercontent
.com" |
| 79 > | 89 > |
| 80 </bot-page> | 90 </bot-page> |
| 81 | 91 |
| 82 </body> | 92 </body> |
| 83 </html> | 93 </html> |
| OLD | NEW |