Skip to content

Commit

Permalink
integrate manual update as an url parameter (?update=manual)
Browse files Browse the repository at this point in the history
if present, it will add a form inside the check update modal box
  • Loading branch information
Stefal committed Jun 19, 2024
1 parent ae97f30 commit 3fa2484
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 62 deletions.
20 changes: 10 additions & 10 deletions web_app/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,12 +409,21 @@ def status_page():
base_coordinates = {"lat" : base_position[0], "lon" : base_position[1]}
return render_template("status.html", base_coordinates = base_coordinates, tms_key = {"maptiler_key" : rtkbaseconfig.get("general", "maptiler_key")})

@app.route('/settings')
@app.route('/settings', methods=['GET', 'POST'])
@login_required
def settings_page():
"""
The settings page where you can manage the various services, the parameters, update, power...
"""
# POST method when updating with a manual file
if request.method == 'POST':
uploaded_file = request.files['file']
if uploaded_file.filename != '':
update_rtkbase(uploaded_file)
else:
print("wrong update file")
return ('', 204)
# variable needed when the gnss receiver offer a web interface
host_url = urllib.parse.urlparse(request.host_url)
gnss_rcv_url = urllib.parse.ParseResult(scheme=host_url.scheme, netloc="{}:{}".format(host_url.hostname, rtkbaseconfig.get("main", "gnss_rcv_web_proxy_port")),
path=host_url.path, params=host_url.params, query=host_url.query, fragment=host_url.fragment)
Expand Down Expand Up @@ -511,15 +520,6 @@ def diagnostic():

return render_template('diagnostic.html', logs = logs)

@app.route('/manual_update', methods=['GET', 'POST'])
@login_required
def upload_file():
if request.method == 'POST':
uploaded_file = request.files['file']
if uploaded_file.filename != '':
update_rtkbase(uploaded_file)
return ('', 204)
return render_template('manual_update.html')

#### Handle connect/disconnect events ####

Expand Down
8 changes: 7 additions & 1 deletion web_app/static/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,13 @@ $(document).ready(function () {
$("#updateModal .modal-title").text("No Update available!");
$("#updateModal .modal-body").text("We're working on it. Come back later!");
$("#updateModal").modal();
}
}
// check if url contains update=manual parameter to display the input form
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
if (urlParams.get('update') === 'manual' ) {
$("#updateModal .modal-body").append('<h3>Manual Update: </h3><form method="POST" action="" enctype="multipart/form-data"> <p><input type="file" name="file"></p><p><input onclick="this.form.submit()" id="submit-button" type="submit" value="Submit"></p></form>');
}
})

$("#start-update-button").on("click", function () {
Expand Down
51 changes: 0 additions & 51 deletions web_app/templates/manual_update.html

This file was deleted.

0 comments on commit 3fa2484

Please sign in to comment.