diff --git a/dashboard/src/js/client.js b/dashboard/src/js/client.js index 81f10c95c..79da2472c 100644 --- a/dashboard/src/js/client.js +++ b/dashboard/src/js/client.js @@ -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; diff --git a/dashboard/src/js/restore.js b/dashboard/src/js/restore.js index cd988e624..0451fcb6a 100644 --- a/dashboard/src/js/restore.js +++ b/dashboard/src/js/restore.js @@ -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; + }); }); } diff --git a/dashboard/src/restore.html b/dashboard/src/restore.html index f9375611f..f16e477a7 100644 --- a/dashboard/src/restore.html +++ b/dashboard/src/restore.html @@ -137,6 +137,12 @@ + +