finished update system

This commit is contained in:
Ross Mountjoy 2020-01-31 19:15:13 -05:00
parent 33381343ca
commit d510921fb5
3 changed files with 38 additions and 11 deletions

View File

@ -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())

View File

@ -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!'});
}
}
});
});

View File

@ -291,15 +291,22 @@
<h5>DashMachine</h5>
<p class="mb-2">version: {{ version }}</p>
{% 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"
) }}
</div>