Fix storage UI to select volumes
This commit is contained in:
@@ -966,16 +966,10 @@
|
||||
|
||||
<br/>
|
||||
|
||||
<div class="form-group" ng-show="storage.location.type === 'custom'" ng-class="{ 'has-error': storageDataDirForm.$dirty && storage.error.dataDir }">
|
||||
<label class="control-label">Folder Path</label>
|
||||
<input type="text" class="form-control" name="dataDir" placeholder="{{ 'app.storage.appdata.dataDirPlaceholder' | tr }}" ng-model="storage.dataDir">
|
||||
<div ng-show="storage.error.dataDir">{{ storage.error.dataDir }}</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" ng-show="storage.location.type === 'volume'" ng-class="{ 'has-error': storageDataDirForm.$dirty && storage.error.dataPrefix }">
|
||||
<label class="control-label">Folder Prefix</label>
|
||||
<input type="text" class="form-control" name="dataPrefix" placeholder="Prefix within the Volume" ng-model="storage.dataPrefix">
|
||||
<div ng-show="storage.error.dataPrefix">{{ storage.error.dataPrefix }}</div>
|
||||
<div class="form-group" ng-show="storage.location.type === 'volume'" ng-class="{ 'has-error': storageDataDirForm.$dirty && storage.error.storageVolumePrefix }">
|
||||
<label class="control-label">Subdirectory</label>
|
||||
<input type="text" class="form-control" name="storageVolumePrefix" placeholder="Prefix within the Volume" ng-model="storage.storageVolumePrefix">
|
||||
<div ng-show="storage.error.storageVolumePrefix">{{ storage.error.storageVolumePrefix }}</div>
|
||||
</div>
|
||||
|
||||
<input class="ng-hide" type="submit" ng-disabled="!storageDataDirForm.$dirty || storageDataDirForm.$invalid || storage.busyDataDir"/>
|
||||
|
||||
@@ -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