some disks refactoring

This commit is contained in:
Jonathan Carter
2026-01-14 13:47:36 +02:00
parent 1c4656ade3
commit 401bfb55d9
12 changed files with 166 additions and 29 deletions

View File

@@ -1,7 +1,9 @@
from flask import Blueprint from flask import Blueprint
bp = Blueprint('disks', __name__, bp = Blueprint('disks', __name__,
template_folder='') template_folder='',
static_folder='static',
static_url_path='/disks/static')
from yasi_applets.disks import routes from yasi_applets.disks import routes

View File

@@ -1,33 +1,6 @@
{% extends "layout.html" %} {% extends "layout.html" %}
{% block body %} {% block body %}
<div style="">
<p><b>How would you like to install Debian?</b></p>
<br>
<div class="radios">
<label class="radio">
<input selected type="radio" name="rsvp" />
Preconfigured partitioning &nbsp;
<!-- Let's hide these babies for the initial release.
<label class="radio">
<input type="radio" name="rsvp" disabled />
Erase entire disk
</label>
<label class="radio">
<input type="radio" name="rsvp" disabled />
Install alongside another operating system
</label>
<label class="radio">
<input type="radio" name="rsvp" disabled />
Edit existing partitions
</label>
-->
</div>
</div>
<br> <br>
<!-- <!--
<div style=""> <div style="">

View File

@@ -0,0 +1,58 @@
{% extends "layout.html" %}
{% block body %}
<p><b>Please confirm the disk to erase:</b></p>
{% for disk in blockdevs["blockdevices"] if disk["name"] != "zram0" and "loop" not in disk["name"] and disk["name"] != "sr0" %}
<div style="padding-top: 20px;"> <!-- partition bars -->
<div style="background-color: gray; padding: 4px 6px 7px 6px; border-radius: 10px;">
<p> <span style="width: 100%; border-radius: 8px 8px 0 0;" class="tag is-black">
<b>{{ disk['name'] }}: &nbsp; </b> {{ disk['model'] }} - {{ disk['tran'] }} disk ({{(disk['size']/1024000000)|round(0)|int }} GB) - Serial: {{ disk['serial'] }} </p>
<center style="padding: 5px; padding-bottom: 5px;">
<td><a hx-get="/disks/choose_disk_erase_disk/{{ disk['name'] }}" hx-swap="outerHTML"><span class="tag is-link"> Select Disk </span></a></td>
</center>
{% if disk['maj:min'] == "252:0" %}
<div class="column">
<div class="box" style="width: 100%; border-radius: 0 0 0px 5px; height: 60px; padding-top: 5px; right: 0px;">
<span class="tag is-link">swap</span>
</p>
</div>
</div>
{% endif %}
{% set colors = ['teal', '#E69F00', '#56B4E9', '#009E73', '#0072B2', '#D55E00', '#CC79A7'] %}
<div id="percentagebar" style="width: 100%; height: 50px; background-color: transparent; display: inline-block; margin: 5; padding: 5; overflow: hidden; display: flex;">
{% for child in disk['children'] %}
<a hx-get="/disks/partition/{{ child['name'] }}" hx-swap="outerHTML">
<div style="min-width: 100px; width: {{ (((child['size'] / disk['size'])*100)|round(0)|int) }}%; height: 100%; background-color: {{ colors[loop.index0 % colors|length] }}; display: inline-block; margin: 1; padding: 1; border-radius: 8px;">
&nbsp; <a hx-get="/disks/partition/{{ child['name'] }}" hx-swap="outerHTML"> <font color="white">{{ child['name'] }} </font>
</div></a>
{% endfor %}
</div>
<table width="100%">
<th>Partition</th>
<th>Type</th>
<th>Mount Point</th>
<th>Label</th>
<th>Size</th>
<th>Used</th>
{% for child in disk['children'] %}
<tr>
<td><a hx-get="/disks/partition/{{ child['name'] }}" hx-swap="outerHTML"><span class="tag is-link">{{ child['name'] }}</span></a></td>
<td>{{ child['fstype'] }}</td>
<td>{{ child['mountpoint'] }}</td>
<td>{{ child['label'] }} </td>
<td>{{ (child['size']/1024000000)|round(2) }} GiB </td>
</tr>
{% endfor %}
</table>
</div>
</div>
{% endfor %}
{% endblock %}

View File

@@ -0,0 +1,60 @@
{% extends "layout.html" %}
{% block body %}
<p><b>How would you like to install Debian?</b></p>
<br>
<center>
<a href="">
<div style="width: 200px; float: left; padding: 10px; color: white;">
<img width="130px;" src="/disks/static/img/install_alongside.png"><br>
Install next to existing partition
</div>
</a>
<a href="/disks/choose_partition_erase">
<div style="width: 200px; float: left; padding: 10px; color: white;">
<img width="130px;" src="/disks/static/img/erase_partition.png"><br>
Replace a partition
</div>
</a>
<a href="/disks/choose_disk_erase">
<div style="width: 200px; float: left; padding: 10px; color: white;">
<img width="130px;" src="/disks/static/img/erase_disk.png"><br>
Erase entire disk
</div>
</a>
<a href="/disks/advanced">
<div style="width: 200px; float: left; padding: 10px; color: white;">
<img width="130px;" src="/disks/static/img/advanced_partitioning.png"><br>
Advanced partitioning
</div>
</a>
<a href="">
<div style="width: 200px; float: left; padding: 10px; color: white;">
<img width="130px;" src="/disks/static/img/preconfigured_partitioning.png"><br>
Preconfigured Partitioning
</div>
</a>
</center>
<div style="float: none;">
<p> <b>The following devices have been detected:</b>
<br><br>
<ul>
{% for disk in blockdevs["blockdevices"] if disk["name"] != "zram0" and "loop" not in disk["name"] and disk["name"] != "sr0" %}
<li>{{ disk['name'] }}
{% endfor %}
</ul>
{% endblock %}
</div>

View File

@@ -5,6 +5,50 @@ import dmm.lsblk as lsblk
from flask import current_app from flask import current_app
@bp.route('/disks') @bp.route('/disks')
def disks_welcome():
"""
Welcome menu for partitioning
"""
menu = current_app.config['CONFIG']['settings']['menu_order'].split(" ")
next_step_url = menu[menu.index("disks")+1]
if menu[menu.index("disks")] == 1:
previous_step_url = False
else:
previous_step_url = menu[menu.index("disks")-1]
blockdevs = lsblk.list_block_devices()
return render_template('disks_welcome.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, blockdevs=blockdevs
)
@bp.route('/disks/choose_disk_erase')
def disks_choose_disk_erase():
"""
Choose a disk to erase
"""
menu = current_app.config['CONFIG']['settings']['menu_order'].split(" ")
next_step_url = menu[menu.index("disks")+1]
if menu[menu.index("disks")] == 1:
previous_step_url = False
else:
previous_step_url = menu[menu.index("disks")-1]
blockdevs = lsblk.list_block_devices()
return render_template('disks_erase_menu.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, blockdevs=blockdevs
)
@bp.route('/disks/advanced')
def disks(): def disks():
""" """
Disks screen for the webui. Disks screen for the webui.
@@ -25,7 +69,7 @@ def disks():
bottom_menu = "" bottom_menu = ""
build_summary() build_summary()
return render_template('disks.html', blockdevs=blockdevs, return render_template('disks_advanced.html', blockdevs=blockdevs,
menu=current_app.config['CONFIG']['settings']['menu'], menu=current_app.config['CONFIG']['settings']['menu'],
menu_order=current_app.config['CONFIG']['settings']['menu_order'].split(), menu_order=current_app.config['CONFIG']['settings']['menu_order'].split(),
previous_step = previous_step_url, previous_step = previous_step_url,

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB