Merge remote-tracking branch 'origin/pr/1083'

* origin/pr/1083:
  Select repos to share with in node editor dialog (fixes #719)
This commit is contained in:
Jakob Borg 2014-12-06 12:30:46 +01:00
commit 1a7921b46c
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> <p translate class="help-block">Any devices configured on an introducer device will be added to this device as well.</p>
</div> </div>
</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> </form>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

@ -640,6 +640,12 @@ angular.module('syncthing.core')
$scope.editingExisting = true; $scope.editingExisting = true;
$scope.editingSelf = (deviceCfg.DeviceID == $scope.myID); $scope.editingSelf = (deviceCfg.DeviceID == $scope.myID);
$scope.currentDevice.AddressesStr = deviceCfg.Addresses.join(', '); $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(); $scope.deviceEditor.$setPristine();
$('#editDevice').modal(); $('#editDevice').modal();
}; };
@ -657,7 +663,8 @@ angular.module('syncthing.core')
$scope.currentDevice = { $scope.currentDevice = {
AddressesStr: 'dynamic', AddressesStr: 'dynamic',
Compression: true, Compression: true,
Introducer: false Introducer: false,
selectedFolders: {}
}; };
$scope.editingExisting = false; $scope.editingExisting = false;
$scope.editingSelf = false; $scope.editingSelf = false;
@ -711,6 +718,31 @@ angular.module('syncthing.core')
$scope.devices.sort(deviceCompare); $scope.devices.sort(deviceCompare);
$scope.config.Devices = $scope.devices; $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(); $scope.saveConfig();
}; };

File diff suppressed because one or more lines are too long