Add core update notification to admin dashboard

This commit is contained in:
Kijin Sung 2021-01-31 02:15:23 +09:00
parent d25690e3e9
commit 9c9629f7e1
5 changed files with 49 additions and 1 deletions

View file

@ -101,6 +101,9 @@ body>.x,
.message.error h3 {
color: #943a38;
}
.message.core_update {
display: none;
}
.x h1 {
font-size: 22px;
}

View file

@ -37,6 +37,11 @@
</ul>
</div>
<div class="message update core_update" data-current-version="{\RX_VERSION}">
<h2>{$lang->update_available}</h2>
<p>{$lang->core_update_available} <a href="https://rhymix.org/" target="_blank">{$lang->core_update_link}</a></p>
</div>
<div class="message update" cond="$addTables || $needUpdate">
<h2>{$lang->need_complete_configuration}</h2>
<p>{$lang->need_complete_configuration_details}</p>

View file

@ -1,4 +1,40 @@
/* NAVER (developers@xpressengine.com) */
// core update check
jQuery(function($) {
var core_update = $('.core_update');
if (!core_update.size()) {
return;
}
var version_decode = function(str) {
var version_number = 0;
var extra_strings = '';
var parts = str.split(/[\.-]/);
$.each(parts, function(i, part) {
if (part.match(/^[0-9]+$/)) {
version_number += parseInt(part, 10) * Math.pow(1000, 3 - i);
} else {
extra_strings = extra_strings + part;
}
});
return String(version_number) + (extra_strings === '' ? 'z' : extra_strings);
};
var current_version = version_decode(core_update.data('current-version'));
$.ajax({
url: 'https://api.rhymix.org/version.json',
dataType: 'json',
cache: true,
success: function(data) {
var latest_version = version_decode(data.latest);
if (latest_version > current_version) {
var version_replace = core_update.find('p').first();
version_replace.html(version_replace.html().replace('$VERSION', data.latest));
core_update.show();
}
}
});
});
// install module
function doInstallModule(module) {
var params = [];