Add button to upload and pre-fill backup config

This commit is contained in:
Johannes Zellner
2020-05-15 00:32:49 +02:00
parent babe0adffb
commit 7088e6682b
2 changed files with 33 additions and 2 deletions

View File

@@ -35,6 +35,7 @@ app.controller('RestoreController', ['$scope', 'Client', function ($scope, Clien
$scope.format = 'tgz';
$scope.advancedVisible = false;
$scope.password = '';
$scope.encrypted = false; // only used if a backup config contains that flag
$scope.sysinfo = {
provider: 'generic',
@@ -326,6 +327,29 @@ app.controller('RestoreController', ['$scope', 'Client', function ($scope, Clien
document.getElementById('gcsKeyFileInput').onchange = readFileLocally($scope.gcsKey, 'content', 'keyFileName');
document.getElementById('backupConfigFileInput').onchange = function (event) {
var reader = new FileReader();
reader.onload = function (result) {
if (!result.target || !result.target.result) return console.error('Unable to read backup config');
var backupConfig;
try {
backupConfig = JSON.parse(result.target.result);
} catch (e) {
console.error('Unable to parse backup config');
return;
}
$scope.$apply(function () {
// we assume property names match here, this does not yet work for gcs keys
Object.keys(backupConfig).forEach(function (k) {
if (k in $scope) $scope[k] = backupConfig[k];
});
});
};
reader.readAsText(event.target.files[0]);
};
function init() {
Client.getStatus(function (error, status) {
if (error) return Client.initError(error, init);