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

Side by Side Diff: appengine/swarming/elements/res/imp/botpage/bot-page-demo.html

Issue 2283133002: Add bot-page stubs (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: Makefile should download demo json Created 4 years, 3 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
OLDNEW
(Empty)
1 <!--
2 Copyright 2016 The LUCI Authors. All rights reserved.
3 Use of this source code is governed under the Apache License, Version 2.0
4 that can be found in the LICENSE file.
5
6 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
10 <title>bot-page Demo</title>
11 <meta charset="utf-8">
12 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
13 <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial- scale=1, user-scalable=yes">
14 <script src="../bower_components/webcomponentsjs/webcomponents-lite.js"></scri pt>
15 <script src="../../../node_modules/skia-common-js/common.js"></script>
16 <script src="/res/js/common.js"></script>
17 <script src="/res/js/alias.js"></script>
18 <script src="../../../node_modules/sinon/pkg/sinon-1.17.5.js"></script>
19 <!-- Makes a var called bots. It's an array of things that could be returned- ->
20 <script type="text/javascript" src="bot-demo.json"></script>
21 <!-- Makes a var called events. It's an array of things that could be returne d-->
22 <script type="text/javascript" src="bot-events-demo.json"></script>
23 <!-- Makes a var called tasks. It's an array of things that could be returned -->
24 <script type="text/javascript" src="bot-tasks-demo.json"></script>
25
26 <script type="text/javascript" charset="utf-8">
27 sinon.format = function(object) {return JSON.stringify(object);}
28 sinon.log = function(message) {console.log(message);};
29 var server = sinon.fakeServer.create();
30 server.autoRespond = true;
31 //server.autoRespondAfter = 2000;
32
33 var genResponse = function(arr) {
34 return function(request){
35 if (!request.requestHeaders.authorization) {
36 sinon.log("You must be logged in (check your Oauth?)");
37 request.respond(403, {}, "You must be logged in (check your Oauth?)");
38 return;
39 }
40 sinon.log("User authenticated :) "+ request.requestHeaders.authorization );
41 sinon.log("Bot Request: "+sinon.format(request));
42 // TODO(kjlubick)make this return a thing from the list
43 request.respond(200, {"Content-Type":"application/json"}, JSON.stringify (arr[0]));
44 }
45 }
46
47
48 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));
50
51 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));
53
54 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/bot\/test-bot-\d+\/tas ks.*/, genResponse(tasks));
55 server.respondWith("GET", /^\/api\/swarming\/v1\/bot\/test-bot-\d+\/tasks.*/ , genResponse(tasks));
56
57 var permissions = {
58 cancel_task: true,
59 delete_bot: true,
60 terminate_bot: true,
61 };
62 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/server\/permissions/, JSON.stringify(permissions));
63 server.respondWith("GET", /^\/api\/swarming\/v1\/server\/permissions/, JSON. stringify(permissions));
64
65 var details = {
66 server_version: "1234-deadbeef",
67 };
68 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/server\/details/, JSON .stringify(details));
69 server.respondWith("GET", /^\/api\/swarming\/v1\/server\/details/, JSON.stri ngify(details));
70 </script>
71
72 <link rel="import" href="bot-page.html">
73 </head>
74 <body>
75
76 <bot-page
77 bot_id="test-bot-001"
78 client_id="20770472288-t5smpbpjptka4nd888fv0ctd23ftba2o.apps.googleusercontent .com"
79 >
80 </bot-page>
81
82 </body>
83 </html>
OLDNEW
« no previous file with comments | « appengine/swarming/elements/res/imp/botpage/bot-page-data.html ('k') | appengine/swarming/templates/public_bot_index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698