1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00

Adding gpx compression buttons to the settings

#504
This commit is contained in:
Patrik J. Braun 2022-06-24 23:15:48 +02:00
parent 3bff1a4383
commit 19e23133f2
6 changed files with 115 additions and 45 deletions

View File

@ -12,7 +12,7 @@ import {
DatabaseType, DatabaseType,
ServerDataBaseConfig, ServerDataBaseConfig,
ServerIndexingConfig, ServerIndexingConfig,
ServerJobConfig, ServerJobConfig, ServerMetaFileConfig,
ServerPhotoConfig, ServerPhotoConfig,
ServerPreviewConfig, ServerPreviewConfig,
ServerThumbnailConfig, ServerThumbnailConfig,
@ -21,7 +21,7 @@ import {
import { import {
ClientAlbumConfig, ClientAlbumConfig,
ClientFacesConfig, ClientFacesConfig,
ClientMapConfig, ClientMapConfig, ClientMediaConfig,
ClientMetaFileConfig, ClientMetaFileConfig,
ClientPhotoConfig, ClientPhotoConfig,
ClientRandomPhotoConfig, ClientRandomPhotoConfig,
@ -166,13 +166,21 @@ export class SettingsMWs {
} }
try { try {
const original = await Config.original(); const settings: {
await ConfigDiagnostics.testMetaFileConfig(req.body.settings as ClientMetaFileConfig, original); server: ServerMetaFileConfig,
client: ClientMetaFileConfig
} = req.body.settings;
Config.Client.MetaFile = (req.body.settings as ClientMetaFileConfig); const original = await Config.original();
await ConfigDiagnostics.testClientMetaFileConfig(settings.client, original);
await ConfigDiagnostics.testServerMetaFileConfig(settings.server, original);
Config.Client.MetaFile = settings.client;
Config.Server.MetaFile = settings.server;
// only updating explicitly set config (not saving config set by the diagnostics) // only updating explicitly set config (not saving config set by the diagnostics)
original.Client.MetaFile = (req.body.settings as ClientMetaFileConfig); original.Client.MetaFile = settings.client;
original.Server.MetaFile = settings.server;
original.save(); original.save();
await ConfigDiagnostics.runDiagnostics(); await ConfigDiagnostics.runDiagnostics();
Logger.info(LOG_TAG, 'new config:'); Logger.info(LOG_TAG, 'new config:');

View File

@ -23,6 +23,7 @@ import {
IPrivateConfig, IPrivateConfig,
ServerDataBaseConfig, ServerDataBaseConfig,
ServerJobConfig, ServerJobConfig,
ServerMetaFileConfig,
ServerPhotoConfig, ServerPhotoConfig,
ServerPreviewConfig, ServerPreviewConfig,
ServerThumbnailConfig, ServerThumbnailConfig,
@ -82,7 +83,7 @@ export class ConfigDiagnostics {
} }
} }
static async testMetaFileConfig( static async testClientMetaFileConfig(
metaFileConfig: ClientMetaFileConfig, metaFileConfig: ClientMetaFileConfig,
config: IPrivateConfig config: IPrivateConfig
): Promise<void> { ): Promise<void> {
@ -91,6 +92,13 @@ export class ConfigDiagnostics {
} }
} }
static async testServerMetaFileConfig(
metaFileConfig: ServerMetaFileConfig,
config: IPrivateConfig
): Promise<void> {
// nothing to check at the moment
}
static testClientVideoConfig(videoConfig: ClientVideoConfig): Promise<void> { static testClientVideoConfig(videoConfig: ClientVideoConfig): Promise<void> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {
@ -150,7 +158,7 @@ export class ConfigDiagnostics {
static testImageFolder(folder: string): Promise<void> { static testImageFolder(folder: string): Promise<void> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!fs.existsSync(folder)) { if (!fs.existsSync(folder)) {
reject("Images folder not exists: '" + folder + "'"); reject('Images folder not exists: \'' + folder + '\'');
} }
fs.access(folder, fs.constants.R_OK, (err) => { fs.access(folder, fs.constants.R_OK, (err) => {
if (err) { if (err) {
@ -327,7 +335,7 @@ export class ConfigDiagnostics {
Logger.warn( Logger.warn(
LOG_TAG, LOG_TAG,
'Thumbnail hardware acceleration is not possible.' + 'Thumbnail hardware acceleration is not possible.' +
" 'sharp' node module is not found." + ' \'sharp\' node module is not found.' +
' Falling back temporally to JS based thumbnail generation' ' Falling back temporally to JS based thumbnail generation'
); );
process.exit(1); process.exit(1);
@ -362,7 +370,7 @@ export class ConfigDiagnostics {
} }
try { try {
await ConfigDiagnostics.testMetaFileConfig( await ConfigDiagnostics.testClientMetaFileConfig(
Config.Client.MetaFile, Config.Client.MetaFile,
Config Config
); );
@ -380,6 +388,25 @@ export class ConfigDiagnostics {
Config.Client.MetaFile.gpx = false; Config.Client.MetaFile.gpx = false;
} }
try {
await ConfigDiagnostics.testServerMetaFileConfig(
Config.Server.MetaFile,
Config
);
} catch (ex) {
const err: Error = ex;
NotificationManager.warning(
'Meta file support error, switching off gpx..',
err.toString()
);
Logger.warn(
LOG_TAG,
'Meta file support error, switching off..',
err.toString()
);
Config.Client.MetaFile.gpx = false;
}
try { try {
await ConfigDiagnostics.testAlbumsConfig(Config.Client.Album, Config); await ConfigDiagnostics.testAlbumsConfig(Config.Client.Album, Config);
} catch (ex) { } catch (ex) {

View File

@ -204,16 +204,16 @@ export class ClientMetaFileConfig {
description: 'Reads *.gpx files and renders them on the map.', description: 'Reads *.gpx files and renders them on the map.',
}) })
gpx: boolean = true; gpx: boolean = true;
@ConfigProperty({
description: 'Reads *.gpx files and renders them on the map.',
})
@ConfigProperty() @ConfigProperty()
GPXCompressing: ClientGPXCompressingConfig = new ClientGPXCompressingConfig(); GPXCompressing: ClientGPXCompressingConfig = new ClientGPXCompressingConfig();
@ConfigProperty({ @ConfigProperty({
description: description:
'Reads *.md files in a directory and shows the next to the map.', 'Reads *.md files in a directory and shows the next to the map.',
}) })
markdown: boolean = true; markdown: boolean = true;
@ConfigProperty({ @ConfigProperty({
description: description:
'Reads *.pg2conf files (You can use it for custom sorting and save search (albums)).', 'Reads *.pg2conf files (You can use it for custom sorting and save search (albums)).',

View File

@ -12,21 +12,42 @@
description="Reads *.gpx files and renders them on the map." description="Reads *.gpx files and renders them on the map."
i18n-description i18n-name i18n-description i18n-name
[disabled]="!(settingsService.Settings | async).Client.Map.enabled" [disabled]="!(settingsService.Settings | async).Client.Map.enabled"
[ngModel]="states.gpx"> [ngModel]="states.client.gpx">
</app-settings-entry> </app-settings-entry>
<app-settings-entry
name="*.gpx compression"
description="Enables *.gpx file compression."
link="https://github.com/bpatrik/pigallery2/issues/504"
linkText="See 504."
i18n-description i18n-name
[disabled]="!(settingsService.Settings | async).Client.Map.enabled || !states.client.gpx.value"
[ngModel]="states.client.GPXCompressing.enabled">
</app-settings-entry>
<app-settings-entry
name="OnTheFly *.gpx compression"
description="Enables on the fly *.gpx compression."
i18n-description i18n-name
[simplifiedMode]="simplifiedMode"
[disabled]="!(settingsService.Settings | async).Client.Map.enabled || !states.client.GPXCompressing.enabled.value || !states.client.gpx.value"
[ngModel]="states.server.GPXCompressing.onTheFly">
</app-settings-entry>
<hr/>
<app-settings-entry <app-settings-entry
name="Markdown files" name="Markdown files"
description="Reads *.md files in a directory and shows the next to the map." description="Reads *.md files in a directory and shows the next to the map."
i18n-description i18n-name i18n-description i18n-name
[ngModel]="states.markdown"> [ngModel]="states.client.markdown">
</app-settings-entry> </app-settings-entry>
<app-settings-entry <app-settings-entry
name="*.pg2conf files" name="*.pg2conf files"
description="Reads *.pg2conf files (You can use it for custom sorting and save search (albums))." description="Reads *.pg2conf files (You can use it for custom sorting and save search (albums))."
i18n-description i18n-name i18n-description i18n-name
[ngModel]="states.pg2conf"> [ngModel]="states.client.pg2conf">
</app-settings-entry> </app-settings-entry>

View File

@ -4,7 +4,8 @@ import { SettingsComponentDirective } from '../_abstract/abstract.settings.compo
import { AuthenticationService } from '../../../model/network/authentication.service'; import { AuthenticationService } from '../../../model/network/authentication.service';
import { NavigationService } from '../../../model/navigation.service'; import { NavigationService } from '../../../model/navigation.service';
import { NotificationService } from '../../../model/notification.service'; import { NotificationService } from '../../../model/notification.service';
import { ClientMetaFileConfig } from '../../../../../common/config/public/ClientConfig'; import {ClientMetaFileConfig, ClientPhotoConfig} from '../../../../../common/config/public/ClientConfig';
import {ServerMetaFileConfig, ServerPhotoConfig} from '../../../../../common/config/private/PrivateConfig';
@Component({ @Component({
selector: 'app-settings-meta-file', selector: 'app-settings-meta-file',
@ -15,7 +16,10 @@ import { ClientMetaFileConfig } from '../../../../../common/config/public/Client
], ],
providers: [MetaFileSettingsService], providers: [MetaFileSettingsService],
}) })
export class MetaFileSettingsComponent extends SettingsComponentDirective<ClientMetaFileConfig> { export class MetaFileSettingsComponent extends SettingsComponentDirective<{
server: ServerMetaFileConfig;
client: ClientMetaFileConfig;
}> {
constructor( constructor(
authService: AuthenticationService, authService: AuthenticationService,
navigation: NavigationService, navigation: NavigationService,
@ -29,7 +33,10 @@ export class MetaFileSettingsComponent extends SettingsComponentDirective<Client
navigation, navigation,
settingsService, settingsService,
notification, notification,
(s) => s.Client.MetaFile (s) => ({
client: s.Client.MetaFile,
server: s.Server.MetaFile,
})
); );
} }
} }

View File

@ -3,9 +3,13 @@ import { NetworkService } from '../../../model/network/network.service';
import {SettingsService} from '../settings.service'; import {SettingsService} from '../settings.service';
import {AbstractSettingsService} from '../_abstract/abstract.settings.service'; import {AbstractSettingsService} from '../_abstract/abstract.settings.service';
import {ClientMetaFileConfig} from '../../../../../common/config/public/ClientConfig'; import {ClientMetaFileConfig} from '../../../../../common/config/public/ClientConfig';
import {ServerMetaFileConfig} from '../../../../../common/config/private/PrivateConfig';
@Injectable() @Injectable()
export class MetaFileSettingsService extends AbstractSettingsService<ClientMetaFileConfig> { export class MetaFileSettingsService extends AbstractSettingsService<{
server: ServerMetaFileConfig;
client: ClientMetaFileConfig;
}> {
constructor( constructor(
private networkService: NetworkService, private networkService: NetworkService,
settingsService: SettingsService settingsService: SettingsService
@ -21,7 +25,10 @@ export class MetaFileSettingsService extends AbstractSettingsService<ClientMetaF
return false; return false;
} }
public updateSettings(settings: ClientMetaFileConfig): Promise<void> { public updateSettings(settings: {
server: ServerMetaFileConfig;
client: ClientMetaFileConfig;
}): Promise<void> {
return this.networkService.putJson('/settings/metafile', {settings}); return this.networkService.putJson('/settings/metafile', {settings});
} }
} }