Files
duplicati/Duplicati/Server/webroot/ngax/scripts/controllers/ImportController.js
T
Kenneth Skovhede e333c14236 Changed the import functionality to load the imported backup into the "Add" view, such that it can be changed before being imported.
Also added support for restoring from an exported configuration file, by loading the values into the restore-direct view.
This adds support for importing a configuration file stored on a remote destination as mentioned in #2282.
This fixes #2321
This fixes #1311
2017-02-27 00:03:46 +01:00

43 lines
1.4 KiB
JavaScript

backupApp.controller('ImportController', function($rootScope, $scope, $timeout, $location, AppService, DialogService) {
$scope.Connecting = false;
$scope.Completed = false;
$scope.ImportURL = AppService.get_import_url();
$scope.restoremode = $location.$$path.indexOf('/restore-import') == 0;
// Ugly, but we need to communicate across the iframe load
$scope.CallbackMethod = 'callback-' + Math.random();
window[$scope.CallbackMethod] = function(message, jobdefinition) {
// The delay fixes an issue with Ghostery
// failing somewhere
$timeout(function() {
$scope.Connecting = false;
$scope.Completed = true;
if (message == 'OK')
$location.path('/');
else if (jobdefinition != null && typeof(jobdefinition) != typeof(''))
{
// Use the root scope to pass the imported job
$rootScope.importConfig = jobdefinition;
if ($scope.restoremode)
$location.path('/restoredirect-import');
else
$location.path('/add-import');
}
else
DialogService.dialog('Error', message);
}, 100);
};
$scope.doSubmit = function() {
// TODO: Ugly non-angular way
$scope.Connecting = true;
document.getElementById('import-form').submit();
};
});