From 71011fcafdfb0e358abb48d855a1f375b2cc35c0 Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Thu, 12 Sep 2024 18:01:52 +0200 Subject: [PATCH] Move files to actual applets --- src/applets/disks/__init__.py | 7 + src/applets/disks/disks.html | 108 ++++++++++ .../disks}/disks_partition.html | 17 +- src/applets/disks/routes.py | 21 ++ src/applets/main/__init__.py | 3 +- .../main/__pycache__/__init__.cpython-311.pyc | Bin 367 -> 0 bytes .../main/__pycache__/routes.cpython-311.pyc | Bin 886 -> 0 bytes src/applets/software/__init__.py | 7 + src/applets/software/routes.py | 11 ++ src/applets/software/software.html | 39 ++++ src/applets/summary/__init__.py | 7 + src/applets/summary/routes.py | 13 ++ .../summary}/summary.html | 3 +- src/applets/users/__init__.py | 7 + src/applets/users/routes.py | 11 ++ src/{templates => applets/users}/users.html | 21 +- src/applets/webui/NOTES.highvoltage | 0 src/applets/welcome/__init__.py | 3 +- src/applets/welcome/routes.py | 8 - src/applets/welcome/static/welcome.css | 1 - .../welcome}/welcome.html | 15 +- src/static/icons/keyboard.svg | 1 + src/system-installer-daemon.py | 20 +- src/templates/disks.html | 184 ------------------ src/templates/layout.html | 21 ++ src/templates/software.html | 53 ----- 26 files changed, 312 insertions(+), 269 deletions(-) create mode 100644 src/applets/disks/__init__.py create mode 100644 src/applets/disks/disks.html rename src/{templates => applets/disks}/disks_partition.html (76%) create mode 100644 src/applets/disks/routes.py delete mode 100644 src/applets/main/__pycache__/__init__.cpython-311.pyc delete mode 100644 src/applets/main/__pycache__/routes.cpython-311.pyc create mode 100644 src/applets/software/__init__.py create mode 100644 src/applets/software/routes.py create mode 100644 src/applets/software/software.html create mode 100644 src/applets/summary/__init__.py create mode 100644 src/applets/summary/routes.py rename src/{templates => applets/summary}/summary.html (87%) create mode 100644 src/applets/users/__init__.py create mode 100644 src/applets/users/routes.py rename src/{templates => applets/users}/users.html (74%) delete mode 100644 src/applets/webui/NOTES.highvoltage delete mode 100644 src/applets/welcome/static/welcome.css rename src/{templates => applets/welcome}/welcome.html (80%) create mode 100644 src/static/icons/keyboard.svg delete mode 100644 src/templates/disks.html create mode 100644 src/templates/layout.html delete mode 100644 src/templates/software.html diff --git a/src/applets/disks/__init__.py b/src/applets/disks/__init__.py new file mode 100644 index 0000000..060d3aa --- /dev/null +++ b/src/applets/disks/__init__.py @@ -0,0 +1,7 @@ +from flask import Blueprint + +bp = Blueprint('disks', __name__, + template_folder='') + +from applets.disks import routes + diff --git a/src/applets/disks/disks.html b/src/applets/disks/disks.html new file mode 100644 index 0000000..0f8f601 --- /dev/null +++ b/src/applets/disks/disks.html @@ -0,0 +1,108 @@ +{% extends "layout.html" %} +{% block body %} + +

Disks and Partitions

+ +
+ +
+ +
+ +
+ +

How would you like to install Debian?

+ +
+ +
+ + + +
+ +
+ +

Proposed layout:

+
+ +
+

Physical disk: TOSHIBA HDWD120 (2000 GB)Healthy

+
+
+
+

/dev/sda1

+

/boot/efi + 200 MB + vfat +

+
+
+ + +
+
+ +

+ +
+

Physical disk: TOSHIBA HDWD120 (2000 GB)Healthy

+
+
+
+

/dev/sda1

+

/boot/efi + 200 MB + vfat +

+
+
+ + +
+
+ +

+ +
+
+
+
+ + + + + +

+ + + + +{% endblock %} diff --git a/src/templates/disks_partition.html b/src/applets/disks/disks_partition.html similarity index 76% rename from src/templates/disks_partition.html rename to src/applets/disks/disks_partition.html index 7bfe09a..77f9683 100644 --- a/src/templates/disks_partition.html +++ b/src/applets/disks/disks_partition.html @@ -10,11 +10,13 @@

Select usage:

@@ -73,10 +78,10 @@
- +
-
+
diff --git a/src/applets/disks/routes.py b/src/applets/disks/routes.py new file mode 100644 index 0000000..29288c2 --- /dev/null +++ b/src/applets/disks/routes.py @@ -0,0 +1,21 @@ +from applets.disks import bp +from flask import Flask, request, session, redirect, \ + url_for, render_template, flash, Blueprint +import dmm.lsblk as lsblk + +@bp.route('/disks/') +def disks(): + """ + Disks screen for the webui. + """ + return render_template('disks.html') + + +@bp.route('/disks/partition/') +def disks_partition(part): + """ + Partition modal for the webui partition screen. + """ + return render_template('disks_partition.html') + + diff --git a/src/applets/main/__init__.py b/src/applets/main/__init__.py index 90d17c0..febc0ae 100644 --- a/src/applets/main/__init__.py +++ b/src/applets/main/__init__.py @@ -1,6 +1,7 @@ from flask import Blueprint -bp = Blueprint('main', __name__) +bp = Blueprint('main', __name__, + template_folder='') from applets.main import routes diff --git a/src/applets/main/__pycache__/__init__.cpython-311.pyc b/src/applets/main/__pycache__/__init__.cpython-311.pyc deleted file mode 100644 index ed1a5d58fe97eeb68483056cd62746734f0463e6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 367 zcmZuqyG{c!5M1A#qwoklq9APw;*JU-#0StI3ep&Zm*l|q9kvsZE+r)$e*i-KOpqwh zRgtLZkkX}MPlN)A(Y|+f_Nmoc1;XY{^YV=HN8S7)TNd+ODjq+uPieDNPu6;_} zswt&Y7Nx9`^Ril3Woa;mZhhoA5uRaQYc5WNR#Azo!l^h=PG}sV5re!x7!@X}K8i37 z5$#UyLR7|}rvtQw6Tx4IrL3rBg_OC=qmD}o5_LaBaczcq}V0-$X`85*x25(wr#{d8T diff --git a/src/applets/main/__pycache__/routes.cpython-311.pyc b/src/applets/main/__pycache__/routes.cpython-311.pyc deleted file mode 100644 index 8fa8c2022b504cc18aa0d043aeed4e86d32ad3b2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 886 zcma)4&1(}u6rb6A8WO9ef*^$l6(pdUo~0C|UV5oY{eXgp$?haOWwVpc%x;^UD&)|= zK>ve^^q*1iAba)XZ6&vye6#5ajTav~Ki<53zxVNDK6g4Tg0_Fs9DJmN{B)PnD%Z|D zMduRb zbZO@G#|z5*zZKDO{oIW6Is(o|G2ffMY605oP{5cE1x!@(D1f1`AP4RO-1mhsU@<`} zWkC%Jf(@ksJ|2UNfkR)bQzLY*_%(g@PDH*M39t$dC&r2q?8nCPC=wc;b1_meynL|- zJADmo_pQ)Is`x3qiFwLp#QTx>LbMxlj)yD`S->r4$13JF?{I~HKw~IY{PH^STIcJt`xjduHfNi; oSEmnig7CXSytOj0UM6+F(T(qPBll|bZcY$f+Pxc*B3vx+2U70RTmS$7 diff --git a/src/applets/software/__init__.py b/src/applets/software/__init__.py new file mode 100644 index 0000000..d09ae64 --- /dev/null +++ b/src/applets/software/__init__.py @@ -0,0 +1,7 @@ +from flask import Blueprint + +bp = Blueprint('software', __name__, + template_folder='') + +from applets.software import routes + diff --git a/src/applets/software/routes.py b/src/applets/software/routes.py new file mode 100644 index 0000000..61cfef9 --- /dev/null +++ b/src/applets/software/routes.py @@ -0,0 +1,11 @@ +from applets.software import bp +from flask import Flask, request, session, redirect, \ + url_for, render_template, flash, Blueprint + + +@bp.route('/software') +def webui_software(): + """ + Software screen for the webui. + """ + return render_template('software.html') diff --git a/src/applets/software/software.html b/src/applets/software/software.html new file mode 100644 index 0000000..980d834 --- /dev/null +++ b/src/applets/software/software.html @@ -0,0 +1,39 @@ +{% extends "layout.html" %} +{% block body %} + +

Select Software

+ +
+ + + + +
+ +

Would you like fries with that?

+ +
+ +
    +
  • Desktop environment
  • +
  • Server software
  • +
+

+ +
+
+
+
+ + + + +{% endblock %} diff --git a/src/applets/summary/__init__.py b/src/applets/summary/__init__.py new file mode 100644 index 0000000..29a4944 --- /dev/null +++ b/src/applets/summary/__init__.py @@ -0,0 +1,7 @@ +from flask import Blueprint + +bp = Blueprint('summary', __name__, + template_folder='') + +from applets.summary import routes + diff --git a/src/applets/summary/routes.py b/src/applets/summary/routes.py new file mode 100644 index 0000000..1c2a0a4 --- /dev/null +++ b/src/applets/summary/routes.py @@ -0,0 +1,13 @@ +from applets.summary import bp +from flask import Flask, request, session, redirect, \ + url_for, render_template, flash, Blueprint + +@bp.route('/summary',methods=['GET', 'POST', 'PUT']) +def summary_index(): + """ + The page you'd get if you access the root of + this app in a browser. + """ + return render_template('summary.html') + + diff --git a/src/templates/summary.html b/src/applets/summary/summary.html similarity index 87% rename from src/templates/summary.html rename to src/applets/summary/summary.html index 3ab4c02..ead12cf 100644 --- a/src/templates/summary.html +++ b/src/applets/summary/summary.html @@ -10,8 +10,7 @@
- -
+

Summary

diff --git a/src/applets/users/__init__.py b/src/applets/users/__init__.py new file mode 100644 index 0000000..a655a07 --- /dev/null +++ b/src/applets/users/__init__.py @@ -0,0 +1,7 @@ +from flask import Blueprint + +bp = Blueprint('users', __name__, + template_folder='') + +from applets.users import routes + diff --git a/src/applets/users/routes.py b/src/applets/users/routes.py new file mode 100644 index 0000000..1126a58 --- /dev/null +++ b/src/applets/users/routes.py @@ -0,0 +1,11 @@ +from applets.software import bp +from flask import Flask, request, session, redirect, \ + url_for, render_template, flash, Blueprint + + +@bp.route('/users') +def users_root(): + """ + Users screen for the webui. + """ + return render_template('users.html') diff --git a/src/templates/users.html b/src/applets/users/users.html similarity index 74% rename from src/templates/users.html rename to src/applets/users/users.html index e2c155d..312b47d 100644 --- a/src/templates/users.html +++ b/src/applets/users/users.html @@ -10,8 +10,7 @@
- -
+

Configure User

@@ -36,14 +35,14 @@
- +
- +
@@ -56,6 +55,20 @@

This username is available

+
+ +
+ +
+
+ +
+ +
+ +
+
+

diff --git a/src/applets/webui/NOTES.highvoltage b/src/applets/webui/NOTES.highvoltage deleted file mode 100644 index e69de29..0000000 diff --git a/src/applets/welcome/__init__.py b/src/applets/welcome/__init__.py index e8226a2..d53f319 100644 --- a/src/applets/welcome/__init__.py +++ b/src/applets/welcome/__init__.py @@ -1,6 +1,7 @@ from flask import Blueprint -bp = Blueprint('welcome', __name__) +bp = Blueprint('welcome', __name__, + template_folder='') from applets.welcome import routes diff --git a/src/applets/welcome/routes.py b/src/applets/welcome/routes.py index 01587ca..5b96902 100644 --- a/src/applets/welcome/routes.py +++ b/src/applets/welcome/routes.py @@ -21,11 +21,3 @@ def welcome2_index(): return ("Changins some text in our htmx front-end") - -@bp.route('/api/') -def api_home(): - """ - Wel - """ - return ("Welcome to the welcome API") - diff --git a/src/applets/welcome/static/welcome.css b/src/applets/welcome/static/welcome.css deleted file mode 100644 index e901b4d..0000000 --- a/src/applets/welcome/static/welcome.css +++ /dev/null @@ -1 +0,0 @@ -test: diff --git a/src/templates/welcome.html b/src/applets/welcome/welcome.html similarity index 80% rename from src/templates/welcome.html rename to src/applets/welcome/welcome.html index 0f781c8..5c6c0ad 100644 --- a/src/templates/welcome.html +++ b/src/applets/welcome/welcome.html @@ -11,7 +11,7 @@
-
+

Welcome to System Installer

@@ -35,6 +35,10 @@
+
+ +
+ +
+
+ +

+
+ +
+ +






diff --git a/src/static/icons/keyboard.svg b/src/static/icons/keyboard.svg new file mode 100644 index 0000000..8b9da70 --- /dev/null +++ b/src/static/icons/keyboard.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/system-installer-daemon.py b/src/system-installer-daemon.py index 2d0eda5..dd50f3e 100755 --- a/src/system-installer-daemon.py +++ b/src/system-installer-daemon.py @@ -10,12 +10,13 @@ from flask import Flask, request, session, redirect, \ from waitress import serve import logging import dmm.lsblk as lsblk +import importlib # configuration VERSION = "0.00" SECRET_KEY = "exampls" DEV_MODE = 1 -APPS = "main welcome" +APPS = "main welcome users disks software summary" if DEV_MODE == 1: print("Note: Starting in devmode!") @@ -29,13 +30,16 @@ app.config.from_object(__name__) # Register blueprints here for APP in APPS.split(" "): - print("Loading applet: %s " % APP) -from applets.main import bp as main_bp -app.register_blueprint(main_bp) -from applets.welcome import bp as welcome_bp -app.register_blueprint(welcome_bp) -from applets.webui import bp as webui_bp -app.register_blueprint(webui_bp) + print(f"Loading applet: {APP} ") + + # Dynamically import the blueprint module + module = importlib.import_module(f"applets.{APP}") + + # Get the blueprint (bp) from the imported module + bp = getattr(module, "bp") + + # Register the blueprint with the app + app.register_blueprint(bp) # configure logs diff --git a/src/templates/disks.html b/src/templates/disks.html deleted file mode 100644 index 92c5c53..0000000 --- a/src/templates/disks.html +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - - - - - - -
- - -
-
- -

Disks and Partitions

- -
- - - - -
- -

How would you like to install Debian?

- -
- -
- - - -
- -
- -

Proposed layout:

-
-
- - -

Physical disk: TOSHIBA HDWD120 (20 GB) - Healthy -

- -
-
-
-

/dev/sda1

-

/boot/efi - 200 MB - vfat -

-
-
- - - -
-
- - - - - -


- -
-
-
-
- -
-
- - - - diff --git a/src/templates/layout.html b/src/templates/layout.html new file mode 100644 index 0000000..62173bb --- /dev/null +++ b/src/templates/layout.html @@ -0,0 +1,21 @@ + + + + + + + + + + + +
+ +
+
+ +{% block body %} +{% endblock %} + + + diff --git a/src/templates/software.html b/src/templates/software.html deleted file mode 100644 index cd4166a..0000000 --- a/src/templates/software.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - -
- - -
-
- -

Select Software

- -
- - - - -
- -

Would you like fries with that?

- -
- -
    -
  • Desktop environment
  • -
  • Server software
  • -
-

- -
-
-
-
- -
-
- - -