Skip to content

Commit

Permalink
Moved build info to variables.js. Simplified info.js build readout. A…
Browse files Browse the repository at this point in the history
…dded versions to user dropdown
  • Loading branch information
glenndehaan committed Oct 7, 2024
1 parent 7fb9956 commit f13ed22
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
6 changes: 1 addition & 5 deletions modules/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ module.exports = () => {
/**
* Output build version
*/
if(fs.existsSync('/etc/unifi_voucher_site_build')) {
log.info(`[Version] Git: ${variables.gitTag}, Build: ${fs.readFileSync('/etc/unifi_voucher_site_build', 'utf-8')}`);
} else {
log.info(`[Version] Git: ${variables.gitTag}, Build: **DEVELOPMENT**`);
}
log.info(`[Version] Git: ${variables.gitTag}, Build: ${variables.gitBuild}`);

/**
* Log external config
Expand Down
8 changes: 7 additions & 1 deletion modules/variables.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Import base packages
*/
const fs = require('fs');

/**
* Import own modules
*/
Expand Down Expand Up @@ -36,5 +41,6 @@ module.exports = {
smtpUsername: config('smtp_username') || process.env.SMTP_USERNAME || '',
smtpPassword: config('smtp_password') || process.env.SMTP_PASSWORD || '',
logLevel: config('log_level') || process.env.LOG_LEVEL || 'info',
gitTag: process.env.GIT_TAG || 'master'
gitTag: process.env.GIT_TAG || 'master',
gitBuild: fs.existsSync('/etc/unifi_voucher_site_build') ? fs.readFileSync('/etc/unifi_voucher_site_build', 'utf-8') : 'Development'
};
2 changes: 2 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ if(variables.serviceWeb) {
res.render('voucher', {
baseUrl: req.headers['x-ingress-path'] ? req.headers['x-ingress-path'] : '',
gitTag: variables.gitTag,
gitBuild: variables.gitBuild,
user: user,
userIcon: req.oidc ? crypto.createHash('sha256').update(user.email).digest('hex') : '',
authDisabled: variables.authDisabled,
Expand Down Expand Up @@ -414,6 +415,7 @@ if(variables.serviceWeb) {
res.render('status', {
baseUrl: req.headers['x-ingress-path'] ? req.headers['x-ingress-path'] : '',
gitTag: variables.gitTag,
gitBuild: variables.gitBuild,
user: user,
userIcon: req.oidc ? crypto.createHash('sha256').update(user.email).digest('hex') : '',
authDisabled: variables.authDisabled,
Expand Down
3 changes: 3 additions & 0 deletions template/partials/navigation.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
Logout
</a>
<% } %>
<div class="px-4 py-1 text-xs text-center text-gray-600 dark:text-gray-400">
Git: <%= gitTag %> - Build: <%= gitBuild %>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit f13ed22

Please sign in to comment.