Add backup config download button

This commit is contained in:
Johannes Zellner
2020-04-20 18:21:35 +02:00
parent c0f5526801
commit 357d5e46a3
2 changed files with 32 additions and 10 deletions
+19
View File
@@ -200,6 +200,25 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
|| provider === 'linode-objectstorage';
};
// https://stackoverflow.com/questions/3665115/how-to-create-a-file-in-memory-for-user-to-download-but-not-through-server#18197341
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
$scope.downloadConfig = function () {
// secrets and tokens already come with placeholder characters
download('cloudron_backup.json', JSON.stringify($scope.backupConfig));
};
$scope.configureBackup = {
busy: false,
error: {},