Compare commits

...

5 Commits

Author SHA1 Message Date
Jonathan Carter
258a359ce1 commit some failed experiments 2025-08-19 20:28:02 +02:00
Jonathan Carter
21b210a689 Some more UI work 2025-08-18 23:08:51 +02:00
Jonathan Carter
430b144d92 Add installer slide placeholder 2025-08-16 14:23:29 +02:00
Jonathan Carter
d4cfa4815c Add button menu placeholders 2025-08-16 14:22:34 +02:00
Jonathan Carter
9f8f89fde2 More UI work 2025-08-16 14:22:13 +02:00
17 changed files with 366 additions and 52 deletions

View File

@@ -0,0 +1,7 @@
from flask import Blueprint
bp = Blueprint('hardware', __name__,
template_folder='')
from applets.hardware import routes

View File

@@ -0,0 +1,41 @@
{% extends "layout.html" %}
{% block body %}
<p> <b> Would you like fries with that? </b></p>
<br>
<div style="background-color: gray; padding: 4px 6px 7px 6px;
border-radius: 10px; margin-bottom: 20px;">
<span style="width: 100%; border-radius: 8px 8px 0 0;"
class="tag is-black">
Real-time Clock
</span>
<div style="padding-left: 15px; padding-right: 15px; background-color: #fff;
color: #000;">
<p>Date / time. / timezone</p> <br>
<input style="background-color: #777777;" type="checkbox" id="popcon"
name="popcon" hx-post="/software/settings" hx-trigger="change"
{% if popcon %} checked {% endif %}>
<label for="popcon"> Participate in PopCon </label><br>
</div>
</div>
<div style="background-color: gray; padding: 4px 6px 7px 6px;
border-radius: 10px; margin-bottom: 20px;">
<span style="width: 100%; border-radius: 8px 8px 0 0;"
class="tag is-black">
Firmware
</span>
<div style="padding-left: 15px; padding-right: 15px; background-color: #fff;
color: #000;">
<p>Install additional firmware.</p> <br>
<input style="background-color: #777777;" type="checkbox" id="popcon"
name="popcon" hx-post="/software/settings" hx-trigger="change"
{% if popcon %} checked {% endif %}>
<label for="popcon"> Participate in PopCon </label><br>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,65 @@
from applets.hardware import bp
from flask import Flask, request, session, redirect, \
url_for, render_template, flash, Blueprint
from flask import current_app
@bp.route('/hardware')
def webui_hardware():
"""
Hardware screen for the webui.
"""
menu = current_app.config['CONFIG']['settings']['menu_order'].split(" ")
next_step_url = menu[menu.index("hardware")+1]
if menu[menu.index("hardware")] == 1:
previous_step_url = False
else:
previous_step_url = menu[menu.index("hardware")-1]
sources_button = '&nbsp; <button class="button iis-info"> <i class="fa fa-cloud-download" aria-hidden="true"></i> &nbsp; Configure Network </button>'
blends_button = '&nbsp; <button class="button iis-info"> <i class="fa fa-download" aria-hidden="true"></i> &nbsp; Install a Blend </button>'
bottom_menu = sources_button + blends_button
build_summary()
return render_template('hardware.html',
menu=current_app.config['CONFIG']['settings']['menu'],
menu_order=current_app.config['CONFIG']['settings']['menu_order'].split(),
previous_step = previous_step_url,
next_step = next_step_url,
bottom_menu = bottom_menu,
popcon=current_app.config['CONFIG']['recipe']['popcon']['enable_popcon'])
@bp.route('/hardware/settings', methods=['GET', 'POST'])
def hardware_settings():
"""
Receive settings for the hardware applet.
"""
if request.method == 'POST':
popcon = "popcon" in request.form
current_app.config['CONFIG']['recipe']['popcon']['enable_popcon'] = popcon
print(current_app.config['CONFIG']['recipe']['popcon']['enable_popcon'])
build_summary()
return ('', 204)
def build_menu():
"""
Define menu items and paths.
"""
# proper one once translations are done:
#current_app.config['CONFIG']['settings']['menu']['welcome'] = (build_stringlist()['menu_item'], "/welcome", 10)
current_app.config['CONFIG']['settings']['menu']['hardware'] = ("Hardware", "/hardware", 40)
def build_summary():
"""
Write up a summary of what this module will do.
"""
current_app.config['CONFIG']['Summary']['hardware'] = {}
current_app.config['CONFIG']['Summary']['hardware']['heading'] = "Hardware"
current_app.config['CONFIG']['Summary']['hardware']['bleh'] = current_app.config['CONFIG']['recipe']['popcon']['enable_popcon']
current_app.config['CONFIG']['Summary']['hardware']['text'] = "Participate in Popularity Contest: " + str(current_app.config['CONFIG']['recipe']['popcon']['enable_popcon']) + "<br/>No desktop environment selected."
return("ok?")
build_menu()

View File

@@ -2,14 +2,48 @@
{% block body %}
<center>
<p style="position: absolute: left: 45px; top: 10px;"> <big><big> Installing...</big></big></p> <br />
<p style="position: absolute: left: 45px; top: 10px;">
<big><big>
Installing...
</big></big>
</p>
<br />
<img style="width: 400px; padding: 20px;" src="/static/slide1.png" /> <br />
<p> Installing system, the rest of the process is automated. </p>
<p style="margin: 20px;"> <input style="background-color: #777777;" type="checkbox" id="reboot" name="reboot" value="reboot" checked>
<p>
Installing system, the rest of the process is automated.
</p>
<p style="margin: 20px;">
<input style="background-color: #777777;" type="checkbox"
id="reboot" name="reboot" value="reboot" checked>
<label for="reboot"> Reboot automatically when ready </label></p><br>
<div id="output"></div>
<!-- Hidden input to track last line -->
<div id="last-line-container">
<input type="hidden" id="last-line" name="last_line" value="0">
</div>
<!-- Poller -->
<div hx-get="/install/status"
hx-trigger="load, every 1s"
hx-include="#last-line"
hx-swap-oob="true"
hx-target="this"
hx-ext="json-enc"
hx-vars="{}">
</div>
</center>
<div style="position: absolute; padding: 10px; background-color: #26495e; left: 40px; right: 40px; bottom: 40px; height: text-align: middle;"> <center> Initializing... </center> </div>
<div style="position: absolute; padding: 10px; background-color: #26495e; left: 40px;
right: 40px; bottom: 40px; height: text-align: middle;">
<center> Initializing... </center>
</div>
</div>
</div>

View File

@@ -1,8 +1,20 @@
from applets.install import bp
from flask import Flask, request, session, redirect, \
url_for, render_template, flash, Blueprint
url_for, render_template, flash, Blueprint, jsonify
from flask import current_app
import subprocess
import threading
status = {
"status": "idle", # idle | running | finished
"output": "",
"exit_code": None,
"lines": []
}
@bp.route('/install',methods=['GET', 'POST', 'PUT'])
def install_index():
"""
@@ -19,14 +31,74 @@ def install_start():
Trigger the installation process
"""
print("The installation process is starting!... in theory at least")
if status["status"] == "running":
return jsonify({"status": "already running"}), 409 # Conflict
threading.Thread(target=run_script).start()
return jsonify({"status": "started"})
print("did it finish?")
@bp.route('/install-status',methods=['GET', 'POST', 'PUT'])
def run_script():
global status
status["status"] = "running"
process = subprocess.Popen(
["bash", "/data/jonathan/devel/highvoltage/system-installer/daemon/src/fake-install-shell.sh"],
stdout = subprocess.PIPE,
stderr = subprocess.STDOUT,
text = True)
lines = []
for line in iter(process.stdout.readline,''):
#lines.append(line.strip())
#status["output"] = "\n".join(lines)
status["lines"].append(line.strip())
process.wait()
status["status"] = 'finished'
status["exit_code"] = process.returncode
print(lines)
print("status:", status["status"], "code:", status["exit_code"])
@bp.route('/install/status', methods=['GET', 'POST'])
def install_status():
"""
Update on the status of the installation process.
"""
print("installation en coers")
# Keep track of the last line posted, so that we can include
# any new lines not provided to the UI yet
last_line = int(request.args.get("last_line", 0))
new_lines = status["lines"][last_line:]
if not new_lines and status["status"] == "finished":
return "" # Empty response = HTMX will stop polling
lines_html = ""
for i, line in enumerate(new_lines, start=last_line + 1):
lines_html += f'<div>{line}</div>'
return {
"output": status['output'],
"status": status['status'],
"lines": lines_html,
"last_line": f'<input type="hidden" id="last-line" name="last_line" value="{last_line + len(new_lines)}">'
}
@bp.route('/install/cancel', methods=["POST"])
def install_cancel():
"""
Cancel the installation process.
"""
if status["status"] != "running" or not status["process"]:
return Response("No running script", status=400)
process["process"].terminate()
process["status"] = "cancelled"
process["exit_code"] = -1
return Response("Cancelled", status=200)
@bp.route('/settings',methods=['GET', 'POST', 'PUT'])

View File

@@ -0,0 +1,18 @@
<div class="modal is-active">
<div class="modal-background"></div>
<div class="modal-content">
<div style="background-color: #424242; padding: 15px; border-radius: 15px; boders: none; color: white;">
<h1 class="is-size-4"> Help </h1>
<br/><p class="title is-6"><span class="tag is-danger">The help system is not yet implemented.</span>
<div class="columns">
<a href="/welcome"><div class="column"><button class="button is-link">Continue</button></div></a>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,17 @@
<div class="modal is-active">
<div class="modal-background"></div>
<div class="modal-content">
<div style="background-color: #424242; padding: 15px; border-radius: 15px; borders: none; color: white;">
<h1 class="is-size-4"> Main menu </h1>
<br />
<p> There's nothing yet to do here.</p>
<br />
<div class="columns">
<a href="/welcome"><div class="column"><button class="button is-link">Continue</button></div></a>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,19 @@
<div class="modal is-active">
<div class="modal-background"></div>
<div class="modal-content">
<div style="background-color: #424242; padding: 15px; border-radius: 15px; boders: none; color: white;">
<h1 class="is-size-4"> Exit system installer </h1>
<br /><p class="title is-6"><span class="tag is-danger">Quitting is not yet implemented.</span>
<br />
<p> ALT+F4 will bring up a dialog that works though. </p>
<br />
<div class="columns">
<a href="/welcome"><div class="column"><button class="button is-link">Continue</button></div></a>
</div>
</div>
</div>
</div>

View File

@@ -1,5 +1,10 @@
from applets.main import bp
from applets.welcome import bp
from flask import Flask, request, session, redirect, \
url_for, render_template, flash, Blueprint
# we use this neat little trick to get config data from the main app
from flask import current_app
import gettext
import dmm.lsblk as lsblk
@bp.route('/')
def index():
@@ -19,3 +24,26 @@ def apihome():
"""
return ("0")
@bp.route('/main/help',methods=['GET', 'POST', 'PUT'])
def main_welcome():
"""
Manages the main help system.
"""
return render_template('help.html')
@bp.route('/main/quit',methods=['GET', 'POST', 'PUT'])
def main_quit():
"""
Manages the quit dialog.
"""
return render_template('quit.html')
@bp.route('/main/menu',methods=['GET', 'POST', 'PUT'])
def main_menu():
"""
Manages the main menu.
"""
return render_template('menu.html')

View File

@@ -33,7 +33,7 @@ def users_root():
else:
previous_step_url = menu[menu.index("users")-1]
root_button = '&nbsp; <button class="button is-light"> <i class="fa fa-user" aria-hidden="true"></i> &nbsp; Setup root user </button>'
root_button = '&nbsp; <button class="button not-allowed is-light"> <i class="fa fa-user" aria-hidden="true"></i> &nbsp; Setup root user </button>'
ldap_button = '&nbsp; <button class="button is-light"> <i class="fa fa-address-card" aria-hidden="true"></i> &nbsp; Connect LDAP </button>'
ad_button = '&nbsp; <button class="button is-light"> <i class="fa fa-address-card" aria-hidden="true"></i> &nbsp; Connect AD </button>'
csv_button = '&nbsp; <button class="button is-light"> <i class="fa fa-users" aria-hidden="true"></i> &nbsp; Import CSV </button>'

View File

@@ -5,6 +5,7 @@ from flask import Flask, request, session, redirect, \
from flask import current_app
import gettext
import dmm.lsblk as lsblk
import dmm.timezone as timezone
# Set up Gettext
def set_language(LANG):
@@ -60,6 +61,7 @@ def welcome_index():
string_dict=string_dict, selected_lang=lang,
menu=current_app.config['CONFIG']['settings']['menu'],
menu_order=current_app.config['CONFIG']['settings']['menu_order'].split(),
timezones=timezone.list_timezones()[1].split("\n"),
previous_step=previous_step_url,
next_step=next_step_url,
bottom_menu=bottom_menu)

View File

@@ -8,10 +8,10 @@
<p><b> {{ string_dict['welcome_text'] }} </b></p>
<p>{{ string_dict['confirm_text'] }} </p> <br />
<div style="padding-left: 15px;">
<form action="/welcome" method="POST">
<i class="fa fa-language" aria-hidden="true"></i> {{ string_dict['language_text'] }}
<!--
<div style="float: left; padding-left: 100px;">
<button class="button is-dark" style="height: 180px;">
<img src="/static/icons/language.jpg" width="96px" alt="{{ string_dict['language_text'] }}" />
<div class="control is-link" width="180px">
<div class="select">
<select hx-post="/welcome" hx-target="body" name="lang" style="width: 220px">
@@ -21,37 +21,35 @@
</select>
</div>
</div>
</form>
<br>
</button>
</div>
-->
<form>
<i class="fa fa-keyboard-o" aria-hidden="true"></i> {{ string_dict['keylayout_text'] }}
<button class="button is-dark" style="float: left; margin-left: 100px; background-color: #242424; padding: 25px;">
<img src="/static/icons/language.jpg" width="96px" alt="{{ string_dict['language_text'] }}" />
<br> {{ string_dict['language_text'] }} {{ selected_lang }}
</button>
<!--
<div style="float: left; position: relative; top: -10px; padding-left: 100px;"
<button class="button is-dark">
<img src="/static/icons/keyboard.png" width="90px" />
<div class="control is-link">
<div class="select">
<select hx-post="/welcome" hx-target="body" name="keyboard" style="width: 220px">
<option>en-us</option>
<option>en-uk</option>
<option>en-za</option>
</select>
</div>
</div>
</form>
<br />
<form>
<i class="fa fa-clock-o" aria-hidden="true"></i> {{ string_dict['timezone_text'] }}
<div class="control is-link">
<div class="select">
<select hx-post="/welcome" hx-target="body" name="timezone" style="width: 220px">
<option>Africa/Johannesburg</option>
<option>UTC</option>
</select>
</div>
</button>
</div>
</form>
-->
<div style="float: left; margin-left: 100px; background-color: #242424; padding: 25px;">
<img src="/static/icons/keyboard,png" width="96px" /><br>
Keyboard
</div>
</div>
</div>
{% endblock %}

BIN
src/static/slide1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -12,7 +12,8 @@ import importlib
import yaml
# configuration
CONFIGFILE="templates/dmm-installer-template.yaml"
#CONFIGFILE="templates/dmm-installer-template.yaml"
CONFIGFILE="templates/dmm-installer-vm-template.yaml"
# import config
global config

View File

@@ -2,23 +2,35 @@
<div style="position: absolute; bottom: 15px; left: 15px;">
{% if previous_step %}
<a href="/{{ previous_step }}"><button class="button is-light">Back</button></a>
<!-- Why two of these? So that we can use two different keyboard shortcuts for back. -->
<button style="display: none;" hx-get="/{{ previous_step }}" hx-target="body"
hx-trigger="click, keydown[altKey&&key=='b'] from:body"></button>
<a href="/{{ previous_step }}"><button hx-get="/{{ previous_step }}" hx-target="body"
hx-trigger="click, keydown[ctrlKey&&code=='PageUp'] from:body" class="button is-light">Back</button></a>
{% endif %}
{% if bottom_menu %}
{{ bottom_menu | safe }}
{{ bottom_menu | safe }}
{% endif %}
</div>
</div> <!-- end buttons on the left -->
<!-- Buttons on the right -->
<div style="position: absolute; bottom: 15px; right: 15px;">
{% if next_step %}
{% if next_step == "install" %}
<a href="/{{ next_step }}"><button hx-trigger="click, keyup[shiftKey&&key=='I'] from:body" class="button is-link">Install</button></a>
{% else %}
<a href="/{{ next_step }}"><button hx-trigger="click, keyup[shiftKey&&key=='N'] from:body" hx-target="/{{ next_step }}" class="button is-link">Next</button></a>
{% endif %}
{% endif %}
</div>
{% if next_step == "install" %}
<a href="/{{ next_step }}"><button hx-get="/{{ next_step }}" hx-target="body"
hx-trigger="click, keyup[altKey&&key=='i'] from:body" class="button is-link">Install</button></a>
{% else %}
<!-- Why two of these? So that we can use two different keyboard shortcuts for next. -->
<a href="/{{ next_step }}"<button hx-get="/{{ next_step }}" hx-target="body"
hx-trigger="click, keydown[ctrlKey&&code=='PageDown'] from:body" class=""></button></a>
<a href="/{{ next_step }}"<button hx-get="/{{ next_step }}" hx-target="body"
hx-trigger="click, keydown[altKey&&key=='n'] from:body" class="button is-link">Next</button></a>
{% endif %}
{% endif %}
</div> <!-- end buttons on the right -->

View File

@@ -2,18 +2,18 @@
<div id="titlebar" style="padding: 15px; margin: -15px; padding-bottom: 30px;">
<!-- drag region class: -->
<!-- <div id="titlebar" class="pywebview-drag-region" style="padding: 15px; margin: -15px; padding-bottom: 30px;"> -->
<div id="titlebar" class="pywebview-drag-region" style="padding: 15px; margin: -15px; padding-bottom: 30px;">
<button class="button is-link"></button>
<a hx-get="/main/menu" hx-swap="outerHTML"/> <button class="button is-link"></button </a>
{% for item in menu_order %}
<a href="{{ menu[item][1]}}"> <button class="button is-{% if request.path == menu[item][1] %}info{% else %}dark{% endif %}"> {{ menu[item][0]}} </button></a>
<a href="{{ menu[item][1]}}"> <button class="button is-{% if request.path == menu[item][1] %}info{% else %}dark{% endif %}"> {{ menu[item][0]}} </button></a>
{% endfor %}
<div style="position: absolute; top: 15px; right: 15px;">
<a href="/help"> <button class="button is-light"> <b> ? </b> </button></a>
<button onclick="closeApp()" class="button is-danger" > 🗙 </button>
<a hx-get="/main/help" hx-swap="outerHTML"/> <button class="button is-light"> <b> ? </b> </button></a>
<a hx-get="/main/quit" hx-swap="outerHTML"/><button onclick="closeApp()" class="button is-danger" > 🗙 </button></a>
</div>
</div> <!-- end pywebview-drag-region -->