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

Side by Side Diff: appengine/swarming/elements/res/js/alias.js

Issue 2269643002: Extract shared filters and aliasing code (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: Address nit 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
(Empty)
1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 this.swarming = this.swarming || {};
6 this.swarming.alias = this.swarming.alias || (function(){
7 var ANDROID_ALIASES = {
8 "bullhead": "Nexus 5X",
9 "flo": "Nexus 7 (2013)",
10 "flounder": "Nexus 9",
11 "foster": "NVIDIA Shield",
12 "fugu": "Nexus Player",
13 "grouper": "Nexus 7 (2012)",
14 "hammerhead": "Nexus 5",
15 "m0": "Galaxy S3",
16 "mako": "Nexus 4",
17 "manta": "Nexus 10",
18 "shamu": "Nexus 6",
19 "sprout": "Android One",
20 };
21
22 var UNKNOWN = "unknown";
23
24 var GPU_ALIASES = {
25 "1002": "AMD",
26 "1002:6779": "AMD Radeon HD 6450/7450/8450",
27 "1002:6821": "AMD Radeon HD 8870M",
28 "1002:683d": "AMD Radeon HD 7770/8760",
29 "1002:9830": "AMD Radeon HD 8400",
30 "102b": "Matrox",
31 "102b:0522": "Matrox MGA G200e",
32 "102b:0532": "Matrox MGA G200eW",
33 "102b:0534": "Matrox G200eR2",
34 "10de": "NVIDIA",
35 "10de:08a4": "NVIDIA GeForce 320M",
36 "10de:08aa": "NVIDIA GeForce 320M",
37 "10de:0fe9": "NVIDIA GeForce GT 750M Mac Edition",
38 "10de:104a": "NVIDIA GeForce GT 610",
39 "10de:11c0": "NVIDIA GeForce GTX 660",
40 "10de:1244": "NVIDIA GeForce GTX 550 Ti",
41 "10de:1401": "NVIDIA GeForce GTX 960",
42 "8086": "Intel",
43 "8086:0412": "Intel Haswell Integrated",
44 "8086:041a": "Intel Xeon Integrated",
45 "8086:0a2e": "Intel Haswell Integrated",
46 "8086:0d26": "Intel Crystal Well Integrated",
47 "8086:22b1": "Intel Braswell Integrated",
48 }
49
50 // For consistency, all aliases are displayed like:
51 // Nexus 5X (bullhead)
52 // This regex matches a string like "ALIAS (ORIG)", with ORIG as group 1.
53 var ALIAS_REGEXP = /.+ \((.*)\)/;
54
55 var alias = {};
56
57 alias.DIMENSIONS_WITH_ALIASES = ["device_type", "gpu"];
58
59 alias.android = function(dt) {
60 return ANDROID_ALIASES[dt] || UNKNOWN;
61 };
62
63 // alias.apply is the consistent way to modify a string to show its alias.
64 alias.apply = function(orig, alias) {
65 return alias +" ("+orig+")";
66 };
67
68 alias.gpu = function(gpu) {
69 return GPU_ALIASES[gpu] || UNKNOWN;
70 };
71
72 // alias.unapply will return the base dimension/state with its alias removed
73 // if it had one. This is handy for sorting and filtering.
74 alias.unapply = function(str) {
75 var match = ALIAS_REGEXP.exec(str);
76 if (match) {
77 return match[1];
78 }
79 return str;
80 };
81
82 return alias;
83 })();
OLDNEW
« no previous file with comments | « appengine/swarming/elements/res/imp/tasklist/task-list-demo.html ('k') | appengine/swarming/elements/res/js/common.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698