Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ImportController.js « controllers « scripts « ngax « webroot « Server « Duplicati - github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8f255778558d348d25a2f1776f9604880190110a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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();
    };

});