mirror of
https://github.com/akuker/RASCSI.git
synced 2026-04-21 18:17:07 +00:00
Further improve the dynamic device info web UI (#657)
* Improve the device type selection UI * Extend the image_files data structure with human readable device name, instead of having complex for loops in the jinja2 template. * Leverage device type constants in the OLED monitor script * Fix typo * Generate the list of valid network devices that can be attached programmatically * Fix typo
This commit is contained in:
@@ -57,7 +57,7 @@ def extend_device_names(device_types):
|
||||
Takes a (list) of (str) device_types with the four letter device acronyms
|
||||
Returns a (dict) of device_type:device_name mappings of localized device names
|
||||
"""
|
||||
mapped_device_types = []
|
||||
mapped_device_types = {}
|
||||
for device_type in device_types:
|
||||
if device_type is "SAHD":
|
||||
device_name = _("SASI Hard Drive")
|
||||
@@ -75,6 +75,6 @@ def extend_device_names(device_types):
|
||||
device_name = _("DaynaPORT SCSI/Link")
|
||||
else:
|
||||
device_name = _("Unknown Device")
|
||||
mapped_device_types.append({device_type: device_name})
|
||||
mapped_device_types[device_type] = device_name
|
||||
|
||||
return mapped_device_types
|
||||
|
||||
@@ -260,27 +260,19 @@
|
||||
<input name="unit" type="number" size="2" value="0" min="0" max="31">
|
||||
{% if file["detected_type"] != "UNDEFINED" %}
|
||||
<input name="type" type="hidden" value="{{ file['detected_type'] }}">
|
||||
{% for device in device_types %}
|
||||
{% for key, value in device.items() %}
|
||||
{% if file["detected_type"] == key %}
|
||||
{{ value }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{{ file['detected_type_name'] }}
|
||||
{% else %}
|
||||
<select name="type">
|
||||
<option selected value="">
|
||||
{{ _("Type") }}
|
||||
<option selected disabled value="">
|
||||
{{ _("Select device type") }}
|
||||
</option>
|
||||
{% for device in device_types %}
|
||||
{% for key, value in device.items() %}
|
||||
{% if key not in ("SCBR", "SCDP") %}
|
||||
{% for key, value in device_types.items() %}
|
||||
{% if key not in NETWORK_DEVICE_TYPES %}
|
||||
<option value="{{ key }}">
|
||||
{{ value }}
|
||||
</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% endif %}
|
||||
<input type="submit" value="{{ _("Attach") }}">
|
||||
@@ -310,7 +302,7 @@
|
||||
{{ _("Attach Network Adapter") }}
|
||||
</summary>
|
||||
<ul>
|
||||
<li>{{ _("Emulates either a <a href=\"%(url1)s\">SCSI DaynaPORT Ethernet Adapter</a>, or an <a href=\"%(url2)s\">X68000 Host Bridge</a>.", url1="https://github.com/akuker/RASCSI/wiki/Dayna-Port-SCSI-Link", url2="https://github.com/akuker/RASCSI/wiki/X68000#Host_File_System_driver") }}
|
||||
<li>{{ _("Emulates either a <a href=\"%(url1)s\">DaynaPORT SCSI/Link Ethernet Adapter</a>, or an <a href=\"%(url2)s\">X68000 Host Bridge</a>.", url1="https://github.com/akuker/RASCSI/wiki/Dayna-Port-SCSI-Link", url2="https://github.com/akuker/RASCSI/wiki/X68000#Host_File_System_driver") }}
|
||||
</li>
|
||||
<li>{{ _("If you have a DHCP setup, choose only the interface you have configured the bridge with. You can ignore the Static IP fields when attaching.") }}</li>
|
||||
<li>{{ _("Configure the network bridge by running easyinstall.sh, or follow the <a href=\"%(url)s\">manual steps in the wiki</a>.", url="https://github.com/akuker/RASCSI/wiki/Dayna-Port-SCSI-Link#manual-setup") }}
|
||||
@@ -337,12 +329,15 @@
|
||||
<input name="mask" type="number" size="2" placeholder="24" min="16" max="30">
|
||||
<label for="type">{{ _("Type:") }}</label>
|
||||
<select name="type">
|
||||
<option selected value="SCDP">
|
||||
{{ _("DaynaPORT") }}
|
||||
</option>
|
||||
<option value="SCBR">
|
||||
{{ _("Host Bridge") }}
|
||||
{% for type in NETWORK_DEVICE_TYPES %}
|
||||
<option value="{{ type }}">
|
||||
{% for key, value in device_types.items() %}
|
||||
{% if key == type %}
|
||||
{{ value }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<label for="scsi_id">{{ _("SCSI ID:") }}</label>
|
||||
<select name="scsi_id">
|
||||
|
||||
+11
-2
@@ -54,6 +54,7 @@ from rascsi.common_settings import (
|
||||
CONFIG_FILE_SUFFIX,
|
||||
PROPERTIES_SUFFIX,
|
||||
REMOVABLE_DEVICE_TYPES,
|
||||
NETWORK_DEVICE_TYPES,
|
||||
RESERVATIONS,
|
||||
)
|
||||
from rascsi.ractl_cmds import RaCtlCmds
|
||||
@@ -115,10 +116,17 @@ def index():
|
||||
image_files = file_cmds.list_images()
|
||||
config_files = file_cmds.list_config_files()
|
||||
|
||||
sorted_image_files = sorted(image_files["files"], key=lambda x: x["name"].lower())
|
||||
sorted_config_files = sorted(config_files, key=lambda x: x.lower())
|
||||
mapped_device_types = extend_device_names(device_types["device_types"])
|
||||
|
||||
extended_image_files = []
|
||||
for image in image_files["files"]:
|
||||
if image["detected_type"] is not "UNDEFINED":
|
||||
image["detected_type_name"] = mapped_device_types[image["detected_type"]]
|
||||
extended_image_files.append(image)
|
||||
|
||||
sorted_image_files = sorted(extended_image_files, key=lambda x: x["name"].lower())
|
||||
sorted_config_files = sorted(config_files, key=lambda x: x.lower())
|
||||
|
||||
attached_images = []
|
||||
units = 0
|
||||
# If there are more than 0 logical unit numbers, display in the Web UI
|
||||
@@ -181,6 +189,7 @@ def index():
|
||||
ARCHIVE_FILE_SUFFIX=ARCHIVE_FILE_SUFFIX,
|
||||
PROPERTIES_SUFFIX=PROPERTIES_SUFFIX,
|
||||
REMOVABLE_DEVICE_TYPES=REMOVABLE_DEVICE_TYPES,
|
||||
NETWORK_DEVICE_TYPES=NETWORK_DEVICE_TYPES,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user