Added a version number display (#78)

* Added a version number

* Appends version number when loading subpages
This commit is contained in:
Michael Green
2023-09-01 23:48:08 +10:00
committed by GitHub
parent 8e922182e2
commit 4b6174e3e2
11 changed files with 88 additions and 16 deletions

View File

@@ -14,6 +14,12 @@ jobs:
uses: actions/checkout@v3
with:
submodules: 'true'
-
name: Install dotnet tool
run: dotnet tool install -g dotnetCampus.TagToVersion
-
name: Set tag to version
run: dotnet TagToVersion -t ${{ github.ref }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2

3
Directory.Build.props Normal file
View File

@@ -0,0 +1,3 @@
<Project>
<Import Project="build\Version.props" />
</Project>

5
build/Version.props Normal file
View File

@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<Version>1.5.0</Version>
</PropertyGroup>
</Project>

View File

@@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using gaseous_tools;
using Microsoft.AspNetCore.Mvc;
@@ -49,6 +51,22 @@ namespace gaseous_server.Controllers
return ReturnValue;
}
[HttpGet]
[Route("Version")]
[ProducesResponseType(StatusCodes.Status200OK)]
public Version GetSystemVersion() {
return Assembly.GetExecutingAssembly().GetName().Version;
}
[HttpGet]
[Route("VersionFile")]
[ProducesResponseType(StatusCodes.Status200OK)]
public FileContentResult GetSystemVersionAsFile() {
string ver = "var AppVersion = \"" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + "\"";
byte[] bytes = Encoding.UTF8.GetBytes(ver);
return File(bytes, "text/javascript");
}
private SystemInfo.PathItem GetDisk(string Path)
{
SystemInfo.PathItem pathItem = new SystemInfo.PathItem {
@@ -63,6 +81,12 @@ namespace gaseous_server.Controllers
public class SystemInfo
{
public Version ApplicationVersion {
get
{
return Assembly.GetExecutingAssembly().GetName().Version;
}
}
public List<PathItem>? Paths { get; set; }
public long DatabaseSize { get; set; }
public List<PlatformStatisticsItem>? PlatformStatistics { get; set; }

View File

@@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.OpenApi.Models;
Logging.Log(Logging.LogType.Information, "Startup", "Starting Gaseous Server");
Logging.Log(Logging.LogType.Information, "Startup", "Starting Gaseous Server " + Assembly.GetExecutingAssembly().GetName().Version);
// set up db
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);

View File

@@ -2,23 +2,42 @@
<html>
<head>
<meta charset="utf-8" />
<link type="text/css" rel="stylesheet" href="/styles/style.css" />
<script src="/api/v1/System/VersionFile"></script>
<link type="text/css" rel="stylesheet" dat-href="/styles/style.css" />
<script src="/scripts/jquery-3.6.0.min.js"></script>
<script src="/scripts/moment.js"></script>
<link href="/styles/select2.min.css" rel="stylesheet" />
<link rel="stylesheet" href="/styles/dropzone.min.css" type="text/css" />
<link href="/styles/dropzone.min.css" rel="stylesheet" type="text/css" />
<script src="/scripts/jquery.lazy.min.js"></script>
<script src="/scripts/jquery.lazy.plugins.min.js"></script>
<script src="/scripts/select2.min.js"></script>
<script src="/scripts/dropzone.min.js"></script>
<script src="/scripts/main.js" type="text/javascript"></script>
<script src="/scripts/filterformating.js" type="text/javascript"></script>
<script src="/scripts/gamesformating.js" type="text/javascript"></script>
<script dat-src="/scripts/main.js" type="text/javascript"></script>
<script dat-src="/scripts/filterformating.js" type="text/javascript"></script>
<script dat-src="/scripts/gamesformating.js" type="text/javascript"></script>
<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="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<title>Gaseous Games</title>
<script type="text/javascript">
// update links
var headLinks = document.getElementsByTagName('link');
for (var i = 0; i < headLinks.length; i++) {
if (headLinks[i].getAttribute('dat-href')) {
headLinks[i].setAttribute('href', headLinks[i].getAttribute('dat-href') + '?v=' + AppVersion);
}
}
// update script src
var headLinks = document.getElementsByTagName('script');
for (var i = 0; i < headLinks.length; i++) {
if (headLinks[i].getAttribute('dat-src')) {
headLinks[i].setAttribute('src', headLinks[i].getAttribute('dat-src') + '?v=' + AppVersion);
}
}
</script>
</head>
<body>
<div id="banner_icon" onclick="window.location.href = '/index.html';">
@@ -78,6 +97,7 @@
<script type="text/javascript">var modalVariables = null;
$(document).ready(function () {
var myParam = getQueryString('page', 'string');
@@ -85,7 +105,8 @@
myParam = 'home';
}
$('#content').load('/pages/' + myParam + '.html');
});</script>
$('#content').load('/pages/' + myParam + '.html?v=' + AppVersion);
});
</script>
</body>
</html>

View File

@@ -55,7 +55,7 @@
subModalVariables = modalVariables;
$('#modal-content-sub').load('/pages/dialogs/' + dialogPage + '.html');
$('#modal-content-sub').load('/pages/dialogs/' + dialogPage + '.html?v=' + AppVersion);
}
function closeSubDialog() {

View File

@@ -44,7 +44,7 @@
switch (getQueryString('engine', 'string')) {
case 'EmulatorJS':
$('#emulator').load('/pages/EmulatorJS.html');
$('#emulator').load('/pages/EmulatorJS.html?v=' + AppVersion);
break;
}
});

View File

@@ -42,6 +42,6 @@
}
}
$('#properties_bodypanel').load('/pages/settings/' + TabName + '.html');
$('#properties_bodypanel').load('/pages/settings/' + TabName + '.html?v=' + AppVersion);
}
</script>

View File

@@ -11,6 +11,10 @@
<th>Bugs and Feature Requests</th>
<td><a href="https://github.com/gaseous-project/gaseous-server/issues" class="romlink">https://github.com/gaseous-project/gaseous-server/issues</a></td>
</tr>
<tr>
<th>Server Version</th>
<td id="settings_appversion"></td>
</tr>
<tr>
<td colspan="2">
<h3>Data Sources</h2>
@@ -39,3 +43,12 @@
</td>
</tr>
</table>
<script type="text/javascript">
ajaxCall('/api/v1/System/Version', 'GET', function (result) {
if (result) {
var versionBox = document.getElementById('settings_appversion');
versionBox.innerHTML = result;
}
});
</script>

View File

@@ -103,7 +103,7 @@ function showDialog(dialogPage, variables) {
modalVariables = variables;
$('#modal-content').load('/pages/dialogs/' + dialogPage + '.html');
$('#modal-content').load('/pages/dialogs/' + dialogPage + '.html?v=' + AppVersion);
}
function closeDialog() {
@@ -145,7 +145,7 @@ function showSubDialog(dialogPage, variables) {
subModalVariables = variables;
$('#modal-content-sub').load('/pages/dialogs/' + dialogPage + '.html');
$('#modal-content-sub').load('/pages/dialogs/' + dialogPage + '.html?v=' + AppVersion);
}
function closeSubDialog() {