mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-03 15:17:25 +00:00
gui: Split device list in folder sharing options by shared / unshared (#5756)
This commit is contained in:
parent
9084510e1b
commit
8b5bd45a29
@ -66,6 +66,14 @@ function folderCompare(a, b) {
|
|||||||
return labelA > labelB;
|
return labelA > labelB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deviceMap(l) {
|
||||||
|
var m = {};
|
||||||
|
l.forEach(function (r) {
|
||||||
|
m[r.deviceID] = r;
|
||||||
|
});
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
function folderMap(l) {
|
function folderMap(l) {
|
||||||
var m = {};
|
var m = {};
|
||||||
l.forEach(function (r) {
|
l.forEach(function (r) {
|
||||||
|
@ -60,7 +60,9 @@ angular.module('syncthing.core')
|
|||||||
} catch (exception) { }
|
} catch (exception) { }
|
||||||
|
|
||||||
$scope.folderDefaults = {
|
$scope.folderDefaults = {
|
||||||
|
sharedDevices: {},
|
||||||
selectedDevices: {},
|
selectedDevices: {},
|
||||||
|
unrelatedDevices: {},
|
||||||
type: "sendreceive",
|
type: "sendreceive",
|
||||||
rescanIntervalS: 3600,
|
rescanIntervalS: 3600,
|
||||||
fsWatcherDelayS: 10,
|
fsWatcherDelayS: 10,
|
||||||
@ -1679,10 +1681,20 @@ angular.module('syncthing.core')
|
|||||||
if ($scope.currentFolder.path.length > 1 && $scope.currentFolder.path.slice(-1) === $scope.system.pathSeparator) {
|
if ($scope.currentFolder.path.length > 1 && $scope.currentFolder.path.slice(-1) === $scope.system.pathSeparator) {
|
||||||
$scope.currentFolder.path = $scope.currentFolder.path.slice(0, -1);
|
$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.selectedDevices = {};
|
||||||
$scope.currentFolder.devices.forEach(function (n) {
|
$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.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") {
|
if ($scope.currentFolder.versioning && $scope.currentFolder.versioning.type === "trashcan") {
|
||||||
$scope.currentFolder.trashcanFileVersioning = true;
|
$scope.currentFolder.trashcanFileVersioning = true;
|
||||||
$scope.currentFolder.fileVersioningSelector = "trashcan";
|
$scope.currentFolder.fileVersioningSelector = "trashcan";
|
||||||
@ -1733,17 +1745,17 @@ angular.module('syncthing.core')
|
|||||||
$scope.editFolderModal();
|
$scope.editFolderModal();
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.selectAllDevices = function () {
|
$scope.selectAllSharedDevices = function (state) {
|
||||||
var devices = $scope.otherDevices();
|
var devices = $scope.currentFolder.sharedDevices;
|
||||||
for (var i = 0; i < devices.length; i++) {
|
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 () {
|
$scope.selectAllUnrelatedDevices = function (state) {
|
||||||
var devices = $scope.otherDevices();
|
var devices = $scope.currentFolder.unrelatedDevices;
|
||||||
for (var i = 0; i < devices.length; i++) {
|
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.editingExisting = false;
|
||||||
$scope.currentFolder = angular.copy($scope.folderDefaults);
|
$scope.currentFolder = angular.copy($scope.folderDefaults);
|
||||||
$scope.currentFolder.id = (data.random.substr(0, 5) + '-' + data.random.substr(5, 5)).toLowerCase();
|
$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').val("");
|
||||||
$('#folder-ignores textarea').removeAttr('disabled');
|
$('#folder-ignores textarea').removeAttr('disabled');
|
||||||
$scope.editFolderModal();
|
$scope.editFolderModal();
|
||||||
@ -1767,6 +1780,7 @@ angular.module('syncthing.core')
|
|||||||
importFromOtherDevice: true
|
importFromOtherDevice: true
|
||||||
};
|
};
|
||||||
$scope.currentFolder.selectedDevices[device] = true;
|
$scope.currentFolder.selectedDevices[device] = true;
|
||||||
|
$scope.currentFolder.unrelatedDevices = $scope.otherDevices();
|
||||||
$('#folder-ignores textarea').val("");
|
$('#folder-ignores textarea').val("");
|
||||||
$('#folder-ignores textarea').removeAttr('disabled');
|
$('#folder-ignores textarea').removeAttr('disabled');
|
||||||
$scope.editFolderModal();
|
$scope.editFolderModal();
|
||||||
@ -1792,7 +1806,9 @@ angular.module('syncthing.core')
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
delete folderCfg.sharedDevices;
|
||||||
delete folderCfg.selectedDevices;
|
delete folderCfg.selectedDevices;
|
||||||
|
delete folderCfg.unrelatedDevices;
|
||||||
|
|
||||||
if (folderCfg.fileVersioningSelector === "trashcan") {
|
if (folderCfg.fileVersioningSelector === "trashcan") {
|
||||||
folderCfg.versioning = {
|
folderCfg.versioning = {
|
||||||
|
@ -44,18 +44,35 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="folder-sharing" class="tab-pane">
|
<div id="folder-sharing" class="tab-pane">
|
||||||
<div class="form-group">
|
<div class="form-group" ng-if="currentFolder.sharedDevices.length">
|
||||||
<label translate for="devices">Share With Devices</label>
|
<label translate>Currently Shared With Devices</label>
|
||||||
|
<p class="help-block">
|
||||||
|
<span translate>Deselect devices to stop sharing this folder with.</span> 
|
||||||
|
<small><a href="#" ng-click="selectAllSharedDevices(true)" translate>Select All</a> 
|
||||||
|
<a href="#" ng-click="selectAllSharedDevices(false)" translate>Deselect All</a></small>
|
||||||
|
</p>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4" ng-repeat="device in currentFolder.sharedDevices">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" ng-model="currentFolder.selectedDevices[device.deviceID]" /> {{deviceName(device)}}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group" ng-if="currentFolder.unrelatedDevices.length || otherDevices().length <= 0">
|
||||||
|
<label translate>Unshared Devices</label>
|
||||||
<p class="help-block" ng-if="otherDevices().length > 0">
|
<p class="help-block" ng-if="otherDevices().length > 0">
|
||||||
<span translate>Select the devices to share this folder with.</span> 
|
<span translate>Select additional devices to share this folder with.</span> 
|
||||||
<small><a href="#" ng-click="selectAllDevices()" translate>Select All</a> 
|
<small><a href="#" ng-click="selectAllUnrelatedDevices(true)" translate>Select All</a> 
|
||||||
<a href="#" ng-click="deSelectAllDevices()" translate>Deselect All</a></small>
|
<a href="#" ng-click="selectAllUnrelatedDevices(false)" translate>Deselect All</a></small>
|
||||||
</p>
|
</p>
|
||||||
<p class="help-block" ng-if="otherDevices().length <= 0">
|
<p class="help-block" ng-if="otherDevices().length <= 0">
|
||||||
<span translate>There are no devices to share this folder with.</span>
|
<span translate>There are no devices to share this folder with.</span>
|
||||||
</p>
|
</p>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4" ng-repeat="device in otherDevices()">
|
<div class="col-md-4" ng-repeat="device in currentFolder.unrelatedDevices">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" ng-model="currentFolder.selectedDevices[device.deviceID]" /> {{deviceName(device)}}
|
<input type="checkbox" ng-model="currentFolder.selectedDevices[device.deviceID]" /> {{deviceName(device)}}
|
||||||
|
Loading…
Reference in New Issue
Block a user