diff --git a/data/web/js/build/014-mailcow.js b/data/web/js/build/014-mailcow.js index a211643a..13bc2911 100644 --- a/data/web/js/build/014-mailcow.js +++ b/data/web/js/build/014-mailcow.js @@ -312,66 +312,6 @@ $(document).ready(function() { localStorage.setItem('darkmode', 'true'); } } - - // show whats new modal - if (mailcow_cc_role === "admin" || mailcow_cc_role === "domainadmin"){ - if (mailcow_info.updatedAt > last_login){ - var parsedSeenTimestamp = parseInt(localStorage.getItem("seenChangelog")); - if (!isNaN(parsedSeenTimestamp) && mailcow_info.updatedAt < parsedSeenTimestamp) { - console.log("changelog seen"); - return; - } - $.ajax({ - type: 'GET', - url: 'https://api.github.com/repos/' + mailcow_info.project_owner + '/' + mailcow_info.project_repo + '/releases/tags/' + mailcow_info.version_tag, - dataType: 'json', - success: function (data) { - var md = window.markdownit(); - var result = md.render(data.body); - result = parseGithubMarkdownLinks(result); - - $('#showWhatsNewModal').find(".modal-body").html(` -

` + data.name + `

- ` + result + ` - `); - - localStorage.setItem("seenChangelog", Math.floor(Date.now() / 1000).toString()); - - new bootstrap.Modal(document.getElementById("showWhatsNewModal"), { - backdrop: 'static', - keyboard: false - }).show(); - } - }); - - } - } - - function parseGithubMarkdownLinks(inputText) { - var replacedText, replacePattern1; - - replacePattern1 = /(\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim; - replacedText = inputText.replace(replacePattern1, (matched, index, original, input_string) => { - if (matched.includes('github.com')){ - // return short link if it's github link - last_uri_path = matched.split('/'); - last_uri_path = last_uri_path[last_uri_path.length - 1]; - - // adjust Full Changelog link to match last git version and new git version, if link is a compare link - if (matched.includes('/compare/') && mailcow_info.last_version_tag !== ''){ - matched = matched.replace(last_uri_path, mailcow_info.last_version_tag + '...' + mailcow_info.version_tag); - last_uri_path = mailcow_info.last_version_tag + '...' + mailcow_info.version_tag; - } - - return '' + last_uri_path + '
'; - }; - - // if it's not a github link, return complete link - return '' + matched + ''; - }); - - return replacedText; - } }); diff --git a/data/web/js/site/debug.js b/data/web/js/site/debug.js index dcc04210..b57f1dbc 100644 --- a/data/web/js/site/debug.js +++ b/data/web/js/site/debug.js @@ -47,6 +47,12 @@ $(document).ready(function() { if (mailcow_info.branch === "master"){ check_update(mailcow_info.version_tag, mailcow_info.project_url); } + $("#maiclow_version").click(function(){ + if (mailcow_cc_role !== "admin" && mailcow_cc_role !== "domainadmin") + return; + + showVersionModal("Version " + mailcow_info.version_tag, mailcow_info.version_tag); + }) // get public ips get_public_ips(); update_container_stats(); @@ -1227,11 +1233,11 @@ function get_public_ips(){ }).then(function(data) { console.log(data); - if (data){ - // display host ips + // display host ips + if (data.ipv4) $("#host_ipv4").text(data.ipv4); + if (data.ipv6) $("#host_ipv6").text(data.ipv6); - } }); } // format hosts uptime seconds to readable string @@ -1452,10 +1458,13 @@ function check_update(current_version, github_repo_url){ } else { // update available $("#mailcow_update").removeClass("text-danger text-success").addClass("text-warning"); - $("#mailcow_update").html( - `` + lang_debug.update_available + ` - `+latest_data.tag_name+`` - ); + $("#mailcow_update").html(lang_debug.update_available + ` `+latest_data.tag_name+``); + $("#mailcow_update_changelog").click(function(){ + if (mailcow_cc_role !== "admin" && mailcow_cc_role !== "domainadmin") + return; + + showVersionModal("New Release " + latest_data.tag_name, latest_data.tag_name); + }) } }).catch(err => { // err @@ -1470,3 +1479,55 @@ function check_update(current_version, github_repo_url){ $("#mailcow_update").html(""+ lang_debug.update_failed +""); }); } +// show version changelog modal +function showVersionModal(title, version){ + $.ajax({ + type: 'GET', + url: 'https://api.github.com/repos/' + mailcow_info.project_owner + '/' + mailcow_info.project_repo + '/releases/tags/' + version, + dataType: 'json', + success: function (data) { + var md = window.markdownit(); + var result = md.render(data.body); + result = parseGithubMarkdownLinks(result); + + $('#showVersionModal').find(".modal-title").html(title); + $('#showVersionModal').find(".modal-body").html(` +

` + data.name + `

+ ` + result + ` + Github Link: + ` + version + ` + + `); + + new bootstrap.Modal(document.getElementById("showVersionModal"), { + backdrop: 'static', + keyboard: false + }).show(); + } + }); +} +function parseGithubMarkdownLinks(inputText) { + var replacedText, replacePattern1; + + replacePattern1 = /(\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim; + replacedText = inputText.replace(replacePattern1, (matched, index, original, input_string) => { + if (matched.includes('github.com')){ + // return short link if it's github link + last_uri_path = matched.split('/'); + last_uri_path = last_uri_path[last_uri_path.length - 1]; + + // adjust Full Changelog link to match last git version and new git version, if link is a compare link + if (matched.includes('/compare/') && mailcow_info.last_version_tag !== ''){ + matched = matched.replace(last_uri_path, mailcow_info.last_version_tag + '...' + mailcow_info.version_tag); + last_uri_path = mailcow_info.last_version_tag + '...' + mailcow_info.version_tag; + } + + return '' + last_uri_path + '
'; + }; + + // if it's not a github link, return complete link + return '' + matched + ''; + }); + + return replacedText; +} \ No newline at end of file diff --git a/data/web/templates/debug.twig b/data/web/templates/debug.twig index 4b21cc47..eb48d54e 100644 --- a/data/web/templates/debug.twig +++ b/data/web/templates/debug.twig @@ -58,19 +58,13 @@ Version -
-

{{ mailcow_info.version_tag }}

-

-
+ +
+

{{ mailcow_info.version_tag }}

+

+
+ - {% if mailcow_info.mailcow_branch|lower == "master" %} - - Changelog - - {{ mailcow_info.project_url }}/releases/tag/{{ mailcow_info.version_tag }} - - - {% endif %} {{ lang.debug.current_time }} - diff --git a/data/web/templates/modals/footer.twig b/data/web/templates/modals/footer.twig index d8b2b5a4..ab5630d1 100644 --- a/data/web/templates/modals/footer.twig +++ b/data/web/templates/modals/footer.twig @@ -347,12 +347,12 @@ - -