mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-22 16:33:17 +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:
parent
f96ade9149
commit
25b9b4ada2
@ -7,6 +7,7 @@ from os import getcwd
|
||||
WORK_DIR = getcwd()
|
||||
|
||||
REMOVABLE_DEVICE_TYPES = ("SCCD", "SCRM", "SCMO")
|
||||
NETWORK_DEVICE_TYPES = ("SCDP", "SCBR")
|
||||
|
||||
# There may be a more elegant way to get the HOME dir of the user that installed RaSCSI
|
||||
HOME_DIR = "/".join(WORK_DIR.split("/")[0:3])
|
||||
|
@ -43,6 +43,11 @@ from pi_cmds import get_ip_and_host
|
||||
from rascsi.ractl_cmds import RaCtlCmds
|
||||
from rascsi.socket_cmds import SocketCmds
|
||||
|
||||
from rascsi.common_settings import (
|
||||
REMOVABLE_DEVICE_TYPES,
|
||||
NETWORK_DEVICE_TYPES,
|
||||
)
|
||||
|
||||
parser = argparse.ArgumentParser(description="RaSCSI OLED Monitor script")
|
||||
parser.add_argument(
|
||||
"--rotation",
|
||||
@ -174,20 +179,17 @@ def formatted_output():
|
||||
output.append("Permission denied!")
|
||||
elif rascsi_list:
|
||||
for line in rascsi_list:
|
||||
if line["device_type"] in ("SCCD", "SCRM", "SCMO"):
|
||||
if line["device_type"] in REMOVABLE_DEVICE_TYPES:
|
||||
# Print image file name only when there is an image attached
|
||||
if line["file"]:
|
||||
output.append(f"{line['id']} {line['device_type'][2:4]} "
|
||||
f"{line['file']} {line['status']}")
|
||||
else:
|
||||
output.append(f"{line['id']} {line['device_type'][2:4]} {line['status']}")
|
||||
# Special handling for the DaynaPort device
|
||||
elif line["device_type"] == "SCDP":
|
||||
# Special handling for network devices
|
||||
elif line["device_type"] in NETWORK_DEVICE_TYPES:
|
||||
output.append(f"{line['id']} {line['device_type'][2:4]} {line['vendor']} "
|
||||
f"{line['product']}")
|
||||
# Special handling for the Host Bridge device
|
||||
elif line["device_type"] == "SCBR":
|
||||
output.append(f"{line['id']} {line['device_type'][2:4]} {line['product']}")
|
||||
# Print only the Vendor/Product info if it's not generic RaSCSI
|
||||
elif line["vendor"] not in "RaSCSI":
|
||||
output.append(f"{line['id']} {line['device_type'][2:4]} {line['file']} "
|
||||
|
@ -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">
|
||||
|
@ -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,
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user