Version determination now with github api

This commit is contained in:
birdhouse 2019-06-22 21:30:17 +02:00
parent ab3f803060
commit e37abbb62d
6 changed files with 63 additions and 32 deletions

View File

@ -4,6 +4,7 @@
<h3 class="page-header"><i class="fa fa-download fa-fw"></i><span data-i18n="main_menu_update_token">Update</span></h3>
<div class="introd">
<h4 data-i18n="update_label_intro">Overview about all available Hyperion versions. On top you could update or downgrade your version of Hyperion whenever you want. Sorted from newest to oldest</h4>
<h4> At the moment the install buttons are not working. Development is still ongoing here. </h4>
<hr />
</div>
<h4 id="update_currver"></h4>
@ -17,10 +18,23 @@
<script>
// performTranslation('trans_update');
performTranslation();
for (key in parsedUpdateJSON)
if(window.gitHubVersionList != null)
{
for (key in window.gitHubVersionList)
{
$('#versionlist').append('<div class="col-lg-6"><div class="panel panel-default"><div class="panel-heading"><i class="fa fa-television fa-fw"></i>Hyperion V'+parsedUpdateJSON[key].versionnr+'</div><div class="panel-body"><p><span style="font-weight:bold;">'+$.i18n('update_label_type')+'</span> '+ parsedUpdateJSON[key].channel +'</p><p><span style="font-weight:bold;">'+$.i18n('update_label_description')+'</span> '+parsedUpdateJSON[key].versiondesc+'</p><hr><a class="btn btn-primary" href="'+ parsedUpdateJSON[key].versionchangelog +'" 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"><i class="fa fa-download fa-fw"></i>'+$.i18n('update_button_install')+'</button></div></div></div>');
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));
}
else
{
$('#versionlist').append($.i18n('update_error_getting_versions'));
}
</script>

View File

@ -256,6 +256,7 @@
"update_button_changelog" : "Zeige Änderungsprotokoll",
"update_label_type" : "Art:",
"update_versreminder" : "Deine Version: $1",
"update_error_getting_versions" : "Wir hatten Probleme die verfügbaren Versionen zu ermitteln.",
"about_version" : "Version",
"about_build" : "Build",
"about_builddate" : "Build Datum",

View File

@ -256,6 +256,7 @@
"update_button_changelog" : "Full changelog",
"update_label_type" : "Type:",
"update_versreminder" : "Your version: $1",
"update_error_getting_versions" : "We had trouble to determinate the available Versions.",
"about_version" : "Version",
"about_build" : "Build",
"about_builddate" : "Build date",

View File

@ -179,11 +179,8 @@
<ul class="nav nav-second-level">
<li> <a class="inactive mnava" href="#conf_webconfig" id="load_webconfig"><i class="fa fa-wrench fa-fw"></i><span data-i18n="main_menu_webconfig_token">Webconfiguration</span></a> </li>
<li> <a class="inactive mnava" href="#conf_logging"><i class="fa fa-reorder fa-fw"></i><span data-i18n="main_menu_logging_token">Log</span></a> </li>
<!-- Update is disabled
<li> <a class="inactive mnava" href="#update"><i class="fa fa-download fa-fw"></i><span data-i18n="main_menu_update_token">Update</span></a> </li>
-->
<li> <a class="inactive mnava" href="#about"><i class="fa fa-info-circle fa-fw"></i><span data-i18n="main_menu_about_token">Update</span></a> </li>
<li> <a class="inactive mnava" href="#about"><i class="fa fa-info-circle fa-fw"></i><span data-i18n="main_menu_about_token">About</span></a> </li>
</ul>
</li>
</ul>

View File

@ -80,40 +80,57 @@ $(document).ready( function() {
$('#dash_ports').html(window.serverConfig.flatbufServer.port+' | '+window.serverConfig.protoServer.port);
$('#dash_versionbranch').html(window.serverConfig.general.versionBranch);
$.get( "https://raw.githubusercontent.com/hyperion-project/hyperion.ng/master/version.json", function( data ) {
window.parsedUpdateJSON = JSON.parse(data);
$.get( window.gitHubReleaseApiUrl, function( releases ) {
window.gitHubVersionList = releases;
for(let i=0; i<window.parsedUpdateJSON.length; i++) {
if(window.parsedUpdateJSON[i].channel == "Stable") {
window.latestStableVersion = window.parsedUpdateJSON[i];
for(i in releases)
{
console.log(releases[i].prerelease)
if(releases[i].prerelease == true)
{
//for(j in releases[i].assets)
//{
//console.log(releases[i].assets[j])
//if(releases[i].assets[j].name.indexOf('Beta') > -1)
//{
window.latestBetaVersion = releases[i];
//break;
//}
//}
break;
}
}
for(let i=0; i<window.parsedUpdateJSON.length; i++) {
if(window.parsedUpdateJSON[i].channel == "Beta") {
window.latestBetaVersion = window.parsedUpdateJSON[i];
break;
$.get( window.gitHubReleaseApiUrl + "/latest", function( latest ) {
window.latestStableVersion = latest;
console.log(window.latestBetaVersion)
console.log(window.latestStableVersion)
//debugger;
console.log("Stable"+ window.latestStableVersion.tag_name.replace(/\./g, ''))
console.log("Beta"+ window.latestBetaVersion.tag_name.replace(/\./g, ''))
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;
}
}
if(window.serverConfig.general.versionBranch == "Beta" && window.latestStableVersion.versionnr.replace(/\./g, '') <= window.latestBetaVersion.versionnr.replace(/\./g, '')) {
window.latestVersion = window.latestBetaVersion;
}
else {
window.latestVersion = window.latestStableVersion;
}
console.log(latestVersion)
var cleanLatestVersion = window.latestVersion.versionnr.replace(/\./g, '');
var cleanCurrentVersion = window.currentVersion.replace(/\./g, '');
var cleanLatestVersion = window.latestVersion.tag_name.replace(/\./g, '');
var cleanCurrentVersion = window.currentVersion.replace(/\./g, '');
$('#dash_latev').html(window.currentVersion);
$('#dash_latev').html(window.latestVersion.versionnr + ' (' + window.latestVersion.channel + ')');
$('#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.versionnr) + ' (' + window.latestVersion.channel + ')</div>');
else
$('#versioninforesult').html('<div class="bs-callout bs-callout-success" style="margin:0px">'+$.i18n('dashboard_infobox_message_updatesuccess')+'</div>');
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

View File

@ -2,12 +2,13 @@
window.webPrio = 1;
window.webOrigin = "Web Configuration";
window.showOptHelp = true;
window.gitHubReleaseApiUrl = "https://api.github.com/repos/b1rdhous3/hyperion.ng/releases";
window.currentVersion = null;
window.latestVersion = null;
window.latestStableVersion = null;
window.latestBetaVersion = null;
window.gitHubVersionList = null;
window.serverInfo = {};
window.parsedUpdateJSON = {};
window.serverSchema = {};
window.serverConfig = {};
window.schema = {};