New version function

This commit is contained in:
birdhouse 2019-06-26 18:17:39 +02:00
parent 2efbaa6175
commit e9f8309b50
4 changed files with 82 additions and 51 deletions

View File

@ -127,4 +127,5 @@
<script type="text/javascript"> <script type="text/javascript">
performTranslation(); performTranslation();
createHintH("intro", $.i18n('support_label_intro'), "supp_intro"); createHintH("intro", $.i18n('support_label_intro'), "supp_intro");
removeOverlay();
</script> </script>

View File

@ -16,25 +16,29 @@
</div> </div>
<script> <script>
// performTranslation('trans_update'); $(document).ready( function(error) {
performTranslation(); performTranslation();
if(Array.isArray(window.gitHubVersionList) && window.gitHubVersionList.length) getReleases(function (callback){
{
for (key in window.gitHubVersionList) if(callback)
{ {
for (var key in window.gitHubVersionList)
if(window.gitHubVersionList[key].name == null || (window.serverConfig.general.versionBranch == "Stable" && window.gitHubVersionList[key].prerelease == true))
{ {
continue;
if(window.gitHubVersionList[key].name == null || (window.serverConfig.general.versionBranch == "Stable" && window.gitHubVersionList[key].prerelease == true))
{
continue;
}
$('#versionlist').append('<div class="col-lg-6"><div class="panel panel-'+ (window.gitHubVersionList[key].prerelease == true ? "danger" : "default") +'"><div class="panel-heading"><i class="fa fa-television fa-fw"></i>Hyperion V'+window.gitHubVersionList[key].tag_name+'</div><div class="panel-body"><p><span style="font-weight:bold;">'+$.i18n('update_label_type') + '</span> ' + (window.gitHubVersionList[key].prerelease == true ? "Beta" : "Stable") + '</p><p><span style="font-weight:bold;">'+$.i18n('update_label_description')+'</span> '+window.gitHubVersionList[key].body+'</p><hr><a class="btn btn-primary" href="'+ window.gitHubVersionList[key].html_url +'" target="_blank"><i class="fa fa-list fa-fw"></i><span style="font-weight:bold;">'+$.i18n('update_button_changelog')+'</span></a><button type="button" class="btn btn-warning pull-right" ' + (window.gitHubVersionList[key].tag_name == window.currentVersion ? "disabled":"") + '><i class="fa fa-download fa-fw"></i>'+$.i18n('update_button_install')+'</button></div></div></div>');
} }
$('#update_currver').append($.i18n('update_versreminder', currentVersion));
$('#versionlist').append('<div class="col-lg-6"><div class="panel panel-'+ (window.gitHubVersionList[key].prerelease == true ? "danger" : "default") +'"><div class="panel-heading"><i class="fa fa-television fa-fw"></i>Hyperion V'+window.gitHubVersionList[key].tag_name+'</div><div class="panel-body"><p><span style="font-weight:bold;">'+$.i18n('update_label_type') + '</span> ' + (window.gitHubVersionList[key].prerelease == true ? "Beta" : "Stable") + '</p><p><span style="font-weight:bold;">'+$.i18n('update_label_description')+'</span> '+window.gitHubVersionList[key].body+'</p><hr><a class="btn btn-primary" href="'+ window.gitHubVersionList[key].html_url +'" target="_blank"><i class="fa fa-list fa-fw"></i><span style="font-weight:bold;">'+$.i18n('update_button_changelog')+'</span></a><button type="button" class="btn btn-warning pull-right" ' + (window.gitHubVersionList[key].tag_name == window.currentVersion ? "disabled":"") + '><i class="fa fa-download fa-fw"></i>'+$.i18n('update_button_install')+'</button></div></div></div>');
} }
$('#update_currver').append($.i18n('update_versreminder', currentVersion)); else
} {
else $('#versionlist').append($.i18n('update_error_getting_versions'));
{ }
$('#versionlist').append($.i18n('update_error_getting_versions')); });
} removeOverlay();
});
</script> </script>

View File

@ -80,43 +80,21 @@ $(document).ready( function() {
$('#dash_ports').html(window.serverConfig.flatbufServer.port+' | '+window.serverConfig.protoServer.port); $('#dash_ports').html(window.serverConfig.flatbufServer.port+' | '+window.serverConfig.protoServer.port);
$('#dash_versionbranch').html(window.serverConfig.general.versionBranch); $('#dash_versionbranch').html(window.serverConfig.general.versionBranch);
$.get( window.gitHubReleaseApiUrl, function( releases ) { getReleases(function(){
window.gitHubVersionList = releases; var cleanLatestVersion = window.latestVersion.tag_name.replace(/\./g, '');
var cleanCurrentVersion = window.currentVersion.replace(/\./g, '');
for(var i in releases) $('#dash_latev').html(window.currentVersion);
{ $('#dash_latev').html(window.latestVersion.tag_name + ' (' + (window.latestVersion.prerelease == true ? "Beta" : "Stable") + ')');
if(releases[i].prerelease == true)
{
window.latestBetaVersion = releases[i];
break;
}
}
$.get( window.gitHubReleaseApiUrl + "/latest", function( latest ) { if ( cleanCurrentVersion < cleanLatestVersion )
window.latestStableVersion = latest; $('#versioninforesult').html('<div class="bs-callout bs-callout-warning" style="margin:0px">'+$.i18n('dashboard_infobox_message_updatewarning', window.latestVersion.tag_name) + ' (' + (window.latestVersion.prerelease == true ? "Beta" : "Stable") + ')</div>');
else
if(window.serverConfig.general.versionBranch == "Beta" && window.latestStableVersion.tag_name.replace(/\./g, '') <= window.latestBetaVersion.tag_name.replace(/\./g, '')) $('#versioninforesult').html('<div class="bs-callout bs-callout-success" style="margin:0px">'+$.i18n('dashboard_infobox_message_updatesuccess')+'</div>');
{
window.latestVersion = window.latestBetaVersion;
}
else
{
window.latestVersion = window.latestStableVersion;
}
var cleanLatestVersion = window.latestVersion.tag_name.replace(/\./g, '');
var cleanCurrentVersion = window.currentVersion.replace(/\./g, '');
$('#dash_latev').html(window.currentVersion);
$('#dash_latev').html(window.latestVersion.tag_name + ' (' + (window.latestVersion.prerelease == true ? "Beta" : "Stable") + ')');
if ( cleanCurrentVersion < cleanLatestVersion )
$('#versioninforesult').html('<div class="bs-callout bs-callout-warning" style="margin:0px">'+$.i18n('dashboard_infobox_message_updatewarning', window.latestVersion.tag_name) + ' (' + (window.latestVersion.prerelease == true ? "Beta" : "Stable") + ')</div>');
else
$('#versioninforesult').html('<div class="bs-callout bs-callout-success" style="margin:0px">'+$.i18n('dashboard_infobox_message_updatesuccess')+'</div>');
});
}); });
//determine platform //determine platform
var grabbers = window.serverInfo.grabbers.available; var grabbers = window.serverInfo.grabbers.available;
var html = ""; var html = "";

View File

@ -709,3 +709,51 @@ function encode_utf8(s)
{ {
return unescape(encodeURIComponent(s)); return unescape(encodeURIComponent(s));
} }
function getReleases(callback)
{
$.ajax({
url: window.gitHubReleaseApiUrl,
method: 'get',
error: function(XMLHttpRequest, textStatus, errorThrown)
{
callback(false);
},
success: function(releases)
{
window.gitHubVersionList = releases;
for(var i in releases)
{
if(releases[i].prerelease == true)
{
window.latestBetaVersion = releases[i];
break;
}
}
$.ajax({
url: window.gitHubReleaseApiUrl + "/latest",
method: 'get',
error: function(XMLHttpRequest, textStatus, errorThrown)
{
callback(false);
},
success: function(latest)
{
window.latestStableVersion = latest;
if(window.serverConfig.general.versionBranch == "Beta" && window.latestStableVersion.tag_name.replace(/\./g, '') <= window.latestBetaVersion.tag_name.replace(/\./g, ''))
{
window.latestVersion = window.latestBetaVersion;
}
else
{
window.latestVersion = window.latestStableVersion;
}
callback(true);
}
});
}
})
}