From 8fb8a42825cdf483f1808b0e63c3f71af74dec52 Mon Sep 17 00:00:00 2001 From: Daniel Markstedt Date: Thu, 14 Oct 2021 17:49:06 -0700 Subject: [PATCH] Hide controls when appropriate (#327) * Hide image file controls when it is attached * Hide device actions when no device is attached --- src/web/templates/index.html | 6 ++++++ src/web/web.py | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/web/templates/index.html b/src/web/templates/index.html index 02723f75..52c58079 100644 --- a/src/web/templates/index.html +++ b/src/web/templates/index.html @@ -60,6 +60,7 @@ {{device.vendor}} {{device.product}} {% endif %} + {% if device.device_type != "-" %} {% if device.device_type in removable_device_types and "No Media" not in device.status %}
@@ -83,6 +84,7 @@
{% endif %} + {% endif %} {% else %} {{device.id}} @@ -129,6 +131,9 @@ + {% if file["name"] in attached_images %} +
Attached!
+ {% else %}
@@ -163,6 +168,7 @@
{% endif %} + {% endif %} {% endfor %} diff --git a/src/web/web.py b/src/web/web.py index d25e4b46..4b0fc682 100644 --- a/src/web/web.py +++ b/src/web/web.py @@ -63,8 +63,11 @@ def index(): sorted_image_files = sorted(files["files"], key = lambda x: x["name"].lower()) sorted_config_files = sorted(config_files, key = lambda x: x.lower()) + from pathlib import Path + attached_images = [] luns = 0 for d in devices["device_list"]: + attached_images.append(Path(d["image"]).name) luns += int(d["un"]) reserved_scsi_ids = server_info["reserved_ids"] @@ -80,7 +83,6 @@ def index(): list(ARCHIVE_FILE_SUFFIX) ) - return render_template( "index.html", bridge_configured=is_bridge_setup(), @@ -91,6 +93,7 @@ def index(): cfg_dir=cfg_dir, scsi_ids=scsi_ids, recommended_id=recommended_id, + attached_images=attached_images, luns=luns, reserved_scsi_ids=reserved_scsi_ids, max_file_size=int(MAX_FILE_SIZE / 1024 / 1024),