Device table refinement in Web UI (#884)

* Refine the attached device table to optimize information displayed

* Error handling when attempting to insert withough image file

* Format the parameters in the jinja template instead

* Call the DaynaPORT device Ethernet Adapter in the Web UI
This commit is contained in:
Daniel Markstedt 2022-10-03 11:47:08 -07:00 committed by GitHub
parent c80953e0a4
commit fd47411322
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 23 deletions

View File

@ -42,21 +42,19 @@
{% if units %}
<td><b>{{ _("LUN") }}</b></td>
{% endif %}
<td><b>{{ _("Type") }}</b></td>
<td><b>{{ _("Status") }}</b></td>
<td><b>{{ _("File") }}</b></td>
<td><b>{{ _("Device") }}</b></td>
<td><b>{{ _("Parameters") }}</b></td>
<td><b>{{ _("Product") }}</b></td>
<td><b>{{ _("Actions") }}</b></td>
</tr>
{% for device in devices %}
{% for device in devices | sort(attribute='id') %}
<tr>
{% if device["id"] not in reserved_scsi_ids %}
<td style="text-align:center">{{ device.id }}</td>
{% if units %}
<td style="text-align:center">{{ device.unit }}</td>
{% endif %}
<td style="text-align:center">{{ device.device_type }}</td>
<td style="text-align:center">{{ device.status }}</td>
<td style="text-align:center">{{ device.device_name }}</td>
<td style="text-align:left">
{% if "No Media" in device.status %}
<form action="/scsi/attach" method="post">
@ -84,14 +82,30 @@
<input type="submit" value="{{ _("Attach") }}">
</form>
{% else %}
{% if device.params %}
{% for key in device.params %}
{% if key == "interface" %}
({{device.params[key]}})
{% elif key == "timeout" %}
({{key}}:{{device.params[key]}})
{% else %}
{{device.params[key]}}
{% endif %}
{% endfor %}
{% elif device.file %}
{{ device.file }}
{% endif %}
</td>
{% if device.vendor == "RaSCSI" %}
<td style="text-align:center">{{ device.product }}</td>
{% else %}
<td style="text-align:center">{{ device.vendor }} {{ device.product }}</td>
{% endif %}
</td>
<td style="text-align:center">
{% if device.vendor != "RaSCSI" %}
{{ device.vendor }}
{% endif %}
{{ device.product }}
{% if device.vendor != "RaSCSI" %}
{{ device.revision }}
{% endif %}
</td>
<td style="text-align:center">
{% if device.device_type != "-" %}
{% if device.device_type in REMOVABLE_DEVICE_TYPES and "No Media" not in device.status %}
@ -119,7 +133,6 @@
{% if units %}
<td class="inactive"></td>
{% endif %}
<td class="inactive"></td>
<td class="inactive">{{ _("Reserved ID") }}</td>
<td class="inactive">{{ RESERVATIONS[device.id] }}</td>
<td class="inactive"></td>
@ -179,7 +192,7 @@
<tr style="font-weight: bold;">
<td>{{ _("File") }}</td>
<td>{{ _("Size") }}</td>
<td>{{ _("Parameters and Actions") }}</td>
<td>{{ _("Actions") }}</td>
</tr>
{% for file in files|sort(attribute='name') %}
<tr>

View File

@ -601,6 +601,9 @@ def attach_image():
unit = request.form.get("unit")
device_type = request.form.get("type")
if not file_name:
return response(error=True, message=_("No image file to insert"))
kwargs = {"unit": int(unit), "params": {"file": file_name}}
if device_type:

View File

@ -47,18 +47,25 @@ def sort_and_format_devices(devices):
For SCSI IDs where no device is attached, inject a (dict) with placeholder text.
"""
occupied_ids = []
formatted_devices = []
for device in devices:
occupied_ids.append(device["id"])
device["device_name"] = get_device_name(device["device_type"])
formatted_devices.append(device)
formatted_devices = devices
# Add padding devices and sort the list
for i in range(8):
if i not in occupied_ids:
formatted_devices.append({"id": i, "device_type": "-", \
"status": "-", "file": "-", "product": "-"})
# Sort list of devices by id
formatted_devices.sort(key=lambda dic: str(dic["id"]))
# Add placeholder data for non-occupied IDs
for scsi_id in range(8):
if scsi_id not in occupied_ids:
formatted_devices.append(
{
"id": scsi_id,
"unit": "-",
"device_name": "-",
"status": "-",
"file": "-",
"product": "-",
}
)
return formatted_devices
@ -91,7 +98,7 @@ def get_device_name(device_type):
if device_type == "SCBR":
return _("Host Bridge")
if device_type == "SCDP":
return _("DaynaPORT SCSI/Link")
return _("Ethernet Adapter")
if device_type == "SCLP":
return _("Printer")
if device_type == "SCHS":