Files
duplicati/Duplicati/Server/webroot/ngax/scripts/controllers/ExportController.js
T

68 lines
3.2 KiB
JavaScript
Raw Normal View History

2018-11-04 17:46:33 +01:00
backupApp.controller("ExportController", function($scope, $routeParams, AppService, DialogService, gettextCatalog) {
$scope.ExportType = "file";
$scope.ExportPasswords = true;
$scope.Connecting = false;
$scope.BackupID = $routeParams.backupid;
$scope.Completed = false;
$scope.doExport = function() {
// Helper function(s)
2018-11-04 17:17:59 +01:00
function warnUnencryptedPasswords(continuation) {
2018-11-04 17:53:41 +01:00
if ($scope.ExportType === "file" && $scope.ExportPasswords && !$scope.fileEncrypted) {
2018-11-04 17:46:33 +01:00
DialogService.dialog(gettextCatalog.getString("Not using encryption"), gettextCatalog.getString("The configuration should be kept safe. Are you sure you want to save an unencrypted file containing your passwords?"), [gettextCatalog.getString("Cancel"), gettextCatalog.getString("Yes, I understand the risk")], function(ix) {
2018-11-04 17:53:41 +01:00
if (ix === 0) {
2018-11-04 17:33:23 +01:00
$scope.CurrentStep = 0;
} else {
continuation();
}
});
} else {
continuation();
}
}
// The actual export function to call after all checks pass
2018-11-04 17:17:59 +01:00
function getExport() {
2018-11-04 17:53:41 +01:00
if ($scope.ExportType === "commandline") {
$scope.Connecting = true;
2018-11-04 17:46:33 +01:00
AppService.get("/backup/" + $scope.BackupID + "/export?cmdline=true&export-passwords=" + encodeURIComponent($scope.ExportPasswords)).then(
function(resp) {
$scope.Connecting = false;
$scope.Completed = true;
$scope.CommandLine = resp.data.Command;
},
function(resp) {
$scope.Connecting = false;
var message = AppService.responseErrorMessage(resp);
DialogService.dialog(gettextCatalog.getString("Error"), gettextCatalog.getString("Failed to connect: {{message}}", { message: message }));
}
);
} else {
$scope.DownloadURL = AppService.get_export_url($scope.BackupID, $scope.UseEncryption ? $scope.Passphrase : null, $scope.ExportPasswords);
$scope.Completed = true;
}
2018-11-04 17:33:23 +01:00
}
// Make checks that do not require user input
$scope.fileEncrypted = false;
2018-11-04 17:53:41 +01:00
if ($scope.UseEncryption && $scope.ExportType === "file") {
2018-12-22 19:17:49 +01:00
if (typeof $scope.Passphrase === "undefined" || $scope.Passphrase.trim().length === 0) {
2018-11-04 17:46:33 +01:00
DialogService.dialog(gettextCatalog.getString("No passphrase entered"), gettextCatalog.getString("To export without a passphrase, uncheck the \"Encrypt file\" box"));
return;
2018-12-22 19:17:49 +01:00
} else if ($scope.Passphrase !== $scope.ConfirmPassphrase) {
DialogService.dialog(gettextCatalog.getString("Error"), gettextCatalog.getString("The passwords do not match"));
2018-12-22 18:41:36 +01:00
return;
2018-11-04 17:33:23 +01:00
} else {
$scope.fileEncrypted = true;
}
}
// Chain various checks that require user input
warnUnencryptedPasswords(function() { getExport(); });
2018-11-04 17:46:33 +01:00
};
});