Skip to content

Commit

Permalink
Isseu #6 Add app version to UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmas committed Jan 8, 2024
1 parent 9f6152a commit 7bc6168
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- name: Build project
run: |
bin/generate-appinfo.sh public/appinfo.json
cp public/appinfo.json src/appinfo.json
npm run build
- name: Upload production-ready build files
Expand Down
2 changes: 1 addition & 1 deletion bin/generate-appinfo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ json=$(cat <<EOF
"buildDate": "$build_date",
"version": "$version",
"gitHash": "$git_hash",
"gitBranch": "$git_branch"
"gitBranch": "$git_branch",
"mode": "$mode"
}
EOF
Expand Down
8 changes: 8 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@
</div>
<div class="window-content-holder">
<div class="window-content">
<p class="app-info">
version: <span class="app-version">n/a</span><br/>
build date: <span class="build-date">n/a</span>
</p>

<p>Stuff in Space is a realtime 3D map of objects in Earth orbit, visualized using WebGL.</p>

<p>The website updates daily with orbit data from <a href="http://www.space-track.org">Space-Track.org</a>
Expand All @@ -188,6 +193,9 @@
</div>
</div>

<div class="release-date-holder">
Build date: <span class="release-date">&nbsp;</span>
</div>
</body>
</html>

11 changes: 11 additions & 0 deletions public/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -558,4 +558,15 @@ canvas {
-webkit-filter: none;
background: black;
}
}

.app-info {
font-size: 12px;
}

.release-date-holder {
position: absolute;
bottom: 13px;
right: 13px;
font-size: 12px;
}
7 changes: 7 additions & 0 deletions src/appinfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"buildDate": "0000-00-00:00:00:00Z",
"version": "",
"gitHash": "unknown",
"gitBranch": "unknown",
"mode": "none"
}
7 changes: 6 additions & 1 deletion src/hud/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ function getCurrentSearch () {
return searchBox.getCurrentSearch();
}

function init (viewerInstance: Viewer) {
function init (viewerInstance: Viewer, appConfig: Record<string, any> = {}) {
viewer = viewerInstance;

windowManager.registerWindow('sat-infobox');
Expand All @@ -310,6 +310,11 @@ function init (viewerInstance: Viewer) {
} else {
onSatDataLoaded();
}

console.log('xoooo', appConfig);
setHtml('.app-version', appConfig.appInfo.version);
setHtml('.build-date', appConfig.appInfo.buildDate);
setHtml('.release-date', appConfig.appInfo.buildDate);
}

export default {
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import axios from 'axios';
import { createViewer } from './viewer/index';
import defaultConfig from './config';
import logger, { setLogLevel } from './utils/logger';
import appinfo from './appinfo.json';

import hud from './hud';

Expand All @@ -10,7 +11,7 @@ async function loadConfig () {
const response = await axios.get(`${baseUrl}config.json`);
let config = defaultConfig;
if (response.data) {
config = { ...defaultConfig, ...response.data };
config = { ...defaultConfig, ...response.data, appInfo: appinfo };
}
logger.info(`.... ${config.baseUrl}`);
return config;
Expand All @@ -24,7 +25,7 @@ async function main () {
await viewer.init();
viewer.animate();

hud.init(viewer);
hud.init(viewer, config);
}

document.addEventListener('DOMContentLoaded', () => {
Expand Down

0 comments on commit 7bc6168

Please sign in to comment.