mirror of
https://github.com/akuker/RASCSI.git
synced 2026-04-21 02:17:25 +00:00
Attach empty removable drives in the Web UI (#877)
* Read the drive properties file once and store it in the Flask app config. Spin out the drive properties formatting to a helper method. * Add empty removable disk drives to the attach peripherals UI * Refinement of UI labels and help text, moving some context to the wiki
This commit is contained in:
@@ -81,15 +81,15 @@ def get_device_name(device_type):
|
||||
Returns the human-readable name for the device type.
|
||||
"""
|
||||
if device_type == "SCHD":
|
||||
return _("Hard Disk")
|
||||
return _("Hard Disk Drive")
|
||||
if device_type == "SCRM":
|
||||
return _("Removable Disk")
|
||||
return _("Removable Disk Drive")
|
||||
if device_type == "SCMO":
|
||||
return _("Magneto-Optical Disk")
|
||||
return _("Magneto-Optical Drive")
|
||||
if device_type == "SCCD":
|
||||
return _("CD / DVD")
|
||||
return _("CD/DVD Drive")
|
||||
if device_type == "SCBR":
|
||||
return _("X68000 Host Bridge")
|
||||
return _("Host Bridge")
|
||||
if device_type == "SCDP":
|
||||
return _("DaynaPORT SCSI/Link")
|
||||
if device_type == "SCLP":
|
||||
@@ -132,6 +132,41 @@ def get_image_description(file_suffix):
|
||||
return file_suffix
|
||||
|
||||
|
||||
def format_drive_properties(drive_properties):
|
||||
"""
|
||||
Takes a (dict) with structured drive properties data
|
||||
Returns a (dict) with the formatted properties, one (list) per device type
|
||||
"""
|
||||
hd_conf = []
|
||||
cd_conf = []
|
||||
rm_conf = []
|
||||
mo_conf = []
|
||||
FORMAT_FILTER = "{:,.2f}"
|
||||
|
||||
for device in drive_properties:
|
||||
if device["device_type"] == "SCHD":
|
||||
device["secure_name"] = secure_filename(device["name"])
|
||||
device["size_mb"] = FORMAT_FILTER.format(device["size"] / 1024 / 1024)
|
||||
hd_conf.append(device)
|
||||
elif device["device_type"] == "SCCD":
|
||||
device["size_mb"] = _("N/A")
|
||||
cd_conf.append(device)
|
||||
elif device["device_type"] == "SCRM":
|
||||
device["secure_name"] = secure_filename(device["name"])
|
||||
device["size_mb"] = FORMAT_FILTER.format(device["size"] / 1024 / 1024)
|
||||
rm_conf.append(device)
|
||||
elif device["device_type"] == "SCMO":
|
||||
device["secure_name"] = secure_filename(device["name"])
|
||||
device["size_mb"] = FORMAT_FILTER.format(device["size"] / 1024 / 1024)
|
||||
mo_conf.append(device)
|
||||
|
||||
return {
|
||||
"hd_conf": hd_conf,
|
||||
"cd_conf": cd_conf,
|
||||
"rm_conf": rm_conf,
|
||||
"mo_conf": mo_conf,
|
||||
}
|
||||
|
||||
def auth_active(group):
|
||||
"""
|
||||
Inspects if the group defined in (str) group exists on the system.
|
||||
|
||||
Reference in New Issue
Block a user