Skip to content

Commit

Permalink
Just need AP stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
brickbots committed Jan 10, 2024
1 parent 5ea841e commit df6b1a9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
20 changes: 10 additions & 10 deletions python/PiFinder/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def home():
def login():
password = request.forms.get("password")
origin_url = request.forms.get("origin_url", "/")
if sys_utils.verify_password("pifinder", password):
if self.system.verify_password("pifinder", password):
# set auth cookie, doesnt matter whats in it, just as long
# as it's there and cryptographically valid
response.set_cookie("pf_auth", str(uuid.uuid4()), secret=SESSION_SECRET)
Expand Down Expand Up @@ -176,10 +176,10 @@ def network_update():
self.system.add_wifi_network(ssid, key_mgmt, psk)
return network_page()

@app.route("/network/delete/<network_id:int>")
@app.route("/network/delete/<network_UUID>")
@auth_required
def network_delete(network_id):
self.system.delete_wifi_network(network_id)
def network_delete(network_UUID):
self.system.delete_wifi_network(network_UUID)
return network_page()

@app.route("/network/update", method="post")
Expand Down Expand Up @@ -207,7 +207,7 @@ def password_change():
)

if new_passworda == new_passwordb:
if sys_utils.change_password(
if self.system.change_password(
"pifinder", current_password, new_passworda
):
return template("tools", status_message="Password Changed")
Expand All @@ -223,7 +223,7 @@ def system_restart():
Restarts the RPI system
"""

sys_utils.restart_system()
self.system.restart_system()
return "restarting"

@app.route("/system/restart_pifinder")
Expand All @@ -232,7 +232,7 @@ def system_restart():
"""
Restarts just the PiFinder software
"""
sys_utils.restart_pifinder()
self.system.restart_pifinder()
return "restarting"

@app.route("/observations")
Expand Down Expand Up @@ -293,20 +293,20 @@ def tools():
@app.route("/tools/backup")
@auth_required
def tools_backup():
backup_file = sys_utils.backup_userdata()
backup_file = self.system.backup_userdata()

# Assumes the standard backup location
return static_file("PiFinder_backup.zip", "/home/pifinder/PiFinder_data")

@app.route("/tools/restore", method="post")
@auth_required
def tools_backup():
sys_utils.remove_backup()
self.system.remove_backup()
backup_file = request.files.get("backup_file")
backup_file.filename = "PiFinder_backup.zip"
backup_file.save("/home/pifinder/PiFinder_data")

sys_utils.restore_userdata(
self.system.restore_userdata(
"/home/pifinder/PiFinder_data/PiFinder_backup.zip"
)

Expand Down
7 changes: 4 additions & 3 deletions python/views/network.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<div class="input-field col s12">
<select name="wifi_mode">
<option value="AP"
% if net.wifi_mode() == "AP":
% if system.get_wifi_mode() == "AP":
selected
%end
>Access Point</option>
<option value="Client"
% if net.wifi_mode() == "Client":
% if system.get_wifi_mode() == "Client":
selected
%end
>Client</option>
Expand All @@ -34,6 +34,7 @@
<div class="input-field col s12">
<input value="{{system.get_host_name()}}" id="host_name" type="text" name="host_name">
<label for="host_name">Host Name</label>
<span class="helper-text" data-error="" data-success="">Only A-Z, a-z, 0-9, and hypen (-) allowed</span>
</div>
</div>
</form>
Expand Down Expand Up @@ -92,7 +93,7 @@
</td>
</tr>
% end
% for network in net.get_wifi_networks():
% for network in system.get_wifi_networks():
% include("network_item", network=network)
% end
</table>
Expand Down
6 changes: 3 additions & 3 deletions python/views/network_item.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
Security: <b>{{network["key_mgmt"]}}</b>
</td>
<td>
<a href="#modal{{network["id"]}}" class="grey-text modal-trigger">
<a href="#modal{{network["UUID"]}}" class="grey-text modal-trigger">
<i class="material-icons">delete</i>
</a>
</td>
</tr>
<div id="modal{{network["id"]}}" class="modal">
<div id="modal{{network["UUID"]}}" class="modal">
<div class="modal-content">
<h4>Delete {{network["ssid"]}}</h4>
<p>This will take effect immediately and can not be undone. Are you sure?</p>
</div>
<div class="modal-footer">
<a href="/network/delete/{{network["id"]}}" class="modal-close btn-flat">Delete</a>
<a href="/network/delete/{{network["UUID"]}}" class="modal-close btn-flat">Delete</a>
<a href="#!" class="modal-close btn-flat">Cancel</a>
</div>
</div>

0 comments on commit df6b1a9

Please sign in to comment.