Skip to content

Commit 3fa2484

Browse files
committed
integrate manual update as an url parameter (?update=manual)
if present, it will add a form inside the check update modal box
1 parent ae97f30 commit 3fa2484

File tree

3 files changed

+17
-62
lines changed

3 files changed

+17
-62
lines changed

web_app/server.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -409,12 +409,21 @@ def status_page():
409409
base_coordinates = {"lat" : base_position[0], "lon" : base_position[1]}
410410
return render_template("status.html", base_coordinates = base_coordinates, tms_key = {"maptiler_key" : rtkbaseconfig.get("general", "maptiler_key")})
411411

412-
@app.route('/settings')
412+
@app.route('/settings', methods=['GET', 'POST'])
413413
@login_required
414414
def settings_page():
415415
"""
416416
The settings page where you can manage the various services, the parameters, update, power...
417417
"""
418+
# POST method when updating with a manual file
419+
if request.method == 'POST':
420+
uploaded_file = request.files['file']
421+
if uploaded_file.filename != '':
422+
update_rtkbase(uploaded_file)
423+
else:
424+
print("wrong update file")
425+
return ('', 204)
426+
# variable needed when the gnss receiver offer a web interface
418427
host_url = urllib.parse.urlparse(request.host_url)
419428
gnss_rcv_url = urllib.parse.ParseResult(scheme=host_url.scheme, netloc="{}:{}".format(host_url.hostname, rtkbaseconfig.get("main", "gnss_rcv_web_proxy_port")),
420429
path=host_url.path, params=host_url.params, query=host_url.query, fragment=host_url.fragment)
@@ -511,15 +520,6 @@ def diagnostic():
511520

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

514-
@app.route('/manual_update', methods=['GET', 'POST'])
515-
@login_required
516-
def upload_file():
517-
if request.method == 'POST':
518-
uploaded_file = request.files['file']
519-
if uploaded_file.filename != '':
520-
update_rtkbase(uploaded_file)
521-
return ('', 204)
522-
return render_template('manual_update.html')
523523

524524
#### Handle connect/disconnect events ####
525525

web_app/static/settings.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,13 @@ $(document).ready(function () {
532532
$("#updateModal .modal-title").text("No Update available!");
533533
$("#updateModal .modal-body").text("We're working on it. Come back later!");
534534
$("#updateModal").modal();
535-
}
535+
}
536+
// check if url contains update=manual parameter to display the input form
537+
const queryString = window.location.search;
538+
const urlParams = new URLSearchParams(queryString);
539+
if (urlParams.get('update') === 'manual' ) {
540+
$("#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>');
541+
}
536542
})
537543

538544
$("#start-update-button").on("click", function () {

web_app/templates/manual_update.html

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)