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

Side by Side Diff: appengine/swarming/ui/res/imp/botlist/bot-list-demo.html

Issue 2883493002: Add UI to mass delete dead bots (Closed)
Patch Set: Refresh list after Done is tapped Created 3 years, 7 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
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-list Demo</title> 10 <title>bot-list Demo</title>
11 <meta charset="utf-8"> 11 <meta charset="utf-8">
12 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 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"> 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> 14 <script src="../bower_components/webcomponentsjs/webcomponents-lite.js"></scri pt>
15 <script src="../../../node_modules/skia-common-js/common.js"></script> 15 <script src="../../../node_modules/skia-common-js/common.js"></script>
16 <script src="../../../build/js/natural-sort.js"></script> 16 <script src="../../../build/js/natural-sort.js"></script>
17 <script src="/res/js/common.js"></script> 17 <script src="/res/js/common.js"></script>
18 <script src="/res/js/alias.js"></script> 18 <script src="/res/js/alias.js"></script>
19 <script src="../../../node_modules/sinon/pkg/sinon-1.17.5.js"></script> 19 <script src="../../../node_modules/sinon/pkg/sinon-1.17.5.js"></script>
20 <!-- Makes a var called data--> 20 <!-- Makes a var called data-->
21 <script type="text/javascript" src="bot-list-demo.json"></script> 21 <script type="text/javascript" src="bot-list-demo.json"></script>
22 <!-- Makes a var called fleetData--> 22 <!-- Makes a var called fleetData-->
23 <script type="text/javascript" src="bot-list-fleet-data-demo.json"></script> 23 <script type="text/javascript" src="bot-list-fleet-data-demo.json"></script>
24 24
25 <script type="text/javascript" charset="utf-8"> 25 <script type="text/javascript" charset="utf-8">
26 sinon.format = function(object) {return JSON.stringify(object);} 26 sinon.format = function(object) {return JSON.stringify(object);}
27 sinon.log = function(message) {console.log(message);}; 27 sinon.log = function(message) {console.log(message);};
28 var server = sinon.fakeServer.create(); 28 var server = sinon.fakeServer.create();
29 server.autoRespond = true; 29 server.autoRespond = true;
30 //server.autoRespondAfter = 2000; 30 server.autoRespondAfter = 1300;
31 31
32 var respond = function(request){ 32 var respond = function(request){
33 if (!request.requestHeaders.authorization) { 33 if (!request.requestHeaders.authorization) {
34 sinon.log("You must be logged in (check your Oauth?)"); 34 sinon.log("You must be logged in (check your Oauth?)");
35 request.respond(403, {}, "You must be logged in (check your Oauth?)"); 35 request.respond(403, {}, "You must be logged in (check your Oauth?)");
36 return; 36 return;
37 } 37 }
38 sinon.log("User authenticated :) "+ request.requestHeaders.authorization); 38 sinon.log("User authenticated :) "+ request.requestHeaders.authorization);
39 sinon.log("List Request: "+sinon.format(request)); 39 sinon.log("List Request: "+sinon.format(request));
40 request.respond(200, {"Content-Type":"application/json"}, JSON.stringify(d ata)); 40 if (request.url.indexOf("is_dead") > 0) {
41 // pretend there are 5 bots to delete
42 request.respond(200, {"Content-Type":"application/json"}, JSON.stringify ({
43 items:data.items.slice(0, 5),
44 }));
45 } else {
46 request.respond(200, {"Content-Type":"application/json"}, JSON.stringify (data));
47 }
48
41 } 49 }
42 50
43 server.respondWith("GET", /^\/api\/swarming\/v1\/bots\/list.*/, respond); 51 server.respondWith("GET", /^\/api\/swarming\/v1\/bots\/list.*/, respond);
44 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/bots\/list.*/, respond ); 52 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/bots\/list.*/, respond );
45 53
46 var mockFleetSummary = { 54 var mockFleetSummary = {
47 "count": "2625", 55 "count": "2625",
48 "busy": "531", 56 "busy": "531",
49 "now": "2016-08-01T17:21:07.239940", 57 "now": "2016-08-01T17:21:07.239940",
50 "dead": "22", 58 "dead": "22",
51 "quarantined": "15", 59 "quarantined": "15",
52 "kind": "swarming#botsItem", 60 "kind": "swarming#botsItem",
53 "etag": "\"nhThK35uIVdvx1_Mr5DChu_DyBs/aO8fy5IdESDx-fy3If19oDKu0f0\"" 61 "etag": "\"nhThK35uIVdvx1_Mr5DChu_DyBs/aO8fy5IdESDx-fy3If19oDKu0f0\""
54 }; 62 };
55 63
56 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/bots\/count/, JSON.str ingify(mockFleetSummary)); 64 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/bots\/count$/, JSON.st ringify(mockFleetSummary));
57 server.respondWith("GET", /^\/api\/swarming\/v1\/bots\/count/, JSON.stringif y(mockFleetSummary)); 65 server.respondWith("GET", /^\/api\/swarming\/v1\/bots\/count$/, JSON.stringi fy(mockFleetSummary));
58 66
59 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/bots\/dimensions/, JSO N.stringify(fleetData)); 67 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/bots\/dimensions/, JSO N.stringify(fleetData));
60 server.respondWith("GET", /^\/api\/swarming\/v1\/bots\/dimensions/, JSON.str ingify(fleetData)); 68 server.respondWith("GET", /^\/api\/swarming\/v1\/bots\/dimensions/, JSON.str ingify(fleetData));
61 69
62 var details = { 70 var details = {
63 server_version: "1234-deadbeef", 71 server_version: "1234-deadbeef",
64 bot_version: "ec524892ac1cd0748b88c2271371df51402f3daf", 72 bot_version: "ec524892ac1cd0748b88c2271371df51402f3daf",
65 machine_provider_template: "http://example.com#/leases/%s?foo=bar", 73 machine_provider_template: "http://example.com#/leases/%s?foo=bar",
66 }; 74 };
67 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/server\/details/, JSON .stringify(details)); 75 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/server\/details/, JSON .stringify(details));
68 server.respondWith("GET", /^\/api\/swarming\/v1\/server\/details/, JSON.stri ngify(details)); 76 server.respondWith("GET", /^\/api\/swarming\/v1\/server\/details/, JSON.stri ngify(details));
69 77
70 var count = { 78 var count = {
79 count: 25,
80 busy: 0,
81 dead: 5,
82 quarantined: 0,
83 }
84 server.respondWith("GET", /^\/api\/swarming\/v1\/bots\/count\?is_dead=TRUE.* /, JSON.stringify(count));
85
86 count = {
71 count: 905, 87 count: 905,
72 busy: 581, 88 busy: 581,
73 dead: 10, 89 dead: 10,
74 quarantined: 0, 90 quarantined: 0,
75 } 91 }
76 server.respondWith("GET", /^\/api\/swarming\/v1\/bots\/count.*/, JSON.string ify(count)); 92 server.respondWith("GET", /^\/api\/swarming\/v1\/bots\/count\?[^i].*/, JSON. stringify(count));
93
94 var permissions = {
95 delete_bot: true
96 };
97 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/server\/permissions/, JSON.stringify(permissions));
98 server.respondWith("GET", /^\/api\/swarming\/v1\/server\/permissions/, JSON. stringify(permissions));
99
100 var deleteRequest = function(request) {
101 console.log("Deleting", request);
102 if (!request.requestHeaders.authorization) {
103 sinon.log("You must be logged in (check your Oauth?)");
104 request.respond(403, {}, "You must be logged in (check your Oauth?)");
105 return;
106 }
107 request.respond(200, {}, "Bot has been deleted.");
108 }
109
110 server.respondWith("POST", /^\/_ah\/api\/swarming\/v1\/bot\/.+\/delete/, del eteRequest);
111 server.respondWith("POST", /^\/api\/swarming\/v1\/bot\/.+\/delete/, deleteRe quest);
77 </script> 112 </script>
78 113
79 <link rel="import" href="bot-list.html"> 114 <link rel="import" href="bot-list.html">
80 </head> 115 </head>
81 <body> 116 <body>
82 117
83 <bot-list 118 <bot-list
84 client_id="20770472288-t5smpbpjptka4nd888fv0ctd23ftba2o.apps.googleusercontent .com"> 119 client_id="20770472288-t5smpbpjptka4nd888fv0ctd23ftba2o.apps.googleusercontent .com">
85 </bot-list> 120 </bot-list>
86 121
87 </body> 122 </body>
88 </html> 123 </html>
OLDNEW
« no previous file with comments | « appengine/swarming/ui/res/imp/botlist/bot-list.html ('k') | appengine/swarming/ui/res/imp/botlist/bot-mass-delete.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698