Add block device selector in restore view

This commit is contained in:
Johannes Zellner
2023-08-08 21:00:13 +02:00
parent fb4921e2d3
commit 842d7e6b61
6 changed files with 58 additions and 7 deletions
+9
View File
@@ -1848,6 +1848,15 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
});
};
Client.prototype.getProvisionBlockDevices = function (callback) {
get('/api/v1/cloudron/block_devices', null, function (error, data, status) {
if (error) return callback(error);
if (status !== 200) return callback(new ClientError(status, data));
callback(null, data.devices);
});
};
Client.prototype.createAdmin = function (data, callback) {
var that = this;
+27 -4
View File
@@ -41,6 +41,8 @@ app.controller('RestoreController', ['$scope', 'Client', function ($scope, Clien
$scope.encrypted = false; // only used if a backup config contains that flag
$scope.setupToken = '';
$scope.skipDnsSetup = false;
$scope.disk = null;
$scope.blockDevices = [];
$scope.mountOptions = {
host: '',
@@ -54,6 +56,11 @@ app.controller('RestoreController', ['$scope', 'Client', function ($scope, Clien
privateKey: ''
};
$scope.$watch('disk', function (newValue) {
if (!newValue) return;
$scope.mountOptions.diskPath = '/dev/disk/by-uuid/' + newValue.uuid;
});
$scope.sysinfo = {
provider: 'generic',
ipv4: '',
@@ -358,10 +365,26 @@ app.controller('RestoreController', ['$scope', 'Client', function ($scope, Clien
return;
}
$scope.status = status;
$scope.instanceId = search.instanceId;
$scope.setupToken = search.setupToken;
$scope.initialized = true;
Client.getProvisionBlockDevices(function (error, result) {
if (error) {
console.error('Failed to list blockdevices:', error);
} else {
// only offer non /, /boot or /home disks
result = result.filter(function (d) { return d.mountpoint !== '/' && d.mountpoint !== '/home' && d.mountpoint !== '/boot'; });
// only offer xfs and ext4 disks
result = result.filter(function (d) { return d.type === 'xfs' || d.type === 'ext4'; });
// amend label for UI
result.forEach(function (d) { d.label = d.path; });
}
$scope.blockDevices = result;
$scope.status = status;
$scope.instanceId = search.instanceId;
$scope.setupToken = search.setupToken;
$scope.initialized = true;
});
});
}
+6
View File
@@ -137,6 +137,12 @@
<input type="text" class="form-control" ng-model="mountOptions.diskPath" id="inputConfigureDiskPath" name="diskPath" ng-disabled="busy" placeholder="Directory for backups" ng-required="provider === 'ext4' || provider === 'xfs'">
</div>
<!-- Disk -->
<div class="form-group" ng-class="{ 'has-error': error.diskPath }" ng-show="provider === 'disk'">
<label class="control-label">Device</label>
<select class="form-control" ng-model="disk" ng-options="item as item.label for item in blockDevices track by item.path" ng-required="provider === 'disk'"></select>
</div>
<!-- SSHFS -->
<div class="form-group" ng-show="provider === 'sshfs'">
<label class="control-label" for="configureBackupPort">SSH Port</label>
-1
View File
@@ -217,7 +217,6 @@
<div class="form-group" ng-class="{ 'has-error': configureBackup.error.diskPath || !configureBackup.mountOptions.diskPath }" ng-show="configureBackup.provider === 'disk'">
<label class="control-label">{{ 'backups.configureBackupStorage.diskPath' | tr }}</label>
<select class="form-control" ng-model="configureBackup.disk" ng-options="item as item.label for item in configureBackup.blockDevices track by item.path" ng-required="configureBackup.provider === 'disk'"></select>
{{ configureBackup.mountOptions.diskPath }}
</div>
<!-- SSHFS -->