Skip to content

Commit

Permalink
gui: Use favicon as indication for status (fixes syncthing#1018)
Browse files Browse the repository at this point in the history
GitHub-Pull-Request: syncthing#3217
  • Loading branch information
norgeous authored and AudriusButkevicius committed Jun 1, 2016
1 parent 3b8ae33 commit 01ae866
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 1 deletion.
20 changes: 20 additions & 0 deletions assets/statusicons/default.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions assets/statusicons/notify.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions assets/statusicons/pause.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions assets/statusicons/sync.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui/default/assets/img/favicon-default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui/default/assets/img/favicon-notify.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui/default/assets/img/favicon-pause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui/default/assets/img/favicon-sync.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed gui/default/assets/img/favicon.png
Binary file not shown.
2 changes: 1 addition & 1 deletion gui/default/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="assets/img/favicon.png">
<link rel="shortcut icon" href="assets/img/favicon-{{syncthingStatus()}}.png">
<link rel="mask-icon" href="assets/img/safari-pinned-tab.svg" color="#0882c8">

<title ng-bind="thisDeviceName() + ' | Syncthing'"></title>
Expand Down
64 changes: 64 additions & 0 deletions gui/default/syncthing/core/syncthingController.js
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,70 @@ angular.module('syncthing.core')
return 'info';
};

$scope.syncthingStatus = function () {
var syncCount = 0;
var notifyCount = 0;
var pauseCount = 0;

// loop through all folders
var folderListCache = $scope.folderList();
for (var i = 0; i < folderListCache.length; i++) {
var status = $scope.folderStatus(folderListCache[i]);
switch (status) {
case 'syncing':
syncCount++;
break;
case 'stopped':
case 'unknown':
case 'outofsync':
case 'error':
notifyCount++;
break;
}
}

// loop through all devices
var deviceCount = $scope.devices.length;
for (var i = 0; i < $scope.devices.length; i++) {
var status = $scope.deviceStatus({
deviceID:$scope.devices[i].deviceID
});
switch (status) {
case 'unknown':
notifyCount++;
break;
case 'paused':
pauseCount++;
break;
case 'unused':
deviceCount--;
break;
}
}

// enumerate notifications
if ($scope.openNoAuth || !$scope.configInSync || Object.keys($scope.deviceRejections).length > 0 || Object.keys($scope.folderRejections).length > 0 || $scope.errorList().length > 0 || !online) {
notifyCount++;
}

// at least one folder is syncing
if (syncCount > 0) {
return 'sync';
}

// a device is unknown or a folder is stopped/unknown/outofsync/error or some other notification is open or gui offline
if (notifyCount > 0) {
return 'notify';
}

// all used devices are paused except (this) one
if (pauseCount === deviceCount-1) {
return 'pause';
}

return 'default';
};

$scope.deviceAddr = function (deviceCfg) {
var conn = $scope.connections[deviceCfg.deviceID];
if (conn && conn.connected) {
Expand Down

0 comments on commit 01ae866

Please sign in to comment.