From 4198b5061f056ef4ffaa1d13c64184d4b34ac42c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Colomb?= Date: Wed, 9 Dec 2020 14:54:51 +0100 Subject: [PATCH] gui: Split folders into two categories on the sharing tab for devices (#7162) --- .../syncthing/core/syncthingController.js | 34 ++++---- .../syncthing/device/editDeviceModalView.html | 35 ++++++-- .../syncthing/core/syncthingController.js | 85 +++++++++---------- .../syncthing/device/editDeviceModalView.html | 9 +- 4 files changed, 94 insertions(+), 69 deletions(-) diff --git a/gui/default/syncthing/core/syncthingController.js b/gui/default/syncthing/core/syncthingController.js index f3dd4b9af..76ea14694 100755 --- a/gui/default/syncthing/core/syncthingController.js +++ b/gui/default/syncthing/core/syncthingController.js @@ -1430,32 +1430,28 @@ angular.module('syncthing.core') } $scope.currentDevice._addressesStr = deviceCfg.addresses.join(', '); initShareEditing('device'); - $scope.currentSharing.selected = {}; - $scope.deviceFolders($scope.currentDevice).forEach(function (folder) { - $scope.currentSharing.selected[folder] = true; + $scope.deviceFolders($scope.currentDevice).forEach(function (folderID) { + $scope.currentSharing.shared.push($scope.folders[folderID]); + $scope.currentSharing.selected[folderID] = true; + }); + $scope.currentSharing.unrelated = $scope.folderList().filter(function (n) { + return !$scope.currentSharing.selected[n.id]; }); $scope.deviceEditor.$setPristine(); $('#editDevice').modal(); }; - $scope.selectAllFolders = function (state) { - var folders = $scope.folders; - for (var id in folders) { - $scope.currentSharing.selected[id] = !!state; - }; - }; - $scope.selectAllSharedFolders = function (state) { - var devices = $scope.currentSharing.shared; - for (var i = 0; i < devices.length; i++) { - $scope.currentSharing.selected[devices[i].deviceID] = !!state; + var folders = $scope.currentSharing.shared; + for (var i = 0; i < folders.length; i++) { + $scope.currentSharing.selected[folders[i].id] = !!state; } }; $scope.selectAllUnrelatedFolders = function (state) { - var devices = $scope.currentSharing.unrelated; - for (var i = 0; i < devices.length; i++) { - $scope.currentSharing.selected[devices[i].deviceID] = !!state; + var folders = $scope.currentSharing.unrelated; + for (var i = 0; i < folders.length; i++) { + $scope.currentSharing.selected[folders[i].id] = !!state; } }; @@ -1485,6 +1481,7 @@ angular.module('syncthing.core') }; $scope.editingExisting = false; initShareEditing('device'); + $scope.currentSharing.unrelated = $scope.folderList(); $scope.deviceEditor.$setPristine(); $('#editDevice').modal(); }); @@ -1533,17 +1530,22 @@ angular.module('syncthing.core') } if (!found) { + // Add device to folder $scope.folders[id].devices.push({ deviceID: deviceCfg.deviceID }); } } else { + // Remove device from folder $scope.folders[id].devices = $scope.folders[id].devices.filter(function (n) { return n.deviceID !== deviceCfg.deviceID; }); } } + delete $scope.currentSharing; + + $scope.config.folders = folderList($scope.folders); $scope.saveConfig(); }; diff --git a/gui/default/syncthing/device/editDeviceModalView.html b/gui/default/syncthing/device/editDeviceModalView.html index 2f846f33b..39573c16a 100644 --- a/gui/default/syncthing/device/editDeviceModalView.html +++ b/gui/default/syncthing/device/editDeviceModalView.html @@ -65,15 +65,38 @@
-
- +
+

- Select the folders to share with this device.  - Select All  - Deselect All + Deselect folders to stop sharing with this device.  + Select All  + Deselect All

-
+
+
+ + +
+
+
+
+
+ +

+ Select additional folders to share with this device.  + Select All  + Deselect All +

+

+ There are no folders to share with this device. +

+
+
- -

+ +

Select additional folders to share with this device.Select AllDeselect All

+

+ There are no folders to share with this device. +