templates: show real sizes in cache inspector

Use real free and available cache in cache_inspector.html
master
Alejandro Sirgo Rica 2024-09-26 10:34:28 +02:00
parent 77a60b717a
commit c1d9018e21
3 changed files with 12 additions and 9 deletions

View File

@ -100,9 +100,9 @@
}
function updateChart(ip) {
var totalCache = toGiB(storageData[ip].total, 3);
var totalCache = toGiB(storageData[ip].used + storageData[ip].free, 3);
var usedCache = toGiB(storageData[ip].used, 3);
var freeCache = toGiB(storageData[ip].total - storageData[ip].used, 3)
var freeCache = toGiB(storageData[ip].free, 3);
cacheChart.data.datasets[0].data = [
usedCache,
@ -134,9 +134,7 @@
$('.badge-pill').each(function(index) {
for (var ip in storageData) {
if ($(this).html().includes(ip)) {
var totalCache = storageData[ip].total;
var usedCache = storageData[ip].used;
var freeCache = toGiB(totalCache - usedCache, 1)
var freeCache = toGiB(storageData[ip].free, 1)
$(this).html($(this).html() + '<br>free: ' + freeCache + ' GiB');
break;
}

View File

@ -180,7 +180,12 @@
let freeSpace = diskSize;
let partNum = 1;
$('#partitionsTable tr').each(function() {
{% if readonly_disk_inspector is defined %}
let partitionSize = parseInt($(this).find('td').eq(3).text().trim());
{% else %}
let partitionSize = parseInt($(this).find('td').eq(3).find('input').val().trim());
{% endif %}
if (isNaN(partitionSize)) {
partitionSize = 0;
}

View File

@ -408,12 +408,12 @@ def hash_password(pwd):
def get_cache_info(clients_info, storage_data, images_data, client_images):
for client_info in clients_info:
ip = client_info['ip']
cache_size = int(client_info['cache_size'])
used_cache = 0
cache_size = client_info['cache_size'] * 1024
used_cache = client_info['used_cache']
free_cache = client_info['free_cache']
for image_info in client_info['images']:
image_name = image_info['name']
checksum = image_info['checksum']
used_cache += int(image_info['size'])
img_identifier = f'{image_name}.{checksum}'
if ip in client_images:
@ -432,7 +432,7 @@ def get_cache_info(clients_info, storage_data, images_data, client_images):
}
storage_data[ip] = {'used': used_cache,
'total': cache_size}
'free': free_cache}
def authenticate_user(username, pwd):
for user in app.config['USERS']: