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

Unified Diff: appengine/swarming/elements/res/imp/common/common-behavior.html

Issue 2338383002: Refactor prior to adding task-page (Closed) Base URL: git@github.com:luci/luci-py@master
Patch Set: Tweak docs 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
Index: appengine/swarming/elements/res/imp/common/common-behavior.html
diff --git a/appengine/swarming/elements/res/imp/common/common-behavior.html b/appengine/swarming/elements/res/imp/common/common-behavior.html
index 76254a1ab1d51fec135169bf19aacd8bab98a269..b7dd0a4de629665ab5cd2e5bbde5429ba16c6e06 100644
--- a/appengine/swarming/elements/res/imp/common/common-behavior.html
+++ b/appengine/swarming/elements/res/imp/common/common-behavior.html
@@ -22,6 +22,13 @@
// This behavior wraps up all the shared swarming functionality.
SwarmingBehaviors.CommonBehavior = {
+ _botLink: function(bot_id) {
+ if (!bot_id) {
+ return undefined;
+ }
+ return "/newui/bot?id=" + bot_id;
+ },
+
// _getJsonAsync makes an XHR to a url, parses the response as JSON
// and sticks the resulting object into the property with the name given
// by "bindTo". If busy is defined, the property with that name will be
@@ -56,6 +63,10 @@
}.bind(this));
},
+ _humanDuration: function(timeInSecs) {
+ return sk.human.strDuration(timeInSecs) || "0s";
+ },
+
_not: function(a) {
return !a;
},
@@ -68,6 +79,35 @@
}
return result;
},
+
+ _taskLink: function(task_id) {
+ if (!task_id) {
+ return undefined;
+ }
+ return "/newui/task?id=" + task_id;
+ },
+
+ // timeDiffApprox returns the approximate difference between now and
stephana 2016/09/15 16:33:52 nit: should be _timeDiffApprox
kjlubick 2016/09/15 16:59:32 Done.
+ // the specified date.
+ _timeDiffApprox: function(date){
+ if (!date) {
+ return "eons";
+ }
+ return sk.human.diffDate(date.getTime());
+ },
+
+ // timeDiffExact returns the exact difference between the two specified
+ // dates. E.g. 2d 22h 22m 28s ago If a second date is not provided,
+ // now is used.
+ _timeDiffExact: function(first, second){
+ if (!first) {
+ return "eons";
+ }
+ if (!second) {
+ second = new Date();
+ }
+ return this._humanDuration((second.getTime() - first.getTime())/1000);
+ },
};
})();
</script>

Powered by Google App Engine
This is Rietveld 408576698