@@ -2301,6 +2301,7 @@ angular.module('syncthing.core')
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.validateXattrFilter();
|
||||
var folderCfg = angular.copy($scope.currentFolder);
|
||||
$scope.currentSharing.selected[$scope.myID] = true;
|
||||
var newDevices = [];
|
||||
@@ -3330,6 +3331,84 @@ angular.module('syncthing.core')
|
||||
|
||||
$scope.showTemporaryTooltip(event, message);
|
||||
};
|
||||
|
||||
$scope.newXattrEntry = function () {
|
||||
var entries = $scope.currentFolder.xattrFilter.entries;
|
||||
var newEntry = {match: '', permit: false};
|
||||
|
||||
if (entries.some(function (n) {
|
||||
return n.match == '';
|
||||
})) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (entries.length > 0 && entries[entries.length -1].match === '*') {
|
||||
if (newEntry.match !== '*') {
|
||||
entries.splice(entries.length - 1, 0, newEntry);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
entries.push(newEntry);
|
||||
};
|
||||
|
||||
$scope.removeXattrEntry = function (entry) {
|
||||
$scope.currentFolder.xattrFilter.entries = $scope.currentFolder.xattrFilter.entries.filter(function (n) {
|
||||
return n !== entry;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getXattrHint = function () {
|
||||
var xattrFilter = $scope.currentFolder.xattrFilter;
|
||||
if (xattrFilter == null || xattrFilter == {}) {
|
||||
return '';
|
||||
}
|
||||
var filterEntries = xattrFilter.entries;
|
||||
if (filterEntries.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// When the user explicitely added a wild-card, we don't show hints.
|
||||
if (filterEntries.length === 1 && filterEntries[0].match === '*') {
|
||||
return '';
|
||||
}
|
||||
// If all the filter entries are 'deny', we suggest adding a permit-any
|
||||
// rule in the end since the default is already deny in that case.
|
||||
if (filterEntries.every(function (entry) {
|
||||
return entry.permit === false;
|
||||
})) {
|
||||
return $translate.instant('Hint: only deny-rules detected while the default is deny. Consider adding "permit any" as last rule.');
|
||||
}
|
||||
|
||||
return '';
|
||||
};
|
||||
|
||||
$scope.getXattrDefault = function () {
|
||||
var xattrFilter = $scope.currentFolder.xattrFilter;
|
||||
if (xattrFilter == null || xattrFilter == {}) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var filterEntries = xattrFilter.entries;
|
||||
// No entries present, default is thus 'allow'
|
||||
if (filterEntries.length === 0) {
|
||||
return $translate.instant('permit');
|
||||
}
|
||||
// If any rule is present and the last entry isn't a wild-card, the default is deny.
|
||||
if (filterEntries[filterEntries.length -1].match !== '*') {
|
||||
return $translate.instant('deny');
|
||||
}
|
||||
|
||||
return '';
|
||||
};
|
||||
|
||||
$scope.validateXattrFilter = function () {
|
||||
// Fitlering out empty rules when saving the config
|
||||
$scope.currentFolder.xattrFilter.entries = $scope.currentFolder.xattrFilter.entries.filter(function (n) {
|
||||
return n.match !== "";
|
||||
});
|
||||
};
|
||||
})
|
||||
.directive('shareTemplate', function () {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user