diff --git a/dashmachine/rest_api/resources.py b/dashmachine/rest_api/resources.py
index 0bad2d9..a18f68a 100755
--- a/dashmachine/rest_api/resources.py
+++ b/dashmachine/rest_api/resources.py
@@ -1,12 +1,12 @@
import os
from flask import request
from flask_restful import Resource
-from dashmachine.version import tcmachine_version
+from dashmachine.version import version
class GetVersion(Resource):
def get(self):
- return {"Version": tcmachine_version}
+ return {"Version": version}
class ServerShutdown(Resource):
diff --git a/dashmachine/settings_system/routes.py b/dashmachine/settings_system/routes.py
index 43b4977..2b54e44 100644
--- a/dashmachine/settings_system/routes.py
+++ b/dashmachine/settings_system/routes.py
@@ -5,6 +5,8 @@ from dashmachine.user_system.forms import UserForm
from dashmachine.main.utils import read_config, row2dict
from dashmachine.main.models import Files, TemplateApps
from dashmachine.paths import backgrounds_images_folder, icons_images_folder
+from dashmachine.update import check_needed, update_dashmachine
+from dashmachine.version import version
from dashmachine.settings_system.utils import load_files_html
settings_system = Blueprint("settings_system", __name__)
@@ -21,12 +23,15 @@ 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,
files_html=files_html,
user_form=user_form,
template_apps=",".join(template_apps),
+ version=version,
+ update_need=update_need,
)
@@ -59,3 +64,9 @@ def get_app_template():
if key not in ["id", "name"]:
template += f"{key} = {value}
"
return template
+
+
+@settings_system.route("/settings/update", methods=["GET"])
+def update():
+ update_dashmachine()
+ return "ok"
diff --git a/dashmachine/static/js/settings_system/settings.js b/dashmachine/static/js/settings_system/settings.js
index c6a0e85..c360334 100644
--- a/dashmachine/static/js/settings_system/settings.js
+++ b/dashmachine/static/js/settings_system/settings.js
@@ -66,4 +66,14 @@ $( document ).ready(function() {
}
});
+ $("#update-btn").on('click', function(e) {
+ $.ajax({
+ url: $(this).attr('data-url'),
+ type: 'GET',
+ success: function(data){
+ M.toast({html: 'DashMachine Updated'});
+ }
+ });
+ });
+
});
\ No newline at end of file
diff --git a/dashmachine/templates/settings_system/settings.html b/dashmachine/templates/settings_system/settings.html
index 4cf38c2..be16861 100644
--- a/dashmachine/templates/settings_system/settings.html
+++ b/dashmachine/templates/settings_system/settings.html
@@ -253,37 +253,56 @@
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 %} + +