diff --git a/dashmachine/settings_system/routes.py b/dashmachine/settings_system/routes.py index 2b54e44..9c11567 100644 --- a/dashmachine/settings_system/routes.py +++ b/dashmachine/settings_system/routes.py @@ -23,7 +23,6 @@ def settings(): t_apps = TemplateApps.query.all() for t_app in t_apps: template_apps.append(f"{t_app.name}&&{t_app.icon}") - update_need = check_needed() return render_template( "settings_system/settings.html", config_form=config_form, @@ -31,7 +30,6 @@ def settings(): user_form=user_form, template_apps=",".join(template_apps), version=version, - update_need=update_need, ) @@ -70,3 +68,8 @@ def get_app_template(): def update(): update_dashmachine() return "ok" + + +@settings_system.route("/settings/check_update", methods=["GET"]) +def check_update(): + return str(check_needed()) diff --git a/dashmachine/static/js/settings_system/settings.js b/dashmachine/static/js/settings_system/settings.js index c360334..a8ebb44 100644 --- a/dashmachine/static/js/settings_system/settings.js +++ b/dashmachine/static/js/settings_system/settings.js @@ -72,6 +72,23 @@ $( document ).ready(function() { type: 'GET', success: function(data){ M.toast({html: 'DashMachine Updated'}); + $("#update-btn").removeClass('hide'); + $("#check-update-btn").addClass('hide'); + } + }); + }); + + $("#check-update-btn").on('click', function(e) { + $.ajax({ + url: $(this).attr('data-url'), + type: 'GET', + success: function(data){ + if (data === "True"){ + $("#update-btn").removeClass('hide'); + $("#check-update-btn").addClass('hide'); + } else { + M.toast({html: 'Up to date!'}); + } } }); }); diff --git a/dashmachine/templates/settings_system/settings.html b/dashmachine/templates/settings_system/settings.html index be16861..089100a 100644 --- a/dashmachine/templates/settings_system/settings.html +++ b/dashmachine/templates/settings_system/settings.html @@ -291,15 +291,22 @@
version: {{ version }}
- {% if update_needed %} - {{ button( - float="left", - id="update-btn", - icon="system_update_alt", - data={"url": url_for('settings_system.update')}, - text="update available" - ) }} - {% endif %} + {{ button( + float="left", + id="update-btn", + icon="system_update_alt", + class="hide", + data={"url": url_for('settings_system.update')}, + text="update available" + ) }} + + {{ button( + float="left", + id="check-update-btn", + icon="security", + data={"url": url_for('settings_system.check_update')}, + text="check for update" + ) }}