mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-21 08:29:59 +00:00
Make the support device UI entirely procedurally generated (#686)
* Make the support device UI entirely procedurally generated, removing the special case network device UI flow. * Clean up helptext.
This commit is contained in:
parent
2beb78727f
commit
01e1aaae3e
@ -161,10 +161,10 @@
|
||||
|
||||
<table border="black" cellpadding="3">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><b>{{ _("File") }}</b></td>
|
||||
<td><b>{{ _("Size") }}</b></td>
|
||||
<td><b>{{ _("Actions") }}</b></td>
|
||||
<tr style="font-weight: bold;">
|
||||
<td>{{ _("File") }}</td>
|
||||
<td>{{ _("Size") }}</td>
|
||||
<td>{{ _("Actions") }}</td>
|
||||
</tr>
|
||||
{% for file in files %}
|
||||
<tr>
|
||||
@ -296,97 +296,52 @@
|
||||
<p><small>{{ _("%(disk_space)s MB disk space remaining on the Pi", disk_space=free_disk) }}</small></p>
|
||||
|
||||
<hr/>
|
||||
|
||||
<details>
|
||||
<summary class="heading">
|
||||
{{ _("Attach Network Adapter") }}
|
||||
{{ _("Attach Support Device") }}
|
||||
</summary>
|
||||
<ul>
|
||||
<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>{{ _("<a href=\"%(url1)s\">DaynaPORT SCSI/Link</a> and <a href=\"%(url2)s\">X68000 Host Bridge</a> are network devices.", 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>
|
||||
<ul>
|
||||
<li>{{ _("If you have a DHCP setup, choose only the interface you have configured the bridge with. You can ignore the inet field 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") }}
|
||||
{% if bridge_configured %}
|
||||
<li>{{ _("The <tt>rascsi_bridge</tt> network bridge is active and ready to be used by an emulated network adapter!") }}</li>
|
||||
{% endif %}
|
||||
</li>
|
||||
</ul>
|
||||
<li>{{ _("The Printer and Host Services device are currently supported on compatible Atari systems, and require <a href=\"%(url)s\">driver software</a> to be installed on the host system.", url="https://www.hddriver.net/en/rascsi_tools.html") }}
|
||||
</li>
|
||||
<li style="list-style: none">{% if bridge_configured %}</li>
|
||||
<li>{{ _("The <tt>rascsi_bridge</tt> network bridge is active and ready to be used by the emulated network adapter!") }}</li>
|
||||
<li style="list-style: none">{% endif %}</li>
|
||||
</ul>
|
||||
</details>
|
||||
<table style="border: none">
|
||||
<tr style="border: none">
|
||||
<td style="border: none; vertical-align:top;">
|
||||
<form action="/scsi/attach_network" method="post">
|
||||
<label for="type">{{ _("Type:") }}</label>
|
||||
<select name="type">
|
||||
{% 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="if">{{ _("Interface:") }}</label>
|
||||
<select name="if">
|
||||
<table border="black" cellpadding="3">
|
||||
<tr style="font-weight: bold;">
|
||||
<td>{{ _("Type") }}</td>
|
||||
<td>{{ _("Actions") }}</td>
|
||||
</tr>
|
||||
{% for type in (NETWORK_DEVICE_TYPES + SUPPORT_DEVICE_TYPES) %}
|
||||
<tr>
|
||||
<td>
|
||||
<div>{{ device_types[type] }}</div>
|
||||
</td>
|
||||
<td>
|
||||
<form action="/scsi/attach_device" method="post">
|
||||
<input name="type" type="hidden" value="{{ type }}">
|
||||
{% for key, value in device_params[type].items() %}
|
||||
<label for="{{ key }}">{{ key }}:</label>
|
||||
{% if value.isnumeric() %}
|
||||
<input name="{{ key }}" type="number" size="{{ value|length }}" placeholder="{{ value }}">
|
||||
{% elif key == "interface" %}
|
||||
<select name="interface">
|
||||
{% for if in netinfo["ifs"] %}
|
||||
<option value="{{ if }}">
|
||||
{{ if }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<label for="ip">{{ _("Static IP (optional):") }}</label>
|
||||
<input name="ip" type="text" size="15" placeholder="10.10.20.1" minlength="7" maxlength="15" pattern="^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$">
|
||||
<input name="mask" type="number" size="2" placeholder="24" min="16" max="30">
|
||||
<label for="scsi_id">{{ _("SCSI ID:") }}</label>
|
||||
<select name="scsi_id">
|
||||
{% for id in scsi_ids %}
|
||||
<option value="{{ id }}"{% if id == recommended_id %} selected{% endif %}>
|
||||
{{ id }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<label for="unit">{{ _("LUN") }}</label>
|
||||
<input name="unit" type="number" size="2" value="0" min="0" max="31">
|
||||
<input type="submit" value="{{ _("Attach") }}">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% if macproxy_configured %}
|
||||
<p><small>{{ _("Macproxy is running at %(ip_addr)s (default port 5000)", ip_addr=ip_addr) }}</small></p>
|
||||
{% else %}
|
||||
<p><small>{{ _("Install <a href=\"%(url)s\">Macproxy</a> to browse the Web with any vintage browser. It's not just for Macs!", url="https://github.com/akuker/RASCSI/wiki/Vintage-Web-Proxy#macproxy") }}</small></p>
|
||||
{% endif %}
|
||||
|
||||
<hr/>
|
||||
<details>
|
||||
<summary class="heading">
|
||||
{{ _("Attach Support Device (EXPERIMENTAL)") }}
|
||||
</summary>
|
||||
<ul>
|
||||
<li>Attach an experimental Support Device that may provide additional functionality for the Host system.
|
||||
</li>
|
||||
<li>Relies on driver software on the Host side that utilizes the exposed functionality.
|
||||
</li>
|
||||
</ul>
|
||||
</details>
|
||||
<table border="black" cellpadding="3">
|
||||
{% for type in SUPPORT_DEVICE_TYPES %}
|
||||
<tr>
|
||||
<td>
|
||||
<div>{{ _("Type:") }} <strong>{{ device_types[type] }}</strong></div>
|
||||
</td>
|
||||
<td>
|
||||
<form action="/scsi/attach_support" method="post">
|
||||
<input name="type" type="hidden" value="{{ type }}">
|
||||
{% for key, value in device_params[type].items() %}
|
||||
<label for="{{ key }}">{{ key }}:</label>
|
||||
{% if value.isnumeric() %}
|
||||
<input name="{{ key }}" type="number" size="{{ value|length }}" value="{{ value }}">
|
||||
{% else %}
|
||||
<input name="{{ key }}" type="text" size="{{ value|length }}" value="{{ value }}">
|
||||
<input name="{{ key }}" type="text" size="{{ value|length }}" placeholder="{{ value }}">
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<label for="scsi_id">{{ _("SCSI ID:") }}</label>
|
||||
@ -405,6 +360,11 @@
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% if macproxy_configured %}
|
||||
<p><small>{{ _("Macproxy is running at %(ip_addr)s (default port 5000)", ip_addr=ip_addr) }}</small></p>
|
||||
{% else %}
|
||||
<p><small>{{ _("Install <a href=\"%(url)s\">Macproxy</a> to browse the Web with any vintage browser. It's not just for Macs!", url="https://github.com/akuker/RASCSI/wiki/Vintage-Web-Proxy#macproxy") }}</small></p>
|
||||
{% endif %}
|
||||
|
||||
<hr/>
|
||||
<details>
|
||||
|
@ -496,11 +496,11 @@ def log_level():
|
||||
return redirect(url_for("index"))
|
||||
|
||||
|
||||
@APP.route("/scsi/attach_support", methods=["POST"])
|
||||
@APP.route("/scsi/attach_device", methods=["POST"])
|
||||
@login_required
|
||||
def attach_support_device():
|
||||
def attach_device():
|
||||
"""
|
||||
Attaches a support device
|
||||
Attaches a support device that doesn't take an image file as argument
|
||||
"""
|
||||
params = {}
|
||||
for item in request.form:
|
||||
@ -511,7 +511,32 @@ def attach_support_device():
|
||||
elif item == "type":
|
||||
device_type = request.form.get(item)
|
||||
else:
|
||||
params.update({item: request.form.get(item)})
|
||||
param = request.form.get(item)
|
||||
if param:
|
||||
params.update({item: param})
|
||||
|
||||
error_url = "https://github.com/akuker/RASCSI/wiki/Dayna-Port-SCSI-Link"
|
||||
error_msg = _("Please follow the instructions at %(url)s", url=error_url)
|
||||
|
||||
if "interface" in params.keys():
|
||||
if params["interface"].startswith("wlan"):
|
||||
if not introspect_file("/etc/sysctl.conf", r"^net\.ipv4\.ip_forward=1$"):
|
||||
flash(_("Configure IPv4 forwarding before using a wireless network device."), "error")
|
||||
flash(error_msg, "error")
|
||||
return redirect(url_for("index"))
|
||||
if not Path("/etc/iptables/rules.v4").is_file():
|
||||
flash(_("Configure NAT before using a wireless network device."), "error")
|
||||
flash(error_msg, "error")
|
||||
return redirect(url_for("index"))
|
||||
else:
|
||||
if not introspect_file("/etc/dhcpcd.conf", r"^denyinterfaces " + params["interface"] + r"$"):
|
||||
flash(_("Configure the network bridge before using a wired network device."), "error")
|
||||
flash(error_msg, "error")
|
||||
return redirect(url_for("index"))
|
||||
if not Path("/etc/network/interfaces.d/rascsi_bridge").is_file():
|
||||
flash(_("Configure the network bridge before using a wired network device."), "error")
|
||||
flash(error_msg, "error")
|
||||
return redirect(url_for("index"))
|
||||
|
||||
kwargs = {
|
||||
"unit": int(unit),
|
||||
@ -523,66 +548,7 @@ def attach_support_device():
|
||||
if process["status"]:
|
||||
flash(_(
|
||||
(
|
||||
"Attached support device of type %(device_type)s "
|
||||
"to SCSI ID %(id_number)s LUN %(unit_number)s"
|
||||
),
|
||||
device_type=device_type,
|
||||
id_number=scsi_id,
|
||||
unit_number=unit,
|
||||
))
|
||||
return redirect(url_for("index"))
|
||||
|
||||
flash(process["msg"], "error")
|
||||
return redirect(url_for("index"))
|
||||
|
||||
|
||||
@APP.route("/scsi/attach_network", methods=["POST"])
|
||||
@login_required
|
||||
def attach_network_device():
|
||||
"""
|
||||
Attaches a network adapter device
|
||||
"""
|
||||
scsi_id = request.form.get("scsi_id")
|
||||
unit = request.form.get("unit")
|
||||
device_type = request.form.get("type")
|
||||
interface = request.form.get("if")
|
||||
ip_addr = request.form.get("ip")
|
||||
mask = request.form.get("mask")
|
||||
|
||||
error_url = "https://github.com/akuker/RASCSI/wiki/Dayna-Port-SCSI-Link"
|
||||
error_msg = _("Please follow the instructions at %(url)s", url=error_url)
|
||||
|
||||
if interface.startswith("wlan"):
|
||||
if not introspect_file("/etc/sysctl.conf", r"^net\.ipv4\.ip_forward=1$"):
|
||||
flash(_("Configure IPv4 forwarding before using a wireless network device."), "error")
|
||||
flash(error_msg, "error")
|
||||
return redirect(url_for("index"))
|
||||
if not Path("/etc/iptables/rules.v4").is_file():
|
||||
flash(_("Configure NAT before using a wireless network device."), "error")
|
||||
flash(error_msg, "error")
|
||||
return redirect(url_for("index"))
|
||||
else:
|
||||
if not introspect_file("/etc/dhcpcd.conf", r"^denyinterfaces " + interface + r"$"):
|
||||
flash(_("Configure the network bridge before using a wired network device."), "error")
|
||||
flash(error_msg, "error")
|
||||
return redirect(url_for("index"))
|
||||
if not Path("/etc/network/interfaces.d/rascsi_bridge").is_file():
|
||||
flash(_("Configure the network bridge before using a wired network device."), "error")
|
||||
flash(error_msg, "error")
|
||||
return redirect(url_for("index"))
|
||||
|
||||
kwargs = {"unit": int(unit), "device_type": device_type}
|
||||
if interface != "":
|
||||
if "" not in (ip_addr, mask):
|
||||
interface += (":" + ip_addr + "/" + mask)
|
||||
kwargs["params"] = {"interfaces": interface}
|
||||
|
||||
process = ractl.attach_device(scsi_id, **kwargs)
|
||||
process = ReturnCodeMapper.add_msg(process)
|
||||
if process["status"]:
|
||||
flash(_(
|
||||
(
|
||||
"Attached network device of type %(device_type)s "
|
||||
"Attached device of type %(device_type)s "
|
||||
"to SCSI ID %(id_number)s LUN %(unit_number)s"
|
||||
),
|
||||
device_type=device_type,
|
||||
|
Loading…
Reference in New Issue
Block a user