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

Unified Diff: appengine/swarming/elements/res/js/alias.js

Issue 2408743002: Move elements/ to ui/ (Closed)
Patch Set: rebase again Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: appengine/swarming/elements/res/js/alias.js
diff --git a/appengine/swarming/elements/res/js/alias.js b/appengine/swarming/elements/res/js/alias.js
deleted file mode 100644
index 980f34ade6b68a11981b37f533aa9fff48289c37..0000000000000000000000000000000000000000
--- a/appengine/swarming/elements/res/js/alias.js
+++ /dev/null
@@ -1,138 +0,0 @@
-// Copyright 2016 The LUCI Authors. All rights reserved.
-// Use of this source code is governed under the Apache License, Version 2.0
-// that can be found in the LICENSE file.
-
-// TODO(kjlubick): add tests for this code
-
-this.swarming = this.swarming || {};
-this.swarming.alias = this.swarming.alias || (function(){
- var ANDROID_ALIASES = {
- "angler": "Nexus 6p",
- "bullhead": "Nexus 5X",
- "flo": "Nexus 7 (2013)",
- "flounder": "Nexus 9",
- "foster": "NVIDIA Shield",
- "fugu": "Nexus Player",
- "grouper": "Nexus 7 (2012)",
- "hammerhead": "Nexus 5",
- "heroqlteatt": "Galaxy S7",
- "m0": "Galaxy S3",
- "mako": "Nexus 4",
- "manta": "Nexus 10",
- "shamu": "Nexus 6",
- "sprout": "Android One",
- };
-
- var UNKNOWN = "unknown";
-
- var GPU_ALIASES = {
- "1002": "AMD",
- "1002:6779": "AMD Radeon HD 6450/7450/8450",
- "1002:6821": "AMD Radeon HD 8870M",
- "1002:683d": "AMD Radeon HD 7770/8760",
- "1002:9830": "AMD Radeon HD 8400",
- "102b": "Matrox",
- "102b:0522": "Matrox MGA G200e",
- "102b:0532": "Matrox MGA G200eW",
- "102b:0534": "Matrox G200eR2",
- "10de": "NVIDIA",
- "10de:08a4": "NVIDIA GeForce 320M",
- "10de:08aa": "NVIDIA GeForce 320M",
- "10de:0fe9": "NVIDIA GeForce GT 750M Mac Edition",
- "10de:104a": "NVIDIA GeForce GT 610",
- "10de:11c0": "NVIDIA GeForce GTX 660",
- "10de:1244": "NVIDIA GeForce GTX 550 Ti",
- "10de:1401": "NVIDIA GeForce GTX 960",
- "8086": "Intel",
- "8086:0412": "Intel Haswell Integrated",
- "8086:041a": "Intel Xeon Integrated",
- "8086:0a2e": "Intel Haswell Integrated",
- "8086:0d26": "Intel Crystal Well Integrated",
- "8086:22b1": "Intel Braswell Integrated",
- }
-
- // Taken from http://developer.android.com/reference/android/os/BatteryManager.html
- var BATTERY_HEALTH_ALIASES = {
- 1: "Unknown",
- 2: "Good",
- 3: "Overheated",
- 4: "Dead",
- 5: "Over Voltage",
- 6: "Unspecified Failure",
- 7: "Too Cold",
- }
-
- var BATTERY_STATUS_ALIASES = {
- 1: "Unknown",
- 2: "Charging",
- 3: "Discharging",
- 4: "Not Charging",
- 5: "Full",
- }
-
- // For consistency, all aliases are displayed like:
- // Nexus 5X (bullhead)
- // This regex matches a string like "ALIAS (ORIG)", with ORIG as group 1.
- var ALIAS_REGEXP = /.+ \((.*)\)/;
-
- var alias = {};
-
- alias.DIMENSIONS_WITH_ALIASES = ["device_type", "gpu", "battery_health"];
-
- alias.android = function(dt) {
- return ANDROID_ALIASES[dt] || UNKNOWN;
- };
-
- alias.battery_health = function(bh) {
- return BATTERY_HEALTH_ALIASES[bh] || UNKNOWN;
- };
-
- alias.battery_status = function(bs) {
- return BATTERY_STATUS_ALIASES[bs] || UNKNOWN;
- };
-
- // alias.apply tries to alias the string "orig" based on what "type" it is.
- // If type is in DIMENSIONS_WITH_ALIASES, the appropriate alias (e.g. gpu)
- // is automatically applied. Otherwise, "type" is treated as the alias.
- // If type is known, but there is no matching alias (e.g. for gpu: FOOBAR)
- // the original will be returned.
- alias.apply = function(orig, type) {
- var aliaser = aliasMap[type];
- if (!aliaser) {
- // treat type as the actual alias
- return type + " ("+orig+")";
- }
- var alias = aliaser(orig);
- if (alias !== UNKNOWN) {
- return alias + " ("+orig+")";
- }
- return orig;
- };
-
- alias.has = function(type) {
- return !!aliasMap[type];
- };
-
- alias.gpu = function(gpu) {
- return GPU_ALIASES[gpu] || UNKNOWN;
- };
-
- // alias.unapply will return the base dimension/state with its alias removed
- // if it had one. This is handy for sorting and filtering.
- alias.unapply = function(str) {
- var match = ALIAS_REGEXP.exec(str);
- if (match) {
- return match[1];
- }
- return str;
- };
-
- var aliasMap = {
- "device_type": alias.android,
- "gpu": alias.gpu,
- "battery_health": alias.battery_health,
- "battery_status": alias.battery_status,
- }
-
- return alias;
-})();
« no previous file with comments | « appengine/swarming/elements/res/imp/taskpage/task-page-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