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

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

Issue 2306103002: Add aliases to bot-page and refactor duplicated code (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@fix-buttons
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/swarming/elements/res/imp/tasklist/task-list-data.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index f07faaa79ee013779b63ccdaa14a338061064196..6d4081fe4f0fec2268f34ab3b7c8e0c4d6cd1a77 100644
--- a/appengine/swarming/elements/res/js/alias.js
+++ b/appengine/swarming/elements/res/js/alias.js
@@ -60,9 +60,22 @@ this.swarming.alias = this.swarming.alias || (function(){
return ANDROID_ALIASES[dt] || UNKNOWN;
};
- // alias.apply is the consistent way to modify a string to show its alias.
- alias.apply = function(orig, alias) {
- return alias +" ("+orig+")";
+ // 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.gpu = function(gpu) {
@@ -79,5 +92,10 @@ this.swarming.alias = this.swarming.alias || (function(){
return str;
};
+ var aliasMap = {
+ "device_type": alias.android,
+ "gpu": alias.gpu,
+ }
+
return alias;
})();
« no previous file with comments | « appengine/swarming/elements/res/imp/tasklist/task-list-data.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698