Skip to content

Commit

Permalink
gui: Mark devices that haven't connected for a long time (fixes synct…
Browse files Browse the repository at this point in the history
…hing#7703)

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 <twilczynski@naver.com>
  • Loading branch information
tomasz1986 committed Sep 19, 2022
1 parent 78be722 commit c87604e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 4 additions & 0 deletions gui/default/assets/lang/lang-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,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 (Stale)": "Disconnected (Stale)",
"Disconnected (Unused)": "Disconnected (Unused)",
"Discovered": "Discovered",
"Discovery": "Discovery",
Expand Down Expand Up @@ -222,6 +223,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",
Expand Down
18 changes: 16 additions & 2 deletions gui/default/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ <h4 class="panel-title">
<span ng-switch-when="paused"><span class="hidden-xs" translate>Paused</span><span class="visible-xs" aria-label="{{'Paused' | translate}}"><i class="fas fa-fw fa-pause"></i></span></span>
<span ng-switch-when="unused-paused"><span class="hidden-xs" translate>Paused (Unused)</span><span class="visible-xs" aria-label="{{'Paused (Unused)' | translate}}"><i class="fas fa-fw fa-unlink"></i></span></span>
<span ng-switch-when="disconnected"><span class="hidden-xs" translate>Disconnected</span><span class="visible-xs" aria-label="{{'Disconnected' | translate}}"><i class="fas fa-fw fa-power-off"></i></span></span>
<span ng-switch-when="disconnected-stale"><span class="hidden-xs" translate>Disconnected (Stale)</span><span class="visible-xs" aria-label="{{'Disconnected (Stale)' | translate}}"><i class="fas fa-fw fa-power-off"></i></span></span>
<span ng-switch-when="unused-disconnected"><span class="hidden-xs" translate>Disconnected (Unused)</span><span class="visible-xs" aria-label="{{'Disconnected (Unused)' | translate}}"><i class="fas fa-fw fa-unlink"></i></span></span>
</span>
<div class="panel-title-text">{{deviceName(deviceCfg)}}</div>
Expand All @@ -755,8 +756,21 @@ <h4 class="panel-title">
<tbody>
<tr ng-if="!connections[deviceCfg.deviceID].connected">
<th><span class="fas fa-fw fa-eye"></span>&nbsp;<span translate>Last seen</span></th>
<td translate ng-if="!deviceStats[deviceCfg.deviceID].lastSeenDays || deviceStats[deviceCfg.deviceID].lastSeenDays >= 365" class="text-right">Never</td>
<td ng-if="deviceStats[deviceCfg.deviceID].lastSeenDays < 365" class="text-right">{{deviceStats[deviceCfg.deviceID].lastSeen | date:"yyyy-MM-dd HH:mm:ss"}}</td>
<td class="text-right">
<div ng-if="!deviceStats[deviceCfg.deviceID].lastSeenDays" translate>
Never
</div>
<div ng-if="deviceStats[deviceCfg.deviceID].lastSeenDays">
<div>
{{deviceStats[deviceCfg.deviceID].lastSeen | date:"yyyy-MM-dd HH:mm:ss"}}
</div>
<div ng-if="deviceStats[deviceCfg.deviceID].lastSeenDays >= 7">
<i ng-if="deviceStats[deviceCfg.deviceID].lastSeenDays < 30" translate>More than a week ago</i>
<i class="text-warning" ng-if="deviceStats[deviceCfg.deviceID].lastSeenDays >= 30 && deviceStats[deviceCfg.deviceID].lastSeenDays < 365" translate>More than a month ago</i>
<i class="text-danger" ng-if="deviceStats[deviceCfg.deviceID].lastSeenDays >= 365" translate>More than a year ago</i>
</div>
</div>
</td>
</tr>
<tr ng-if="!connections[deviceCfg.deviceID].connected && deviceFolders(deviceCfg).length > 0">
<th><span class="fas fa-fw fa-cloud"></span>&nbsp;<span translate>Sync Status</span></th>
Expand Down
6 changes: 5 additions & 1 deletion gui/default/syncthing/core/syncthingController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,11 @@ angular.module('syncthing.core')
}

// Disconnected
return status + 'disconnected';
if ($scope.deviceStats[deviceCfg.deviceID].lastSeenDays >= 7) {
return 'disconnected-stale';
} else {
return status + 'disconnected';
}
};

$scope.deviceClass = function (deviceCfg) {
Expand Down

0 comments on commit c87604e

Please sign in to comment.