diff --git a/gui/default/syncthing/app.js b/gui/default/syncthing/app.js index 493eb3ed3..21aa69256 100644 --- a/gui/default/syncthing/app.js +++ b/gui/default/syncthing/app.js @@ -66,6 +66,14 @@ function folderCompare(a, b) { return labelA > labelB; } +function deviceMap(l) { + var m = {}; + l.forEach(function (r) { + m[r.deviceID] = r; + }); + return m; +} + function folderMap(l) { var m = {}; l.forEach(function (r) { diff --git a/gui/default/syncthing/core/syncthingController.js b/gui/default/syncthing/core/syncthingController.js index 1479a1da6..ce0f8c167 100755 --- a/gui/default/syncthing/core/syncthingController.js +++ b/gui/default/syncthing/core/syncthingController.js @@ -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 = { diff --git a/gui/default/syncthing/folder/editFolderModalView.html b/gui/default/syncthing/folder/editFolderModalView.html index 0af8f93e6..69f407879 100644 --- a/gui/default/syncthing/folder/editFolderModalView.html +++ b/gui/default/syncthing/folder/editFolderModalView.html @@ -44,18 +44,35 @@
-
- +
+ +

+ Deselect devices to stop sharing this folder with.  + Select All  + Deselect All +

+
+
+
+ +
+
+
+
+
+

- Select the devices to share this folder with.  - Select All  - Deselect All + Select additional devices to share this folder with.  + Select All  + Deselect All

There are no devices to share this folder with.

-
+