Added case-insensitive handling for size dropdowns.
Added extended parsing to support --exclude-file-attributes where parts of the option is in the UI, and other parts are in advanced options. This fixes #1643
This commit is contained in:
@@ -165,16 +165,6 @@ backupApp.controller('EditBackupController', function ($scope, $routeParams, $lo
|
||||
if (!$scope.ExcludeLargeFiles)
|
||||
delete opts['--skip-files-larger-than'];
|
||||
|
||||
if (($scope.ExcludeAttributes || []).length > 0) {
|
||||
opts['--exclude-files-attributes'] = $scope.ExcludeAttributes.join(',');
|
||||
|
||||
while (opts['--exclude-files-attributes'].indexOf(',') == 0)
|
||||
opts['--exclude-files-attributes'] = opts['--exclude-files-attributes'].substr(1);
|
||||
|
||||
if (opts['--exclude-files-attributes'] == '')
|
||||
delete opts['--exclude-files-attributes'];
|
||||
}
|
||||
|
||||
var encryptionEnabled = true;
|
||||
if ((opts['encryption-module'] || '').length == 0) {
|
||||
opts['--no-encryption'] = 'true';
|
||||
@@ -184,6 +174,24 @@ backupApp.controller('EditBackupController', function ($scope, $routeParams, $lo
|
||||
if (!AppUtils.parse_extra_options(scope.ExtendedOptions, opts))
|
||||
return false;
|
||||
|
||||
var exclattr = ($scope.ExcludeAttributes || []).concat((opts['--exclude-files-attributes'] || '').split(','));
|
||||
var exclmap = { '': true };
|
||||
|
||||
// Remove duplicates
|
||||
for (var i = exclattr.length - 1; i >= 0; i--) {
|
||||
exclattr[i] = (exclattr[i] || '').trim();
|
||||
var cmp = exclattr[i].toLowerCase();
|
||||
if (exclmap[cmp])
|
||||
exclattr.splice(i, 1);
|
||||
else
|
||||
exclmap[cmp] = true;
|
||||
}
|
||||
|
||||
if (exclattr.length == 0)
|
||||
delete opts['--exclude-files-attributes'];
|
||||
else
|
||||
opts['--exclude-files-attributes'] = exclattr.join(',')
|
||||
|
||||
if (($scope.Backup.Name || '').trim().length == 0) {
|
||||
DialogService.dialog('Missing name', 'You must enter a name for the backup');
|
||||
$scope.CurrentStep = 0;
|
||||
@@ -411,7 +419,38 @@ backupApp.controller('EditBackupController', function ($scope, $routeParams, $lo
|
||||
$scope.ExcludeLargeFiles = (extopts['--skip-files-larger-than'] || '').trim().length > 0;
|
||||
if ($scope.ExcludeLargeFiles)
|
||||
$scope.Options['--skip-files-larger-than'] = extopts['--skip-files-larger-than'];
|
||||
$scope.ExcludeAttributes = (extopts['--exclude-files-attributes'] || '').split(',');
|
||||
|
||||
var exclattr = (extopts['--exclude-files-attributes'] || '').split(',');
|
||||
var dispattr = [];
|
||||
var dispmap = {};
|
||||
|
||||
for (var i = exclattr.length - 1; i >= 0; i--) {
|
||||
var cmp = (exclattr[i] || '').trim().toLowerCase();
|
||||
|
||||
// Remove empty entries
|
||||
if (cmp.length == 0) {
|
||||
exclattr.splice(i, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (var j = scope.fileAttributes.length - 1; j >= 0; j--) {
|
||||
if (scope.fileAttributes[j].value == cmp) {
|
||||
// Remote duplicates
|
||||
if (dispmap[cmp] == null) {
|
||||
dispattr.push(scope.fileAttributes[j].value);
|
||||
dispmap[cmp] = true;
|
||||
}
|
||||
exclattr.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$scope.ExcludeAttributes = dispattr;
|
||||
if (exclattr.length == 0)
|
||||
delete extopts['--exclude-files-attributes'];
|
||||
else
|
||||
extopts['--exclude-files-attributes'] = exclattr.join(',');
|
||||
|
||||
$scope.RepeatPasshrase = $scope.Options['passphrase'];
|
||||
|
||||
@@ -426,7 +465,7 @@ backupApp.controller('EditBackupController', function ($scope, $routeParams, $lo
|
||||
$scope.KeepType = 'versions';
|
||||
}
|
||||
|
||||
var delopts = ['--skip-files-larger-than', '--exclude-files-attributes', '--no-encryption']
|
||||
var delopts = ['--skip-files-larger-than', '--no-encryption']
|
||||
for(var n in delopts)
|
||||
delete extopts[delopts[n]];
|
||||
|
||||
|
||||
@@ -167,6 +167,9 @@ backupApp.directive('parseAdvancedOptionSizeNumber', function(AppUtils) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
require: ['ngModel'],
|
||||
scope: {
|
||||
parseAdvancedOptionSizeNumber: '@'
|
||||
},
|
||||
link: function(scope, element, attr, ctrl) {
|
||||
|
||||
var name = null;
|
||||
@@ -192,7 +195,12 @@ backupApp.directive('parseAdvancedOptionSizeNumber', function(AppUtils) {
|
||||
}
|
||||
else
|
||||
{
|
||||
multiplier = parts[1];
|
||||
if (scope.parseAdvancedOptionSizeNumber == 'uppercase')
|
||||
multiplier = parts[1].toUpperCase();
|
||||
else if (scope.parseAdvancedOptionSizeNumber == 'lowercase')
|
||||
multiplier = parts[1].toLowerCase();
|
||||
else
|
||||
multiplier = parts[1];
|
||||
return parseInt(parts[0], 10);
|
||||
}
|
||||
}
|
||||
@@ -211,6 +219,9 @@ backupApp.directive('parseAdvancedOptionSizeMultiplier', function(AppUtils) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
require: ['ngModel'],
|
||||
scope: {
|
||||
parseAdvancedOptionSizeMultiplier: '@'
|
||||
},
|
||||
link: function(scope, element, attr, ctrl) {
|
||||
|
||||
var name = null;
|
||||
@@ -237,7 +248,12 @@ backupApp.directive('parseAdvancedOptionSizeMultiplier', function(AppUtils) {
|
||||
else
|
||||
{
|
||||
number = parseInt(parts[0]);
|
||||
return parts[1];
|
||||
if (scope.parseAdvancedOptionSizeMultiplier == 'uppercase')
|
||||
return parts[1].toUpperCase();
|
||||
else if (scope.parseAdvancedOptionSizeMultiplier == 'lowercase')
|
||||
return parts[1].toLowerCase();
|
||||
else
|
||||
return parts[1];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -2,6 +2,9 @@ backupApp.directive('parseSizeNumber', function(AppUtils) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
require: ['ngModel'],
|
||||
scope: {
|
||||
parseSizeNumber: '@'
|
||||
},
|
||||
link: function(scope, element, attr, ctrl) {
|
||||
var multiplier = null;
|
||||
|
||||
@@ -17,7 +20,12 @@ backupApp.directive('parseSizeNumber', function(AppUtils) {
|
||||
return null;
|
||||
}
|
||||
|
||||
multiplier = parts[1];
|
||||
if (scope.parseSizeNumber == 'uppercase')
|
||||
multiplier = parts[1].toUpperCase();
|
||||
else if (scope.parseSizeNumber == 'lowercase')
|
||||
multiplier = parts[1].toLowerCase();
|
||||
else
|
||||
multiplier = parts[1];
|
||||
|
||||
return parts[0];
|
||||
});
|
||||
@@ -28,6 +36,9 @@ backupApp.directive('parseSizeNumber', function(AppUtils) {
|
||||
backupApp.directive('parseSizeMultiplier', function(AppUtils) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
scope: {
|
||||
parseSizeMultiplier: '@'
|
||||
},
|
||||
require: ['ngModel'],
|
||||
link: function(scope, element, attr, ctrl) {
|
||||
|
||||
@@ -45,7 +56,12 @@ backupApp.directive('parseSizeMultiplier', function(AppUtils) {
|
||||
}
|
||||
|
||||
number = parts[0];
|
||||
return parts[1];
|
||||
if (scope.parseSizeMultiplier == 'uppercase')
|
||||
return parts[1].toUpperCase();
|
||||
else if (scope.parseSizeMultiplier == 'lowercase')
|
||||
return parts[1].toLowerCase();
|
||||
else
|
||||
return parts[1];
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -152,8 +152,8 @@
|
||||
<input id="exclude-large-files" type="checkbox" class="simple-checkbox" ng-model="ExcludeLargeFiles" />
|
||||
<label for="exclude-large-files">Files larger than:</label>
|
||||
|
||||
<input type="number" parse-size-number ng-model="Options['--skip-files-larger-than']" id="exclude-larger-than-number" ng-disabled="!ExcludeLargeFiles" value="1" />
|
||||
<select parse-size-multiplier id="exclude-larger-than-multiplier" ng-model="Options['--skip-files-larger-than']" ng-disabled="!ExcludeLargeFiles" ng-options="item.value as item.name for item in AppUtils.fileSizeMultipliers">
|
||||
<input type="number" parse-size-number="uppercase" ng-model="Options['--skip-files-larger-than']" id="exclude-larger-than-number" ng-disabled="!ExcludeLargeFiles" value="1" />
|
||||
<select parse-size-multiplier="uppercase" id="exclude-larger-than-multiplier" ng-model="Options['--skip-files-larger-than']" ng-disabled="!ExcludeLargeFiles" ng-options="item.value as item.name for item in AppUtils.fileSizeMultipliers">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -219,12 +219,11 @@
|
||||
<h2>General options</h2>
|
||||
<div class="input multiple text select maxSize">
|
||||
<label for="dblockSizeNumber">Max backup file size</label>
|
||||
<input type="number" class="number" parse-size-number id="dblockSizeNumber" ng-model="Options['dblock-size']" />
|
||||
<select parse-size-multiplier id="dblockSizeMultiplier" ng-model="Options['dblock-size']">
|
||||
<option value="kb">KByte</option>
|
||||
<option value="mb">MByte</option>
|
||||
<option value="gb">GByte</option>
|
||||
<option value="tb">TByte</option>
|
||||
<input type="number" class="number" parse-size-number="uppercase" id="dblockSizeNumber" ng-model="Options['dblock-size']" />
|
||||
<select parse-size-multiplier="uppercase" id="dblockSizeMultiplier" ng-model="Options['dblock-size']" ng-options="item.value as item.name for item in AppUtils.fileSizeMultipliers"></select>
|
||||
<option value="MB">MByte</option>
|
||||
<option value="GB">GByte</option>
|
||||
<option value="TB">TByte</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="input multiple text select keepBackups">
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
<input ng-if="getInputType(item) == 'int'" type="number" ng-model="$parent.ngModel[$index]" parse-advanced-option-integer ></input>
|
||||
|
||||
<div ng-if="getInputType(item) == 'size'" class="input type multiple">
|
||||
<input type="number" parse-advanced-option-size-number ng-model="$parent.ngModel[$index]" />
|
||||
<select parse-advanced-option-size-multiplier ng-model="$parent.ngModel[$index]">
|
||||
<input type="number" parse-advanced-option-size-number="lowercase" ng-model="$parent.ngModel[$index]" />
|
||||
<select parse-advanced-option-size-multiplier="lowercase" ng-model="$parent.ngModel[$index]">
|
||||
<option value="kb">KByte</option>
|
||||
<option value="mb">MByte</option>
|
||||
<option value="gb">GByte</option>
|
||||
|
||||
Reference in New Issue
Block a user