Migrate away from system version file to fetch
This commit is contained in:
@@ -72,10 +72,50 @@ namespace gaseous_server.Controllers
|
|||||||
[MapToApiVersion("1.1")]
|
[MapToApiVersion("1.1")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("Version")]
|
[Route("Version")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(Dictionary<string, object>), StatusCodes.Status200OK)]
|
||||||
public Version GetSystemVersion()
|
public ActionResult GetSystemVersion()
|
||||||
{
|
{
|
||||||
return Assembly.GetExecutingAssembly().GetName().Version;
|
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
|
|
||||||
|
// get age ratings dictionary
|
||||||
|
Dictionary<int, string> ClassificationBoardsStrings = new Dictionary<int, string>();
|
||||||
|
foreach (IGDB.Models.AgeRatingCategory ageRatingCategory in Enum.GetValues(typeof(IGDB.Models.AgeRatingCategory)))
|
||||||
|
{
|
||||||
|
ClassificationBoardsStrings.Add((int)ageRatingCategory, ageRatingCategory.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<int, string> AgeRatingsStrings = new Dictionary<int, string>();
|
||||||
|
foreach (IGDB.Models.AgeRatingTitle ageRatingTitle in Enum.GetValues(typeof(IGDB.Models.AgeRatingTitle)))
|
||||||
|
{
|
||||||
|
AgeRatingsStrings.Add((int)ageRatingTitle, ageRatingTitle.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, object> retVal = new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{
|
||||||
|
"AppVersion", Assembly.GetExecutingAssembly().GetName().Version.ToString()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DBSchemaVersion", db.GetDatabaseSchemaVersion().ToString()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"FirstRunStatus", Config.ReadSetting<string>("FirstRunStatus", "0")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"AgeRatingBoardsStrings", ClassificationBoardsStrings
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"AgeRatingStrings", AgeRatingsStrings
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"AgeRatingGroups", AgeGroups.AgeGroupingsFlat
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"emulatorDebugMode", Config.ReadSetting<string>("emulatorDebugMode", false.ToString()).ToLower()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return Ok(retVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MapToApiVersion("1.0")]
|
[MapToApiVersion("1.0")]
|
||||||
|
@@ -3,7 +3,11 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<script src="/api/v1.1/System/VersionFile"></script>
|
<script type="text/javascript" src="/scripts/jquery-3.6.0.min.js"></script>
|
||||||
|
<script type="text/javascript" src="/scripts/jquery.lazy.min.js"></script>
|
||||||
|
<script type="text/javascript" src="/scripts/jquery.lazy.plugins.min.js"></script>
|
||||||
|
<script type="text/javascript" src="/scripts/moment-with-locales.min.js"></script>
|
||||||
|
<script type="text/javascript" src="/scripts/select2.min.js"></script>
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||||
@@ -21,11 +25,6 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
let scriptLinks = [
|
let scriptLinks = [
|
||||||
"/scripts/jquery-3.6.0.min.js",
|
|
||||||
"/scripts/jquery.lazy.min.js",
|
|
||||||
"/scripts/jquery.lazy.plugins.min.js",
|
|
||||||
"/scripts/moment-with-locales.min.js",
|
|
||||||
"/scripts/select2.min.js",
|
|
||||||
"/scripts/filterformating.js",
|
"/scripts/filterformating.js",
|
||||||
"/scripts/gamesformating.js",
|
"/scripts/gamesformating.js",
|
||||||
"/scripts/main.js",
|
"/scripts/main.js",
|
||||||
@@ -60,31 +59,21 @@
|
|||||||
<div id="content"></div>
|
<div id="content"></div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
// Gaseous Games - Main Application Script
|
||||||
|
|
||||||
|
let APIVersion = "v1.1";
|
||||||
|
|
||||||
// start the application
|
// start the application
|
||||||
|
let AppVersion = "0.0.0";
|
||||||
|
let DBSchemaVersion = "1000";
|
||||||
|
let FirstRunStatus = "0";
|
||||||
|
let AgeRatingBoardStrings = {};
|
||||||
|
let AgeRatingStrings = {};
|
||||||
|
let AgeRatingGroups = {};
|
||||||
|
let emulatorDebugMode = "false";
|
||||||
|
|
||||||
let backgroundImageHandler = undefined;
|
let backgroundImageHandler = undefined;
|
||||||
|
|
||||||
async function loadScriptsAndStyles() {
|
|
||||||
// update script links
|
|
||||||
for (let i = 0; i < scriptLinks.length; i++) {
|
|
||||||
let newScript = document.createElement('script');
|
|
||||||
newScript.src = scriptLinks[i] + '?v=' + AppVersion;
|
|
||||||
newScript.type = "text/javascript";
|
|
||||||
newScript.async = false;
|
|
||||||
|
|
||||||
head.appendChild(newScript);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update stylesheet links
|
|
||||||
for (let i = 0; i < styleSheets.length; i++) {
|
|
||||||
let newLink = document.createElement('link');
|
|
||||||
newLink.rel = "stylesheet";
|
|
||||||
newLink.href = styleSheets[i] + '?v=' + AppVersion;
|
|
||||||
newLink.type = "text/css";
|
|
||||||
|
|
||||||
head.appendChild(newLink);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function LoadPageContent(page, targetDiv) {
|
async function LoadPageContent(page, targetDiv) {
|
||||||
if (targetDiv == undefined || targetDiv == null || targetDiv == '') {
|
if (targetDiv == undefined || targetDiv == null || targetDiv == '') {
|
||||||
targetDiv = 'content';
|
targetDiv = 'content';
|
||||||
@@ -107,9 +96,43 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function startApp() {
|
async function startApp() {
|
||||||
await loadScriptsAndStyles();
|
// load /api/v1.1/System/Version
|
||||||
|
await fetch('/api/v1.1/System/Version')
|
||||||
|
.then(async response => {
|
||||||
|
if (response.ok) {
|
||||||
|
// get version information
|
||||||
|
let versionFile = await response.json();
|
||||||
|
AppVersion = versionFile.AppVersion;
|
||||||
|
DBSchemaVersion = versionFile.DBSchemaVersion;
|
||||||
|
FirstRunStatus = versionFile.FirstRunStatus;
|
||||||
|
AgeRatingBoardStrings = versionFile.AgeRatingBoardStrings;
|
||||||
|
AgeRatingStrings = versionFile.AgeRatingStrings;
|
||||||
|
AgeRatingGroups = versionFile.AgeRatingGroups;
|
||||||
|
emulatorDebugMode = versionFile.EmulatorDebugMode;
|
||||||
|
|
||||||
console.log("Starting Gaseous Games");
|
// load scripts and style files
|
||||||
|
// update script links
|
||||||
|
for (let i = 0; i < scriptLinks.length; i++) {
|
||||||
|
let newScript = document.createElement('script');
|
||||||
|
newScript.src = scriptLinks[i] + '?v=' + AppVersion;
|
||||||
|
newScript.type = "text/javascript";
|
||||||
|
newScript.async = false;
|
||||||
|
|
||||||
|
head.appendChild(newScript);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update stylesheet links
|
||||||
|
for (let i = 0; i < styleSheets.length; i++) {
|
||||||
|
let newLink = document.createElement('link');
|
||||||
|
newLink.rel = "stylesheet";
|
||||||
|
newLink.href = styleSheets[i] + '?v=' + AppVersion;
|
||||||
|
newLink.type = "text/css";
|
||||||
|
|
||||||
|
head.appendChild(newLink);
|
||||||
|
}
|
||||||
|
|
||||||
|
// start the application
|
||||||
|
console.log("Starting Gaseous");
|
||||||
console.log("App Version: " + AppVersion);
|
console.log("App Version: " + AppVersion);
|
||||||
console.log("First Run Status: " + FirstRunStatus);
|
console.log("First Run Status: " + FirstRunStatus);
|
||||||
switch (FirstRunStatus) {
|
switch (FirstRunStatus) {
|
||||||
@@ -151,6 +174,11 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch(async (error) => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
window.document.addEventListener('DOMContentLoaded', startApp);
|
window.document.addEventListener('DOMContentLoaded', startApp);
|
||||||
</script>
|
</script>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
function getSystemSettings() {
|
function getSystemSettings() {
|
||||||
ajaxCall(
|
ajaxCall(
|
||||||
'/api/v1/System/Settings/System',
|
'/api/v1.1/System/Settings/System',
|
||||||
'GET',
|
'GET',
|
||||||
function (result) {
|
function (result) {
|
||||||
console.log(result);
|
console.log(result);
|
||||||
@@ -66,7 +66,7 @@ function setSystemSettings() {
|
|||||||
console.log(model);
|
console.log(model);
|
||||||
|
|
||||||
ajaxCall(
|
ajaxCall(
|
||||||
'/api/v1/System/Settings/System',
|
'/api/v1.1/System/Settings/System',
|
||||||
'POST',
|
'POST',
|
||||||
function (result) {
|
function (result) {
|
||||||
getSystemSettings();
|
getSystemSettings();
|
||||||
|
Reference in New Issue
Block a user