From 9cb3a952b4ceb3c33e8481250179023fdf5ceebb Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Thu, 16 May 2024 12:38:28 +0200 Subject: ogcp: add cache management page Implement cache management through cache/list and cache/delete API REST methods. The view corresponds to the URL action/cache and contains three main parts: - Free cache available in the client's bubbles. - Image selection form to request the deletion and view the client with that image in cache. - Cache details per client to see total, used and available cache. The main usecase for the view is the removal of cache to make room for new images in clients with slow connections. Checking clients where available cache space is not enough to hold the new image and then requesting removal of specific images. The html template receives the following structures from the view: storage_data[ip] = {'used': 223452345, 'total': 2345234523452} client_images[ip] = [f'{image_name}.{image_checksum}', ...] image_data[f'{image_name}.{image_checksum}'] = { clients: ['192.168.0.1', ...], size: 34534530850, name: image_name, } --- ogcp/templates/actions/cache.html | 192 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 ogcp/templates/actions/cache.html (limited to 'ogcp/templates/actions/cache.html') diff --git a/ogcp/templates/actions/cache.html b/ogcp/templates/actions/cache.html new file mode 100644 index 0000000..07f5b16 --- /dev/null +++ b/ogcp/templates/actions/cache.html @@ -0,0 +1,192 @@ +{% extends 'commands.html' %} +{% import "bootstrap/wtf.html" as wtf %} + +{% set sidebar_state = 'disabled' %} +{% set btn_back = true %} + +{% block nav_client %} active{% endblock %} +{% block nav_client_cache %} active{% endblock %} +{% block content %} + +{% set ip_list = form.ips.data.split(' ') %} +{% set ip_count = ip_list | length %} +

+ {{ _('Manage Cache') }} +

+ +

{{ _('Check free cache space in the client\'s bubbles:') }}

+ +{{ macros.cmd_selected_clients(selected_clients) }} + +

{{ _('Select the images to be deleted:') }}

+ +
+ + + + + + + + + + {{ form.hidden_tag() }} + {% for image in form.images %} + + + + + {% endfor %} + +
{{ _('Image') }}{{ _('Clients') }}
+ {{ image.selected(class_="form-control") }} + {{ image.image_name() }} + {{ image.clients() }} + {{ image.image_name.data }} ({{ (images_data[image.selected.label.text]['size'] | int / 2**20)|round(3) }} MiB) + {{ ', '.join(images_data[image.selected.label.text]['clients']) }}
+ +
+ +
+ +
+
+ {{ _('Detailed cache usage') }} +
+
+ + + +
    +
  • + +
  • +
  • +

    {{ _('Images in cache:') }}

    +
    +
  • +
+
    +
  • + {{ _('Disk size') }} +
  • +
  • + {{ _('used') }} (%) +
  • +
  • + {{ _('available') }} (%) +
  • +
+
    +
  • +
  • +
  • +
+
+
+ + + + + + + +{% endblock %} -- cgit v1.2.3-18-g5258