Skip to content

Commit

Permalink
Web UI: Create a system settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmark committed Nov 1, 2023
1 parent 063e8ed commit 99d31eb
Show file tree
Hide file tree
Showing 8 changed files with 257 additions and 162 deletions.
1 change: 1 addition & 0 deletions python/web/src/static/themes/modern/icons/cloud-off.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions python/web/src/static/themes/modern/icons/cloud.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
38 changes: 36 additions & 2 deletions python/web/src/static/themes/modern/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ div.header div.authentication-disabled a {
color: #fff;
}

div.header div.login-status.logged-in a {
background: var(--danger) no-repeat right 0.5rem center;
div.header div.login-status.logged-in span.log-out-button a {
background: var(--primary) no-repeat right 0.5rem center;
background-image: url("icons/log-out.svg");
background-size: var(--icon-size);
border-radius: var(--border-radius);
Expand All @@ -434,6 +434,17 @@ div.header div.authentication-disabled a {
color: #fff;
}

div.header div.login-status.logged-in span.admin-button a {
background: var(--secondary) no-repeat right 0.5rem center;
background-image: url("icons/command.svg");
background-size: var(--icon-size);
border-radius: var(--border-radius);
padding: 0.25rem 2.25rem 0.25rem 0.75rem;
display: inline-block;
text-decoration: none;
color: #fff;
}

div.header div.login-status.logged-in span.logged-in-as-text {
margin-right: 1rem;
}
Expand Down Expand Up @@ -958,6 +969,29 @@ section#manual a p {
margin: 0;
}

/*
------------------------------------------------------------------------------
Admin > Section: Services
------------------------------------------------------------------------------
*/
section#services ul {
list-style: none;
padding-left: 0;
}

section#services li {
margin-bottom: 0.5em;
padding: 0.25rem 0 0.25rem 2rem;
}

section#services li.enabled {
background: url("icons/cloud.svg") no-repeat left center;
}

section#services li.disabled {
background: url("icons/cloud-off.svg") no-repeat left center;
}

/*
------------------------------------------------------------------------------
Drives page
Expand Down
194 changes: 194 additions & 0 deletions python/web/src/templates/admin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
{% 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 == env["locale"] %}
<option value="{{ locale.language }}" 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>
{% if netatalk_configured %}
<li class="enabled">
{{ _("Mac AFP file sharing is enabled.") }}
{% else %}
<li class="disabled">
{{ _("Mac AFP file sharing is disabled.") }}
{% endif %}
</li>
{% if webmin_configured %}
<li>
<a href="https://{{ env["ip_addr"] }}:10000/netatalk2/" target=\"_blank\">
{{ _("Manage the AFP server") }}
</a>
</li>
{% endif %}
{% if samba_configured %}
<li class="enabled">
{{ _("Windows SMB file sharing is enabled.") }}
{% else %}
<li class="disabled">
{{ _("Windows SMB file sharing is disabled.") }}
{% endif %}
</li>
{% if webmin_configured %}
<li>
<a href="https://{{ env["ip_addr"] }}:10000/samba/" target=\"_blank\">
{{ _("Manage the SMB server") }}
</a>
</li>
{% endif %}
{% if ftp_configured %}
<li class="enabled">
{{ _("FTP file sharing is enabled.") }}
{% else %}
<li class="disabled">
{{ _("FTP file sharing is disabled.") }}
{% endif %}
</li>
{% if macproxy_configured %}
<li class="enabled">
{{ _("Vintage web proxy is running at %(ip_addr)s (default port 5000)", ip_addr=env['ip_addr']) }}
{% else %}
<li class="disabled">
{{ _("Vintage web proxy 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 %}
51 changes: 3 additions & 48 deletions python/web/src/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
<div align="center" class="login-status logged-in">
<span class="logged-in-as-text">{{ _("Logged in as <em>%(username)s</em>", username=env["username"]) }}</span>
<span class="separator">-</span>
<a href="/logout">{{ _("Log Out") }}</a>
<span class="log-out-button"><a href="/logout">{{ _("Log Out") }}</a></span>
<span class="separator">-</span>
<span class="admin-button"><a href="/sys/admin">{{ _("Settings") }}</a></span>
</div>
{% else %}
<div align="center" class="login-status logged-out">
Expand Down Expand Up @@ -104,53 +106,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
Loading

0 comments on commit 99d31eb

Please sign in to comment.