gui: Split device list in folder sharing options by shared / unshared (#5756)

This commit is contained in:
André Colomb
2019-10-21 21:28:10 +02:00
committed by Simon Frei
parent 9084510e1b
commit 8b5bd45a29
3 changed files with 53 additions and 12 deletions

View File

@@ -60,7 +60,9 @@ angular.module('syncthing.core')
} catch (exception) { }
$scope.folderDefaults = {
sharedDevices: {},
selectedDevices: {},
unrelatedDevices: {},
type: "sendreceive",
rescanIntervalS: 3600,
fsWatcherDelayS: 10,
@@ -1679,10 +1681,20 @@ angular.module('syncthing.core')
if ($scope.currentFolder.path.length > 1 && $scope.currentFolder.path.slice(-1) === $scope.system.pathSeparator) {
$scope.currentFolder.path = $scope.currentFolder.path.slice(0, -1);
}
// Cache complete device objects indexed by ID for lookups
var devMap = deviceMap($scope.devices)
$scope.currentFolder.sharedDevices = [];
$scope.currentFolder.selectedDevices = {};
$scope.currentFolder.devices.forEach(function (n) {
if (n.deviceID !== $scope.myID) {
$scope.currentFolder.sharedDevices.push(devMap[n.deviceID]);
}
$scope.currentFolder.selectedDevices[n.deviceID] = true;
});
$scope.currentFolder.unrelatedDevices = $scope.devices.filter(function (n) {
return n.deviceID !== $scope.myID
&& ! $scope.currentFolder.selectedDevices[n.deviceID]
});
if ($scope.currentFolder.versioning && $scope.currentFolder.versioning.type === "trashcan") {
$scope.currentFolder.trashcanFileVersioning = true;
$scope.currentFolder.fileVersioningSelector = "trashcan";
@@ -1733,17 +1745,17 @@ angular.module('syncthing.core')
$scope.editFolderModal();
};
$scope.selectAllDevices = function () {
var devices = $scope.otherDevices();
$scope.selectAllSharedDevices = function (state) {
var devices = $scope.currentFolder.sharedDevices;
for (var i = 0; i < devices.length; i++) {
$scope.currentFolder.selectedDevices[devices[i].deviceID] = true;
$scope.currentFolder.selectedDevices[devices[i].deviceID] = !!state;
}
};
$scope.deSelectAllDevices = function () {
var devices = $scope.otherDevices();
$scope.selectAllUnrelatedDevices = function (state) {
var devices = $scope.currentFolder.unrelatedDevices;
for (var i = 0; i < devices.length; i++) {
$scope.currentFolder.selectedDevices[devices[i].deviceID] = false;
$scope.currentFolder.selectedDevices[devices[i].deviceID] = !!state;
}
};
@@ -1752,6 +1764,7 @@ angular.module('syncthing.core')
$scope.editingExisting = false;
$scope.currentFolder = angular.copy($scope.folderDefaults);
$scope.currentFolder.id = (data.random.substr(0, 5) + '-' + data.random.substr(5, 5)).toLowerCase();
$scope.currentFolder.unrelatedDevices = $scope.otherDevices();
$('#folder-ignores textarea').val("");
$('#folder-ignores textarea').removeAttr('disabled');
$scope.editFolderModal();
@@ -1767,6 +1780,7 @@ angular.module('syncthing.core')
importFromOtherDevice: true
};
$scope.currentFolder.selectedDevices[device] = true;
$scope.currentFolder.unrelatedDevices = $scope.otherDevices();
$('#folder-ignores textarea').val("");
$('#folder-ignores textarea').removeAttr('disabled');
$scope.editFolderModal();
@@ -1792,7 +1806,9 @@ angular.module('syncthing.core')
});
}
}
delete folderCfg.sharedDevices;
delete folderCfg.selectedDevices;
delete folderCfg.unrelatedDevices;
if (folderCfg.fileVersioningSelector === "trashcan") {
folderCfg.versioning = {