1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-25 02:04:15 +02: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,
ServerDataBaseConfig,
ServerIndexingConfig,
ServerJobConfig,
ServerJobConfig, ServerMetaFileConfig,
ServerPhotoConfig,
ServerPreviewConfig,
ServerThumbnailConfig,
@ -21,7 +21,7 @@ import {
import {
ClientAlbumConfig,
ClientFacesConfig,
ClientMapConfig,
ClientMapConfig, ClientMediaConfig,
ClientMetaFileConfig,
ClientPhotoConfig,
ClientRandomPhotoConfig,
@ -166,13 +166,21 @@ export class SettingsMWs {
}
try {
const original = await Config.original();
await ConfigDiagnostics.testMetaFileConfig(req.body.settings as ClientMetaFileConfig, original);
const settings: {
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)
original.Client.MetaFile = (req.body.settings as ClientMetaFileConfig);
original.Client.MetaFile = settings.client;
original.Server.MetaFile = settings.server;
original.save();
await ConfigDiagnostics.runDiagnostics();
Logger.info(LOG_TAG, 'new config:');

View File

@ -1,9 +1,9 @@
import { Config } from '../../../common/config/private/Config';
import { Logger } from '../../Logger';
import { NotificationManager } from '../NotifocationManager';
import { SQLConnection } from '../database/sql/SQLConnection';
import {Config} from '../../../common/config/private/Config';
import {Logger} from '../../Logger';
import {NotificationManager} from '../NotifocationManager';
import {SQLConnection} from '../database/sql/SQLConnection';
import * as fs from 'fs';
import { FFmpegFactory } from '../FFmpegFactory';
import {FFmpegFactory} from '../FFmpegFactory';
import {
ClientAlbumConfig,
ClientFacesConfig,
@ -23,17 +23,18 @@ import {
IPrivateConfig,
ServerDataBaseConfig,
ServerJobConfig,
ServerMetaFileConfig,
ServerPhotoConfig,
ServerPreviewConfig,
ServerThumbnailConfig,
ServerVideoConfig,
} from '../../../common/config/private/PrivateConfig';
import { SearchQueryParser } from '../../../common/SearchQueryParser';
import {SearchQueryParser} from '../../../common/SearchQueryParser';
import {
SearchQueryTypes,
TextSearch,
} from '../../../common/entities/SearchQueryDTO';
import { Utils } from '../../../common/Utils';
import {Utils} from '../../../common/Utils';
const LOG_TAG = '[ConfigDiagnostics]';
@ -76,13 +77,13 @@ export class ConfigDiagnostics {
} catch (e) {
throw new Error(
'Cannot read or write sqlite storage file: ' +
SQLConnection.getSQLiteDB(databaseConfig)
SQLConnection.getSQLiteDB(databaseConfig)
);
}
}
}
static async testMetaFileConfig(
static async testClientMetaFileConfig(
metaFileConfig: ClientMetaFileConfig,
config: IPrivateConfig
): 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> {
return new Promise((resolve, reject) => {
try {
@ -101,7 +109,7 @@ export class ConfigDiagnostics {
return reject(
new Error(
'Error accessing ffmpeg, cant find executable: ' +
err.toString()
err.toString()
)
);
}
@ -110,7 +118,7 @@ export class ConfigDiagnostics {
return reject(
new Error(
'Error accessing ffmpeg-probe, cant find executable: ' +
err2.toString()
err2.toString()
)
);
}
@ -150,7 +158,7 @@ export class ConfigDiagnostics {
static testImageFolder(folder: string): Promise<void> {
return new Promise((resolve, reject) => {
if (!fs.existsSync(folder)) {
reject("Images folder not exists: '" + folder + "'");
reject('Images folder not exists: \'' + folder + '\'');
}
fs.access(folder, fs.constants.R_OK, (err) => {
if (err) {
@ -327,8 +335,8 @@ export class ConfigDiagnostics {
Logger.warn(
LOG_TAG,
'Thumbnail hardware acceleration is not possible.' +
" 'sharp' node module is not found." +
' Falling back temporally to JS based thumbnail generation'
' \'sharp\' node module is not found.' +
' Falling back temporally to JS based thumbnail generation'
);
process.exit(1);
}
@ -362,7 +370,7 @@ export class ConfigDiagnostics {
}
try {
await ConfigDiagnostics.testMetaFileConfig(
await ConfigDiagnostics.testClientMetaFileConfig(
Config.Client.MetaFile,
Config
);
@ -380,6 +388,25 @@ export class ConfigDiagnostics {
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 {
await ConfigDiagnostics.testAlbumsConfig(Config.Client.Album, Config);
} catch (ex) {
@ -419,7 +446,7 @@ export class ConfigDiagnostics {
const err: Error = ex;
NotificationManager.warning(
'Search is not supported with these settings. Disabling temporally. ' +
'Please adjust the config properly.',
'Please adjust the config properly.',
err.toString()
);
Logger.warn(
@ -455,7 +482,7 @@ export class ConfigDiagnostics {
const err: Error = ex;
NotificationManager.warning(
'Faces are not supported with these settings. Disabling temporally. ' +
'Please adjust the config properly.',
'Please adjust the config properly.',
err.toString()
);
Logger.warn(
@ -472,7 +499,7 @@ export class ConfigDiagnostics {
const err: Error = ex;
NotificationManager.warning(
'Some Tasks are not supported with these settings. Disabling temporally. ' +
'Please adjust the config properly.',
'Please adjust the config properly.',
err.toString()
);
Logger.warn(
@ -489,7 +516,7 @@ export class ConfigDiagnostics {
const err: Error = ex;
NotificationManager.warning(
'Sharing is not supported with these settings. Disabling temporally. ' +
'Please adjust the config properly.',
'Please adjust the config properly.',
err.toString()
);
Logger.warn(
@ -509,7 +536,7 @@ export class ConfigDiagnostics {
const err: Error = ex;
NotificationManager.warning(
'Random Media is not supported with these settings. Disabling temporally. ' +
'Please adjust the config properly.',
'Please adjust the config properly.',
err.toString()
);
Logger.warn(
@ -526,13 +553,13 @@ export class ConfigDiagnostics {
const err: Error = ex;
NotificationManager.warning(
'Maps is not supported with these settings. Using open street maps temporally. ' +
'Please adjust the config properly.',
'Please adjust the config properly.',
err.toString()
);
Logger.warn(
LOG_TAG,
'Maps is not supported with these settings. Using open street maps temporally ' +
'Please adjust the config properly.',
'Please adjust the config properly.',
err.toString()
);
Config.Client.Map.mapProvider = MapProviders.OpenStreetMap;

View File

@ -204,16 +204,16 @@ export class ClientMetaFileConfig {
description: 'Reads *.gpx files and renders them on the map.',
})
gpx: boolean = true;
@ConfigProperty({
description: 'Reads *.gpx files and renders them on the map.',
})
@ConfigProperty()
GPXCompressing: ClientGPXCompressingConfig = new ClientGPXCompressingConfig();
@ConfigProperty({
description:
'Reads *.md files in a directory and shows the next to the map.',
})
markdown: boolean = true;
@ConfigProperty({
description:
'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."
i18n-description i18n-name
[disabled]="!(settingsService.Settings | async).Client.Map.enabled"
[ngModel]="states.gpx">
[ngModel]="states.client.gpx">
</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
name="Markdown files"
description="Reads *.md files in a directory and shows the next to the map."
i18n-description i18n-name
[ngModel]="states.markdown">
[ngModel]="states.client.markdown">
</app-settings-entry>
<app-settings-entry
name="*.pg2conf files"
description="Reads *.pg2conf files (You can use it for custom sorting and save search (albums))."
i18n-description i18n-name
[ngModel]="states.pg2conf">
[ngModel]="states.client.pg2conf">
</app-settings-entry>

View File

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

View File

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