From d00e437b8d76bc32732643a92f0ea32fbe0b7901 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Thu, 29 Aug 2024 11:55:52 +0200 Subject: ogcp: add support for multi-disk partition and format Add support for selecting different disks in the disk inspector. Add disk_inspector.html as a template to show the disk contents of a client. The view can define the variable readonly_disk_inspector to make the view non editable. Use disk_inspector.html in the following views: - client details - partition and format Update code to obtain the partitions of a client to better fit the requirements of disk_inspector.html Remove code to setup the SetupForm as the contents of the disks are now dynamically loaded through javascript. --- ogcp/templates/actions/client_details.html | 29 +-- ogcp/templates/actions/select_client.html | 42 ++++ ogcp/templates/actions/setup.html | 226 +-------------------- ogcp/templates/disk_inspector.html | 306 +++++++++++++++++++++++++++++ 4 files changed, 353 insertions(+), 250 deletions(-) create mode 100644 ogcp/templates/disk_inspector.html (limited to 'ogcp/templates') diff --git a/ogcp/templates/actions/client_details.html b/ogcp/templates/actions/client_details.html index a718450..6bccace 100644 --- a/ogcp/templates/actions/client_details.html +++ b/ogcp/templates/actions/client_details.html @@ -37,31 +37,10 @@ -{% if setup|length > 0 %} - - - - - - - - - - - - - {% for entry in setup %} - - - - - - - - {% endfor %} - -
{{_('Partition')}}{{_('Type')}}{{_('Filesystem')}}{{_('Size')}} (MiB){{_('Image')}}
{{ entry.partition }}{{ entry.code }}{{ entry.filesystem }}{{ entry.size // 1024}}{{ entry.image }}
-{% endif %} +{% set show_part_images = True %} +{% set readonly_disk_inspector = True %} +{% include 'disk_inspector.html' %} + {% include 'cache_inspector.html' %} diff --git a/ogcp/templates/actions/select_client.html b/ogcp/templates/actions/select_client.html index 0415621..a44c551 100644 --- a/ogcp/templates/actions/select_client.html +++ b/ogcp/templates/actions/select_client.html @@ -17,6 +17,48 @@ {{ macros.cmd_selected_clients(selected_clients) }} +{% if common_disk_data|length > 0 %} + +
+ + + + + + + + + + + {% for disk, data in common_disk_data.items() %} + {% for size, ips in data.inventory.items() %} + + {% if loop.first %} + + {% endif %} + + + + {% endfor %} + + {% endfor %} + +
{{ _('Disk') }}{{ _('Size (MiB)') }}{{ _('Clients') }}
{{ disk }} + {% if size == data.common_size %} + {{ size // 1024 }} + {% else %} + {{ size // 1024 }} + {% endif %} + + {% for ip in ips %} +
{{ ip }}
+ {% endfor %} +
+

{{ _('Note: the disk size in bold represents the selected common size for partitioning') }}

+
+ +{% endif %} + {{ wtf.quick_form(form, action=url_for('action_setup_show'), method='get', diff --git a/ogcp/templates/actions/setup.html b/ogcp/templates/actions/setup.html index 934d72f..6ae7c15 100644 --- a/ogcp/templates/actions/setup.html +++ b/ogcp/templates/actions/setup.html @@ -9,230 +9,6 @@

{{_('Partition and Format')}}

-
- - -
- -
- - - - - - - - - - - - - {{ form.hidden_tag() }} - - - - -
{{ _('Disk') }}{{ _('Partition Table Type') }}{{ _('Total Disk Size') }} (MiB)
- - {{ form.disk_type(class_="form-control") }}{{ disk_size }}
- - - - - - - - - - - - - {% for partition in form.partitions %} - - {{ partition.hidden_tag() }} - - - - - - - {% endfor %} - -
{{ _('Partition') }}{{ _('Type') }}{{ _('Filesystem') }}{{ _('Size') }} (MiB)
{{ partition.partition.data }}{{ partition.part_type(class_="form-control") }}{{ partition.fs(class_="form-control") }}{{ partition.size(class_="form-control", oninput="handleEdit(this)") }} - -
-
- - - - - -
-
- {{ _('Partition graph') }} -
-
- -
-
- - - - - - +{% include 'disk_inspector.html' %} {% endblock %} diff --git a/ogcp/templates/disk_inspector.html b/ogcp/templates/disk_inspector.html new file mode 100644 index 0000000..90a8996 --- /dev/null +++ b/ogcp/templates/disk_inspector.html @@ -0,0 +1,306 @@ +{% if selected_disk is defined and setup_data is defined %} + +
+ {{ disk_form.hidden_tag() }} + {{ disk_form.ips() }} + + + + + + + + + + + + + + {{ disk_form.hidden_tag() }} + + + + +
{{ _('Disk') }}{{ _('Partition Table Type') }}{{ _('Total Disk Size') }} (MiB)
+ {{ disk_form.disk(class_="form-control", onchange="handleDiskChange(this)") }} + + {% if readonly_disk_inspector is defined %} + {{ disk_form.disk_type(class_="form-control", id="diskType", readonly="readonly") }} + {% else %} + {{ disk_form.disk_type(class_="form-control", id="diskType") }} + {% endif %} + {{ disk_size }}
+ + + + + + + + {% if show_part_images is defined %} + + {% endif %} + + + + + + {% for partition in disk_form.partitions %} + + {{ partition.hidden_tag() }} + + + + + {% if show_part_images is defined %} + + {% endif %} + + + {% endfor %} + +
{{ _('Partition') }}{{ _('Type') }}{{ _('Filesystem') }}{{ _('Size') }} (MiB){{ _('Image') }}
{{ partition.partition.data }} + {% if readonly_disk_inspector is defined %} + {{ partition.part_type(class_="form-control", readonly="readonly") }} + {% else %} + {{ partition.part_type(class_="form-control") }} + {% endif %} + + {% if readonly_disk_inspector is defined %} + {{ partition.fs(class_="form-control", readonly="readonly") }} + {% else %} + {{ partition.fs(class_="form-control") }} + {% endif %} + + {% if readonly_disk_inspector is defined %} + {{ partition.size(class_="form-control", oninput="handleEdit(this)", readonly="readonly") }} + {% else %} + {{ partition.size(class_="form-control", oninput="handleEdit(this)") }} + {% endif %} + + +
+
+ + + +{% if not readonly_disk_inspector is defined %} + +{% endif %} + +
+
+ {{ _('Partition graph') }} +
+
+ +
+
+ + + + + + + +{% endif %} -- cgit v1.2.3-18-g5258