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

Unified Diff: remoting/webapp/crd/js/host_table_entry.js

Issue 882463003: Basic webapp UI for host-offline-reason. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« remoting/resources/remoting_strings.grd ('K') | « remoting/webapp/crd/js/host.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/crd/js/host_table_entry.js
diff --git a/remoting/webapp/crd/js/host_table_entry.js b/remoting/webapp/crd/js/host_table_entry.js
index edea77078da5d6684af2bbf6c1e2482bdde90ab4..0e159a87df5636f1d7ede2bd969c286ae5d17331 100644
--- a/remoting/webapp/crd/js/host_table_entry.js
+++ b/remoting/webapp/crd/js/host_table_entry.js
@@ -314,6 +314,25 @@ remoting.HostTableEntry.prototype.removeEditBox_ = function() {
};
/**
+ * Formats host's updateTime value relative to current time (i.e. only
+ * displaying hours and minutes if updateTime is less than a day in the past).
+ * @param {string} updateTime RFC 3339 formatted date-time value.
+ * @return {string} Formatted value (i.e. 11/11/2014)
+ */
+function formatUpdateTime(/** number */ updateTime) {
+ var lastOnline = new Date(updateTime);
+ var now = new Date();
+ var displayString = '';
+ if (now.getFullYear() == lastOnline.getFullYear() &&
+ now.getMonth() == lastOnline.getMonth() &&
+ now.getDate() == lastOnline.getDate()) {
+ return lastOnline.toLocaleTimeString();
+ } else {
+ return lastOnline.toLocaleDateString();
+ }
+}
+
+/**
* Create the DOM nodes and event handlers for the hostname cell.
* @return {void} Nothing.
* @private
@@ -340,19 +359,28 @@ remoting.HostTableEntry.prototype.setHostName_ = function() {
};
hostNameNode.addEventListener('keydown', onKeyDown, false);
} else {
- if (this.host.updatedTime) {
- var lastOnline = new Date(this.host.updatedTime);
- var now = new Date();
- var displayString = '';
- if (now.getFullYear() == lastOnline.getFullYear() &&
- now.getMonth() == lastOnline.getMonth() &&
- now.getDate() == lastOnline.getDate()) {
- displayString = lastOnline.toLocaleTimeString();
- } else {
- displayString = lastOnline.toLocaleDateString();
+ if (this.host.hostOfflineReason) {
+ var formattedTime = formatUpdateTime(this.host.updatedTime);
+ hostNameNode.innerText = chrome.i18n.getMessage(
+ /*i18n-content*/'LAST_OFFLINE_REASON',
+ [this.host.hostName, formattedTime]);
+ var detailsText = chrome.i18n.getMessage(
+ 'OFFLINE_REASON_' +
+ this.host.hostOfflineReason + '_GENERATED_AT_RUNTIME',
Jamie 2015/02/07 00:46:46 Rather than constructing this tag programmatically
Łukasz Anforowicz 2015/02/09 19:21:58 Good idea. Done.
+ [this.host.hostName, formattedTime]);
+ if (!detailsText) {
+ detailsText = chrome.i18n.getMessage(
+ /*i18n-content*/'OFFLINE_REASON_UNKNOWN',
+ [this.host.hostOfflineReason, formattedTime]);
Jamie 2015/02/07 00:46:46 The time is already included in the status string.
Łukasz Anforowicz 2015/02/09 19:21:58 Ok - removed.
}
+ // TODO(lukasza): Put detailsText into a hideable div (title/tooltip
+ // is not as discoverable + doesn't work well for touchscreens).
+ hostNameNode.title = detailsText;
+ }
+ else if (this.host.updatedTime) {
+ var formattedTime = formatUpdateTime(this.host.updatedTime);
hostNameNode.innerText = chrome.i18n.getMessage(
- /*i18n-content*/'LAST_ONLINE', [this.host.hostName, displayString]);
+ /*i18n-content*/'LAST_ONLINE', [this.host.hostName, formattedTime]);
} else {
hostNameNode.innerText = chrome.i18n.getMessage(
/*i18n-content*/'OFFLINE', this.host.hostName);
« remoting/resources/remoting_strings.grd ('K') | « remoting/webapp/crd/js/host.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698