Skip to content

Commit

Permalink
Web UI: Create a system admin page and move options there
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmark committed Sep 26, 2023
1 parent 65c1b19 commit 16d47d3
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 157 deletions.
1 change: 1 addition & 0 deletions python/web/src/static/themes/modern/icons/command.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions python/web/src/static/themes/modern/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,27 @@ section#manual a p {
margin: 0;
}

/*
------------------------------------------------------------------------------
Index > Section: Admin
------------------------------------------------------------------------------
*/
section#admin {
margin: 2rem 0 1rem;
}

section#admin a {
margin: auto;
display: block;
padding: 0.25rem 0 0.25rem 2rem;
background: url("icons/command.svg") no-repeat left center;
font-weight: bold;
}

section#admin a p {
margin: 0;
}

/*
------------------------------------------------------------------------------
Drives page
Expand Down
186 changes: 186 additions & 0 deletions python/web/src/templates/admin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
{% extends "base.html" %}
{% block content %}

<section id="logging">
<details>
<summary class="heading">
{{ _("Logging") }}
</summary>
<ul>
<li>{{ _("The current dropdown selection indicates the active log level.") }}</li>
</ul>
</details>

<div>
<form action="/logs/show" method="post">
<label for="log_lines">{{ _("Log Lines:") }}</label>
<input name="lines" id="log_lines" type="number" value="200" min="0" max="99999" step="100">
<label for="log_scope">{{ _("Scope:") }}</label>
<select name="scope" id="log_scope">
<option value="">
{{ _("All logs") }}
</option>
<option value="piscsi">
piscsi
</option>
<option value="piscsi-web">
piscsi-web
</option>
<option value="piscsi-oled">
piscsi-oled
</option>
<option value="piscsi-ctrlboard">
piscsi-ctrlboard
</option>
</select>
<input type="submit" value="{{ _("Show Logs") }}">
</form>
</div>

<div>
<form action="/logs/level" method="post">
<label for="log_level">{{ _("Log Level:") }}</label>
<select name="level" id="log_level">
{% for level in log_levels %}
<option value="{{ level }}"{% if level == current_log_level %} selected{% endif %}>
{{ level }}
</option>
{% endfor %}
</select>
<input type="submit" value="{{ _("Set Log Level") }}">
</form>
</div>
</section>

<hr/>

<section id="appearance">
<details>
<summary class="heading">
{{ _("Appearance") }}
</summary>
<ul>
<li>{{ _("Theme and language are auto-detected for your user agent. Here you can change the default.") }}</li>
<li>{{ _("The System Name is the \"pretty\" hostname if set, with a fallback to the regular hostname.") }}</li>
</ul>
</details>

<div>
<div class="theme-change-hint">
{{ _("The current theme is %(theme)s.", theme=current_theme) }}
{% if current_theme == "classic" %}
{{ _('Switch to the <a href="/theme?name=%(theme)s">%(theme)s theme</a>', theme="modern") }}
{% else %}
{{ _('Switch to the <a href="/theme?name=%(theme)s">%(theme)s theme</a>', theme="classic") }}
{% endif %}
</div>

<form action="/language" method="post">
<label for="locale">{{ _("Language:") }}</label>
<select name="locale" id="locale">
{% for locale in locales %}
{% if locale.language == locale %}
<option value="{{ locale.language }}" selected="selected">
{% else %}
<option value="{{ locale.language }}">
{% endif %}
{{ locale.language }} - {{ locale.display_name }}
</option>
{% endfor %}
</select>
<input type="submit" value="{{ _("Change Language") }}">
</form>
</div>

<div>
<form action="/sys/rename" method="post">
<label for="system_name">{{ _("System Name:") }}</label>
<input name="system_name" id="system_name" type="text" maxlength=120 required value="{{ env['system_name'] }}">
<input type="submit" value="{{ _("Rename") }}">
</form>
<form action="/sys/rename" method="post">
<input name="system_name" type="hidden" value="">
<input type="submit" value="{{ _("Reset") }}">
</form>
</div>
</section>

<hr/>

<section id="services">
<details>
<summary class="heading">
{{ _("Companion Services") }}
</summary>
<ul>
<li>{{ _("If you want to add a service, run the easyinstall.sh script and choose the one to install.") }}</li>
<li>{{ _("In order to manage the services in the Web UI, you may install Webmin as well.") }}</li>
</ul>
</details>
<ul>
<li>
{% if env["netatalk_configured"] %}
{{ _("Mac AFP file sharing is enabled.") }}
{% if webmin_configured %}
<a href="https://{{ env["ip_addr"] }}:10000/netatalk2/" target=\"_blank\">
{{ _("Manage the server") }}
</a>
{% endif %}
{% else %}
{{ _("Mac AFP file sharing is disabled.") }}
{% endif %}
</li>
<li>
{% if samba_configured %}
{{ _("Windows SMB file sharing is enabled.") }}
{% if webmin_configured %}
<a href="https://{{ env["ip_addr"] }}:10000/samba/" target=\"_blank\">
{{ _("Manage the server") }}
</a>
{% endif %}
{% else %}
{{ _("Windows SMB file sharing is disabled.") }}
{% endif %}
</li>
<li>
{% if ftp_configured %}
{{ _("FTP file sharing is enabled.") }}
{% else %}
{{ _("FTP file sharing is disabled.") }}
{% endif %}
</li>
<li>
{% if macproxy_configured %}
{{ _("Macproxy is running at %(ip_addr)s (default port 5000)", ip_addr=env['ip_addr']) }}
{% else %}
{{ _("Macproxy is disabled.") }}
{% endif %}
</li>
<ul>
</section>

<hr/>

<section id="system">
<details>
<summary class="heading">
{{ _("System Operations") }}
</summary>
<ul>
<li>{{ _("IMPORTANT: Always shut down the system before turning off the power. Failing to do so may lead to data loss.") }}</li>
</ul>
</details>

<div class="power-control">
<form action="/sys/reboot" method="post" onclick="if (confirm('{{ _("Reboot the System?") }}')) shutdownNotify('{{ _("Rebooting the system...") }}'); else event.preventDefault();">
<input type="submit" value="{{ _("Reboot System") }}">
</form>
<form action="/sys/shutdown" method="post" onclick="if (confirm('{{ _("Shut Down the System?") }}')) shutdownNotify('{{ _("Shutting down the system...") }}'); else event.preventDefault();">
<input type="submit" value="{{ _("Shut Down System") }}">
</form>
</div>
</section>

<p class="home"><a href="/">{{ _("Go to Home") }}</a></p>

{% endblock content %}
47 changes: 0 additions & 47 deletions python/web/src/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,53 +104,6 @@ <h1>
{% block content %}{% endblock content %}
</div>
<div align="center" class="footer">
<div class="theme-change-hint">
{% if current_theme == "classic" %}
{{ _('Switch to the <a href="/theme?name=%(theme)s">%(theme)s theme</a>', theme="modern") }}
{% else %}
{{ _('Switch to the <a href="/theme?name=%(theme)s">%(theme)s theme</a>', theme="classic") }}
{% endif %}
</div>

<div>
{% if env["netatalk_configured"] %}
{{ _("Mac AFP file sharing is enabled.") }}
{% if env["webmin_configured"] %}
<a href="https://{{ env["ip_addr"] }}:10000/netatalk2/" target=\"_blank\">
{{ ("Server administration") }}
</a>
{% endif %}
{% else %}
{{ _("Mac AFP file sharing is disabled.") }}
{% endif %}
</div>
<div>
{% if env["samba_configured"] %}
{{ _("Windows SMB file sharing is enabled.") }}
{% if env["webmin_configured"] %}
<a href="https://{{ env["ip_addr"] }}:10000/samba/" target=\"_blank\">
{{ ("Server administration") }}
</a>
{% endif %}
{% else %}
{{ _("Windows SMB file sharing is disabled.") }}
{% endif %}
</div>
<div>
{% if env["ftp_configured"] %}
{{ _("FTP file sharing is enabled.") }}
{% else %}
{{ _("FTP file sharing is disabled.") }}
{% endif %}
</div>
<div>
{% if env["macproxy_configured"] %}
{{ _("Macproxy is running at %(ip_addr)s (default port 5000)", ip_addr=env['ip_addr']) }}
{% else %}
{{ _("Macproxy is disabled.") }}
{% endif %}
</div>

<div>
{{ _("PiSCSI software version:") }} <b>{{ env["version"] }}</b>
</div>
Expand Down
104 changes: 2 additions & 102 deletions python/web/src/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,6 @@

<hr/>

<section id="logging">
<section id="attach-devices">
<details>
<summary class="heading">
Expand Down Expand Up @@ -669,109 +668,10 @@

<hr/>

<details>
<summary class="heading">
{{ _("Logging") }}
</summary>
<ul>
<li>{{ _("The current dropdown selection indicates the active log level.") }}</li>
</ul>
</details>

<div>
<form action="/logs/show" method="post">
<label for="log_lines">{{ _("Log Lines:") }}</label>
<input name="lines" id="log_lines" type="number" value="200" min="0" max="99999" step="100">
<label for="log_scope">{{ _("Scope:") }}</label>
<select name="scope" id="log_scope">
<option value="">
{{ _("All logs") }}
</option>
<option value="piscsi">
piscsi
</option>
<option value="piscsi-web">
piscsi-web
</option>
<option value="piscsi-oled">
piscsi-oled
</option>
<option value="piscsi-ctrlboard">
piscsi-ctrlboard
</option>
</select>
<input type="submit" value="{{ _("Show Logs") }}">
</form>
</div>

<div>
<form action="/logs/level" method="post">
<label for="log_level">{{ _("Log Level:") }}</label>
<select name="level" id="log_level">
{% for level in log_levels %}
<option value="{{ level }}"{% if level == current_log_level %} selected{% endif %}>
{{ level }}
</option>
{% endfor %}
</select>
<input type="submit" value="{{ _("Set Log Level") }}">
</form>
</div>
<section id="admin">
<a href="/sys/admin"><p>{{ _("System Administration") }}</p></a>
</section>

<hr/>

<section id="system">
<details>
<summary class="heading">
{{ _("System Operations") }}
</summary>
<ul>
<li>{{ _("The System Name is the \"pretty\" hostname if set, with a fallback to the regular hostname.") }}</li>
<li>{{ _("IMPORTANT: Always shut down the system before turning off the power. Failing to do so may lead to data loss.") }}</li>
</ul>
</details>

<div>
<form action="/language" method="post">
<label for="locale">{{ _("Language:") }}</label>
<select name="locale" id="locale">
{% for locale in locales %}
{% if locale.language == env['locale'] %}
<option value="{{ locale.language }}" selected="selected">
{% else %}
<option value="{{ locale.language }}">
{% endif %}
{{ locale.language }} - {{ locale.display_name }}
</option>
{% endfor %}
</select>
<input type="submit" value="{{ _("Change Language") }}">
</form>
</div>
<div>
<form action="/sys/rename" method="post">
<label for="system_name">{{ _("System Name:") }}</label>
<input name="system_name" id="system_name" type="text" maxlength=120 required>
<input type="submit" value="{{ _("Rename") }}">
</form>
<form action="/sys/rename" method="post">
<input name="system_name" type="hidden" value="">
<input type="submit" value="{{ _("Reset") }}">
</form>
</div>
<div class="power-control">
<form action="/sys/reboot" method="post" onclick="if (confirm('{{ _("Reboot the System?") }}')) shutdownNotify('{{ _("Rebooting the system...") }}'); else event.preventDefault();">
<input type="submit" value="{{ _("Reboot System") }}">
</form>
<form action="/sys/shutdown" method="post" onclick="if (confirm('{{ _("Shut Down the System?") }}')) shutdownNotify('{{ _("Shutting down the system...") }}'); else event.preventDefault();">
<input type="submit" value="{{ _("Shut Down System") }}">
</form>
</div>
</section>

<hr/>

<section id="manual">
<a href="/sys/manpage?app=piscsi"><p>{{ _("Read the PiSCSI Manual") }}</p></a>
</section>
Expand Down
Loading

0 comments on commit 16d47d3

Please sign in to comment.