Select repos to share with in node editor dialog (fixes #719)

This commit is contained in:
Audrius Butkevicius 2014-12-05 00:22:16 +00:00
parent 7f97037190
commit 05eab51a0d
3 changed files with 52 additions and 3 deletions

View File

@ -416,6 +416,23 @@
<p translate class="help-block">Any devices configured on an introducer device will be added to this device as well.</p>
</div>
</div>
<div class="row" ng-if="!editingSelf">
<div class="col-md-12">
<div class="form-group">
<label translate for="folders">Share Folders With Device</label>
<p translate class="help-block">Select the folders to share with this device.</p>
<div class="three-columns">
<div class="checkbox" ng-repeat="folder in folderList()">
<label>
<input type="checkbox" ng-model="currentDevice.selectedFolders[folder.ID]"> {{folder.ID}}
</label>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">

View File

@ -640,6 +640,12 @@ angular.module('syncthing.core')
$scope.editingExisting = true;
$scope.editingSelf = (deviceCfg.DeviceID == $scope.myID);
$scope.currentDevice.AddressesStr = deviceCfg.Addresses.join(', ');
if (!$scope.editingSelf) {
$scope.currentDevice.selectedFolders = {};
$scope.deviceFolders($scope.currentDevice).forEach(function (folder) {
$scope.currentDevice.selectedFolders[folder] = true;
});
}
$scope.deviceEditor.$setPristine();
$('#editDevice').modal();
};
@ -657,7 +663,8 @@ angular.module('syncthing.core')
$scope.currentDevice = {
AddressesStr: 'dynamic',
Compression: true,
Introducer: false
Introducer: false,
selectedFolders: {}
};
$scope.editingExisting = false;
$scope.editingSelf = false;
@ -711,6 +718,31 @@ angular.module('syncthing.core')
$scope.devices.sort(deviceCompare);
$scope.config.Devices = $scope.devices;
if (!$scope.editingSelf) {
for (var id in deviceCfg.selectedFolders) {
if (deviceCfg.selectedFolders[id]) {
var found = false;
for (i = 0; i < $scope.folders[id].Devices.length; i++) {
if ($scope.folders[id].Devices[i].DeviceID == deviceCfg.DeviceID) {
found = true;
break;
}
}
if (!found) {
$scope.folders[id].Devices.push({
DeviceID: deviceCfg.DeviceID
});
}
continue
} else {
$scope.folders[id].Devices = $scope.folders[id].Devices.filter(function (n) {
return n.DeviceID != deviceCfg.DeviceID;
});
}
}
}
$scope.saveConfig();
};

File diff suppressed because one or more lines are too long