Skip to content

Commit 89a6db2

Browse files
committed
improved error feedback from backend in templates
1 parent 2859283 commit 89a6db2

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

src/adminui/static/admin-dashboard.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ function onChangedField(el, evt) {
7171
addClass(el, 'changed')
7272
}
7373
function manuallyValidateFormOnSubmit(form, event) {
74-
if (!form.checkValidity()) {
75-
event.preventDefault()
76-
event.stopPropagation()
77-
}
78-
addClass(form, 'was-validated');
74+
if (!form.checkValidity()) {
75+
event.preventDefault();
76+
event.stopPropagation();
77+
}
78+
addClass(form, 'was-validated');
7979
}

src/adminui/templates/base.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@
7474
border-color: var(--bs-warning-border-subtle) !important;
7575
}
7676

77+
/* form mode, display backend errors until frontend check validates */
78+
.display-until-validated {
79+
display: block;
80+
}
81+
form.was-validated .display-until-validated {
82+
display: none;
83+
}
84+
7785
/* form-mode, display form-wide error */
7886
.all-error {
7987
padding: .7rem;
@@ -105,7 +113,7 @@
105113
<header>
106114
<div class="container-sm row m-auto">
107115
<div class="offset-md-2 col-md-8">
108-
<a class="navbar-brand" href="{{ url_for('home') }}"><img src="http://localhost/branding/horizontal-logo-light.png" /></a>
116+
<a class="navbar-brand" href="{{ url_for('home') }}"><img src="{{ url_for('static', path='branding/horizontal-logo-light.png') }}" /></a>
109117
</div>
110118
</div>
111119
</header>

src/adminui/templates/optional/config.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ <h1 class="">Optional Features</h1>
3636
<div class="form-check form-switch">
3737
<input class="form-check-input" type="checkbox" value="yes" role="switch" name="sshd"{% if form.sshd %} checked{% endif %}>
3838
</div>
39-
<div class="invalid-feedback">{% if errors.profile %}{{ errors.profile }}{% else %}Either enabled or disabled.{% endif %}</div>
39+
<div class="invalid-feedback {% if errors.ssh %}display-until-validated{% endif %}">{% if errors.ssh %}{{ errors.ssh }}{% else %}Either enabled or disabled.{% endif %}</div>
4040
</div>
4141
<div class="feature-doc">
4242
<p><strong>SSH</strong> is a Secure Shell that is used to connect to the Hotspot's terminal console from another computer on the network.</p>
@@ -55,7 +55,7 @@ <h1 class="">Optional Features</h1>
5555
<div class="form-check form-switch">
5656
<input class="form-check-input" type="checkbox" value="yes" role="switch" name="sshd"{% if form.sshd %} checked{% endif %} disabled>
5757
</div>
58-
<div class="invalid-feedback">{% if errors.profile %}{{ errors.profile }}{% else %}Either enabled or disabled.{% endif %}</div>
58+
<div class="invalid-feedback {% if errors.kiosk %}display-until-validated{% endif %}">{% if errors.kiosk %}{{ errors.kiosk }}{% else %}Either enabled or disabled.{% endif %}</div>
5959
</div>
6060
<div class="feature-doc">
6161
<p>Allows using the Hotspot device as a <em>client</em> (in addition to its server mode) by plugging it to a screen, keyboard and mouse.</p>

src/adminui/templates/wifi/config.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ <h1 class="">Configuring WiFi</h1>
2525
<option value="perf" {% if form.profile == "perf" %}selected="selected"{% endif %}>Performance</option>
2626
<option value="coverage" {% if form.profile == "coverage" %}selected="selected"{% endif %}>Coverage</option>
2727
</select>
28-
<div class="invalid-feedback">{% if errors.profile %}{{ errors.profile }}{% else %}Only Performance and Coverage available.{% endif %}</div>
28+
<div class="invalid-feedback {% if errors.profile %}display-until-validated{% endif %}">{% if errors.profile %}{{ errors.profile }}{% else %}Only Performance and Coverage available.{% endif %}</div>
2929
</div>
3030

3131
<div class="feature-doc">
@@ -48,7 +48,7 @@ <h1 class="">Configuring WiFi</h1>
4848
<div class="field-row mb-2">
4949
<!-- ^[^!#;+\]/"\t][^+\]/"\t]{0,31}$ -->
5050
<input class="form-control {% if errors.ssid %} is-invalid{% endif %}" pattern='^[^!#;+\]\/"\t][^+\]\/"\t]{0,31}$' required minlength="1" maxlength="31" type="text" name="ssid" placeholder="My Network name" value="{{ form.ssid }}" />
51-
<div class="invalid-feedback">{% if errors.ssid %}{{ errors.ssid }}{% else %}Max 32 chars. Can't start with a symbol. <code>+</code>, <code>]</code>, <code>/</code>, <code>"</code>, <code>\t</code> prohibited.{% endif %}</div>
51+
<div class="invalid-feedback {% if errors.ssid %}display-until-validated{% endif %}">{% if errors.ssid %}{{ errors.ssid }}{% else %}Max 32 chars. Can't start with a symbol. <code>+</code>, <code>]</code>, <code>/</code>, <code>"</code>, <code>\t</code> prohibited.{% endif %}</div>
5252
</div>
5353

5454
<div class="feature-doc">
@@ -67,7 +67,7 @@ <h1 class="">Configuring WiFi</h1>
6767
<input id="wifi_open_switch" class="form-check-input" type="checkbox" value="yes" role="switch" name="open"{% if form.open %} checked{% endif %}>
6868
</div>
6969
</div>
70-
<div class="invalid-feedback">{% if errors.open %}{{ errors.open }}{% else %}Either open or not.{% endif %}</div>
70+
<div class="invalid-feedback {% if errors.open %}display-until-validated{% endif %}">{% if errors.open %}{{ errors.open }}{% else %}Either open or not.{% endif %}</div>
7171
<div class="feature-doc">
7272
<p>Your network can be <em>Open</em> (anybody can join it) or ask <em>clients</em> to supply a passphrase to join (only the first time).</p>
7373
<p>Your device has a fixed WiFi <em>clients</em> capacity so it's a good idea to set a passphrase if you want to restrict its access.</p>
@@ -82,7 +82,7 @@ <h1 class="">Configuring WiFi</h1>
8282
<div class="col-12 col-md-10">
8383
<div class="field-row mb-2">
8484
<input class="form-control" id="passphrase-input" type="text" name="passphrase" pattern="^[\u0020-\u007e]{8,63}$" {% if not form.open %} required{% endif %} minlength="8" maxlength="63" value="{{ form.passphrase or '' }}" />
85-
<div class="invalid-feedback">{% if errors.passphrase %}{{ errors.passphrase }}{% else %}Must be 8 to 63 chars long. Common latin chars and symbols.{% endif %}</div>
85+
<div class="invalid-feedback {% if errors.passphrase %}display-until-validated{% endif %}">{% if errors.passphrase %}{{ errors.passphrase }}{% else %}Must be 8 to 63 chars long. Common latin chars and symbols.{% endif %}</div>
8686
</div>
8787
<div class="feature-doc">
8888
<p>Passphrase must be at least 8 latin characters long</p>

0 commit comments

Comments
 (0)