service: fix broken memory sliders
This commit is contained in:
@@ -10,6 +10,7 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
|
||||
$scope.ready = false;
|
||||
$scope.services = [];
|
||||
$scope.isRebootRequired = false;
|
||||
$scope.memory = null;
|
||||
|
||||
function refresh(serviceName, callback) {
|
||||
callback = callback || function () {};
|
||||
@@ -96,7 +97,7 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
|
||||
// create ticks starting from manifest memory limit. the memory limit here is currently split into ram+swap (and thus *2 below)
|
||||
// TODO: the *2 will overallocate since 4GB is max swap that cloudron itself allocates
|
||||
$scope.serviceConfigure.memoryTicks = [];
|
||||
var npow2 = Math.pow(2, Math.ceil(Math.log($scope.config.memory)/Math.log(2)));
|
||||
var npow2 = Math.pow(2, Math.ceil(Math.log($scope.memory.memory)/Math.log(2)));
|
||||
for (var i = 256; i <= (npow2*2/1024/1024); i *= 2) {
|
||||
$scope.serviceConfigure.memoryTicks.push(i * 1024 * 1024);
|
||||
}
|
||||
@@ -135,21 +136,33 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
|
||||
}
|
||||
};
|
||||
|
||||
function getMemory(callback) {
|
||||
Client.memory(function (error, memory) {
|
||||
if (error) console.error(error);
|
||||
|
||||
$scope.memory = memory;
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
Client.onReady(function () {
|
||||
Client.isRebootRequired(function (error, result) {
|
||||
if (error) console.error(error);
|
||||
|
||||
$scope.isRebootRequired = !!result;
|
||||
|
||||
Client.getServices(function (error, result) {
|
||||
if (error) return Client.error(error);
|
||||
getMemory(function () {
|
||||
Client.getServices(function (error, result) {
|
||||
if (error) return Client.error(error);
|
||||
|
||||
$scope.services = result.map(function (serviceName) { return { name: serviceName }; });
|
||||
$scope.services = result.map(function (serviceName) { return { name: serviceName }; });
|
||||
|
||||
// just kick off the status fetching
|
||||
refreshAll();
|
||||
// just kick off the status fetching
|
||||
refreshAll();
|
||||
|
||||
$scope.ready = true;
|
||||
$scope.ready = true;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user