2017-02-27 00:03:46 +01:00
|
|
|
backupApp.controller('ImportController', function($rootScope, $scope, $timeout, $location, AppService, DialogService) {
|
2015-11-29 00:39:43 +01:00
|
|
|
$scope.Connecting = false;
|
|
|
|
|
$scope.Completed = false;
|
|
|
|
|
$scope.ImportURL = AppService.get_import_url();
|
|
|
|
|
|
2017-02-27 00:03:46 +01:00
|
|
|
$scope.restoremode = $location.$$path.indexOf('/restore-import') == 0;
|
|
|
|
|
|
2015-11-29 00:39:43 +01:00
|
|
|
// Ugly, but we need to communicate across the iframe load
|
|
|
|
|
$scope.CallbackMethod = 'callback-' + Math.random();
|
2017-02-27 00:03:46 +01:00
|
|
|
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);
|
2015-11-29 00:39:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.doSubmit = function() {
|
2016-09-15 11:39:27 +02:00
|
|
|
// TODO: Ugly non-angular way
|
2017-02-27 00:03:46 +01:00
|
|
|
$scope.Connecting = true;
|
2016-09-15 11:39:27 +02:00
|
|
|
document.getElementById('import-form').submit();
|
2015-11-29 00:39:43 +01:00
|
|
|
};
|
|
|
|
|
|
2016-09-15 11:39:27 +02:00
|
|
|
});
|