Skip to content

Commit

Permalink
gui: Sort folders and devices on status (#fixes 5044)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bahadir Yilmaz committed Oct 8, 2018
1 parent f12ca95 commit 5f48488
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 40 deletions.
4 changes: 2 additions & 2 deletions gui/default/index.html
Expand Up @@ -299,7 +299,7 @@ <h3 class="panel-title">
<div class="col-md-6" aria-labelledby="folder_list" role="region" >
<h3 id="folder_list" translate>Folders</h3>
<div class="panel-group" id="folders">
<div class="panel panel-default" ng-repeat="folder in folderList()">
<div class="panel panel-default" ng-repeat="folder in guiShowFolderList()">
<button class="btn panel-heading" data-toggle="collapse" data-parent="#folders" data-target="#folder-{{$index}}" aria-expanded="false">
<div class="panel-progress" ng-show="folderStatus(folder) == 'syncing'" ng-attr-style="width: {{syncPercentage(folder.id) | percent}}"></div>
<div class="panel-progress" ng-show="folderStatus(folder) == 'scanning' && scanProgress[folder.id] != undefined" ng-attr-style="width: {{scanPercentage(folder.id) | percent}}"></div>
Expand Down Expand Up @@ -627,7 +627,7 @@ <h4 class="panel-title">
<!-- Remote devices -->
<h3 translate>Remote Devices</h3>
<div class="panel-group" id="devices">
<div class="panel panel-default" ng-repeat="deviceCfg in otherDevices()">
<div class="panel panel-default" ng-repeat="deviceCfg in guiShowOtherDevices()">
<button class="btn panel-heading" data-toggle="collapse" data-parent="#devices" data-target="#device-{{$index}}" aria-expanded="false">
<div class="panel-progress" ng-show="deviceStatus(deviceCfg) == 'syncing'" ng-attr-style="width: {{completion[deviceCfg.deviceID]._total | percent}}"></div>
<h4 class="panel-title">
Expand Down
119 changes: 119 additions & 0 deletions gui/default/syncthing/core/syncthingController.js
Expand Up @@ -395,6 +395,8 @@ angular.module('syncthing.core')
&& guiCfg.authMode !== 'ldap'
&& !guiCfg.insecureAdminAccess;

$scope.statusSort = $scope.config.options.folderDeviceSortByStatus;

if (!hasConfig) {
$scope.$emit('ConfigLoaded');
}
Expand Down Expand Up @@ -1508,6 +1510,60 @@ angular.module('syncthing.core')
});
};

$scope.statusOtherDevices = function () {
var unknownArray = [], unusedArray = [], pausedArray = [], insyncArray = [], disconnectedArray = [], defaultArray =[];

// loop through all devices
var devices = $scope.otherDevices();
var deviceLength = devices.length;
for (var i = 0; i < deviceLength; i++) {
var status = $scope.deviceStatus({
deviceID:$scope.devices[i].deviceID
});

switch (status){
case 'unused':
unusedArray.push(devices[i]);
break;

case 'unknown':
unknownArray.push(devices[i]);
break;

case 'paused':
pausedArray.push(devices[i]);
break;

case 'insync' || 'syncing':
insyncArray.push(devices[i]);
break;

case 'disconnected':
disconnectedArray.push(devices[i]);
break;

default:
defaultArray.push(devices[i]);
}
};

return unknownArray.concat(insyncArray, disconnectedArray, pausedArray, unusedArray, defaultArray);
};

$scope.guiShowOtherDevices = function () {
if($scope.statusSort == 'undefined'){
return $timeout(function () {
if ($scope.statusSort){return $scope.statusOtherDevices();}
return $scope.otherDevices();
}, 1000);
} else {
if ($scope.statusSort){
return $scope.statusOtherDevices();
}
return $scope.otherDevices();
}
};

$scope.thisDevice = function () {
for (var i = 0; i < $scope.devices.length; i++) {
var n = $scope.devices[i];
Expand Down Expand Up @@ -1559,6 +1615,69 @@ angular.module('syncthing.core')
return folderList($scope.folders);
};

$scope.statusFolderList = function () {
var unknownArray = [], idleArray = [], pausedArray = [], syncingArray = [];
var stoppedArray = [], unsharedArray = [], defaultArray = [];

// loop through all folders
var folders = $scope.folderList();
for (var i = 0; i < folders.length; i++) {
var status = $scope.folderStatus(folders[i]);

switch (status){
case 'idle':
idleArray.push(folders[i]);
break;

case 'paused':
pausedArray.push(folders[i]);
break;

case 'syncing' || 'scanning':
syncingArray.push(folders[i]);
break;

case 'unknown':
unknownArray.push(folders[i]);
break;

case 'stopped' || 'outofsync' || 'error':
stoppedArray.push(folders[i]);
break;

case 'unshared':
unsharedArray.push(folders[i]);
break;

default:
defaultArray.push(folders[i]);
}
};

idleArray = folderList(idleArray)
pausedArray = folderList(pausedArray)
syncingArray = folderList(syncingArray)
unknownArray = folderList(unknownArray)
stoppedArray = folderList(stoppedArray)
unsharedArray = folderList(unsharedArray)
defaultArray = folderList(defaultArray)
return unknownArray.concat(idleArray, pausedArray, unsharedArray, syncingArray, stoppedArray, defaultArray);
};

$scope.guiShowFolderList = function (){
if($scope.statusSort == 'undefined'){
return $timeout(function () {
if ($scope.statusSort){return $scope.statusFolderList();}
return $scope.folderList();
}, 1000);
} else {
if ($scope.statusSort){
return $scope.statusFolderList();
}
return $scope.folderList();
}
};

$scope.directoryList = [];

$scope.$watch('currentFolder.path', function (newvalue) {
Expand Down
77 changes: 39 additions & 38 deletions lib/config/optionsconfiguration.go
Expand Up @@ -13,44 +13,45 @@ import (
)

type OptionsConfiguration struct {
ListenAddresses []string `xml:"listenAddress" json:"listenAddresses" default:"default"`
GlobalAnnServers []string `xml:"globalAnnounceServer" json:"globalAnnounceServers" json:"globalAnnounceServer" default:"default" restart:"true"`
GlobalAnnEnabled bool `xml:"globalAnnounceEnabled" json:"globalAnnounceEnabled" default:"true" restart:"true"`
LocalAnnEnabled bool `xml:"localAnnounceEnabled" json:"localAnnounceEnabled" default:"true" restart:"true"`
LocalAnnPort int `xml:"localAnnouncePort" json:"localAnnouncePort" default:"21027" restart:"true"`
LocalAnnMCAddr string `xml:"localAnnounceMCAddr" json:"localAnnounceMCAddr" default:"[ff12::8384]:21027" restart:"true"`
MaxSendKbps int `xml:"maxSendKbps" json:"maxSendKbps"`
MaxRecvKbps int `xml:"maxRecvKbps" json:"maxRecvKbps"`
ReconnectIntervalS int `xml:"reconnectionIntervalS" json:"reconnectionIntervalS" default:"60"`
RelaysEnabled bool `xml:"relaysEnabled" json:"relaysEnabled" default:"true"`
RelayReconnectIntervalM int `xml:"relayReconnectIntervalM" json:"relayReconnectIntervalM" default:"10"`
StartBrowser bool `xml:"startBrowser" json:"startBrowser" default:"true"`
NATEnabled bool `xml:"natEnabled" json:"natEnabled" default:"true"`
NATLeaseM int `xml:"natLeaseMinutes" json:"natLeaseMinutes" default:"60"`
NATRenewalM int `xml:"natRenewalMinutes" json:"natRenewalMinutes" default:"30"`
NATTimeoutS int `xml:"natTimeoutSeconds" json:"natTimeoutSeconds" default:"10"`
URAccepted int `xml:"urAccepted" json:"urAccepted"` // Accepted usage reporting version; 0 for off (undecided), -1 for off (permanently)
URSeen int `xml:"urSeen" json:"urSeen"` // Report which the user has been prompted for.
URUniqueID string `xml:"urUniqueID" json:"urUniqueId"` // Unique ID for reporting purposes, regenerated when UR is turned on.
URURL string `xml:"urURL" json:"urURL" default:"https://data.syncthing.net/newdata"`
URPostInsecurely bool `xml:"urPostInsecurely" json:"urPostInsecurely" default:"false"` // For testing
URInitialDelayS int `xml:"urInitialDelayS" json:"urInitialDelayS" default:"1800"`
RestartOnWakeup bool `xml:"restartOnWakeup" json:"restartOnWakeup" default:"true" restart:"true"`
AutoUpgradeIntervalH int `xml:"autoUpgradeIntervalH" json:"autoUpgradeIntervalH" default:"12" restart:"true"` // 0 for off
UpgradeToPreReleases bool `xml:"upgradeToPreReleases" json:"upgradeToPreReleases" restart:"true"` // when auto upgrades are enabled
KeepTemporariesH int `xml:"keepTemporariesH" json:"keepTemporariesH" default:"24"` // 0 for off
CacheIgnoredFiles bool `xml:"cacheIgnoredFiles" json:"cacheIgnoredFiles" default:"false" restart:"true"`
ProgressUpdateIntervalS int `xml:"progressUpdateIntervalS" json:"progressUpdateIntervalS" default:"5"`
LimitBandwidthInLan bool `xml:"limitBandwidthInLan" json:"limitBandwidthInLan" default:"false"`
MinHomeDiskFree Size `xml:"minHomeDiskFree" json:"minHomeDiskFree" default:"1 %"`
ReleasesURL string `xml:"releasesURL" json:"releasesURL" default:"https://upgrades.syncthing.net/meta.json" restart:"true"`
AlwaysLocalNets []string `xml:"alwaysLocalNet" json:"alwaysLocalNets"`
OverwriteRemoteDevNames bool `xml:"overwriteRemoteDeviceNamesOnConnect" json:"overwriteRemoteDeviceNamesOnConnect" default:"false"`
TempIndexMinBlocks int `xml:"tempIndexMinBlocks" json:"tempIndexMinBlocks" default:"10"`
UnackedNotificationIDs []string `xml:"unackedNotificationID" json:"unackedNotificationIDs"`
TrafficClass int `xml:"trafficClass" json:"trafficClass"`
DefaultFolderPath string `xml:"defaultFolderPath" json:"defaultFolderPath" default:"~"`
SetLowPriority bool `xml:"setLowPriority" json:"setLowPriority" default:"true"`
ListenAddresses []string `xml:"listenAddress" json:"listenAddresses" default:"default"`
GlobalAnnServers []string `xml:"globalAnnounceServer" json:"globalAnnounceServers" json:"globalAnnounceServer" default:"default" restart:"true"`
GlobalAnnEnabled bool `xml:"globalAnnounceEnabled" json:"globalAnnounceEnabled" default:"true" restart:"true"`
LocalAnnEnabled bool `xml:"localAnnounceEnabled" json:"localAnnounceEnabled" default:"true" restart:"true"`
LocalAnnPort int `xml:"localAnnouncePort" json:"localAnnouncePort" default:"21027" restart:"true"`
LocalAnnMCAddr string `xml:"localAnnounceMCAddr" json:"localAnnounceMCAddr" default:"[ff12::8384]:21027" restart:"true"`
MaxSendKbps int `xml:"maxSendKbps" json:"maxSendKbps"`
MaxRecvKbps int `xml:"maxRecvKbps" json:"maxRecvKbps"`
ReconnectIntervalS int `xml:"reconnectionIntervalS" json:"reconnectionIntervalS" default:"60"`
RelaysEnabled bool `xml:"relaysEnabled" json:"relaysEnabled" default:"true"`
RelayReconnectIntervalM int `xml:"relayReconnectIntervalM" json:"relayReconnectIntervalM" default:"10"`
StartBrowser bool `xml:"startBrowser" json:"startBrowser" default:"true"`
NATEnabled bool `xml:"natEnabled" json:"natEnabled" default:"true"`
NATLeaseM int `xml:"natLeaseMinutes" json:"natLeaseMinutes" default:"60"`
NATRenewalM int `xml:"natRenewalMinutes" json:"natRenewalMinutes" default:"30"`
NATTimeoutS int `xml:"natTimeoutSeconds" json:"natTimeoutSeconds" default:"10"`
URAccepted int `xml:"urAccepted" json:"urAccepted"` // Accepted usage reporting version; 0 for off (undecided), -1 for off (permanently)
URSeen int `xml:"urSeen" json:"urSeen"` // Report which the user has been prompted for.
URUniqueID string `xml:"urUniqueID" json:"urUniqueId"` // Unique ID for reporting purposes, regenerated when UR is turned on.
URURL string `xml:"urURL" json:"urURL" default:"https://data.syncthing.net/newdata"`
URPostInsecurely bool `xml:"urPostInsecurely" json:"urPostInsecurely" default:"false"` // For testing
URInitialDelayS int `xml:"urInitialDelayS" json:"urInitialDelayS" default:"1800"`
RestartOnWakeup bool `xml:"restartOnWakeup" json:"restartOnWakeup" default:"true" restart:"true"`
AutoUpgradeIntervalH int `xml:"autoUpgradeIntervalH" json:"autoUpgradeIntervalH" default:"12" restart:"true"` // 0 for off
UpgradeToPreReleases bool `xml:"upgradeToPreReleases" json:"upgradeToPreReleases" restart:"true"` // when auto upgrades are enabled
KeepTemporariesH int `xml:"keepTemporariesH" json:"keepTemporariesH" default:"24"` // 0 for off
CacheIgnoredFiles bool `xml:"cacheIgnoredFiles" json:"cacheIgnoredFiles" default:"false" restart:"true"`
ProgressUpdateIntervalS int `xml:"progressUpdateIntervalS" json:"progressUpdateIntervalS" default:"5"`
LimitBandwidthInLan bool `xml:"limitBandwidthInLan" json:"limitBandwidthInLan" default:"false"`
MinHomeDiskFree Size `xml:"minHomeDiskFree" json:"minHomeDiskFree" default:"1 %"`
ReleasesURL string `xml:"releasesURL" json:"releasesURL" default:"https://upgrades.syncthing.net/meta.json" restart:"true"`
AlwaysLocalNets []string `xml:"alwaysLocalNet" json:"alwaysLocalNets"`
OverwriteRemoteDevNames bool `xml:"overwriteRemoteDeviceNamesOnConnect" json:"overwriteRemoteDeviceNamesOnConnect" default:"false"`
TempIndexMinBlocks int `xml:"tempIndexMinBlocks" json:"tempIndexMinBlocks" default:"10"`
UnackedNotificationIDs []string `xml:"unackedNotificationID" json:"unackedNotificationIDs"`
TrafficClass int `xml:"trafficClass" json:"trafficClass"`
DefaultFolderPath string `xml:"defaultFolderPath" json:"defaultFolderPath" default:"~"`
SetLowPriority bool `xml:"setLowPriority" json:"setLowPriority" default:"true"`
FolderDeviceSortByStatus bool `xml:"folderDeviceSortByStatus,omitempty" json:"folderDeviceSortByStatus" default:"false"`

DeprecatedUPnPEnabled bool `xml:"upnpEnabled,omitempty" json:"-"`
DeprecatedUPnPLeaseM int `xml:"upnpLeaseMinutes,omitempty" json:"-"`
Expand Down

0 comments on commit 5f48488

Please sign in to comment.