diff --git a/docker/alpine/Dockerfile.build b/docker/alpine/Dockerfile.build index 70d55c88..ef5bca38 100644 --- a/docker/alpine/Dockerfile.build +++ b/docker/alpine/Dockerfile.build @@ -22,6 +22,8 @@ ENV NODE_ENV=production \ default-Server-Database-dbFolder=/app/data/db \ default-Server-Media-folder=/app/data/images \ default-Server-Media-tempFolder=/app/data/tmp + # flagging dockerized environemnt + PI_DOCKER=true # command line arg orverride the config.json with these settings ENTRYPOINT ["node", "./src/backend/index", \ # after a extensive job (like video converting), pigallery calls gc, to clean up everthing as fast as possible diff --git a/docker/debian-stretch/Dockerfile.build b/docker/debian-stretch/Dockerfile.build index d29d78ff..e106dc42 100644 --- a/docker/debian-stretch/Dockerfile.build +++ b/docker/debian-stretch/Dockerfile.build @@ -20,6 +20,8 @@ ENV NODE_ENV=production \ default-Server-Database-dbFolder=/app/data/db \ default-Server-Media-folder=/app/data/images \ default-Server-Media-tempFolder=/app/data/tmp + # flagging dockerized environemnt + PI_DOCKER=true # command line arg orverride the config.json with these settings ENTRYPOINT ["node", "./src/backend/index", \ # after a extensive job (like video converting), pigallery calls gc, to clean up everthing as fast as possible diff --git a/src/backend/server.ts b/src/backend/server.ts index 2c54c48c..ba4c87c9 100644 --- a/src/backend/server.ts +++ b/src/backend/server.ts @@ -49,10 +49,6 @@ export class Server { Logger.info(LOG_TAG, 'running diagnostics...'); 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; - Config.Client.upTime = (new Date()).toISOString(); Logger.verbose(LOG_TAG, JSON.stringify(Config, null, '\t')); this.app = _express(); diff --git a/src/common/config/private/Config.ts b/src/common/config/private/Config.ts index 210897bb..e21ac87e 100644 --- a/src/common/config/private/Config.ts +++ b/src/common/config/private/Config.ts @@ -6,6 +6,8 @@ import {ConfigClass, ConfigClassBuilder} from 'typeconfig/node'; import {ConfigProperty, IConfigClass} from 'typeconfig/common'; +declare const process: any; + @ConfigClass({ configPath: path.join(__dirname, './../../../../config.json'), saveIfNotExist: true, @@ -40,8 +42,15 @@ export class PrivateConfigClass implements IPrivateConfig { crypto.randomBytes(256).toString('hex'), crypto.randomBytes(256).toString('hex')]; } + + this.Server.Environment.appVersion = require('../../../../package.json').version; + this.Server.Environment.buildTime = require('../../../../package.json').buildTime; + this.Server.Environment.buildCommitHash = require('../../../../package.json').buildCommitHash; + this.Server.Environment.upTime = (new Date()).toISOString(); + this.Server.Environment.isDocker = !!process.env['PI_DOCKER']; } + async original(): Promise { const pc = ConfigClassBuilder.attachInterface(new PrivateConfigClass()); await pc.load(); diff --git a/src/common/config/private/PrivateConfig.ts b/src/common/config/private/PrivateConfig.ts index 4c38caf5..7654b749 100644 --- a/src/common/config/private/PrivateConfig.ts +++ b/src/common/config/private/PrivateConfig.ts @@ -291,8 +291,24 @@ export module ServerConfig { } + @SubConfigClass() + export class EnvironmentConfig { + @ConfigProperty({volatile: true}) + upTime: string; + @ConfigProperty({volatile: true}) + appVersion: string; + @ConfigProperty({volatile: true}) + buildTime: string; + @ConfigProperty({volatile: true}) + buildCommitHash: string; + @ConfigProperty({volatile: true}) + isDocker: boolean; + } + @SubConfigClass() export class Config { + @ConfigProperty({volatile: true}) + Environment: EnvironmentConfig = new EnvironmentConfig(); @ConfigProperty({arrayType: 'string'}) sessionSecret: string[] = []; @ConfigProperty({type: 'unsignedInt', envAlias: 'PORT', min: 0, max: 65535}) diff --git a/src/common/config/public/ClientConfig.ts b/src/common/config/public/ClientConfig.ts index 444c48fa..d1da3ac1 100644 --- a/src/common/config/public/ClientConfig.ts +++ b/src/common/config/public/ClientConfig.ts @@ -153,15 +153,6 @@ export module ClientConfig { @SubConfigClass() export class Config { - - @ConfigProperty({volatile: true}) - upTime: string; - @ConfigProperty({volatile: true}) - appVersion: string; - @ConfigProperty({volatile: true}) - buildTime: string; - @ConfigProperty({volatile: true}) - buildCommitHash: string; @ConfigProperty() applicationTitle: string = 'PiGallery 2'; @ConfigProperty() diff --git a/src/frontend/app/ui/admin/admin.component.html b/src/frontend/app/ui/admin/admin.component.html index 98fbd63e..9565c2c7 100644 --- a/src/frontend/app/ui/admin/admin.component.html +++ b/src/frontend/app/ui/admin/admin.component.html @@ -1,3 +1,14 @@ + + Application version: v{{(settingsService.settings | async).Server.Environment.appVersion}} + +
+ Built at: {{(settingsService.settings | async).Server.Environment.buildTime | date:'medium' }} +
+ +
+ Git commit: {{(settingsService.settings | async).Server.Environment.buildCommitHash}} +
+
@@ -22,9 +33,16 @@
- - App version: v{{appVersion}} - +
+ + App version: {{'v'+((settingsService.settings | async).Server.Environment.appVersion || '----')}} + +
Up time: {{upTime | date:'medium'}} + -->: {{(settingsService.settings | async).Server.Environment.upTime | date:'medium'}}
diff --git a/src/frontend/app/ui/admin/admin.component.ts b/src/frontend/app/ui/admin/admin.component.ts index 99a3b103..282645d2 100644 --- a/src/frontend/app/ui/admin/admin.component.ts +++ b/src/frontend/app/ui/admin/admin.component.ts @@ -5,10 +5,9 @@ import {NotificationService} from '../../model/notification.service'; import {NotificationType} from '../../../../common/entities/NotificationDTO'; import {NavigationService} from '../../model/navigation.service'; 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'; +import {SettingsService} from '../settings/settings.service'; @Component({ selector: 'app-admin', @@ -17,9 +16,6 @@ import {formatDate} from '@angular/common'; }) export class AdminComponent implements OnInit, AfterViewInit { simplifiedMode = true; - appVersion = Config.Client.appVersion; - versionExtra = ''; - upTime = Config.Client.upTime; @ViewChildren('setting') settingsComponents: QueryList; @ViewChildren('setting', {read: ElementRef}) settingsComponentsElemRef: QueryList; contents: ISettingsComponent[] = []; @@ -27,16 +23,9 @@ export class AdminComponent implements OnInit, AfterViewInit { constructor(private _authService: AuthenticationService, private _navigation: NavigationService, public notificationService: NotificationService, + public settingsService: SettingsService, @Inject(LOCALE_ID) private locale: string, public i18n: I18n) { - - 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 { diff --git a/src/frontend/app/ui/settings/_abstract/settings-entry/settings-entry.component.html b/src/frontend/app/ui/settings/_abstract/settings-entry/settings-entry.component.html index f6da35da..7d0da2a8 100644 --- a/src/frontend/app/ui/settings/_abstract/settings-entry/settings-entry.component.html +++ b/src/frontend/app/ui/settings/_abstract/settings-entry/settings-entry.component.html @@ -1,64 +1,67 @@ + + It seems that you are running the application in a Docker container. + This setting should not be changed in docker. + Make sure, that you know what you are doing. + + -
- - {{description}} - -
-
-
- -
- - {{description}} - - -
-
-
- -
- - +
+ + + + + +
+ +
+
{{description}} diff --git a/src/frontend/app/ui/settings/_abstract/settings-entry/settings-entry.component.ts b/src/frontend/app/ui/settings/_abstract/settings-entry/settings-entry.component.ts index 43fff9b7..dd26308b 100644 --- a/src/frontend/app/ui/settings/_abstract/settings-entry/settings-entry.component.ts +++ b/src/frontend/app/ui/settings/_abstract/settings-entry/settings-entry.component.ts @@ -26,6 +26,7 @@ export class SettingsEntryComponent implements ControlValueAccessor, Validator, @Input() name: string; @Input() required: boolean; + @Input() dockerWarning: boolean; @Input() optionMap: (v: { key: number, value: string }) => { key: number, value: string }; @Input() placeholder: string; @Input() options: { key: number | string, value: number | string }[]; diff --git a/src/frontend/app/ui/settings/_abstract/settings-entry/settings-entry.settings.component.css b/src/frontend/app/ui/settings/_abstract/settings-entry/settings-entry.settings.component.css index 07baa5aa..0daa845e 100644 --- a/src/frontend/app/ui/settings/_abstract/settings-entry/settings-entry.settings.component.css +++ b/src/frontend/app/ui/settings/_abstract/settings-entry/settings-entry.settings.component.css @@ -1,7 +1,7 @@ .changed-settings input, .changed-settings select { border-color: #007bff; - border-width: 1.5px; + border-width: 1px; } .changed-settings label { @@ -9,3 +9,15 @@ font-weight: bold; } +.changed-settings.docker-warning label { + color: #ffc107; +} + +.changed-settings.docker-warning select, .changed-settings.docker-warning input { + border-color: #ffc107; +} + +.warning-icon { + font-size: x-large; + margin-top: 5px; +} diff --git a/src/frontend/app/ui/settings/basic/basic.settings.component.html b/src/frontend/app/ui/settings/basic/basic.settings.component.html index 97fa2dca..b5facc64 100644 --- a/src/frontend/app/ui/settings/basic/basic.settings.component.html +++ b/src/frontend/app/ui/settings/basic/basic.settings.component.html @@ -33,6 +33,7 @@ i18n-description i18n-name [ngModel]="states.port" required="true" + [dockerWarning]="(_settingsService.Settings | async).Server.Environment.isDocker" [simplifiedMode]="simplifiedMode"> @@ -43,6 +44,7 @@ placeholder="path" i18n-description i18n-name required + [dockerWarning]="(_settingsService.Settings | async).Server.Environment.isDocker" [ngModel]="states.imagesFolder"> @@ -54,6 +56,7 @@ placeholder="path" i18n-description i18n-name required="true" + [dockerWarning]="(_settingsService.Settings | async).Server.Environment.isDocker" [ngModel]="states.tempFolder"> diff --git a/src/frontend/app/ui/settings/database/database.settings.component.html b/src/frontend/app/ui/settings/database/database.settings.component.html index d201e4de..f3c2ac5d 100644 --- a/src/frontend/app/ui/settings/database/database.settings.component.html +++ b/src/frontend/app/ui/settings/database/database.settings.component.html @@ -22,6 +22,7 @@ description="All file-based data will be stored here (sqlite database, user database in case of memory db, job history data)" [ngModel]="states.dbFolder" i18n-name i18n-description + [dockerWarning]="(_settingsService.Settings | async).Server.Environment.isDocker" required="true"> diff --git a/src/frontend/app/ui/settings/settings.service.ts b/src/frontend/app/ui/settings/settings.service.ts index 89617b91..0f2531c5 100644 --- a/src/frontend/app/ui/settings/settings.service.ts +++ b/src/frontend/app/ui/settings/settings.service.ts @@ -12,6 +12,7 @@ export class SettingsService { constructor(private _networkService: NetworkService) { this.settings = new BehaviorSubject(new WebConfig()); + this.getSettings().catch(console.error); } public async getSettings(): Promise { @@ -28,6 +29,4 @@ export class SettingsService { } this.fetchingSettings = false; } - - }