mirror of
https://github.com/akuker/RASCSI.git
synced 2024-08-21 04:29:39 +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">
|
<table border="black" cellpadding="3">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr style="font-weight: bold;">
|
||||||
<td><b>{{ _("File") }}</b></td>
|
<td>{{ _("File") }}</td>
|
||||||
<td><b>{{ _("Size") }}</b></td>
|
<td>{{ _("Size") }}</td>
|
||||||
<td><b>{{ _("Actions") }}</b></td>
|
<td>{{ _("Actions") }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% for file in files %}
|
{% for file in files %}
|
||||||
<tr>
|
<tr>
|
||||||
@ -296,97 +296,52 @@
|
|||||||
<p><small>{{ _("%(disk_space)s MB disk space remaining on the Pi", disk_space=free_disk) }}</small></p>
|
<p><small>{{ _("%(disk_space)s MB disk space remaining on the Pi", disk_space=free_disk) }}</small></p>
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary class="heading">
|
<summary class="heading">
|
||||||
{{ _("Attach Network Adapter") }}
|
{{ _("Attach Support Device") }}
|
||||||
</summary>
|
</summary>
|
||||||
<ul>
|
<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>
|
||||||
<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") }}
|
<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>
|
||||||
<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>
|
</ul>
|
||||||
</details>
|
</details>
|
||||||
<table style="border: none">
|
<table border="black" cellpadding="3">
|
||||||
<tr style="border: none">
|
<tr style="font-weight: bold;">
|
||||||
<td style="border: none; vertical-align:top;">
|
<td>{{ _("Type") }}</td>
|
||||||
<form action="/scsi/attach_network" method="post">
|
<td>{{ _("Actions") }}</td>
|
||||||
<label for="type">{{ _("Type:") }}</label>
|
</tr>
|
||||||
<select name="type">
|
{% for type in (NETWORK_DEVICE_TYPES + SUPPORT_DEVICE_TYPES) %}
|
||||||
{% for type in NETWORK_DEVICE_TYPES %}
|
<tr>
|
||||||
<option value="{{ type }}">
|
<td>
|
||||||
{% for key, value in device_types.items() %}
|
<div>{{ device_types[type] }}</div>
|
||||||
{% if key == type %}
|
</td>
|
||||||
{{ value }}
|
<td>
|
||||||
{% endif %}
|
<form action="/scsi/attach_device" method="post">
|
||||||
{% endfor %}
|
<input name="type" type="hidden" value="{{ type }}">
|
||||||
</option>
|
{% for key, value in device_params[type].items() %}
|
||||||
{% endfor %}
|
<label for="{{ key }}">{{ key }}:</label>
|
||||||
</select>
|
{% if value.isnumeric() %}
|
||||||
<label for="if">{{ _("Interface:") }}</label>
|
<input name="{{ key }}" type="number" size="{{ value|length }}" placeholder="{{ value }}">
|
||||||
<select name="if">
|
{% elif key == "interface" %}
|
||||||
|
<select name="interface">
|
||||||
{% for if in netinfo["ifs"] %}
|
{% for if in netinfo["ifs"] %}
|
||||||
<option value="{{ if }}">
|
<option value="{{ if }}">
|
||||||
{{ if }}
|
{{ if }}
|
||||||
</option>
|
</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</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 %}
|
{% else %}
|
||||||
<input name="{{ key }}" type="text" size="{{ value|length }}" value="{{ value }}">
|
<input name="{{ key }}" type="text" size="{{ value|length }}" placeholder="{{ value }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<label for="scsi_id">{{ _("SCSI ID:") }}</label>
|
<label for="scsi_id">{{ _("SCSI ID:") }}</label>
|
||||||
@ -405,6 +360,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</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/>
|
<hr/>
|
||||||
<details>
|
<details>
|
||||||
|
@ -496,11 +496,11 @@ def log_level():
|
|||||||
return redirect(url_for("index"))
|
return redirect(url_for("index"))
|
||||||
|
|
||||||
|
|
||||||
@APP.route("/scsi/attach_support", methods=["POST"])
|
@APP.route("/scsi/attach_device", methods=["POST"])
|
||||||
@login_required
|
@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 = {}
|
params = {}
|
||||||
for item in request.form:
|
for item in request.form:
|
||||||
@ -511,7 +511,32 @@ def attach_support_device():
|
|||||||
elif item == "type":
|
elif item == "type":
|
||||||
device_type = request.form.get(item)
|
device_type = request.form.get(item)
|
||||||
else:
|
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 = {
|
kwargs = {
|
||||||
"unit": int(unit),
|
"unit": int(unit),
|
||||||
@ -523,66 +548,7 @@ def attach_support_device():
|
|||||||
if process["status"]:
|
if process["status"]:
|
||||||
flash(_(
|
flash(_(
|
||||||
(
|
(
|
||||||
"Attached support 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,
|
|
||||||
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 "
|
|
||||||
"to SCSI ID %(id_number)s LUN %(unit_number)s"
|
"to SCSI ID %(id_number)s LUN %(unit_number)s"
|
||||||
),
|
),
|
||||||
device_type=device_type,
|
device_type=device_type,
|
||||||
|
Loading…
Reference in New Issue
Block a user