diff --git a/gulpfile.ts b/gulpfile.ts index 7b612945..dfcfde6a 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -117,7 +117,9 @@ gulp.task('copy-package', function () { devDependencies: { [key: string]: string }, scripts: { [key: string]: string }, dependencies: { [key: string]: string }, - optionalDependencies: { [key: string]: string } + optionalDependencies: { [key: string]: string }, + buildTime: string, + buildCommitHash: string }) => { delete json.devDependencies; json.scripts = {start: 'node ./src/backend/index.js'}; @@ -139,6 +141,13 @@ gulp.task('copy-package', function () { } delete json.optionalDependencies; } + json.buildTime = (new Date()).toISOString(); + + try { + json.buildCommitHash = require('child_process').execSync('git rev-parse HEAD'); + } catch (e) { + } + return json; })) .pipe(gulp.dest('./release')); diff --git a/src/backend/server.ts b/src/backend/server.ts index 4315ce77..6b5a8bc7 100644 --- a/src/backend/server.ts +++ b/src/backend/server.ts @@ -41,6 +41,8 @@ export class Server { await ConfigDiagnostics.runDiagnostics(); Logger.verbose(LOG_TAG, 'using config:'); Config.Client.appVersion = require('../../package.json').version; + Config.Client.buildTime = require('../../package.json').buildTime; + Config.Client.buildCommitHash = require('../../package.json').buildCommitHash; Logger.verbose(LOG_TAG, JSON.stringify(Config, null, '\t')); this.app = _express(); diff --git a/src/common/config/public/ConfigClass.ts b/src/common/config/public/ConfigClass.ts index 02047374..b74911d9 100644 --- a/src/common/config/public/ConfigClass.ts +++ b/src/common/config/public/ConfigClass.ts @@ -92,6 +92,8 @@ export module ClientConfig { export interface Config { appVersion: string; + buildTime: string; + buildCommitHash: string; applicationTitle: string; publicUrl: string; urlBase: string; @@ -118,6 +120,8 @@ export class PublicConfigClass { public Client: ClientConfig.Config = { applicationTitle: 'PiGallery 2', appVersion: '', + buildCommitHash: '', + buildTime: '', Media: { Video: { enabled: true diff --git a/src/frontend/app/ui/admin/admin.component.html b/src/frontend/app/ui/admin/admin.component.html index 4d675d92..f3072d0a 100644 --- a/src/frontend/app/ui/admin/admin.component.html +++ b/src/frontend/app/ui/admin/admin.component.html @@ -22,7 +22,7 @@
- + App version: v{{appVersion}}
@@ -55,7 +55,8 @@ (click)="scrollTo(i)" [hidden]="!s.HasAvailableSettings"> {{s.Name}}* + --> + *
diff --git a/src/frontend/app/ui/admin/admin.component.ts b/src/frontend/app/ui/admin/admin.component.ts index 955952f7..caf22c63 100644 --- a/src/frontend/app/ui/admin/admin.component.ts +++ b/src/frontend/app/ui/admin/admin.component.ts @@ -1,4 +1,4 @@ -import {AfterViewInit, Component, ElementRef, OnInit, QueryList, ViewChildren} from '@angular/core'; +import {AfterViewInit, Component, ElementRef, Inject, LOCALE_ID, OnInit, QueryList, ViewChildren} from '@angular/core'; import {AuthenticationService} from '../../model/network/authentication.service'; import {UserRoles} from '../../../../common/entities/UserDTO'; import {NotificationService} from '../../model/notification.service'; @@ -8,6 +8,7 @@ import {I18n} from '@ngx-translate/i18n-polyfill'; import {Config} from '../../../../common/config/public/Config'; import {ISettingsComponent} from '../settings/_abstract/ISettingsComponent'; import {PageHelper} from '../../model/page.helper'; +import {formatDate} from '@angular/common'; @Component({ selector: 'app-admin', @@ -21,6 +22,9 @@ export class AdminComponent implements OnInit, AfterViewInit { Simplified: 'Simplified' }; appVersion = Config.Client.appVersion; + versionExtra = ''; + buildTime = Config.Client.buildTime; + buildCommitHash = Config.Client.buildCommitHash; @ViewChildren('setting') settingsComponents: QueryList; @ViewChildren('setting', {read: ElementRef}) settingsComponents2: QueryList; contents: ISettingsComponent[] = []; @@ -28,9 +32,17 @@ export class AdminComponent implements OnInit, AfterViewInit { constructor(private _authService: AuthenticationService, private _navigation: NavigationService, public notificationService: NotificationService, + @Inject(LOCALE_ID) private locale: string, public i18n: I18n) { this.text.Advanced = i18n('Advanced'); this.text.Simplified = i18n('Simplified'); + if (Config.Client.buildTime) { + this.versionExtra = i18n('Built at') + ': ' + formatDate(Config.Client.buildTime, 'medium', locale); + } + if (Config.Client.buildCommitHash) { + this.versionExtra += ', ' + i18n('git hash') + ': ' + Config.Client.buildCommitHash; + } + } ngAfterViewInit(): void {