Enable custom app data dir setting

This commit is contained in:
Johannes Zellner
2019-09-18 17:12:10 +02:00
parent 300ff09a47
commit 92257afdab
2 changed files with 48 additions and 15 deletions
+24 -5
View File
@@ -286,13 +286,14 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$scope.resources = {
busy: false,
busyDataDir: false,
error: {},
success: false,
currentMemoryLimit: 0,
memoryLimit: 0,
memoryTicks: [],
dataDir: null,
currentDataDirEnabled: false,
dataDirEnabled: false,
show: function () {
@@ -301,6 +302,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$scope.resources.currentMemoryLimit = app.memoryLimit || app.manifest.memoryLimit || (256 * 1024 * 1024);
$scope.resources.memoryLimit = $scope.resources.currentMemoryLimit;
$scope.resources.dataDirEnabled = !!app.dataDir;
$scope.resources.currentDataDirEnabled = $scope.resources.dataDirEnabled
$scope.resources.dataDir = app.dataDir;
// create ticks starting from manifest memory limit. the memory limit here is currently split into ram+swap (and thus *2 below)
@@ -315,20 +317,37 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
}
},
submit: function () {
submitMemoryLimit: function () {
$scope.resources.busy = true;
$scope.resources.error = {};
// TODO handle data dir once we show it
var memoryLimit = $scope.resources.memoryLimit === $scope.resources.memoryTicks[0] ? 0 : $scope.resources.memoryLimit;
Client.configureApp($scope.app.id, 'memory_limit', { memoryLimit: memoryLimit }, function (error) {
if (error) return Client.error(error);
$scope.resources.currentMemoryLimit = $scope.resources.memoryLimit;
$scope.resources.success = true;
$scope.resources.busy = false;
refreshApp();
});
},
submitDataDir: function () {
$scope.resources.busyDataDir = true;
$scope.resources.error = {};
Client.configureApp($scope.app.id, 'data_dir', { dataDir: $scope.resources.dataDirEnabled ? $scope.resources.dataDir : null }, function (error) {
if (error && error.statusCode === 400) {
$scope.resources.error.dataDir = error.message;
$scope.resources.busyDataDir = false;
return;
}
if (error) return Client.error(error);
$scope.resources.currentDataDirEnabled = $scope.resources.dataDirEnabled;
$scope.resourcesDataDirForm.$setPristine();
$scope.resources.busyDataDir = false;
refreshApp();
});
}