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

Side by Side Diff: appengine/swarming/elements/res/imp/botlist/bot-list-shared.html

Issue 2227803002: Mirror filters and sort preferences to url-params (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@use-dimensions
Patch Set: Tweak docs Created 4 years, 4 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 window.SwarmingBehaviors.BotListBehavior contains any shared functions and 6 window.SwarmingBehaviors.BotListBehavior contains any shared functions and
7 constants used by the bot-list and its sub-elements. 7 constants used by the bot-list and its sub-elements.
8 8
9 To use it, include 9 To use it, include
10 behaviors: [SwarmingBehaviors.BotListBehavior] 10 behaviors: [SwarmingBehaviors.BotListBehavior]
11 in the creation of your Polymer element. 11 in the creation of your Polymer element.
12 --> 12 -->
13 <script> 13 <script>
14 14
15 window.SwarmingBehaviors = window.SwarmingBehaviors || {}; 15 window.SwarmingBehaviors = window.SwarmingBehaviors || {};
16 (function(){ 16 (function(){
17 var ANDROID_ALIASES = { 17 var ANDROID_ALIASES = {
18 "bullhead": "Nexus 5X", 18 "bullhead": "Nexus 5X",
19 "flo": "Nexus 7", 19 "flo": "Nexus 7 (2013)",
20 "flounder": "Nexus 9", 20 "flounder": "Nexus 9",
21 "foster": "NVIDIA Shield",
22 "fugu": "Nexus Player",
23 "grouper": "Nexus 7 (2012)",
21 "hammerhead": "Nexus 5", 24 "hammerhead": "Nexus 5",
25 "m0": "Galaxy S3",
22 "mako": "Nexus 4", 26 "mako": "Nexus 4",
27 "manta": "Nexus 10",
23 "shamu": "Nexus 6", 28 "shamu": "Nexus 6",
29 "sprout": "Android One",
24 }; 30 };
25 // Taken from http://developer.android.com/reference/android/os/BatteryManag er.html 31 // Taken from http://developer.android.com/reference/android/os/BatteryManag er.html
26 var BATTERY_HEALTH_UNKNOWN = 1; 32 var BATTERY_HEALTH_UNKNOWN = 1;
27 var BATTERY_HEALTH_GOOD = 2; 33 var BATTERY_HEALTH_GOOD = 2;
28 var BATTERY_STATUS_CHARGING = 2; 34 var BATTERY_STATUS_CHARGING = 2;
29 35
30 var UNAUTHENTICATED = "unauthenticated"; 36 var UNAUTHENTICATED = "unauthenticated";
31 var AVAILABLE = "available"; 37 var AVAILABLE = "available";
32 var UNKNOWN = "unknown"; 38 var UNKNOWN = "unknown";
33 39
34 var GPU_ALIASES = { 40 var GPU_ALIASES = {
35 "1002": "AMD", 41 "1002": "AMD",
36 "1002:6779": "AMD Radeon HD 6450/7450/8450", 42 "1002:6779": "AMD Radeon HD 6450/7450/8450",
37 "1002:6821": "AMD Radeon HD 8870M", 43 "1002:6821": "AMD Radeon HD 8870M",
44 "1002:683d": "AMD Radeon HD 7770/8760",
38 "1002:9830": "AMD Radeon HD 8400", 45 "1002:9830": "AMD Radeon HD 8400",
39 "102b": "Matrox", 46 "102b": "Matrox",
40 "102b:0522": "Matrox MGA G200e", 47 "102b:0522": "Matrox MGA G200e",
41 "102b:0532": "Matrox MGA G200eW", 48 "102b:0532": "Matrox MGA G200eW",
42 "102b:0534": "Matrox G200eR2", 49 "102b:0534": "Matrox G200eR2",
43 "10de": "NVIDIA", 50 "10de": "NVIDIA",
51 "10de:08a4": "NVIDIA GeForce 320M",
44 "10de:08aa": "NVIDIA GeForce 320M", 52 "10de:08aa": "NVIDIA GeForce 320M",
45 "10de:0fe9": "NVIDIA GeForce GT 750M Mac Edition", 53 "10de:0fe9": "NVIDIA GeForce GT 750M Mac Edition",
46 "10de:104a": "NVIDIA GeForce GT 610", 54 "10de:104a": "NVIDIA GeForce GT 610",
47 "10de:11c0": "NVIDIA GeForce GTX 660", 55 "10de:11c0": "NVIDIA GeForce GTX 660",
48 "10de:1244": "NVIDIA GeForce GTX 550 Ti", 56 "10de:1244": "NVIDIA GeForce GTX 550 Ti",
49 "10de:1401": "NVIDIA GeForce GTX 960", 57 "10de:1401": "NVIDIA GeForce GTX 960",
50 "8086": "Intel", 58 "8086": "Intel",
59 "8086:0412": "Intel Haswell Integrated",
51 "8086:041a": "Intel Xeon Integrated", 60 "8086:041a": "Intel Xeon Integrated",
52 "8086:0a2e": "Intel Haswell Integrated", 61 "8086:0a2e": "Intel Haswell Integrated",
53 "8086:0d26": "Intel Crystal Well Integrated", 62 "8086:0d26": "Intel Crystal Well Integrated",
63 "8086:22b1": "Intel Braswell Integrated",
54 } 64 }
55 65
56 // For consistency, all aliases are displayed like: 66 // For consistency, all aliases are displayed like:
57 // Nexus 5X (bullhead) 67 // Nexus 5X (bullhead)
58 // This regex matches a string like "ALIAS (ORIG)", with ORIG as group 1. 68 // This regex matches a string like "ALIAS (ORIG)", with ORIG as group 1.
59 var ALIAS_REGEXP = /.+ \((.*)\)/; 69 var ALIAS_REGEXP = /.+ \((.*)\)/;
60 70
61 // This behavior wraps up all the shared bot-list functionality. 71 // This behavior wraps up all the shared bot-list functionality.
62 SwarmingBehaviors.BotListBehavior = { 72 SwarmingBehaviors.BotListBehavior = {
63 73
64 properties: { 74 properties: {
65 // TODO(kjlubick): Add more of these things from state, as they
66 // needed/useful/requested.
67 DIMENSIONS: {
68 type: Array,
69 value: function(){
70 return ["android_devices", "cores", "cpu", "device_type",
71 "device_os", "gpu", "id", "os", "pool"];
72 },
73 },
74 DIMENSIONS_WITH_ALIASES: { 75 DIMENSIONS_WITH_ALIASES: {
75 type: Array, 76 type: Array,
76 value: function(){ 77 value: function(){
77 return ["device_type", "gpu"]; 78 return ["device_type", "gpu"];
78 }, 79 },
79 }, 80 },
80 BOT_PROPERTIES: { 81 BOT_PROPERTIES: {
81 type: Array, 82 type: Array,
82 value: function() { 83 value: function() {
84 // TODO(kjlubick): Add more of these things from state, as they
85 // needed/useful/requested.
83 return ["disk_space", "task", "status"]; 86 return ["disk_space", "task", "status"];
84 } 87 }
85 }, 88 },
86 }, 89 },
87 90
88 _androidAlias: function(dt) { 91 _androidAlias: function(dt) {
89 return ANDROID_ALIASES[dt] || UNKNOWN; 92 return ANDROID_ALIASES[dt] || UNKNOWN;
90 }, 93 },
91 94
92 // _applyAlias is the consistent way to modify a string to show its alias. 95 // _applyAlias is the consistent way to modify a string to show its alias.
(...skipping 10 matching lines...) Expand all
103 }, 106 },
104 107
105 _devices: function(bot) { 108 _devices: function(bot) {
106 var devices = []; 109 var devices = [];
107 var d = (bot && bot.state && bot.state.devices) || {}; 110 var d = (bot && bot.state && bot.state.devices) || {};
108 // state.devices is like {Serial:Object}, so we need to keep the serial 111 // state.devices is like {Serial:Object}, so we need to keep the serial
109 for (key in d) { 112 for (key in d) {
110 var o = d[key]; 113 var o = d[key];
111 o.serial = key; 114 o.serial = key;
112 o.okay = (o.state === AVAILABLE); 115 o.okay = (o.state === AVAILABLE);
116 // It is easier to assume all devices on a bot are of the same type
117 // than to pick through the (incomplete) device state and find it.
118 o.device_type = this._attribute(bot, "device_type")[0];
113 devices.push(o); 119 devices.push(o);
114 } 120 }
115 return devices; 121 return devices;
116 }, 122 },
117 123
118 // _deviceType returns the codename of a given Android device. 124 // _deviceType returns the codename of a given Android device.
119 _deviceType: function(device) { 125 _deviceType: function(device) {
120 if (!device || !device.build) { 126 return device.device_type.toLowerCase();
121 return UNKNOWN;
122 }
123 var t = device.build["build.product"] || device.build["product.board"] | |
124 device.build["product.device"] || UNKNOWN;
125 return t.toLowerCase();
126 }, 127 },
127 128
128 // _dimension returns the given dimension of a bot. If it is defined, it 129 // _dimension returns the given dimension of a bot. If it is defined, it
129 // is an array of strings. 130 // is an array of strings.
130 _dimension: function(bot, dim) { 131 _dimension: function(bot, dim) {
131 if (!bot || !bot.dimensions || !dim) { 132 if (!bot || !bot.dimensions || !dim) {
132 return undefined; 133 return undefined;
133 } 134 }
134 for (var i = 0; i < bot.dimensions.length; i++) { 135 for (var i = 0; i < bot.dimensions.length; i++) {
135 if (bot.dimensions[i].key === dim) { 136 if (bot.dimensions[i].key === dim) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 _unalias: function(str) { 183 _unalias: function(str) {
183 var match = ALIAS_REGEXP.exec(str); 184 var match = ALIAS_REGEXP.exec(str);
184 if (match) { 185 if (match) {
185 return match[1]; 186 return match[1];
186 } 187 }
187 return str; 188 return str;
188 }, 189 },
189 } 190 }
190 })() 191 })()
191 </script> 192 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698