diff --git a/cps/helper.py b/cps/helper.py index d13496bc..5a8e71de 100755 --- a/cps/helper.py +++ b/cps/helper.py @@ -547,3 +547,23 @@ def check_unrar(unrarLocation): error=True return (error, version) + +def is_sha1(sha1): + if len(sha1) != 40: + return False + try: + int(sha1, 16) + except ValueError: + return False + return True + + +def get_current_version_info(): + content = {} + # content[0] = '$Format: % H$' + # content[1] = '$Format: % cI$' + content[0] = 'bb7d2c6273ae4560e83950d36d64533343623a57' + content[1] = '2018-09-09T10:13:08+02:00' + if is_sha1(content[0]) and len(content[1]) > 0: + return {'hash': content[0], 'datetime': content[1]} + return False diff --git a/cps/static/js/main.js b/cps/static/js/main.js index 524abdb0..38a7fb87 100644 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -104,18 +104,39 @@ $(function() { var $this = $(this); var buttonText = $this.html(); $this.html("..."); + $("#update_error").addClass("hidden") $.ajax({ dataType: "json", url: window.location.pathname + "/../../get_update_status", success: function success(data) { $this.html(buttonText); - if (data.status === true) { - $("#check_for_update").addClass("hidden"); - $("#perform_update").removeClass("hidden"); - $("#update_info") - .removeClass("hidden") - .find("span").html(data.commit); + + var cssClass = ''; + var message = '' + + if (data.success === true) { + if (data.update === true) { + $("#check_for_update").addClass("hidden"); + $("#perform_update").removeClass("hidden"); + $("#update_info") + .removeClass("hidden") + .find("span").html(data.commit); + + data.history.reverse().forEach((entry, index) => { + $("" + entry[0] + "" + entry[1] + "").appendTo($("#update_table")); + }); + cssClass = 'alert-warning' + } else { + cssClass = 'alert-success' + } + } else { + cssClass = 'alert-danger' } + + message = '
×' + data.message + '
'; + + $(message).insertAfter($("#update_table")); } }); }); diff --git a/cps/templates/admin.html b/cps/templates/admin.html index 81ff05c5..767bdd41 100644 --- a/cps/templates/admin.html +++ b/cps/templates/admin.html @@ -1,105 +1,140 @@ {% extends "layout.html" %} {% block body %} -
-

{{_('User list')}}

- - - - - - - - - - - - {% for user in content %} - {% if not user.role_anonymous() or config.config_anonbrowse %} - - - - - - - - - - - {% endif %} - {% endfor %} -
{{_('Nickname')}}{{_('E-mail')}}{{_('Kindle')}}{{_('DLS')}}
{{user.nickname}}{{user.email}}{{user.kindle_mail}}{{user.downloads.count()}}
-
{{_('Add new user')}}
-

{{_('SMTP e-mail server settings')}}

- - - - - - - - - - - - - - -
{{_('SMTP hostname')}}{{_('SMTP port')}}{{_('SSL')}}{{_('SMTP login')}}
{{email.mail_server}}{{email.mail_port}}{% if email.mail_use_ssl %}{% else %}{% endif %}{{email.mail_login}}
-
{{_('Change SMTP settings')}}
-
-

{{_('Configuration')}}

-
-
-
{{_('Calibre DB dir')}}
-
{{config.config_calibre_dir}}
-
-
-
{{_('Log level')}}
-
{{config.get_Log_Level()}}
-
-
-
{{_('Port')}}
-
{{config.config_port}}
+
+
+
+

{{_('User list')}}

+ + + + + + + + + + + + {% for user in content %} + {% if not user.role_anonymous() or config.config_anonbrowse %} + + + + + + + + + + + {% endif %} + {% endfor %} +
{{_('Nickname')}}{{_('E-mail')}}{{_('Kindle')}}{{_('DLS')}}
{{user.nickname}}{{user.email}}{{user.kindle_mail}}{{user.downloads.count()}}
+
-
-
-
{{_('Books per page')}}
-
{{config.config_books_per_page}}
-
-
-
{{_('Uploading')}}
-
{% if config.config_uploading %}{% else %}{% endif %}
-
-
-
{{_('Anonymous browsing')}}
-
{% if config.config_anonbrowse %}{% else %}{% endif %}
+ +
+
+

{{_('SMTP e-mail server settings')}}

+ + + + + + + + + + + + + + + +
{{_('SMTP hostname')}}{{_('SMTP port')}}{{_('SSL')}}{{_('SMTP login')}}
{{email.mail_server}}{{email.mail_port}}{% if email.mail_use_ssl %}{% else %}{% endif %}{{email.mail_login}}
+
-
-
{{_('Public registration')}}
-
{% if config.config_public_reg %}{% else %}{% endif %}
+
+ +
+
+

{{_('Configuration')}}

+
+
+
{{_('Calibre DB dir')}}
+
{{config.config_calibre_dir}}
+
+
+
{{_('Log level')}}
+
{{config.get_Log_Level()}}
+
+
+
{{_('Port')}}
+
{{config.config_port}}
+
+
+
+
+
{{_('Books per page')}}
+
{{config.config_books_per_page}}
+
+
+
{{_('Uploading')}}
+
{% if config.config_uploading %}{% else %}{% endif %}
+
+
+
{{_('Anonymous browsing')}}
+
{% if config.config_anonbrowse %}{% else %}{% endif %}
+
+
+
{{_('Public registration')}}
+
{% if config.config_public_reg %}{% else %}{% endif %}
+
+
+
{{_('Remote login')}}
+
{% if config.config_remote_login %}{% else %}{% endif %}
+
+
+ +
-
-
{{_('Remote login')}}
-
{% if config.config_remote_login %}{% else %}{% endif %}
+
+ +
+
+

{{_('Administration')}}

+
{{_('Reconnect to Calibre DB')}}
+
{{_('Restart Calibre-Web')}}
+
{{_('Stop Calibre-Web')}}
-
-
-

- - + +
+
+

{{_('Update')}}

+ + + + + + + + + + + + + +
{{_('Version')}}{{_('Details')}}
{{commit}} {{_('Current version')}}
+ + +
{{_('Check for update')}}
+
-

{{_('Administration')}}

-
{{_('Current commit timestamp')}}: {{commit}}
- -

-
{{_('Reconnect to Calibre DB')}}
-
{{_('Restart Calibre-Web')}}
-
{{_('Stop Calibre-Web')}}
-
{{_('Check for update')}}
- +
+ -