From d8296ce111336f8162cfeb1547161e5f538dcaf7 Mon Sep 17 00:00:00 2001 From: tomasz1986 Date: Thu, 3 Nov 2022 12:09:28 +0100 Subject: [PATCH] gui: Mark devices that haven't connected for a long time (fixes #7703) (#8530) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, a disconnected device is marked as "Disconnected" without any consideration whether the state is just temporary or rather it has been like that for a long time, potentially requiring user intervention. This commit adds a new state called "Disconnected (Inactive)" which is shown for devices that have been disconnected for longer than a week. It also changes the "Last seen" information, so that "Never" is used only when the device hasn't connected at all, and the exact date is displayed otherwise. Additionally, when the date is older than 1 week, a note about that is displayed below the date. Furthermore, when the date becomes older than 1 month, the note text colour changes to orange, and when it exceeds 1 year, the colour changes again to red. This is done to provide the user with a visual clue that something may potentially be wrong and requires a manual fix. Signed-off-by: Tomasz Wilczyński Co-authored-by: André Colomb --- gui/default/assets/lang/lang-en.json | 4 ++++ gui/default/index.html | 18 ++++++++++++++++-- .../syncthing/core/syncthingController.js | 13 ++++++++++--- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/gui/default/assets/lang/lang-en.json b/gui/default/assets/lang/lang-en.json index bd448ab47..ee135ce8c 100644 --- a/gui/default/assets/lang/lang-en.json +++ b/gui/default/assets/lang/lang-en.json @@ -101,6 +101,7 @@ "Disables comparing and syncing file permissions. Useful on systems with nonexistent or custom permissions (e.g. FAT, exFAT, Synology, Android).": "Disables comparing and syncing file permissions. Useful on systems with nonexistent or custom permissions (e.g. FAT, exFAT, Synology, Android).", "Discard": "Discard", "Disconnected": "Disconnected", + "Disconnected (Inactive)": "Disconnected (Inactive)", "Disconnected (Unused)": "Disconnected (Unused)", "Discovered": "Discovered", "Discovery": "Discovery", @@ -228,6 +229,9 @@ "Minimum Free Disk Space": "Minimum Free Disk Space", "Mod. Device": "Mod. Device", "Mod. Time": "Mod. Time", + "More than a month ago": "More than a month ago", + "More than a week ago": "More than a week ago", + "More than a year ago": "More than a year ago", "Move to top of queue": "Move to top of queue", "Multi level wildcard (matches multiple directory levels)": "Multi level wildcard (matches multiple directory levels)", "Never": "Never", diff --git a/gui/default/index.html b/gui/default/index.html index 59d348768..62f3eaef1 100644 --- a/gui/default/index.html +++ b/gui/default/index.html @@ -748,6 +748,7 @@ + @@ -767,8 +768,21 @@  Last seen - Never - {{deviceStats[deviceCfg.deviceID].lastSeen | date:"yyyy-MM-dd HH:mm:ss"}} + +
+ Never +
+
+
+ {{deviceStats[deviceCfg.deviceID].lastSeen | date:"yyyy-MM-dd HH:mm:ss"}} +
+
+ More than a week ago + More than a month ago + More than a year ago +
+
+  Sync Status diff --git a/gui/default/syncthing/core/syncthingController.js b/gui/default/syncthing/core/syncthingController.js index 4fe78e7ff..ed480a725 100755 --- a/gui/default/syncthing/core/syncthingController.js +++ b/gui/default/syncthing/core/syncthingController.js @@ -865,7 +865,9 @@ angular.module('syncthing.core') $scope.deviceStats = data; for (var device in $scope.deviceStats) { $scope.deviceStats[device].lastSeen = new Date($scope.deviceStats[device].lastSeen); - $scope.deviceStats[device].lastSeenDays = (new Date() - $scope.deviceStats[device].lastSeen) / 1000 / 86400; + if ($scope.deviceStats[device].lastSeen.toISOString() !== '1970-01-01T00:00:00.000Z') { + $scope.deviceStats[device].lastSeenDays = (new Date() - $scope.deviceStats[device].lastSeen) / 1000 / 86400; + } } console.log("refreshDeviceStats", data); }).error($scope.emitHTTPError); @@ -1073,8 +1075,9 @@ angular.module('syncthing.core') $scope.deviceStatus = function (deviceCfg) { var status = ''; + var unused = $scope.deviceFolders(deviceCfg).length === 0; - if ($scope.deviceFolders(deviceCfg).length === 0) { + if (unused) { status = 'unused-'; } @@ -1095,7 +1098,11 @@ angular.module('syncthing.core') } // Disconnected - return status + 'disconnected'; + if (!unused && $scope.deviceStats[deviceCfg.deviceID].lastSeenDays >= 7) { + return status + 'disconnected-inactive'; + } else { + return status + 'disconnected'; + } }; $scope.deviceClass = function (deviceCfg) {