Fix storage UI to select volumes
This commit is contained in:
@@ -679,16 +679,10 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
busy: false,
|
||||
|
||||
busyDataDir: false,
|
||||
dataDir: null,
|
||||
|
||||
dataPrefix: '',
|
||||
|
||||
location: {
|
||||
id: '', // default, custom, volume+<volumeid>
|
||||
type: '', // default, custom, volume
|
||||
value: '' // emtpy, path, volumeId
|
||||
},
|
||||
storageVolumeId: null,
|
||||
storageVolumePrefix: '',
|
||||
|
||||
location: null,
|
||||
locationOptions: [],
|
||||
|
||||
busyBinds: false,
|
||||
@@ -698,25 +692,19 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
var app = $scope.app;
|
||||
|
||||
$scope.storage.error = {};
|
||||
$scope.storage.dataDir = app.dataDir;
|
||||
$scope.storage.storageVolumeId = app.storageVolumeId;
|
||||
$scope.storage.storageVolumePrefix = app.storageVolumePrefix;
|
||||
$scope.storage.mounts = [];
|
||||
|
||||
$scope.storage.locationOptions = [
|
||||
{ id: 'default', type: 'default', value: '', displayName: 'Default - /home/yellowtent/appsdata/' + app.id },
|
||||
{ id: 'custom', type: 'custom', value: app.dataDir, displayName: 'Custom Folder Path' }
|
||||
{ id: 'default', type: 'default', displayName: 'Default - /home/yellowtent/appsdata/' + app.id },
|
||||
];
|
||||
|
||||
$scope.volumes.forEach(function (volume) {
|
||||
$scope.storage.locationOptions.push({ id: 'volume-'+volume.id, type: 'volume', value: volume.id, displayName: 'Volume - ' + volume.name });
|
||||
$scope.storage.locationOptions.push({ id: volume.id, type: 'volume', value: volume.id, displayName: 'Volume - ' + volume.name });
|
||||
});
|
||||
|
||||
if (!app.dataDir) {
|
||||
$scope.storage.location = { id: 'default', type: 'default', value: '' };
|
||||
} else if (app.dataDir) {
|
||||
$scope.storage.location = { id: 'custom', type: 'custom', value: app.dataDir };
|
||||
} else {
|
||||
// TODO how to determine volume is used?
|
||||
}
|
||||
$scope.storage.location = $scope.storage.locationOptions.find(function (l) { return l.id === (app.storageVolumeId || 'default'); });
|
||||
|
||||
app.mounts.forEach(function (mount) { // { volumeId, readOnly }
|
||||
var volume = $scope.volumes.find(function (v) { return v.id === mount.volumeId; });
|
||||
@@ -728,9 +716,15 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
$scope.storage.busyDataDir = true;
|
||||
$scope.storage.error = {};
|
||||
|
||||
Client.configureApp($scope.app.id, 'storage', { dataDir: $scope.storage.dataDir || null }, function (error) {
|
||||
var data = { storageVolumeId: null, storageVolumePrefix: null };
|
||||
if ($scope.storage.location.id !== 'default') {
|
||||
data.storageVolumeId = $scope.storage.location.id;
|
||||
data.storageVolumePrefix = $scope.storage.storageVolumePrefix;
|
||||
}
|
||||
|
||||
Client.configureApp($scope.app.id, 'storage', data, function (error) {
|
||||
if (error && error.statusCode === 400) {
|
||||
$scope.storage.error.dataDir = error.message;
|
||||
$scope.storage.error.storageVolumePrefix = error.message;
|
||||
$scope.storage.busyDataDir = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user