mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
adding meta file settings
This commit is contained in:
parent
a3026fbc51
commit
b0077708ae
@ -103,6 +103,29 @@ export class AdminMWs {
|
||||
}
|
||||
}
|
||||
|
||||
public static async updateMetaFileSettings(req: Request, res: Response, next: NextFunction) {
|
||||
if ((typeof req.body === 'undefined') || (typeof req.body.settings === 'undefined')) {
|
||||
return next(new ErrorDTO(ErrorCodes.INPUT_ERROR, 'settings is needed'));
|
||||
}
|
||||
|
||||
try {
|
||||
const original = Config.original();
|
||||
await ConfigDiagnostics.testMetaFileConfig(<ClientConfig.MetaFileConfig>req.body.settings, original);
|
||||
|
||||
Config.Client.MetaFile = <ClientConfig.MetaFileConfig>req.body.settings;
|
||||
// only updating explicitly set config (not saving config set by the diagnostics)
|
||||
|
||||
original.Client.MetaFile = <ClientConfig.MetaFileConfig>req.body.settings;
|
||||
original.save();
|
||||
await ConfigDiagnostics.runDiagnostics();
|
||||
Logger.info(LOG_TAG, 'new config:');
|
||||
Logger.info(LOG_TAG, JSON.stringify(Config, null, '\t'));
|
||||
return next();
|
||||
} catch (err) {
|
||||
return next(new ErrorDTO(ErrorCodes.SETTINGS_ERROR, 'Settings error: ' + err.toString(), err));
|
||||
}
|
||||
}
|
||||
|
||||
public static async updateShareSettings(req: Request, res: Response, next: NextFunction) {
|
||||
if ((typeof req.body === 'undefined') || (typeof req.body.settings === 'undefined')) {
|
||||
return next(new ErrorDTO(ErrorCodes.INPUT_ERROR, 'settings is needed'));
|
||||
|
@ -14,6 +14,7 @@ import * as fs from 'fs';
|
||||
import {ClientConfig} from '../../../common/config/public/ConfigClass';
|
||||
import VideoConfig = ClientConfig.VideoConfig;
|
||||
import {FFmpegFactory} from '../FFmpegFactory';
|
||||
import MetaFileConfig = ClientConfig.MetaFileConfig;
|
||||
|
||||
const LOG_TAG = '[ConfigDiagnostics]';
|
||||
|
||||
@ -26,6 +27,14 @@ export class ConfigDiagnostics {
|
||||
}
|
||||
|
||||
|
||||
static async testMetaFileConfig(metaFileConfig: MetaFileConfig, config: IPrivateConfig) {
|
||||
if (metaFileConfig.enabled === true &&
|
||||
config.Client.Map.enabled === false) {
|
||||
throw new Error('*.gpx meta files are not supported without MAP');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static testVideoConfig(videoConfig: VideoConfig) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
@ -200,6 +209,15 @@ export class ConfigDiagnostics {
|
||||
Config.Client.Video.enabled = false;
|
||||
}
|
||||
|
||||
try {
|
||||
await ConfigDiagnostics.testMetaFileConfig(Config.Client.MetaFile, Config);
|
||||
} catch (ex) {
|
||||
const err: Error = ex;
|
||||
NotificationManager.warning('Meta file support error, switching off..', err.toString());
|
||||
Logger.warn(LOG_TAG, 'Meta file support error, switching off..', err.toString());
|
||||
Config.Client.MetaFile.enabled = false;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
await ConfigDiagnostics.testImageFolder(Config.Server.imagesFolder);
|
||||
|
@ -182,7 +182,7 @@ export class DiskMangerWorker {
|
||||
return new Promise<PhotoMetadata>((resolve, reject) => {
|
||||
const fd = fs.openSync(fullPath, 'r');
|
||||
|
||||
const data = new Buffer(65535);
|
||||
const data = Buffer.allocUnsafe(65535);
|
||||
fs.read(fd, data, 0, 65535, 0, (err) => {
|
||||
// fs.readFile(fullPath, (err, data) => {
|
||||
if (err) {
|
||||
|
@ -66,6 +66,12 @@ export class AdminRouter {
|
||||
AdminMWs.updateVideoSettings,
|
||||
RenderingMWs.renderOK
|
||||
);
|
||||
app.put('/api/settings/metafile',
|
||||
AuthenticationMWs.authenticate,
|
||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||
AdminMWs.updateMetaFileSettings,
|
||||
RenderingMWs.renderOK
|
||||
);
|
||||
|
||||
app.put('/api/settings/authentication',
|
||||
AuthenticationMWs.authenticate,
|
||||
|
@ -50,10 +50,11 @@
|
||||
<app-settings-share #share [hidden]="!share.hasAvailableSettings"
|
||||
[simplifiedMode]="simplifiedMode"></app-settings-share>
|
||||
<app-settings-map #map [hidden]="!map.hasAvailableSettings" [simplifiedMode]="simplifiedMode"></app-settings-map>
|
||||
<app-settings-random-photo #random [hidden]="!random.hasAvailableSettings"
|
||||
[simplifiedMode]="simplifiedMode"></app-settings-random-photo>
|
||||
<app-settings-meta-file #metaFile [hidden]="!metaFile.hasAvailableSettings" [simplifiedMode]="simplifiedMode"></app-settings-meta-file>
|
||||
<app-settings-other #other [hidden]="!other.hasAvailableSettings"
|
||||
[simplifiedMode]="simplifiedMode"></app-settings-other>
|
||||
<app-settings-random-photo #random [hidden]="!random.hasAvailableSettings"
|
||||
[simplifiedMode]="simplifiedMode"></app-settings-random-photo>
|
||||
<app-settings-indexing #indexing [hidden]="!indexing.hasAvailableSettings"
|
||||
[simplifiedMode]="simplifiedMode"></app-settings-indexing>
|
||||
</div>
|
||||
|
@ -76,6 +76,7 @@ import {FixOrientationPipe} from './gallery/FixOrientationPipe';
|
||||
import {VideoSettingsComponent} from './settings/video/video.settings.component';
|
||||
import {DurationPipe} from './pipes/DurationPipe';
|
||||
import {MapService} from './gallery/map/map.service';
|
||||
import {MetaFileSettingsComponent} from './settings/metafiles/metafile.settings.component';
|
||||
|
||||
@Injectable()
|
||||
export class GoogleMapsConfig {
|
||||
@ -163,6 +164,7 @@ export function translationsFactory(locale: string) {
|
||||
MapSettingsComponent,
|
||||
ThumbnailSettingsComponent,
|
||||
VideoSettingsComponent,
|
||||
MetaFileSettingsComponent,
|
||||
SearchSettingsComponent,
|
||||
ShareSettingsComponent,
|
||||
RandomPhotoSettingsComponent,
|
||||
|
@ -0,0 +1,36 @@
|
||||
<form #settingsForm="ngForm" class="form-horizontal">
|
||||
<div class="card mb-4">
|
||||
<h5 class="card-header">
|
||||
<ng-container i18n>Meta file settings</ng-container>
|
||||
<div class="switch-wrapper">
|
||||
<bSwitch
|
||||
class="switch"
|
||||
name="enabled"
|
||||
[switch-on-color]="'success'"
|
||||
[switch-inverse]="'inverse'"
|
||||
[switch-off-text]="text.Disabled"
|
||||
[switch-on-text]="text.Enabled"
|
||||
[switch-disabled]="inProgress"
|
||||
[switch-handle-width]="'100'"
|
||||
[switch-label-width]="'20'"
|
||||
[(ngModel)]="settings.enabled">
|
||||
</bSwitch>
|
||||
</div>
|
||||
</h5>
|
||||
<div class="card-body">
|
||||
<div [hidden]="!error" class="alert alert-danger" role="alert"><strong>Error: </strong>{{error}}</div>
|
||||
|
||||
<ng-container i18n>Reads and show *.gpx files on the map</ng-container>
|
||||
|
||||
|
||||
<button class="btn btn-success float-right"
|
||||
[disabled]="!settingsForm.form.valid || !changed || inProgress"
|
||||
(click)="save()" i18n>Save
|
||||
</button>
|
||||
<button class="btn btn-default float-right"
|
||||
(click)="reset()" i18n>Reset
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
@ -0,0 +1,32 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {MetaFileSettingsService} from './metafile.settings.service';
|
||||
import {SettingsComponent} from '../_abstract/abstract.settings.component';
|
||||
import {AuthenticationService} from '../../model/network/authentication.service';
|
||||
import {NavigationService} from '../../model/navigation.service';
|
||||
import {NotificationService} from '../../model/notification.service';
|
||||
import {ClientConfig} from '../../../../common/config/public/ConfigClass';
|
||||
import {I18n} from '@ngx-translate/i18n-polyfill';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-settings-meta-file',
|
||||
templateUrl: './metafile.settings.component.html',
|
||||
styleUrls: ['./metafile.settings.component.css',
|
||||
'./../_abstract/abstract.settings.component.css'],
|
||||
providers: [MetaFileSettingsService],
|
||||
})
|
||||
export class MetaFileSettingsComponent extends SettingsComponent<ClientConfig.MetaFileConfig> {
|
||||
|
||||
constructor(_authService: AuthenticationService,
|
||||
_navigation: NavigationService,
|
||||
_settingsService: MetaFileSettingsService,
|
||||
notification: NotificationService,
|
||||
i18n: I18n) {
|
||||
super(i18n('Meta file'), _authService, _navigation, <any>_settingsService, notification, i18n, s => s.Client.MetaFile);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
24
frontend/app/settings/metafiles/metafile.settings.service.ts
Normal file
24
frontend/app/settings/metafiles/metafile.settings.service.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {NetworkService} from '../../model/network/network.service';
|
||||
import {ClientConfig} from '../../../../common/config/public/ConfigClass';
|
||||
import {SettingsService} from '../settings.service';
|
||||
import {AbstractSettingsService} from '../_abstract/abstract.settings.service';
|
||||
|
||||
@Injectable()
|
||||
export class MetaFileSettingsService extends AbstractSettingsService<ClientConfig.MetaFileConfig> {
|
||||
constructor(private _networkService: NetworkService,
|
||||
_settingsService: SettingsService) {
|
||||
super(_settingsService);
|
||||
|
||||
}
|
||||
|
||||
public isSupported(): boolean {
|
||||
return this._settingsService.settings.value.Client.Map.enabled === true;
|
||||
}
|
||||
|
||||
|
||||
public updateSettings(settings: ClientConfig.MetaFileConfig): Promise<void> {
|
||||
return this._networkService.putJson('/settings/metafile', {settings: settings});
|
||||
}
|
||||
|
||||
}
|
@ -182,7 +182,7 @@
|
||||
</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app/gallery/gallery.component.html</context>
|
||||
<context context-type="linenumber">44</context>
|
||||
<context context-type="linenumber">46</context>
|
||||
</context-group>
|
||||
<target>Too many results to show. Refine your search.</target>
|
||||
</trans-unit>
|
||||
@ -190,7 +190,7 @@
|
||||
<source>Searching for:</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app/gallery/gallery.component.html</context>
|
||||
<context context-type="linenumber">49</context>
|
||||
<context context-type="linenumber">51</context>
|
||||
</context-group>
|
||||
<target>Searching for:</target>
|
||||
</trans-unit>
|
||||
@ -627,6 +627,10 @@
|
||||
<context context-type="sourcefile">app/settings/video/video.settings.component.html</context>
|
||||
<context context-type="linenumber">28</context>
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app/settings/metafiles/metafile.settings.component.html</context>
|
||||
<context context-type="linenumber">28</context>
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app/settings/search/search.settings.component.html</context>
|
||||
<context context-type="linenumber">73</context>
|
||||
@ -664,6 +668,10 @@
|
||||
<context context-type="sourcefile">app/settings/video/video.settings.component.html</context>
|
||||
<context context-type="linenumber">31</context>
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app/settings/metafiles/metafile.settings.component.html</context>
|
||||
<context context-type="linenumber">31</context>
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app/settings/search/search.settings.component.html</context>
|
||||
<context context-type="linenumber">76</context>
|
||||
@ -836,6 +844,22 @@
|
||||
</context-group>
|
||||
<target>Video support uses ffmpeg. ffmpeg and ffprobe binaries need to be available in the PATH or the @ffmpeg-installer/ffmpeg and @ffprobe-installer/ffprobe optional node packages need to be installed.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="c45b54bd977f2e5b0d635231051f1143e0abf1c1" datatype="html">
|
||||
<source>Meta file settings</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app/settings/metafiles/metafile.settings.component.html</context>
|
||||
<context context-type="linenumber">4</context>
|
||||
</context-group>
|
||||
<target>Meta file settings</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="219e36c6747ef991081a68fc8ab2678677583e11" datatype="html">
|
||||
<source>Reads and show *.gpx files on the map</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app/settings/metafiles/metafile.settings.component.html</context>
|
||||
<context context-type="linenumber">23</context>
|
||||
</context-group>
|
||||
<target>Reads and show *.gpx files on the map</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2e75ae3885931555902da6b288ed616843d5dc3c" datatype="html">
|
||||
<source>Search settings</source>
|
||||
<context-group purpose="location">
|
||||
@ -1671,6 +1695,14 @@
|
||||
</context-group>
|
||||
<target>Map</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="6bf63e55f9a54c6d0e7a5ee7ed3e3f3ab412fa61" datatype="html">
|
||||
<source>Meta files</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">frontend/app/settings/metafiles/metafile.settings.component.ts</context>
|
||||
<context context-type="linenumber">1</context>
|
||||
</context-group>
|
||||
<target>Meta files</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="c2a9de3714f5767b174d0424bc8abe2dc37acc41" datatype="html">
|
||||
<source>Other</source>
|
||||
<context-group purpose="location">
|
||||
|
@ -182,7 +182,7 @@
|
||||
</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app/gallery/gallery.component.html</context>
|
||||
<context context-type="linenumber">44</context>
|
||||
<context context-type="linenumber">46</context>
|
||||
</context-group>
|
||||
<target>Túl sok eredmény jelenik meg. Pontosítsa a keresést.</target>
|
||||
</trans-unit>
|
||||
@ -190,7 +190,7 @@
|
||||
<source>Searching for:</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app/gallery/gallery.component.html</context>
|
||||
<context context-type="linenumber">49</context>
|
||||
<context context-type="linenumber">51</context>
|
||||
</context-group>
|
||||
<target>Keresés:</target>
|
||||
</trans-unit>
|
||||
@ -627,6 +627,10 @@
|
||||
<context context-type="sourcefile">app/settings/video/video.settings.component.html</context>
|
||||
<context context-type="linenumber">28</context>
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app/settings/metafiles/metafile.settings.component.html</context>
|
||||
<context context-type="linenumber">28</context>
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app/settings/search/search.settings.component.html</context>
|
||||
<context context-type="linenumber">73</context>
|
||||
@ -664,6 +668,10 @@
|
||||
<context context-type="sourcefile">app/settings/video/video.settings.component.html</context>
|
||||
<context context-type="linenumber">31</context>
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app/settings/metafiles/metafile.settings.component.html</context>
|
||||
<context context-type="linenumber">31</context>
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app/settings/search/search.settings.component.html</context>
|
||||
<context context-type="linenumber">76</context>
|
||||
@ -836,6 +844,22 @@
|
||||
</context-group>
|
||||
<target>A videó lejátszához az ffmpeg szükséges. Az ffmpeg és az ffprobe binárisoknak rendelkezésre kell állniuk a PATH-ban vagy az @ffmpeg-installer/ffmpeg és @ffprobe-installer/ffprobe opcionális node csomagokat kell telepíteni.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="c45b54bd977f2e5b0d635231051f1143e0abf1c1" datatype="html">
|
||||
<source>Meta file settings</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app/settings/metafiles/metafile.settings.component.html</context>
|
||||
<context context-type="linenumber">4</context>
|
||||
</context-group>
|
||||
<target>Meta fájl beállítások</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="219e36c6747ef991081a68fc8ab2678677583e11" datatype="html">
|
||||
<source>Reads and show *.gpx files on the map</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app/settings/metafiles/metafile.settings.component.html</context>
|
||||
<context context-type="linenumber">23</context>
|
||||
</context-group>
|
||||
<target>Megjeleníti a *.gpx fájlokat a térképen</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2e75ae3885931555902da6b288ed616843d5dc3c" datatype="html">
|
||||
<source>Search settings</source>
|
||||
<context-group purpose="location">
|
||||
@ -1671,6 +1695,14 @@
|
||||
</context-group>
|
||||
<target>Térkép</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="6bf63e55f9a54c6d0e7a5ee7ed3e3f3ab412fa61" datatype="html">
|
||||
<source>Meta files</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">frontend/app/settings/metafiles/metafile.settings.component.ts</context>
|
||||
<context context-type="linenumber">1</context>
|
||||
</context-group>
|
||||
<target>Metafájlok</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="c2a9de3714f5767b174d0424bc8abe2dc37acc41" datatype="html">
|
||||
<source>Other</source>
|
||||
<context-group purpose="location">
|
||||
|
@ -113,6 +113,26 @@ describe('GalleryManager', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should skip meta files', async () => {
|
||||
const gm = new GalleryManagerTest();
|
||||
const parent = TestHelper.getRandomizedDirectoryEntry();
|
||||
const p1 = TestHelper.getRandomizedPhotoEntry(parent, 'Photo1');
|
||||
const p2 = TestHelper.getRandomizedPhotoEntry(parent, 'Photo2');
|
||||
const gpx = TestHelper.getRandomizedGPXEntry(parent, 'GPX1');
|
||||
DirectoryDTO.removeReferences(parent);
|
||||
Config.Client.MetaFile.enabled = true;
|
||||
await gm.saveToDB(Utils.clone(parent));
|
||||
|
||||
Config.Client.MetaFile.enabled = false;
|
||||
const conn = await SQLConnection.getConnection();
|
||||
const selected = await gm.selectParentDir(conn, parent.name, parent.path);
|
||||
await gm.fillParentDir(conn, selected);
|
||||
|
||||
delete parent.metaFile;
|
||||
DirectoryDTO.removeReferences(selected);
|
||||
removeIds(selected);
|
||||
expect(Utils.clone(selected)).to.deep.equal(Utils.clone(parent));
|
||||
});
|
||||
|
||||
it('should update sub directory', async () => {
|
||||
const gm = new GalleryManagerTest();
|
||||
|
Loading…
x
Reference in New Issue
Block a user