mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-01-12 04:23:09 +02:00
implementing video settings saving
refactoring settings
This commit is contained in:
parent
41a51e79a9
commit
1be392e7da
@ -1,11 +1,11 @@
|
|||||||
import * as winston from 'winston';
|
import * as winston from 'winston';
|
||||||
import {Config} from '../common/config/private/Config';
|
import {Config} from '../common/config/private/Config';
|
||||||
import {LogLevel} from '../common/config/private/IPrivateConfig';
|
import {ServerConfig} from '../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
export const winstonSettings = {
|
export const winstonSettings = {
|
||||||
transports: [
|
transports: [
|
||||||
new winston.transports.Console(<any>{
|
new winston.transports.Console(<any>{
|
||||||
level: LogLevel[Config.Server.Log.level],
|
level: ServerConfig.LogLevel[Config.Server.Log.level],
|
||||||
handleExceptions: true,
|
handleExceptions: true,
|
||||||
json: false,
|
json: false,
|
||||||
colorize: true,
|
colorize: true,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as os from 'os';
|
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as util from 'util';
|
import * as util from 'util';
|
||||||
import {ITaskExecuter, TaskExecuter} from '../model/threading/TaskExecuter';
|
import {ITaskExecuter, TaskExecuter} from '../model/threading/TaskExecuter';
|
||||||
@ -12,7 +11,7 @@ const existPr = util.promisify(fs.exists);
|
|||||||
|
|
||||||
export class VideoConverterMWs {
|
export class VideoConverterMWs {
|
||||||
private static taskQue: ITaskExecuter<VideoConverterInput, void> =
|
private static taskQue: ITaskExecuter<VideoConverterInput, void> =
|
||||||
new TaskExecuter(Math.max(1, os.cpus().length - 1), (input => VideoConverterWorker.convert(input)));
|
new TaskExecuter(1, (input => VideoConverterWorker.convert(input)));
|
||||||
|
|
||||||
|
|
||||||
public static generateConvertedFileName(videoPath: string): string {
|
public static generateConvertedFileName(videoPath: string): string {
|
||||||
|
105
backend/middlewares/admin/AdminMWs.ts
Normal file
105
backend/middlewares/admin/AdminMWs.ts
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
import {NextFunction, Request, Response} from 'express';
|
||||||
|
import {ErrorCodes, ErrorDTO} from '../../../common/entities/Error';
|
||||||
|
import {ObjectManagers} from '../../model/ObjectManagers';
|
||||||
|
import {Config} from '../../../common/config/private/Config';
|
||||||
|
import {ISQLGalleryManager} from '../../model/sql/IGalleryManager';
|
||||||
|
import {ServerConfig} from '../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
|
const LOG_TAG = '[AdminMWs]';
|
||||||
|
|
||||||
|
export class AdminMWs {
|
||||||
|
|
||||||
|
public static async loadStatistic(req: Request, res: Response, next: NextFunction) {
|
||||||
|
if (Config.Server.Database.type === ServerConfig.DatabaseType.memory) {
|
||||||
|
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, 'Statistic is only available for indexed content'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const galleryManager = <ISQLGalleryManager>ObjectManagers.getInstance().GalleryManager;
|
||||||
|
try {
|
||||||
|
req.resultPipe = {
|
||||||
|
directories: await galleryManager.countDirectories(),
|
||||||
|
photos: await galleryManager.countPhotos(),
|
||||||
|
videos: await galleryManager.countVideos(),
|
||||||
|
diskUsage: await galleryManager.countMediaSize(),
|
||||||
|
};
|
||||||
|
return next();
|
||||||
|
} catch (err) {
|
||||||
|
if (err instanceof Error) {
|
||||||
|
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, 'Error while getting statistic: ' + err.toString(), err));
|
||||||
|
}
|
||||||
|
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, 'Error while getting statistic', err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getDuplicates(req: Request, res: Response, next: NextFunction) {
|
||||||
|
if (Config.Server.Database.type === ServerConfig.DatabaseType.memory) {
|
||||||
|
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, 'Statistic is only available for indexed content'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const galleryManager = <ISQLGalleryManager>ObjectManagers.getInstance().GalleryManager;
|
||||||
|
try {
|
||||||
|
req.resultPipe = await galleryManager.getPossibleDuplicates();
|
||||||
|
return next();
|
||||||
|
} catch (err) {
|
||||||
|
if (err instanceof Error) {
|
||||||
|
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, 'Error while getting duplicates: ' + err.toString(), err));
|
||||||
|
}
|
||||||
|
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, 'Error while getting duplicates', err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static startTask(req: Request, res: Response, next: NextFunction) {
|
||||||
|
try {
|
||||||
|
const id = req.params.id;
|
||||||
|
const taskConfig: any = req.body.config;
|
||||||
|
ObjectManagers.getInstance().TaskManager.run(id, taskConfig);
|
||||||
|
req.resultPipe = 'ok';
|
||||||
|
return next();
|
||||||
|
} catch (err) {
|
||||||
|
if (err instanceof Error) {
|
||||||
|
return next(new ErrorDTO(ErrorCodes.TASK_ERROR, 'Task error: ' + err.toString(), err));
|
||||||
|
}
|
||||||
|
return next(new ErrorDTO(ErrorCodes.TASK_ERROR, 'Task error: ' + JSON.stringify(err, null, ' '), err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static stopTask(req: Request, res: Response, next: NextFunction) {
|
||||||
|
try {
|
||||||
|
const id = req.params.id;
|
||||||
|
ObjectManagers.getInstance().TaskManager.stop(id);
|
||||||
|
req.resultPipe = 'ok';
|
||||||
|
return next();
|
||||||
|
} catch (err) {
|
||||||
|
if (err instanceof Error) {
|
||||||
|
return next(new ErrorDTO(ErrorCodes.TASK_ERROR, 'Task error: ' + err.toString(), err));
|
||||||
|
}
|
||||||
|
return next(new ErrorDTO(ErrorCodes.TASK_ERROR, 'Task error: ' + JSON.stringify(err, null, ' '), err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getAvailableTasks(req: Request, res: Response, next: NextFunction) {
|
||||||
|
try {
|
||||||
|
req.resultPipe = ObjectManagers.getInstance().TaskManager.getAvailableTasks();
|
||||||
|
return next();
|
||||||
|
} catch (err) {
|
||||||
|
if (err instanceof Error) {
|
||||||
|
return next(new ErrorDTO(ErrorCodes.TASK_ERROR, 'Task error: ' + err.toString(), err));
|
||||||
|
}
|
||||||
|
return next(new ErrorDTO(ErrorCodes.TASK_ERROR, 'Task error: ' + JSON.stringify(err, null, ' '), err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getTaskProgresses(req: Request, res: Response, next: NextFunction) {
|
||||||
|
try {
|
||||||
|
req.resultPipe = ObjectManagers.getInstance().TaskManager.getProgresses();
|
||||||
|
return next();
|
||||||
|
} catch (err) {
|
||||||
|
if (err instanceof Error) {
|
||||||
|
return next(new ErrorDTO(ErrorCodes.TASK_ERROR, 'Task error: ' + err.toString(), err));
|
||||||
|
}
|
||||||
|
return next(new ErrorDTO(ErrorCodes.TASK_ERROR, 'Task error: ' + JSON.stringify(err, null, ' '), err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,64 +1,21 @@
|
|||||||
|
/**/
|
||||||
import {NextFunction, Request, Response} from 'express';
|
import {NextFunction, Request, Response} from 'express';
|
||||||
import {ErrorCodes, ErrorDTO} from '../../common/entities/Error';
|
import {ErrorCodes, ErrorDTO} from '../../../common/entities/Error';
|
||||||
import {ObjectManagers} from '../model/ObjectManagers';
|
import {ObjectManagers} from '../../model/ObjectManagers';
|
||||||
import {Logger} from '../Logger';
|
import {Logger} from '../../Logger';
|
||||||
import {SQLConnection} from '../model/sql/SQLConnection';
|
import {SQLConnection} from '../../model/sql/SQLConnection';
|
||||||
import {DataBaseConfig, DatabaseType, IndexingConfig, TaskConfig, ThumbnailConfig} from '../../common/config/private/IPrivateConfig';
|
import {Config} from '../../../common/config/private/Config';
|
||||||
import {Config} from '../../common/config/private/Config';
|
import {ConfigDiagnostics} from '../../model/diagnostics/ConfigDiagnostics';
|
||||||
import {ConfigDiagnostics} from '../model/diagnostics/ConfigDiagnostics';
|
import {ClientConfig} from '../../../common/config/public/ConfigClass';
|
||||||
import {ClientConfig} from '../../common/config/public/ConfigClass';
|
import {BasicConfigDTO} from '../../../common/entities/settings/BasicConfigDTO';
|
||||||
import {BasicConfigDTO} from '../../common/entities/settings/BasicConfigDTO';
|
import {OtherConfigDTO} from '../../../common/entities/settings/OtherConfigDTO';
|
||||||
import {OtherConfigDTO} from '../../common/entities/settings/OtherConfigDTO';
|
import {ProjectPath} from '../../ProjectPath';
|
||||||
import {ProjectPath} from '../ProjectPath';
|
import {PrivateConfigClass} from '../../../common/config/private/PrivateConfigClass';
|
||||||
import {PrivateConfigClass} from '../../common/config/private/PrivateConfigClass';
|
import {ServerConfig} from '../../../common/config/private/IPrivateConfig';
|
||||||
import {ISQLGalleryManager} from '../model/sql/IGalleryManager';
|
|
||||||
|
|
||||||
const LOG_TAG = '[AdminMWs]';
|
const LOG_TAG = '[SettingsMWs]';
|
||||||
|
|
||||||
export class AdminMWs {
|
export class SettingsMWs {
|
||||||
|
|
||||||
|
|
||||||
public static async loadStatistic(req: Request, res: Response, next: NextFunction) {
|
|
||||||
if (Config.Server.Database.type === DatabaseType.memory) {
|
|
||||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, 'Statistic is only available for indexed content'));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const galleryManager = <ISQLGalleryManager>ObjectManagers.getInstance().GalleryManager;
|
|
||||||
try {
|
|
||||||
req.resultPipe = {
|
|
||||||
directories: await galleryManager.countDirectories(),
|
|
||||||
photos: await galleryManager.countPhotos(),
|
|
||||||
videos: await galleryManager.countVideos(),
|
|
||||||
diskUsage: await galleryManager.countMediaSize(),
|
|
||||||
};
|
|
||||||
return next();
|
|
||||||
} catch (err) {
|
|
||||||
if (err instanceof Error) {
|
|
||||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, 'Error while getting statistic: ' + err.toString(), err));
|
|
||||||
}
|
|
||||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, 'Error while getting statistic', err));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static async getDuplicates(req: Request, res: Response, next: NextFunction) {
|
|
||||||
if (Config.Server.Database.type === DatabaseType.memory) {
|
|
||||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, 'Statistic is only available for indexed content'));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const galleryManager = <ISQLGalleryManager>ObjectManagers.getInstance().GalleryManager;
|
|
||||||
try {
|
|
||||||
req.resultPipe = await galleryManager.getPossibleDuplicates();
|
|
||||||
return next();
|
|
||||||
} catch (err) {
|
|
||||||
if (err instanceof Error) {
|
|
||||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, 'Error while getting duplicates: ' + err.toString(), err));
|
|
||||||
}
|
|
||||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, 'Error while getting duplicates', err));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async updateDatabaseSettings(req: Request, res: Response, next: NextFunction) {
|
public static async updateDatabaseSettings(req: Request, res: Response, next: NextFunction) {
|
||||||
|
|
||||||
@ -66,17 +23,17 @@ export class AdminMWs {
|
|||||||
return next(new ErrorDTO(ErrorCodes.INPUT_ERROR, 'settings is needed'));
|
return next(new ErrorDTO(ErrorCodes.INPUT_ERROR, 'settings is needed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
const databaseSettings = <DataBaseConfig>req.body.settings;
|
const databaseSettings = <ServerConfig.DataBaseConfig>req.body.settings;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (databaseSettings.type !== DatabaseType.memory) {
|
if (databaseSettings.type !== ServerConfig.DatabaseType.memory) {
|
||||||
await SQLConnection.tryConnection(databaseSettings);
|
await SQLConnection.tryConnection(databaseSettings);
|
||||||
}
|
}
|
||||||
Config.Server.Database = databaseSettings;
|
Config.Server.Database = databaseSettings;
|
||||||
// only updating explicitly set config (not saving config set by the diagnostics)
|
// only updating explicitly set config (not saving config set by the diagnostics)
|
||||||
const original = Config.original();
|
const original = Config.original();
|
||||||
original.Server.Database = databaseSettings;
|
original.Server.Database = databaseSettings;
|
||||||
if (databaseSettings.type === DatabaseType.memory) {
|
if (databaseSettings.type === ServerConfig.DatabaseType.memory) {
|
||||||
original.Client.Sharing.enabled = false;
|
original.Client.Sharing.enabled = false;
|
||||||
original.Client.Search.enabled = false;
|
original.Client.Search.enabled = false;
|
||||||
}
|
}
|
||||||
@ -86,7 +43,7 @@ export class AdminMWs {
|
|||||||
Logger.info(LOG_TAG, JSON.stringify(Config, null, '\t'));
|
Logger.info(LOG_TAG, JSON.stringify(Config, null, '\t'));
|
||||||
|
|
||||||
await ObjectManagers.reset();
|
await ObjectManagers.reset();
|
||||||
if (Config.Server.Database.type !== DatabaseType.memory) {
|
if (Config.Server.Database.type !== ServerConfig.DatabaseType.memory) {
|
||||||
await ObjectManagers.InitSQLManagers();
|
await ObjectManagers.InitSQLManagers();
|
||||||
} else {
|
} else {
|
||||||
await ObjectManagers.InitMemoryManagers();
|
await ObjectManagers.InitMemoryManagers();
|
||||||
@ -132,12 +89,20 @@ export class AdminMWs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ConfigDiagnostics.testVideoConfig(<ClientConfig.VideoConfig>req.body.settings);
|
const settings: {
|
||||||
|
server: ServerConfig.VideoConfig,
|
||||||
|
client: ClientConfig.VideoConfig
|
||||||
|
} = req.body.settings;
|
||||||
|
|
||||||
|
|
||||||
Config.Client.Video = <ClientConfig.VideoConfig>req.body.settings;
|
|
||||||
// only updating explicitly set config (not saving config set by the diagnostics)
|
|
||||||
const original = Config.original();
|
const original = Config.original();
|
||||||
original.Client.Video = <ClientConfig.VideoConfig>req.body.settings;
|
await ConfigDiagnostics.testClientVideoConfig(settings.client);
|
||||||
|
await ConfigDiagnostics.testServerVideoConfig(settings.server, original);
|
||||||
|
Config.Server.Video = settings.server;
|
||||||
|
Config.Client.Video = settings.client;
|
||||||
|
// only updating explicitly set config (not saving config set by the diagnostics)
|
||||||
|
original.Server.Video = settings.server;
|
||||||
|
original.Client.Video = settings.client;
|
||||||
original.save();
|
original.save();
|
||||||
await ConfigDiagnostics.runDiagnostics();
|
await ConfigDiagnostics.runDiagnostics();
|
||||||
Logger.info(LOG_TAG, 'new config:');
|
Logger.info(LOG_TAG, 'new config:');
|
||||||
@ -202,7 +167,6 @@ export class AdminMWs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static async updateRandomPhotoSettings(req: Request, res: Response, next: NextFunction) {
|
public static async updateRandomPhotoSettings(req: Request, res: Response, next: NextFunction) {
|
||||||
if ((typeof req.body === 'undefined') || (typeof req.body.settings === 'undefined')) {
|
if ((typeof req.body === 'undefined') || (typeof req.body.settings === 'undefined')) {
|
||||||
return next(new ErrorDTO(ErrorCodes.INPUT_ERROR, 'settings is needed'));
|
return next(new ErrorDTO(ErrorCodes.INPUT_ERROR, 'settings is needed'));
|
||||||
@ -278,7 +242,6 @@ export class AdminMWs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static async updateAuthenticationSettings(req: Request, res: Response, next: NextFunction) {
|
public static async updateAuthenticationSettings(req: Request, res: Response, next: NextFunction) {
|
||||||
if ((typeof req.body === 'undefined') || (typeof req.body.settings === 'undefined')) {
|
if ((typeof req.body === 'undefined') || (typeof req.body.settings === 'undefined')) {
|
||||||
return next(new ErrorDTO(ErrorCodes.INPUT_ERROR, 'settings is needed'));
|
return next(new ErrorDTO(ErrorCodes.INPUT_ERROR, 'settings is needed'));
|
||||||
@ -312,7 +275,7 @@ export class AdminMWs {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const settings: {
|
const settings: {
|
||||||
server: ThumbnailConfig,
|
server: ServerConfig.ThumbnailConfig,
|
||||||
client: ClientConfig.ThumbnailConfig
|
client: ClientConfig.ThumbnailConfig
|
||||||
} = req.body.settings;
|
} = req.body.settings;
|
||||||
|
|
||||||
@ -338,7 +301,6 @@ export class AdminMWs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static async updateBasicSettings(req: Request, res: Response, next: NextFunction) {
|
public static async updateBasicSettings(req: Request, res: Response, next: NextFunction) {
|
||||||
if ((typeof req.body === 'undefined') || (typeof req.body.settings === 'undefined')) {
|
if ((typeof req.body === 'undefined') || (typeof req.body.settings === 'undefined')) {
|
||||||
return next(new ErrorDTO(ErrorCodes.INPUT_ERROR, 'settings is needed'));
|
return next(new ErrorDTO(ErrorCodes.INPUT_ERROR, 'settings is needed'));
|
||||||
@ -375,7 +337,6 @@ export class AdminMWs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static async updateOtherSettings(req: Request, res: Response, next: NextFunction) {
|
public static async updateOtherSettings(req: Request, res: Response, next: NextFunction) {
|
||||||
if ((typeof req.body === 'undefined') || (typeof req.body.settings === 'undefined')) {
|
if ((typeof req.body === 'undefined') || (typeof req.body.settings === 'undefined')) {
|
||||||
return next(new ErrorDTO(ErrorCodes.INPUT_ERROR, 'settings is needed'));
|
return next(new ErrorDTO(ErrorCodes.INPUT_ERROR, 'settings is needed'));
|
||||||
@ -419,7 +380,7 @@ export class AdminMWs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const settings: IndexingConfig = req.body.settings;
|
const settings: ServerConfig.IndexingConfig = req.body.settings;
|
||||||
Config.Server.Indexing = settings;
|
Config.Server.Indexing = settings;
|
||||||
|
|
||||||
// only updating explicitly set config (not saving config set by the diagnostics)
|
// only updating explicitly set config (not saving config set by the diagnostics)
|
||||||
@ -438,7 +399,6 @@ export class AdminMWs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static async updateTasksSettings(req: Request, res: Response, next: NextFunction) {
|
public static async updateTasksSettings(req: Request, res: Response, next: NextFunction) {
|
||||||
if ((typeof req.body === 'undefined') || (typeof req.body.settings === 'undefined')) {
|
if ((typeof req.body === 'undefined') || (typeof req.body.settings === 'undefined')) {
|
||||||
return next(new ErrorDTO(ErrorCodes.INPUT_ERROR, 'settings is needed'));
|
return next(new ErrorDTO(ErrorCodes.INPUT_ERROR, 'settings is needed'));
|
||||||
@ -447,7 +407,7 @@ export class AdminMWs {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
// only updating explicitly set config (not saving config set by the diagnostics)
|
// only updating explicitly set config (not saving config set by the diagnostics)
|
||||||
const settings: TaskConfig = req.body.settings;
|
const settings: ServerConfig.TaskConfig = req.body.settings;
|
||||||
const original = Config.original();
|
const original = Config.original();
|
||||||
await ConfigDiagnostics.testTasksConfig(settings, original);
|
await ConfigDiagnostics.testTasksConfig(settings, original);
|
||||||
|
|
||||||
@ -468,58 +428,4 @@ export class AdminMWs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static startTask(req: Request, res: Response, next: NextFunction) {
|
|
||||||
try {
|
|
||||||
const id = req.params.id;
|
|
||||||
const taskConfig: any = req.body.config;
|
|
||||||
ObjectManagers.getInstance().TaskManager.run(id, taskConfig);
|
|
||||||
req.resultPipe = 'ok';
|
|
||||||
return next();
|
|
||||||
} catch (err) {
|
|
||||||
if (err instanceof Error) {
|
|
||||||
return next(new ErrorDTO(ErrorCodes.TASK_ERROR, 'Task error: ' + err.toString(), err));
|
|
||||||
}
|
|
||||||
return next(new ErrorDTO(ErrorCodes.TASK_ERROR, 'Task error: ' + JSON.stringify(err, null, ' '), err));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static stopTask(req: Request, res: Response, next: NextFunction) {
|
|
||||||
try {
|
|
||||||
const id = req.params.id;
|
|
||||||
ObjectManagers.getInstance().TaskManager.stop(id);
|
|
||||||
req.resultPipe = 'ok';
|
|
||||||
return next();
|
|
||||||
} catch (err) {
|
|
||||||
if (err instanceof Error) {
|
|
||||||
return next(new ErrorDTO(ErrorCodes.TASK_ERROR, 'Task error: ' + err.toString(), err));
|
|
||||||
}
|
|
||||||
return next(new ErrorDTO(ErrorCodes.TASK_ERROR, 'Task error: ' + JSON.stringify(err, null, ' '), err));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static getAvailableTasks(req: Request, res: Response, next: NextFunction) {
|
|
||||||
try {
|
|
||||||
req.resultPipe = ObjectManagers.getInstance().TaskManager.getAvailableTasks();
|
|
||||||
return next();
|
|
||||||
} catch (err) {
|
|
||||||
if (err instanceof Error) {
|
|
||||||
return next(new ErrorDTO(ErrorCodes.TASK_ERROR, 'Task error: ' + err.toString(), err));
|
|
||||||
}
|
|
||||||
return next(new ErrorDTO(ErrorCodes.TASK_ERROR, 'Task error: ' + JSON.stringify(err, null, ' '), err));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static getTaskProgresses(req: Request, res: Response, next: NextFunction) {
|
|
||||||
try {
|
|
||||||
req.resultPipe = ObjectManagers.getInstance().TaskManager.getProgresses();
|
|
||||||
return next();
|
|
||||||
} catch (err) {
|
|
||||||
if (err instanceof Error) {
|
|
||||||
return next(new ErrorDTO(ErrorCodes.TASK_ERROR, 'Task error: ' + err.toString(), err));
|
|
||||||
}
|
|
||||||
return next(new ErrorDTO(ErrorCodes.TASK_ERROR, 'Task error: ' + JSON.stringify(err, null, ' '), err));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,13 +8,13 @@ import {ContentWrapper} from '../../../common/entities/ConentWrapper';
|
|||||||
import {DirectoryDTO} from '../../../common/entities/DirectoryDTO';
|
import {DirectoryDTO} from '../../../common/entities/DirectoryDTO';
|
||||||
import {ProjectPath} from '../../ProjectPath';
|
import {ProjectPath} from '../../ProjectPath';
|
||||||
import {Config} from '../../../common/config/private/Config';
|
import {Config} from '../../../common/config/private/Config';
|
||||||
import {ThumbnailProcessingLib} from '../../../common/config/private/IPrivateConfig';
|
|
||||||
import {ThumbnailTH} from '../../model/threading/ThreadPool';
|
import {ThumbnailTH} from '../../model/threading/ThreadPool';
|
||||||
import {RendererInput, ThumbnailSourceType, ThumbnailWorker} from '../../model/threading/ThumbnailWorker';
|
import {RendererInput, ThumbnailSourceType, ThumbnailWorker} from '../../model/threading/ThumbnailWorker';
|
||||||
import {MediaDTO} from '../../../common/entities/MediaDTO';
|
import {MediaDTO} from '../../../common/entities/MediaDTO';
|
||||||
import {ITaskExecuter, TaskExecuter} from '../../model/threading/TaskExecuter';
|
import {ITaskExecuter, TaskExecuter} from '../../model/threading/TaskExecuter';
|
||||||
import {FaceRegion, PhotoDTO} from '../../../common/entities/PhotoDTO';
|
import {FaceRegion, PhotoDTO} from '../../../common/entities/PhotoDTO';
|
||||||
import {PersonWithPhoto} from '../PersonMWs';
|
import {PersonWithPhoto} from '../PersonMWs';
|
||||||
|
import {ServerConfig} from '../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
|
|
||||||
export class ThumbnailGeneratorMWs {
|
export class ThumbnailGeneratorMWs {
|
||||||
@ -38,7 +38,7 @@ export class ThumbnailGeneratorMWs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Config.Server.Threading.enable === true &&
|
if (Config.Server.Threading.enable === true &&
|
||||||
Config.Server.Thumbnail.processingLibrary === ThumbnailProcessingLib.Jimp) {
|
Config.Server.Thumbnail.processingLibrary === ServerConfig.ThumbnailProcessingLib.Jimp) {
|
||||||
this.taskQue = new ThumbnailTH(Config.Client.Thumbnail.concurrentThumbnailGenerations);
|
this.taskQue = new ThumbnailTH(Config.Client.Thumbnail.concurrentThumbnailGenerations);
|
||||||
} else {
|
} else {
|
||||||
this.taskQue = new TaskExecuter(Config.Client.Thumbnail.concurrentThumbnailGenerations,
|
this.taskQue = new TaskExecuter(Config.Client.Thumbnail.concurrentThumbnailGenerations,
|
||||||
|
@ -1,12 +1,4 @@
|
|||||||
import {Config} from '../../../common/config/private/Config';
|
import {Config} from '../../../common/config/private/Config';
|
||||||
import {
|
|
||||||
DataBaseConfig,
|
|
||||||
DatabaseType,
|
|
||||||
IPrivateConfig,
|
|
||||||
TaskConfig,
|
|
||||||
ThumbnailConfig,
|
|
||||||
ThumbnailProcessingLib
|
|
||||||
} from '../../../common/config/private/IPrivateConfig';
|
|
||||||
import {Logger} from '../../Logger';
|
import {Logger} from '../../Logger';
|
||||||
import {NotificationManager} from '../NotifocationManager';
|
import {NotificationManager} from '../NotifocationManager';
|
||||||
import {ProjectPath} from '../../ProjectPath';
|
import {ProjectPath} from '../../ProjectPath';
|
||||||
@ -14,21 +6,20 @@ import {SQLConnection} from '../sql/SQLConnection';
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import {ClientConfig} from '../../../common/config/public/ConfigClass';
|
import {ClientConfig} from '../../../common/config/public/ConfigClass';
|
||||||
import {FFmpegFactory} from '../FFmpegFactory';
|
import {FFmpegFactory} from '../FFmpegFactory';
|
||||||
import VideoConfig = ClientConfig.VideoConfig;
|
import {IPrivateConfig, ServerConfig} from '../../../common/config/private/IPrivateConfig';
|
||||||
import MetaFileConfig = ClientConfig.MetaFileConfig;
|
|
||||||
|
|
||||||
const LOG_TAG = '[ConfigDiagnostics]';
|
const LOG_TAG = '[ConfigDiagnostics]';
|
||||||
|
|
||||||
export class ConfigDiagnostics {
|
export class ConfigDiagnostics {
|
||||||
|
|
||||||
static async testDatabase(databaseConfig: DataBaseConfig) {
|
static async testDatabase(databaseConfig: ServerConfig.DataBaseConfig) {
|
||||||
if (databaseConfig.type !== DatabaseType.memory) {
|
if (databaseConfig.type !== ServerConfig.DatabaseType.memory) {
|
||||||
await SQLConnection.tryConnection(databaseConfig);
|
await SQLConnection.tryConnection(databaseConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static async testMetaFileConfig(metaFileConfig: MetaFileConfig, config: IPrivateConfig) {
|
static async testMetaFileConfig(metaFileConfig: ClientConfig.MetaFileConfig, config: IPrivateConfig) {
|
||||||
if (metaFileConfig.enabled === true &&
|
if (metaFileConfig.enabled === true &&
|
||||||
config.Client.Map.enabled === false) {
|
config.Client.Map.enabled === false) {
|
||||||
throw new Error('*.gpx meta files are not supported without MAP');
|
throw new Error('*.gpx meta files are not supported without MAP');
|
||||||
@ -36,7 +27,7 @@ export class ConfigDiagnostics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static testVideoConfig(videoConfig: VideoConfig) {
|
static testClientVideoConfig(videoConfig: ClientConfig.VideoConfig) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
if (videoConfig.enabled === true) {
|
if (videoConfig.enabled === true) {
|
||||||
@ -61,13 +52,21 @@ export class ConfigDiagnostics {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static async testThumbnailLib(processingLibrary: ThumbnailProcessingLib) {
|
static async testServerVideoConfig(videoConfig: ServerConfig.VideoConfig, config: IPrivateConfig) {
|
||||||
|
if (config.Client.Video.enabled === true) {
|
||||||
|
if (videoConfig.transcoding.fps <= 0) {
|
||||||
|
throw new Error('fps should be grater than 0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async testThumbnailLib(processingLibrary: ServerConfig.ThumbnailProcessingLib) {
|
||||||
switch (processingLibrary) {
|
switch (processingLibrary) {
|
||||||
case ThumbnailProcessingLib.sharp:
|
case ServerConfig.ThumbnailProcessingLib.sharp:
|
||||||
const sharp = require('sharp');
|
const sharp = require('sharp');
|
||||||
sharp();
|
sharp();
|
||||||
break;
|
break;
|
||||||
case ThumbnailProcessingLib.gm:
|
case ServerConfig.ThumbnailProcessingLib.gm:
|
||||||
const gm = require('gm');
|
const gm = require('gm');
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
gm(ProjectPath.FrontendFolder + '/assets/icon.png').size((err: Error) => {
|
gm(ProjectPath.FrontendFolder + '/assets/icon.png').size((err: Error) => {
|
||||||
@ -107,7 +106,7 @@ export class ConfigDiagnostics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static async testServerThumbnailConfig(thumbnailConfig: ThumbnailConfig) {
|
static async testServerThumbnailConfig(thumbnailConfig: ServerConfig.ThumbnailConfig) {
|
||||||
await ConfigDiagnostics.testThumbnailLib(thumbnailConfig.processingLibrary);
|
await ConfigDiagnostics.testThumbnailLib(thumbnailConfig.processingLibrary);
|
||||||
await ConfigDiagnostics.testThumbnailFolder(thumbnailConfig.folder);
|
await ConfigDiagnostics.testThumbnailFolder(thumbnailConfig.folder);
|
||||||
}
|
}
|
||||||
@ -128,13 +127,13 @@ export class ConfigDiagnostics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static async testTasksConfig(faces: TaskConfig, config: IPrivateConfig) {
|
static async testTasksConfig(faces: ServerConfig.TaskConfig, config: IPrivateConfig) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async testFacesConfig(faces: ClientConfig.FacesConfig, config: IPrivateConfig) {
|
static async testFacesConfig(faces: ClientConfig.FacesConfig, config: IPrivateConfig) {
|
||||||
if (faces.enabled === true) {
|
if (faces.enabled === true) {
|
||||||
if (config.Server.Database.type === DatabaseType.memory) {
|
if (config.Server.Database.type === ServerConfig.DatabaseType.memory) {
|
||||||
throw new Error('Memory Database do not support faces');
|
throw new Error('Memory Database do not support faces');
|
||||||
}
|
}
|
||||||
if (config.Client.Search.enabled === false) {
|
if (config.Client.Search.enabled === false) {
|
||||||
@ -145,7 +144,7 @@ export class ConfigDiagnostics {
|
|||||||
|
|
||||||
static async testSearchConfig(search: ClientConfig.SearchConfig, config: IPrivateConfig) {
|
static async testSearchConfig(search: ClientConfig.SearchConfig, config: IPrivateConfig) {
|
||||||
if (search.enabled === true &&
|
if (search.enabled === true &&
|
||||||
config.Server.Database.type === DatabaseType.memory) {
|
config.Server.Database.type === ServerConfig.DatabaseType.memory) {
|
||||||
throw new Error('Memory Database do not support searching');
|
throw new Error('Memory Database do not support searching');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,7 +152,7 @@ export class ConfigDiagnostics {
|
|||||||
|
|
||||||
static async testSharingConfig(sharing: ClientConfig.SharingConfig, config: IPrivateConfig) {
|
static async testSharingConfig(sharing: ClientConfig.SharingConfig, config: IPrivateConfig) {
|
||||||
if (sharing.enabled === true &&
|
if (sharing.enabled === true &&
|
||||||
config.Server.Database.type === DatabaseType.memory) {
|
config.Server.Database.type === ServerConfig.DatabaseType.memory) {
|
||||||
throw new Error('Memory Database do not support sharing');
|
throw new Error('Memory Database do not support sharing');
|
||||||
}
|
}
|
||||||
if (sharing.enabled === true &&
|
if (sharing.enabled === true &&
|
||||||
@ -164,8 +163,8 @@ export class ConfigDiagnostics {
|
|||||||
|
|
||||||
static async testRandomPhotoConfig(sharing: ClientConfig.RandomPhotoConfig, config: IPrivateConfig) {
|
static async testRandomPhotoConfig(sharing: ClientConfig.RandomPhotoConfig, config: IPrivateConfig) {
|
||||||
if (sharing.enabled === true &&
|
if (sharing.enabled === true &&
|
||||||
config.Server.Database.type === DatabaseType.memory) {
|
config.Server.Database.type === ServerConfig.DatabaseType.memory) {
|
||||||
throw new Error('Memory Database do not support sharing');
|
throw new Error('Memory Database do not support random photo');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +193,7 @@ export class ConfigDiagnostics {
|
|||||||
|
|
||||||
static async runDiagnostics() {
|
static async runDiagnostics() {
|
||||||
|
|
||||||
if (Config.Server.Database.type !== DatabaseType.memory) {
|
if (Config.Server.Database.type !== ServerConfig.DatabaseType.memory) {
|
||||||
try {
|
try {
|
||||||
await ConfigDiagnostics.testDatabase(Config.Server.Database);
|
await ConfigDiagnostics.testDatabase(Config.Server.Database);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
@ -202,23 +201,23 @@ export class ConfigDiagnostics {
|
|||||||
Logger.warn(LOG_TAG, '[SQL error]', err.toString());
|
Logger.warn(LOG_TAG, '[SQL error]', err.toString());
|
||||||
Logger.warn(LOG_TAG, 'Error during initializing SQL falling back temporally to memory DB');
|
Logger.warn(LOG_TAG, 'Error during initializing SQL falling back temporally to memory DB');
|
||||||
NotificationManager.warning('Error during initializing SQL falling back temporally to memory DB', err.toString());
|
NotificationManager.warning('Error during initializing SQL falling back temporally to memory DB', err.toString());
|
||||||
Config.setDatabaseType(DatabaseType.memory);
|
Config.setDatabaseType(ServerConfig.DatabaseType.memory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.Server.Thumbnail.processingLibrary !== ThumbnailProcessingLib.Jimp) {
|
if (Config.Server.Thumbnail.processingLibrary !== ServerConfig.ThumbnailProcessingLib.Jimp) {
|
||||||
try {
|
try {
|
||||||
await ConfigDiagnostics.testThumbnailLib(Config.Server.Thumbnail.processingLibrary);
|
await ConfigDiagnostics.testThumbnailLib(Config.Server.Thumbnail.processingLibrary);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
const err: Error = ex;
|
const err: Error = ex;
|
||||||
NotificationManager.warning('Thumbnail hardware acceleration is not possible.' +
|
NotificationManager.warning('Thumbnail hardware acceleration is not possible.' +
|
||||||
' \'' + ThumbnailProcessingLib[Config.Server.Thumbnail.processingLibrary] + '\' node module is not found.' +
|
' \'' + ServerConfig.ThumbnailProcessingLib[Config.Server.Thumbnail.processingLibrary] + '\' node module is not found.' +
|
||||||
' Falling back temporally to JS based thumbnail generation', err.toString());
|
' Falling back temporally to JS based thumbnail generation', err.toString());
|
||||||
Logger.warn(LOG_TAG, '[Thumbnail hardware acceleration] module error: ', err.toString());
|
Logger.warn(LOG_TAG, '[Thumbnail hardware acceleration] module error: ', err.toString());
|
||||||
Logger.warn(LOG_TAG, 'Thumbnail hardware acceleration is not possible.' +
|
Logger.warn(LOG_TAG, 'Thumbnail hardware acceleration is not possible.' +
|
||||||
' \'' + ThumbnailProcessingLib[Config.Server.Thumbnail.processingLibrary] + '\' node module is not found.' +
|
' \'' + ServerConfig.ThumbnailProcessingLib[Config.Server.Thumbnail.processingLibrary] + '\' node module is not found.' +
|
||||||
' Falling back temporally to JS based thumbnail generation');
|
' Falling back temporally to JS based thumbnail generation');
|
||||||
Config.Server.Thumbnail.processingLibrary = ThumbnailProcessingLib.Jimp;
|
Config.Server.Thumbnail.processingLibrary = ServerConfig.ThumbnailProcessingLib.Jimp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +231,8 @@ export class ConfigDiagnostics {
|
|||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ConfigDiagnostics.testVideoConfig(Config.Client.Video);
|
await ConfigDiagnostics.testClientVideoConfig(Config.Server.Video);
|
||||||
|
await ConfigDiagnostics.testServerVideoConfig(Config.Server.Video, Config);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
const err: Error = ex;
|
const err: Error = ex;
|
||||||
NotificationManager.warning('Video support error, switching off..', err.toString());
|
NotificationManager.warning('Video support error, switching off..', err.toString());
|
||||||
|
@ -5,9 +5,9 @@ import * as fs from 'fs';
|
|||||||
import {DiskManager} from '../DiskManger';
|
import {DiskManager} from '../DiskManger';
|
||||||
import {ProjectPath} from '../../ProjectPath';
|
import {ProjectPath} from '../../ProjectPath';
|
||||||
import {Config} from '../../../common/config/private/Config';
|
import {Config} from '../../../common/config/private/Config';
|
||||||
import {ReIndexingSensitivity} from '../../../common/config/private/IPrivateConfig';
|
|
||||||
import {PhotoDTO} from '../../../common/entities/PhotoDTO';
|
import {PhotoDTO} from '../../../common/entities/PhotoDTO';
|
||||||
import {DiskMangerWorker} from '../threading/DiskMangerWorker';
|
import {DiskMangerWorker} from '../threading/DiskMangerWorker';
|
||||||
|
import {ServerConfig} from '../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
export class GalleryManager implements IGalleryManager {
|
export class GalleryManager implements IGalleryManager {
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ export class GalleryManager implements IGalleryManager {
|
|||||||
const lastModified = DiskMangerWorker.calcLastModified(stat);
|
const lastModified = DiskMangerWorker.calcLastModified(stat);
|
||||||
if (Date.now() - knownLastScanned <= Config.Server.Indexing.cachedFolderTimeout &&
|
if (Date.now() - knownLastScanned <= Config.Server.Indexing.cachedFolderTimeout &&
|
||||||
lastModified === knownLastModified &&
|
lastModified === knownLastModified &&
|
||||||
Config.Server.Indexing.reIndexingSensitivity < ReIndexingSensitivity.high) {
|
Config.Server.Indexing.reIndexingSensitivity < ServerConfig.ReIndexingSensitivity.high) {
|
||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,9 @@ import {PhotoEntity} from './enitites/PhotoEntity';
|
|||||||
import {ProjectPath} from '../../ProjectPath';
|
import {ProjectPath} from '../../ProjectPath';
|
||||||
import {Config} from '../../../common/config/private/Config';
|
import {Config} from '../../../common/config/private/Config';
|
||||||
import {ISQLGalleryManager} from './IGalleryManager';
|
import {ISQLGalleryManager} from './IGalleryManager';
|
||||||
import {DatabaseType, ReIndexingSensitivity} from '../../../common/config/private/IPrivateConfig';
|
|
||||||
import {PhotoDTO} from '../../../common/entities/PhotoDTO';
|
import {PhotoDTO} from '../../../common/entities/PhotoDTO';
|
||||||
import {OrientationType} from '../../../common/entities/RandomQueryDTO';
|
import {OrientationType} from '../../../common/entities/RandomQueryDTO';
|
||||||
import {Brackets, Connection} from 'typeorm';
|
import {Brackets, Connection, SelectQueryBuilder} from 'typeorm';
|
||||||
import {MediaEntity} from './enitites/MediaEntity';
|
import {MediaEntity} from './enitites/MediaEntity';
|
||||||
import {VideoEntity} from './enitites/VideoEntity';
|
import {VideoEntity} from './enitites/VideoEntity';
|
||||||
import {DiskMangerWorker} from '../threading/DiskMangerWorker';
|
import {DiskMangerWorker} from '../threading/DiskMangerWorker';
|
||||||
@ -19,6 +18,7 @@ import {Logger} from '../../Logger';
|
|||||||
import {FaceRegionEntry} from './enitites/FaceRegionEntry';
|
import {FaceRegionEntry} from './enitites/FaceRegionEntry';
|
||||||
import {ObjectManagers} from '../ObjectManagers';
|
import {ObjectManagers} from '../ObjectManagers';
|
||||||
import {DuplicatesDTO} from '../../../common/entities/DuplicatesDTO';
|
import {DuplicatesDTO} from '../../../common/entities/DuplicatesDTO';
|
||||||
|
import {ServerConfig} from '../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
const LOG_TAG = '[GalleryManager]';
|
const LOG_TAG = '[GalleryManager]';
|
||||||
|
|
||||||
@ -43,11 +43,11 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
|
|||||||
if (knownLastModified && knownLastScanned
|
if (knownLastModified && knownLastScanned
|
||||||
&& lastModified === knownLastModified &&
|
&& lastModified === knownLastModified &&
|
||||||
dir.lastScanned === knownLastScanned) {
|
dir.lastScanned === knownLastScanned) {
|
||||||
if (Config.Server.Indexing.reIndexingSensitivity === ReIndexingSensitivity.low) {
|
if (Config.Server.Indexing.reIndexingSensitivity === ServerConfig.ReIndexingSensitivity.low) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (Date.now() - dir.lastScanned <= Config.Server.Indexing.cachedFolderTimeout &&
|
if (Date.now() - dir.lastScanned <= Config.Server.Indexing.cachedFolderTimeout &&
|
||||||
Config.Server.Indexing.reIndexingSensitivity === ReIndexingSensitivity.medium) {
|
Config.Server.Indexing.reIndexingSensitivity === ServerConfig.ReIndexingSensitivity.medium) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,8 +62,8 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
|
|||||||
|
|
||||||
// not indexed since a while, index it in a lazy manner
|
// not indexed since a while, index it in a lazy manner
|
||||||
if ((Date.now() - dir.lastScanned > Config.Server.Indexing.cachedFolderTimeout &&
|
if ((Date.now() - dir.lastScanned > Config.Server.Indexing.cachedFolderTimeout &&
|
||||||
Config.Server.Indexing.reIndexingSensitivity >= ReIndexingSensitivity.medium) ||
|
Config.Server.Indexing.reIndexingSensitivity >= ServerConfig.ReIndexingSensitivity.medium) ||
|
||||||
Config.Server.Indexing.reIndexingSensitivity >= ReIndexingSensitivity.high) {
|
Config.Server.Indexing.reIndexingSensitivity >= ServerConfig.ReIndexingSensitivity.high) {
|
||||||
// on the fly reindexing
|
// on the fly reindexing
|
||||||
|
|
||||||
Logger.silly(LOG_TAG, 'lazy reindexing reason: cache timeout: lastScanned: '
|
Logger.silly(LOG_TAG, 'lazy reindexing reason: cache timeout: lastScanned: '
|
||||||
@ -86,7 +86,7 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
|
|||||||
public async getRandomPhoto(queryFilter: RandomQuery): Promise<PhotoDTO> {
|
public async getRandomPhoto(queryFilter: RandomQuery): Promise<PhotoDTO> {
|
||||||
const connection = await SQLConnection.getConnection();
|
const connection = await SQLConnection.getConnection();
|
||||||
const photosRepository = connection.getRepository(PhotoEntity);
|
const photosRepository = connection.getRepository(PhotoEntity);
|
||||||
const query = photosRepository.createQueryBuilder('photo');
|
const query: SelectQueryBuilder<PhotoEntity> = photosRepository.createQueryBuilder('photo');
|
||||||
query.innerJoinAndSelect('photo.directory', 'directory');
|
query.innerJoinAndSelect('photo.directory', 'directory');
|
||||||
|
|
||||||
if (queryFilter.directory) {
|
if (queryFilter.directory) {
|
||||||
@ -133,7 +133,7 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
|
|||||||
query.andWhere('photo.metadata.size.width <= photo.metadata.size.height');
|
query.andWhere('photo.metadata.size.width <= photo.metadata.size.height');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.Server.Database.type === DatabaseType.mysql) {
|
if (Config.Server.Database.type === ServerConfig.DatabaseType.mysql) {
|
||||||
return await query.groupBy('RAND(), photo.id').limit(1).getOne();
|
return await query.groupBy('RAND(), photo.id').limit(1).getOne();
|
||||||
}
|
}
|
||||||
return await query.groupBy('RANDOM()').limit(1).getOne();
|
return await query.groupBy('RANDOM()').limit(1).getOne();
|
||||||
|
@ -6,7 +6,6 @@ import {PhotoEntity} from './enitites/PhotoEntity';
|
|||||||
import {DirectoryEntity} from './enitites/DirectoryEntity';
|
import {DirectoryEntity} from './enitites/DirectoryEntity';
|
||||||
import {Config} from '../../../common/config/private/Config';
|
import {Config} from '../../../common/config/private/Config';
|
||||||
import {SharingEntity} from './enitites/SharingEntity';
|
import {SharingEntity} from './enitites/SharingEntity';
|
||||||
import {DataBaseConfig, DatabaseType, SQLLogLevel} from '../../../common/config/private/IPrivateConfig';
|
|
||||||
import {PasswordHelper} from '../PasswordHelper';
|
import {PasswordHelper} from '../PasswordHelper';
|
||||||
import {ProjectPath} from '../../ProjectPath';
|
import {ProjectPath} from '../../ProjectPath';
|
||||||
import {VersionEntity} from './enitites/VersionEntity';
|
import {VersionEntity} from './enitites/VersionEntity';
|
||||||
@ -18,6 +17,7 @@ import {FileEntity} from './enitites/FileEntity';
|
|||||||
import {FaceRegionEntry} from './enitites/FaceRegionEntry';
|
import {FaceRegionEntry} from './enitites/FaceRegionEntry';
|
||||||
import {PersonEntry} from './enitites/PersonEntry';
|
import {PersonEntry} from './enitites/PersonEntry';
|
||||||
import {Utils} from '../../../common/Utils';
|
import {Utils} from '../../../common/Utils';
|
||||||
|
import {ServerConfig} from '../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
|
|
||||||
export class SQLConnection {
|
export class SQLConnection {
|
||||||
@ -45,8 +45,8 @@ export class SQLConnection {
|
|||||||
VersionEntity
|
VersionEntity
|
||||||
];
|
];
|
||||||
options.synchronize = false;
|
options.synchronize = false;
|
||||||
if (Config.Server.Log.sqlLevel !== SQLLogLevel.none) {
|
if (Config.Server.Log.sqlLevel !== ServerConfig.SQLLogLevel.none) {
|
||||||
options.logging = SQLLogLevel[Config.Server.Log.sqlLevel];
|
options.logging = ServerConfig.SQLLogLevel[Config.Server.Log.sqlLevel];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.connection = await this.createConnection(options);
|
this.connection = await this.createConnection(options);
|
||||||
@ -55,7 +55,7 @@ export class SQLConnection {
|
|||||||
return this.connection;
|
return this.connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async tryConnection(config: DataBaseConfig) {
|
public static async tryConnection(config: ServerConfig.DataBaseConfig) {
|
||||||
try {
|
try {
|
||||||
await getConnection('test').close();
|
await getConnection('test').close();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -75,8 +75,8 @@ export class SQLConnection {
|
|||||||
VersionEntity
|
VersionEntity
|
||||||
];
|
];
|
||||||
options.synchronize = false;
|
options.synchronize = false;
|
||||||
if (Config.Server.Log.sqlLevel !== SQLLogLevel.none) {
|
if (Config.Server.Log.sqlLevel !== ServerConfig.SQLLogLevel.none) {
|
||||||
options.logging = SQLLogLevel[Config.Server.Log.sqlLevel];
|
options.logging = ServerConfig.SQLLogLevel[Config.Server.Log.sqlLevel];
|
||||||
}
|
}
|
||||||
const conn = await this.createConnection(options);
|
const conn = await this.createConnection(options);
|
||||||
await SQLConnection.schemeSync(conn);
|
await SQLConnection.schemeSync(conn);
|
||||||
@ -163,9 +163,9 @@ export class SQLConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static getDriver(config: DataBaseConfig): ConnectionOptions {
|
private static getDriver(config: ServerConfig.DataBaseConfig): ConnectionOptions {
|
||||||
let driver: ConnectionOptions = null;
|
let driver: ConnectionOptions = null;
|
||||||
if (config.type === DatabaseType.mysql) {
|
if (config.type === ServerConfig.DatabaseType.mysql) {
|
||||||
driver = {
|
driver = {
|
||||||
type: 'mysql',
|
type: 'mysql',
|
||||||
host: config.mysql.host,
|
host: config.mysql.host,
|
||||||
@ -175,7 +175,7 @@ export class SQLConnection {
|
|||||||
database: config.mysql.database,
|
database: config.mysql.database,
|
||||||
charset: 'utf8'
|
charset: 'utf8'
|
||||||
};
|
};
|
||||||
} else if (config.type === DatabaseType.sqlite) {
|
} else if (config.type === ServerConfig.DatabaseType.sqlite) {
|
||||||
driver = {
|
driver = {
|
||||||
type: 'sqlite',
|
type: 'sqlite',
|
||||||
database: ProjectPath.getAbsolutePath(config.sqlite.storage)
|
database: ProjectPath.getAbsolutePath(config.sqlite.storage)
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
import {Config} from '../../../../common/config/private/Config';
|
import {Config} from '../../../../common/config/private/Config';
|
||||||
import {DatabaseType} from '../../../../common/config/private/IPrivateConfig';
|
import {ServerConfig} from '../../../../common/config/private/IPrivateConfig';
|
||||||
import {ColumnOptions} from 'typeorm/decorator/options/ColumnOptions';
|
import {ColumnOptions} from 'typeorm/decorator/options/ColumnOptions';
|
||||||
|
|
||||||
export class ColumnCharsetCS implements ColumnOptions {
|
export class ColumnCharsetCS implements ColumnOptions {
|
||||||
|
|
||||||
public get charset(): string {
|
public get charset(): string {
|
||||||
return Config.Server.Database.type === DatabaseType.mysql ? 'utf8' : null;
|
return Config.Server.Database.type === ServerConfig.DatabaseType.mysql ? 'utf8' : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get collation(): string {
|
public get collation(): string {
|
||||||
return Config.Server.Database.type === DatabaseType.mysql ? 'utf8_bin' : null;
|
return Config.Server.Database.type === ServerConfig.DatabaseType.mysql ? 'utf8_bin' : null;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ import {MediaDimension, MediaDTO, MediaMetadata} from '../../../../common/entiti
|
|||||||
import {OrientationTypes} from 'ts-exif-parser';
|
import {OrientationTypes} from 'ts-exif-parser';
|
||||||
import {CameraMetadataEntity, PositionMetaDataEntity} from './PhotoEntity';
|
import {CameraMetadataEntity, PositionMetaDataEntity} from './PhotoEntity';
|
||||||
import {FaceRegionEntry} from './FaceRegionEntry';
|
import {FaceRegionEntry} from './FaceRegionEntry';
|
||||||
import {Config} from '../../../../common/config/private/Config';
|
|
||||||
import {DatabaseType} from '../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {columnCharsetCS} from './EntityUtils';
|
import {columnCharsetCS} from './EntityUtils';
|
||||||
|
|
||||||
export class MediaDimensionEntity implements MediaDimension {
|
export class MediaDimensionEntity implements MediaDimension {
|
||||||
@ -59,7 +57,6 @@ export class MediaMetadataEntity implements MediaMetadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: fix inheritance once its working in typeorm
|
// TODO: fix inheritance once its working in typeorm
|
||||||
@Entity()
|
@Entity()
|
||||||
@Unique(['name', 'directory'])
|
@Unique(['name', 'directory'])
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import {TaskProgressDTO} from '../../../../common/entities/settings/TaskProgressDTO';
|
import {TaskProgressDTO} from '../../../../common/entities/settings/TaskProgressDTO';
|
||||||
import {ObjectManagers} from '../../ObjectManagers';
|
import {ObjectManagers} from '../../ObjectManagers';
|
||||||
import {Config} from '../../../../common/config/private/Config';
|
import {Config} from '../../../../common/config/private/Config';
|
||||||
import {DatabaseType} from '../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {ConfigTemplateEntry, DefaultsTasks} from '../../../../common/entities/task/TaskDTO';
|
import {ConfigTemplateEntry, DefaultsTasks} from '../../../../common/entities/task/TaskDTO';
|
||||||
import {Task} from './Task';
|
import {Task} from './Task';
|
||||||
|
import {ServerConfig} from '../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
const LOG_TAG = '[DBRestTask]';
|
const LOG_TAG = '[DBRestTask]';
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ export class DBRestTask extends Task {
|
|||||||
public readonly ConfigTemplate: ConfigTemplateEntry[] = null;
|
public readonly ConfigTemplate: ConfigTemplateEntry[] = null;
|
||||||
|
|
||||||
public get Supported(): boolean {
|
public get Supported(): boolean {
|
||||||
return Config.Server.Database.type !== DatabaseType.memory;
|
return Config.Server.Database.type !== ServerConfig.DatabaseType.memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async init() {
|
protected async init() {
|
||||||
|
@ -9,8 +9,8 @@ import {MediaDTO} from '../../../../common/entities/MediaDTO';
|
|||||||
import {ProjectPath} from '../../../ProjectPath';
|
import {ProjectPath} from '../../../ProjectPath';
|
||||||
import {ThumbnailGeneratorMWs} from '../../../middlewares/thumbnail/ThumbnailGeneratorMWs';
|
import {ThumbnailGeneratorMWs} from '../../../middlewares/thumbnail/ThumbnailGeneratorMWs';
|
||||||
import {Task} from './Task';
|
import {Task} from './Task';
|
||||||
import {DatabaseType} from '../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {ConfigTemplateEntry, DefaultsTasks} from '../../../../common/entities/task/TaskDTO';
|
import {ConfigTemplateEntry, DefaultsTasks} from '../../../../common/entities/task/TaskDTO';
|
||||||
|
import {ServerConfig} from '../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
declare const global: any;
|
declare const global: any;
|
||||||
const LOG_TAG = '[IndexingTask]';
|
const LOG_TAG = '[IndexingTask]';
|
||||||
@ -26,7 +26,7 @@ export class IndexingTask extends Task<{ createThumbnails: boolean }> {
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
public get Supported(): boolean {
|
public get Supported(): boolean {
|
||||||
return Config.Server.Database.type !== DatabaseType.memory;
|
return Config.Server.Database.type !== ServerConfig.DatabaseType.memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async init() {
|
protected async init() {
|
||||||
|
@ -2,23 +2,23 @@ import {Metadata, Sharp} from 'sharp';
|
|||||||
import {Dimensions, State} from 'gm';
|
import {Dimensions, State} from 'gm';
|
||||||
import {Logger} from '../../Logger';
|
import {Logger} from '../../Logger';
|
||||||
import {FfmpegCommand, FfprobeData} from 'fluent-ffmpeg';
|
import {FfmpegCommand, FfprobeData} from 'fluent-ffmpeg';
|
||||||
import {ThumbnailProcessingLib} from '../../../common/config/private/IPrivateConfig';
|
|
||||||
import {FFmpegFactory} from '../FFmpegFactory';
|
import {FFmpegFactory} from '../FFmpegFactory';
|
||||||
|
import {ServerConfig} from '../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
export class ThumbnailWorker {
|
export class ThumbnailWorker {
|
||||||
|
|
||||||
private static imageRenderer: (input: RendererInput) => Promise<void> = null;
|
private static imageRenderer: (input: RendererInput) => Promise<void> = null;
|
||||||
private static videoRenderer: (input: RendererInput) => Promise<void> = null;
|
private static videoRenderer: (input: RendererInput) => Promise<void> = null;
|
||||||
private static rendererType: ThumbnailProcessingLib = null;
|
private static rendererType: ServerConfig.ThumbnailProcessingLib = null;
|
||||||
|
|
||||||
public static render(input: RendererInput, renderer: ThumbnailProcessingLib): Promise<void> {
|
public static render(input: RendererInput, renderer: ServerConfig.ThumbnailProcessingLib): Promise<void> {
|
||||||
if (input.type === ThumbnailSourceType.Image) {
|
if (input.type === ThumbnailSourceType.Image) {
|
||||||
return this.renderFromImage(input, renderer);
|
return this.renderFromImage(input, renderer);
|
||||||
}
|
}
|
||||||
return this.renderFromVideo(input);
|
return this.renderFromVideo(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static renderFromImage(input: RendererInput, renderer: ThumbnailProcessingLib): Promise<void> {
|
public static renderFromImage(input: RendererInput, renderer: ServerConfig.ThumbnailProcessingLib): Promise<void> {
|
||||||
if (ThumbnailWorker.rendererType !== renderer) {
|
if (ThumbnailWorker.rendererType !== renderer) {
|
||||||
ThumbnailWorker.imageRenderer = ImageRendererFactory.build(renderer);
|
ThumbnailWorker.imageRenderer = ImageRendererFactory.build(renderer);
|
||||||
ThumbnailWorker.rendererType = renderer;
|
ThumbnailWorker.rendererType = renderer;
|
||||||
@ -117,13 +117,13 @@ export class VideoRendererFactory {
|
|||||||
|
|
||||||
export class ImageRendererFactory {
|
export class ImageRendererFactory {
|
||||||
|
|
||||||
public static build(renderer: ThumbnailProcessingLib): (input: RendererInput) => Promise<void> {
|
public static build(renderer: ServerConfig.ThumbnailProcessingLib): (input: RendererInput) => Promise<void> {
|
||||||
switch (renderer) {
|
switch (renderer) {
|
||||||
case ThumbnailProcessingLib.Jimp:
|
case ServerConfig.ThumbnailProcessingLib.Jimp:
|
||||||
return ImageRendererFactory.Jimp();
|
return ImageRendererFactory.Jimp();
|
||||||
case ThumbnailProcessingLib.gm:
|
case ServerConfig.ThumbnailProcessingLib.gm:
|
||||||
return ImageRendererFactory.Gm();
|
return ImageRendererFactory.Gm();
|
||||||
case ThumbnailProcessingLib.sharp:
|
case ServerConfig.ThumbnailProcessingLib.sharp:
|
||||||
return ImageRendererFactory.Sharp();
|
return ImageRendererFactory.Sharp();
|
||||||
}
|
}
|
||||||
throw new Error('unknown renderer');
|
throw new Error('unknown renderer');
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import {Logger} from '../../Logger';
|
import {Logger} from '../../Logger';
|
||||||
import {FfmpegCommand} from 'fluent-ffmpeg';
|
import {FfmpegCommand} from 'fluent-ffmpeg';
|
||||||
import {FFmpegFactory} from '../FFmpegFactory';
|
import {FFmpegFactory} from '../FFmpegFactory';
|
||||||
|
import {ServerConfig} from '../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
|
|
||||||
export interface VideoConverterInput {
|
export interface VideoConverterInput {
|
||||||
@ -8,10 +9,10 @@ export interface VideoConverterInput {
|
|||||||
output: {
|
output: {
|
||||||
path: string,
|
path: string,
|
||||||
bitRate?: number,
|
bitRate?: number,
|
||||||
resolution?: 240 | 360 | 480 | 720 | 1080 | 1440 | 2160 | 4320,
|
resolution?: ServerConfig.resolutionType,
|
||||||
fps?: number,
|
fps?: number,
|
||||||
codec: string,
|
codec: ServerConfig.codecType,
|
||||||
format: string
|
format: ServerConfig.formatType
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import {DiskMangerWorker} from './DiskMangerWorker';
|
import {DiskMangerWorker} from './DiskMangerWorker';
|
||||||
import {Logger} from '../../Logger';
|
import {Logger} from '../../Logger';
|
||||||
import {RendererInput, ThumbnailWorker} from './ThumbnailWorker';
|
import {RendererInput, ThumbnailWorker} from './ThumbnailWorker';
|
||||||
import {ThumbnailProcessingLib} from '../../../common/config/private/IPrivateConfig';
|
|
||||||
import {DirectoryDTO} from '../../../common/entities/DirectoryDTO';
|
import {DirectoryDTO} from '../../../common/entities/DirectoryDTO';
|
||||||
import {Utils} from '../../../common/Utils';
|
import {Utils} from '../../../common/Utils';
|
||||||
|
import {ServerConfig} from '../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
export class Worker {
|
export class Worker {
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ export interface DiskManagerTask extends WorkerTask {
|
|||||||
|
|
||||||
export interface ThumbnailTask extends WorkerTask {
|
export interface ThumbnailTask extends WorkerTask {
|
||||||
input: RendererInput;
|
input: RendererInput;
|
||||||
renderer: ThumbnailProcessingLib;
|
renderer: ServerConfig.ThumbnailProcessingLib;
|
||||||
}
|
}
|
||||||
|
|
||||||
export module WorkerTask {
|
export module WorkerTask {
|
||||||
|
28
backend/routes/Router.ts
Normal file
28
backend/routes/Router.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import {Express} from 'express';
|
||||||
|
import {PublicRouter} from './PublicRouter';
|
||||||
|
import {UserRouter} from './UserRouter';
|
||||||
|
import {GalleryRouter} from './GalleryRouter';
|
||||||
|
import {PersonRouter} from './PersonRouter';
|
||||||
|
import {SharingRouter} from './SharingRouter';
|
||||||
|
import {AdminRouter} from './admin/AdminRouter';
|
||||||
|
import {SettingsRouter} from './admin/SettingsRouter';
|
||||||
|
import {NotificationRouter} from './NotificationRouter';
|
||||||
|
import {ErrorRouter} from './ErrorRouter';
|
||||||
|
|
||||||
|
export class Router {
|
||||||
|
|
||||||
|
public static route(app: Express) {
|
||||||
|
|
||||||
|
PublicRouter.route(app);
|
||||||
|
|
||||||
|
UserRouter.route(app);
|
||||||
|
GalleryRouter.route(app);
|
||||||
|
PersonRouter.route(app);
|
||||||
|
SharingRouter.route(app);
|
||||||
|
AdminRouter.route(app);
|
||||||
|
SettingsRouter.route(app);
|
||||||
|
NotificationRouter.route(app);
|
||||||
|
|
||||||
|
ErrorRouter.route(app);
|
||||||
|
}
|
||||||
|
}
|
61
backend/routes/admin/AdminRouter.ts
Normal file
61
backend/routes/admin/AdminRouter.ts
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
import {AuthenticationMWs} from '../../middlewares/user/AuthenticationMWs';
|
||||||
|
import {UserRoles} from '../../../common/entities/UserDTO';
|
||||||
|
import {RenderingMWs} from '../../middlewares/RenderingMWs';
|
||||||
|
import {AdminMWs} from '../../middlewares/admin/AdminMWs';
|
||||||
|
import {Express} from 'express';
|
||||||
|
|
||||||
|
export class AdminRouter {
|
||||||
|
public static route(app: Express) {
|
||||||
|
|
||||||
|
this.addGetStatistic(app);
|
||||||
|
this.addGetDuplicates(app);
|
||||||
|
this.addTasks(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static addGetStatistic(app: Express) {
|
||||||
|
app.get('/api/admin/statistic',
|
||||||
|
AuthenticationMWs.authenticate,
|
||||||
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
|
AdminMWs.loadStatistic,
|
||||||
|
RenderingMWs.renderResult
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static addGetDuplicates(app: Express) {
|
||||||
|
app.get('/api/admin/duplicates',
|
||||||
|
AuthenticationMWs.authenticate,
|
||||||
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
|
AdminMWs.getDuplicates,
|
||||||
|
RenderingMWs.renderResult
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static addTasks(app: Express) {
|
||||||
|
app.get('/api/admin/tasks/available',
|
||||||
|
AuthenticationMWs.authenticate,
|
||||||
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
|
AdminMWs.getAvailableTasks,
|
||||||
|
RenderingMWs.renderResult
|
||||||
|
);
|
||||||
|
app.get('/api/admin/tasks/scheduled/progress',
|
||||||
|
AuthenticationMWs.authenticate,
|
||||||
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
|
AdminMWs.getTaskProgresses,
|
||||||
|
RenderingMWs.renderResult
|
||||||
|
);
|
||||||
|
app.post('/api/admin/tasks/scheduled/:id/start',
|
||||||
|
AuthenticationMWs.authenticate,
|
||||||
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
|
AdminMWs.startTask,
|
||||||
|
RenderingMWs.renderResult
|
||||||
|
);
|
||||||
|
app.post('/api/admin/tasks/scheduled/:id/stop',
|
||||||
|
AuthenticationMWs.authenticate,
|
||||||
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
|
AdminMWs.stopTask,
|
||||||
|
RenderingMWs.renderResult
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,63 +1,15 @@
|
|||||||
import {AuthenticationMWs} from '../middlewares/user/AuthenticationMWs';
|
import {AuthenticationMWs} from '../../middlewares/user/AuthenticationMWs';
|
||||||
import {UserRoles} from '../../common/entities/UserDTO';
|
import {UserRoles} from '../../../common/entities/UserDTO';
|
||||||
import {RenderingMWs} from '../middlewares/RenderingMWs';
|
import {RenderingMWs} from '../../middlewares/RenderingMWs';
|
||||||
import {AdminMWs} from '../middlewares/AdminMWs';
|
|
||||||
import {Express} from 'express';
|
import {Express} from 'express';
|
||||||
|
import {SettingsMWs} from '../../middlewares/admin/SettingsMWs';
|
||||||
|
|
||||||
export class AdminRouter {
|
export class SettingsRouter {
|
||||||
public static route(app: Express) {
|
public static route(app: Express) {
|
||||||
|
|
||||||
this.addGetStatistic(app);
|
|
||||||
this.addGetDuplicates(app);
|
|
||||||
this.addTasks(app);
|
|
||||||
this.addSettings(app);
|
this.addSettings(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static addGetStatistic(app: Express) {
|
|
||||||
app.get('/api/admin/statistic',
|
|
||||||
AuthenticationMWs.authenticate,
|
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
|
||||||
AdminMWs.loadStatistic,
|
|
||||||
RenderingMWs.renderResult
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static addGetDuplicates(app: Express) {
|
|
||||||
app.get('/api/admin/duplicates',
|
|
||||||
AuthenticationMWs.authenticate,
|
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
|
||||||
AdminMWs.getDuplicates,
|
|
||||||
RenderingMWs.renderResult
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static addTasks(app: Express) {
|
|
||||||
app.get('/api/admin/tasks/available',
|
|
||||||
AuthenticationMWs.authenticate,
|
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
|
||||||
AdminMWs.getAvailableTasks,
|
|
||||||
RenderingMWs.renderResult
|
|
||||||
);
|
|
||||||
app.get('/api/admin/tasks/scheduled/progress',
|
|
||||||
AuthenticationMWs.authenticate,
|
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
|
||||||
AdminMWs.getTaskProgresses,
|
|
||||||
RenderingMWs.renderResult
|
|
||||||
);
|
|
||||||
app.post('/api/admin/tasks/scheduled/:id/start',
|
|
||||||
AuthenticationMWs.authenticate,
|
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
|
||||||
AdminMWs.startTask,
|
|
||||||
RenderingMWs.renderResult
|
|
||||||
);
|
|
||||||
app.post('/api/admin/tasks/scheduled/:id/stop',
|
|
||||||
AuthenticationMWs.authenticate,
|
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
|
||||||
AdminMWs.stopTask,
|
|
||||||
RenderingMWs.renderResult
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static addSettings(app: Express) {
|
private static addSettings(app: Express) {
|
||||||
app.get('/api/settings',
|
app.get('/api/settings',
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
@ -69,87 +21,87 @@ export class AdminRouter {
|
|||||||
app.put('/api/settings/database',
|
app.put('/api/settings/database',
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
AdminMWs.updateDatabaseSettings,
|
SettingsMWs.updateDatabaseSettings,
|
||||||
RenderingMWs.renderOK
|
RenderingMWs.renderOK
|
||||||
);
|
);
|
||||||
|
|
||||||
app.put('/api/settings/map',
|
app.put('/api/settings/map',
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
AdminMWs.updateMapSettings,
|
SettingsMWs.updateMapSettings,
|
||||||
RenderingMWs.renderOK
|
RenderingMWs.renderOK
|
||||||
);
|
);
|
||||||
app.put('/api/settings/video',
|
app.put('/api/settings/video',
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
AdminMWs.updateVideoSettings,
|
SettingsMWs.updateVideoSettings,
|
||||||
RenderingMWs.renderOK
|
RenderingMWs.renderOK
|
||||||
);
|
);
|
||||||
app.put('/api/settings/metafile',
|
app.put('/api/settings/metafile',
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
AdminMWs.updateMetaFileSettings,
|
SettingsMWs.updateMetaFileSettings,
|
||||||
RenderingMWs.renderOK
|
RenderingMWs.renderOK
|
||||||
);
|
);
|
||||||
|
|
||||||
app.put('/api/settings/authentication',
|
app.put('/api/settings/authentication',
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
AdminMWs.updateAuthenticationSettings,
|
SettingsMWs.updateAuthenticationSettings,
|
||||||
RenderingMWs.renderOK
|
RenderingMWs.renderOK
|
||||||
);
|
);
|
||||||
app.put('/api/settings/thumbnail',
|
app.put('/api/settings/thumbnail',
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
AdminMWs.updateThumbnailSettings,
|
SettingsMWs.updateThumbnailSettings,
|
||||||
RenderingMWs.renderOK
|
RenderingMWs.renderOK
|
||||||
);
|
);
|
||||||
app.put('/api/settings/search',
|
app.put('/api/settings/search',
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
AdminMWs.updateSearchSettings,
|
SettingsMWs.updateSearchSettings,
|
||||||
RenderingMWs.renderOK
|
RenderingMWs.renderOK
|
||||||
);
|
);
|
||||||
app.put('/api/settings/faces',
|
app.put('/api/settings/faces',
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
AdminMWs.updateFacesSettings,
|
SettingsMWs.updateFacesSettings,
|
||||||
RenderingMWs.renderOK
|
RenderingMWs.renderOK
|
||||||
);
|
);
|
||||||
app.put('/api/settings/share',
|
app.put('/api/settings/share',
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
AdminMWs.updateShareSettings,
|
SettingsMWs.updateShareSettings,
|
||||||
RenderingMWs.renderOK
|
RenderingMWs.renderOK
|
||||||
);
|
);
|
||||||
app.put('/api/settings/randomPhoto',
|
app.put('/api/settings/randomPhoto',
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
AdminMWs.updateRandomPhotoSettings,
|
SettingsMWs.updateRandomPhotoSettings,
|
||||||
RenderingMWs.renderOK
|
RenderingMWs.renderOK
|
||||||
);
|
);
|
||||||
app.put('/api/settings/basic',
|
app.put('/api/settings/basic',
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
AdminMWs.updateBasicSettings,
|
SettingsMWs.updateBasicSettings,
|
||||||
RenderingMWs.renderOK
|
RenderingMWs.renderOK
|
||||||
);
|
);
|
||||||
app.put('/api/settings/other',
|
app.put('/api/settings/other',
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
AdminMWs.updateOtherSettings,
|
SettingsMWs.updateOtherSettings,
|
||||||
RenderingMWs.renderOK
|
RenderingMWs.renderOK
|
||||||
);
|
);
|
||||||
app.put('/api/settings/indexing',
|
app.put('/api/settings/indexing',
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
AdminMWs.updateIndexingSettings,
|
SettingsMWs.updateIndexingSettings,
|
||||||
RenderingMWs.renderOK
|
RenderingMWs.renderOK
|
||||||
);
|
);
|
||||||
app.put('/api/settings/tasks',
|
app.put('/api/settings/tasks',
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||||
AdminMWs.updateTasksSettings,
|
SettingsMWs.updateTasksSettings,
|
||||||
RenderingMWs.renderOK
|
RenderingMWs.renderOK
|
||||||
);
|
);
|
||||||
}
|
}
|
@ -5,24 +5,17 @@ import * as _http from 'http';
|
|||||||
import {Server as HttpServer} from 'http';
|
import {Server as HttpServer} from 'http';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import * as locale from 'locale';
|
import * as locale from 'locale';
|
||||||
import {PublicRouter} from './routes/PublicRouter';
|
|
||||||
import {UserRouter} from './routes/UserRouter';
|
|
||||||
import {GalleryRouter} from './routes/GalleryRouter';
|
|
||||||
import {AdminRouter} from './routes/AdminRouter';
|
|
||||||
import {ErrorRouter} from './routes/ErrorRouter';
|
|
||||||
import {SharingRouter} from './routes/SharingRouter';
|
|
||||||
import {ObjectManagers} from './model/ObjectManagers';
|
import {ObjectManagers} from './model/ObjectManagers';
|
||||||
import {Logger} from './Logger';
|
import {Logger} from './Logger';
|
||||||
import {Config} from '../common/config/private/Config';
|
import {Config} from '../common/config/private/Config';
|
||||||
import {DatabaseType} from '../common/config/private/IPrivateConfig';
|
|
||||||
import {LoggerRouter} from './routes/LoggerRouter';
|
import {LoggerRouter} from './routes/LoggerRouter';
|
||||||
import {ThumbnailGeneratorMWs} from './middlewares/thumbnail/ThumbnailGeneratorMWs';
|
import {ThumbnailGeneratorMWs} from './middlewares/thumbnail/ThumbnailGeneratorMWs';
|
||||||
import {DiskManager} from './model/DiskManger';
|
import {DiskManager} from './model/DiskManger';
|
||||||
import {NotificationRouter} from './routes/NotificationRouter';
|
|
||||||
import {ConfigDiagnostics} from './model/diagnostics/ConfigDiagnostics';
|
import {ConfigDiagnostics} from './model/diagnostics/ConfigDiagnostics';
|
||||||
import {Localizations} from './model/Localizations';
|
import {Localizations} from './model/Localizations';
|
||||||
import {CookieNames} from '../common/CookieNames';
|
import {CookieNames} from '../common/CookieNames';
|
||||||
import {PersonRouter} from './routes/PersonRouter';
|
import {Router} from './routes/Router';
|
||||||
|
import {ServerConfig} from '../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
const _session = require('cookie-session');
|
const _session = require('cookie-session');
|
||||||
|
|
||||||
@ -82,22 +75,13 @@ export class Server {
|
|||||||
Localizations.init();
|
Localizations.init();
|
||||||
|
|
||||||
this.app.use(locale(Config.Client.languages, 'en'));
|
this.app.use(locale(Config.Client.languages, 'en'));
|
||||||
if (Config.Server.Database.type !== DatabaseType.memory) {
|
if (Config.Server.Database.type !== ServerConfig.DatabaseType.memory) {
|
||||||
await ObjectManagers.InitSQLManagers();
|
await ObjectManagers.InitSQLManagers();
|
||||||
} else {
|
} else {
|
||||||
await ObjectManagers.InitMemoryManagers();
|
await ObjectManagers.InitMemoryManagers();
|
||||||
}
|
}
|
||||||
|
|
||||||
PublicRouter.route(this.app);
|
Router.route(this.app);
|
||||||
|
|
||||||
UserRouter.route(this.app);
|
|
||||||
GalleryRouter.route(this.app);
|
|
||||||
PersonRouter.route(this.app);
|
|
||||||
SharingRouter.route(this.app);
|
|
||||||
AdminRouter.route(this.app);
|
|
||||||
NotificationRouter.route(this.app);
|
|
||||||
|
|
||||||
ErrorRouter.route(this.app);
|
|
||||||
|
|
||||||
|
|
||||||
// Get PORT from environment and store in Express.
|
// Get PORT from environment and store in Express.
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import {SQLConnection} from '../backend/model/sql/SQLConnection';
|
import {SQLConnection} from '../backend/model/sql/SQLConnection';
|
||||||
import {Config} from '../common/config/private/Config';
|
import {Config} from '../common/config/private/Config';
|
||||||
import {DatabaseType, ReIndexingSensitivity} from '../common/config/private/IPrivateConfig';
|
|
||||||
import {ObjectManagers} from '../backend/model/ObjectManagers';
|
import {ObjectManagers} from '../backend/model/ObjectManagers';
|
||||||
import {DiskMangerWorker} from '../backend/model/threading/DiskMangerWorker';
|
import {DiskMangerWorker} from '../backend/model/threading/DiskMangerWorker';
|
||||||
import {IndexingManager} from '../backend/model/sql/IndexingManager';
|
import {IndexingManager} from '../backend/model/sql/IndexingManager';
|
||||||
@ -10,6 +9,7 @@ import {SearchTypes} from '../common/entities/AutoCompleteItem';
|
|||||||
import {Utils} from '../common/Utils';
|
import {Utils} from '../common/Utils';
|
||||||
import {GalleryManager} from '../backend/model/sql/GalleryManager';
|
import {GalleryManager} from '../backend/model/sql/GalleryManager';
|
||||||
import {DirectoryDTO} from '../common/entities/DirectoryDTO';
|
import {DirectoryDTO} from '../common/entities/DirectoryDTO';
|
||||||
|
import {ServerConfig} from '../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
export interface BenchmarkResult {
|
export interface BenchmarkResult {
|
||||||
duration: number;
|
duration: number;
|
||||||
@ -45,7 +45,7 @@ export class Benchmarks {
|
|||||||
async bmListDirectory(): Promise<BenchmarkResult> {
|
async bmListDirectory(): Promise<BenchmarkResult> {
|
||||||
const gm = new GalleryManager();
|
const gm = new GalleryManager();
|
||||||
await this.setupDB();
|
await this.setupDB();
|
||||||
Config.Server.Indexing.reIndexingSensitivity = ReIndexingSensitivity.low;
|
Config.Server.Indexing.reIndexingSensitivity = ServerConfig.ReIndexingSensitivity.low;
|
||||||
return await this.benchmark(() => gm.listDirectory('./'));
|
return await this.benchmark(() => gm.listDirectory('./'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ export class Benchmarks {
|
|||||||
if (fs.existsSync(this.dbPath)) {
|
if (fs.existsSync(this.dbPath)) {
|
||||||
fs.unlinkSync(this.dbPath);
|
fs.unlinkSync(this.dbPath);
|
||||||
}
|
}
|
||||||
Config.Server.Database.type = DatabaseType.sqlite;
|
Config.Server.Database.type = ServerConfig.DatabaseType.sqlite;
|
||||||
Config.Server.Database.sqlite.storage = this.dbPath;
|
Config.Server.Database.sqlite.storage = this.dbPath;
|
||||||
await ObjectManagers.InitSQLManagers();
|
await ObjectManagers.InitSQLManagers();
|
||||||
};
|
};
|
||||||
|
@ -10,19 +10,29 @@ export const SupportedFormats = {
|
|||||||
'mp4',
|
'mp4',
|
||||||
'webm',
|
'webm',
|
||||||
'ogv',
|
'ogv',
|
||||||
'ogg',
|
'ogg'
|
||||||
'avi'
|
|
||||||
],
|
],
|
||||||
MetaFiles: [
|
MetaFiles: [
|
||||||
'gpx'
|
'gpx'
|
||||||
],
|
],
|
||||||
|
TranscodeNeed: {
|
||||||
|
Photos: <string[]>[],
|
||||||
|
Videos: [
|
||||||
|
'avi',
|
||||||
|
'mkv',
|
||||||
|
'mov',
|
||||||
|
'wmv',
|
||||||
|
'flv'
|
||||||
|
],
|
||||||
|
},
|
||||||
WithDots: {
|
WithDots: {
|
||||||
Photos: <string[]>[],
|
Photos: <string[]>[],
|
||||||
Videos: <string[]>[],
|
Videos: <string[]>[],
|
||||||
MetaFiles: <string[]>[],
|
MetaFiles: <string[]>[],
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
SupportedFormats.Photos = SupportedFormats.Photos.concat(SupportedFormats.TranscodeNeed.Photos);
|
||||||
|
SupportedFormats.Videos = SupportedFormats.Videos.concat(SupportedFormats.TranscodeNeed.Videos);
|
||||||
SupportedFormats.WithDots.Photos = SupportedFormats.Photos.map(f => '.' + f);
|
SupportedFormats.WithDots.Photos = SupportedFormats.Photos.map(f => '.' + f);
|
||||||
SupportedFormats.WithDots.Videos = SupportedFormats.Videos.map(f => '.' + f);
|
SupportedFormats.WithDots.Videos = SupportedFormats.Videos.map(f => '.' + f);
|
||||||
SupportedFormats.WithDots.MetaFiles = SupportedFormats.MetaFiles.map(f => '.' + f);
|
SupportedFormats.WithDots.MetaFiles = SupportedFormats.MetaFiles.map(f => '.' + f);
|
||||||
|
@ -1,114 +1,117 @@
|
|||||||
import {ClientConfig} from '../public/ConfigClass';
|
import {ClientConfig} from '../public/ConfigClass';
|
||||||
import {TaskScheduleDTO} from '../../entities/task/TaskScheduleDTO';
|
import {TaskScheduleDTO} from '../../entities/task/TaskScheduleDTO';
|
||||||
|
|
||||||
export enum DatabaseType {
|
export module ServerConfig {
|
||||||
memory = 1, mysql = 2, sqlite = 3
|
export enum DatabaseType {
|
||||||
}
|
memory = 1, mysql = 2, sqlite = 3
|
||||||
|
}
|
||||||
|
|
||||||
export enum LogLevel {
|
export enum LogLevel {
|
||||||
error = 1, warn = 2, info = 3, verbose = 4, debug = 5, silly = 6
|
error = 1, warn = 2, info = 3, verbose = 4, debug = 5, silly = 6
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SQLLogLevel {
|
export enum SQLLogLevel {
|
||||||
none = 1, error = 2, all = 3
|
none = 1, error = 2, all = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ThumbnailProcessingLib {
|
export enum ThumbnailProcessingLib {
|
||||||
Jimp = 1,
|
Jimp = 1,
|
||||||
gm = 2,
|
gm = 2,
|
||||||
sharp = 3
|
sharp = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MySQLConfig {
|
export interface MySQLConfig {
|
||||||
host: string;
|
host: string;
|
||||||
database: string;
|
database: string;
|
||||||
username: string;
|
username: string;
|
||||||
password: string;
|
password: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SQLiteConfig {
|
export interface SQLiteConfig {
|
||||||
storage: string;
|
storage: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DataBaseConfig {
|
export interface DataBaseConfig {
|
||||||
type: DatabaseType;
|
type: DatabaseType;
|
||||||
mysql?: MySQLConfig;
|
mysql?: MySQLConfig;
|
||||||
sqlite?: SQLiteConfig;
|
sqlite?: SQLiteConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ThumbnailConfig {
|
export interface ThumbnailConfig {
|
||||||
folder: string;
|
folder: string;
|
||||||
processingLibrary: ThumbnailProcessingLib;
|
processingLibrary: ThumbnailProcessingLib;
|
||||||
qualityPriority: boolean;
|
qualityPriority: boolean;
|
||||||
personFaceMargin: number; // in ration [0-1]
|
personFaceMargin: number; // in ration [0-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SharingConfig {
|
export interface SharingConfig {
|
||||||
updateTimeout: number;
|
updateTimeout: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ReIndexingSensitivity {
|
export enum ReIndexingSensitivity {
|
||||||
low = 1, medium = 2, high = 3
|
low = 1, medium = 2, high = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IndexingConfig {
|
export interface IndexingConfig {
|
||||||
folderPreviewSize: number;
|
folderPreviewSize: number;
|
||||||
cachedFolderTimeout: number; // Do not rescans the folder if seems ok
|
cachedFolderTimeout: number; // Do not rescans the folder if seems ok
|
||||||
reIndexingSensitivity: ReIndexingSensitivity;
|
reIndexingSensitivity: ReIndexingSensitivity;
|
||||||
excludeFolderList: string[];
|
excludeFolderList: string[];
|
||||||
excludeFileList: string[];
|
excludeFileList: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ThreadingConfig {
|
export interface ThreadingConfig {
|
||||||
enable: boolean;
|
enable: boolean;
|
||||||
thumbnailThreads: number;
|
thumbnailThreads: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DuplicatesConfig {
|
export interface DuplicatesConfig {
|
||||||
listingLimit: number; // maximum number of duplicates to list
|
listingLimit: number; // maximum number of duplicates to list
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LogConfig {
|
export interface LogConfig {
|
||||||
level: LogLevel;
|
level: LogLevel;
|
||||||
sqlLevel: SQLLogLevel;
|
sqlLevel: SQLLogLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TaskConfig {
|
export interface TaskConfig {
|
||||||
scheduled: TaskScheduleDTO[];
|
scheduled: TaskScheduleDTO[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export type codecType = 'libvpx-vp9' | 'libx264' | 'libvpx' | 'libx265';
|
export type codecType = 'libvpx-vp9' | 'libx264' | 'libvpx' | 'libx265';
|
||||||
export type resolutionType = 240 | 360 | 480 | 720 | 1080 | 1440 | 2160 | 4320;
|
export type resolutionType = 240 | 360 | 480 | 720 | 1080 | 1440 | 2160 | 4320;
|
||||||
export type formatType = 'mp4' | 'webm';
|
export type formatType = 'mp4' | 'webm';
|
||||||
|
|
||||||
export interface VideoConfig {
|
export interface VideoConfig {
|
||||||
transcoding: {
|
transcoding: {
|
||||||
bitRate: number,
|
bitRate: number,
|
||||||
resolution: resolutionType,
|
resolution: resolutionType,
|
||||||
fps: number,
|
fps: number,
|
||||||
codec: codecType,
|
codec: codecType,
|
||||||
format: formatType
|
format: formatType
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ServerConfig {
|
|
||||||
port: number;
|
export interface Config {
|
||||||
host: string;
|
port: number;
|
||||||
imagesFolder: string;
|
host: string;
|
||||||
Thumbnail: ThumbnailConfig;
|
imagesFolder: string;
|
||||||
Threading: ThreadingConfig;
|
Thumbnail: ThumbnailConfig;
|
||||||
Database: DataBaseConfig;
|
Threading: ThreadingConfig;
|
||||||
Sharing: SharingConfig;
|
Database: DataBaseConfig;
|
||||||
sessionTimeout: number;
|
Sharing: SharingConfig;
|
||||||
Indexing: IndexingConfig;
|
sessionTimeout: number;
|
||||||
photoMetadataSize: number;
|
Indexing: IndexingConfig;
|
||||||
Duplicates: DuplicatesConfig;
|
photoMetadataSize: number;
|
||||||
Log: LogConfig;
|
Duplicates: DuplicatesConfig;
|
||||||
Tasks: TaskConfig;
|
Log: LogConfig;
|
||||||
Video: VideoConfig;
|
Tasks: TaskConfig;
|
||||||
|
Video: VideoConfig;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPrivateConfig {
|
export interface IPrivateConfig {
|
||||||
Server: ServerConfig;
|
Server: ServerConfig.Config;
|
||||||
Client: ClientConfig.Config;
|
Client: ClientConfig.Config;
|
||||||
}
|
}
|
||||||
|
@ -1,41 +1,35 @@
|
|||||||
import {PublicConfigClass} from '../public/ConfigClass';
|
import {PublicConfigClass} from '../public/ConfigClass';
|
||||||
import {
|
import {IPrivateConfig, ServerConfig,} from './IPrivateConfig';
|
||||||
DatabaseType,
|
|
||||||
IPrivateConfig,
|
|
||||||
LogLevel,
|
|
||||||
ReIndexingSensitivity,
|
|
||||||
ServerConfig,
|
|
||||||
SQLLogLevel,
|
|
||||||
ThumbnailProcessingLib
|
|
||||||
} from './IPrivateConfig';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import {ConfigLoader} from 'typeconfig';
|
import {ConfigLoader} from 'typeconfig';
|
||||||
import {Utils} from '../../Utils';
|
import {Utils} from '../../Utils';
|
||||||
import {UserRoles} from '../../entities/UserDTO';
|
import {UserRoles} from '../../entities/UserDTO';
|
||||||
|
import {TaskTriggerType} from '../../entities/task/TaskScheduleDTO';
|
||||||
|
import {DefaultsTasks} from '../../entities/task/TaskDTO';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This configuration will be only at backend
|
* This configuration will be only at backend
|
||||||
*/
|
*/
|
||||||
export class PrivateConfigClass extends PublicConfigClass implements IPrivateConfig {
|
export class PrivateConfigClass extends PublicConfigClass implements IPrivateConfig {
|
||||||
|
|
||||||
public Server: ServerConfig = {
|
public Server: ServerConfig.Config = {
|
||||||
port: 80,
|
port: 80,
|
||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
imagesFolder: 'demo/images',
|
imagesFolder: 'demo/images',
|
||||||
Thumbnail: {
|
Thumbnail: {
|
||||||
folder: 'demo/TEMP',
|
folder: 'demo/TEMP',
|
||||||
processingLibrary: ThumbnailProcessingLib.sharp,
|
processingLibrary: ServerConfig.ThumbnailProcessingLib.sharp,
|
||||||
qualityPriority: true,
|
qualityPriority: true,
|
||||||
personFaceMargin: 0.6
|
personFaceMargin: 0.6
|
||||||
},
|
},
|
||||||
Log: {
|
Log: {
|
||||||
level: LogLevel.info,
|
level: ServerConfig.LogLevel.info,
|
||||||
sqlLevel: SQLLogLevel.error
|
sqlLevel: ServerConfig.SQLLogLevel.error
|
||||||
},
|
},
|
||||||
sessionTimeout: 1000 * 60 * 60 * 24 * 7,
|
sessionTimeout: 1000 * 60 * 60 * 24 * 7,
|
||||||
photoMetadataSize: 512 * 1024,
|
photoMetadataSize: 512 * 1024,
|
||||||
Database: {
|
Database: {
|
||||||
type: DatabaseType.sqlite,
|
type: ServerConfig.DatabaseType.sqlite,
|
||||||
mysql: {
|
mysql: {
|
||||||
host: '',
|
host: '',
|
||||||
username: '',
|
username: '',
|
||||||
@ -57,7 +51,7 @@ export class PrivateConfigClass extends PublicConfigClass implements IPrivateCon
|
|||||||
Indexing: {
|
Indexing: {
|
||||||
folderPreviewSize: 2,
|
folderPreviewSize: 2,
|
||||||
cachedFolderTimeout: 1000 * 60 * 60,
|
cachedFolderTimeout: 1000 * 60 * 60,
|
||||||
reIndexingSensitivity: ReIndexingSensitivity.low,
|
reIndexingSensitivity: ServerConfig.ReIndexingSensitivity.low,
|
||||||
excludeFolderList: [],
|
excludeFolderList: [],
|
||||||
excludeFileList: []
|
excludeFileList: []
|
||||||
},
|
},
|
||||||
@ -65,7 +59,19 @@ export class PrivateConfigClass extends PublicConfigClass implements IPrivateCon
|
|||||||
listingLimit: 1000
|
listingLimit: 1000
|
||||||
},
|
},
|
||||||
Tasks: {
|
Tasks: {
|
||||||
scheduled: []
|
scheduled: [{
|
||||||
|
taskName: DefaultsTasks[DefaultsTasks['Database Reset']],
|
||||||
|
config: {},
|
||||||
|
trigger: {type: TaskTriggerType.never}
|
||||||
|
}, {
|
||||||
|
taskName: DefaultsTasks[DefaultsTasks.Indexing],
|
||||||
|
config: {},
|
||||||
|
trigger: {type: TaskTriggerType.never}
|
||||||
|
}, {
|
||||||
|
taskName: DefaultsTasks[DefaultsTasks['Video Converting']],
|
||||||
|
config: {},
|
||||||
|
trigger: {type: TaskTriggerType.never}
|
||||||
|
}]
|
||||||
},
|
},
|
||||||
Video: {
|
Video: {
|
||||||
transcoding: {
|
transcoding: {
|
||||||
@ -79,9 +85,9 @@ export class PrivateConfigClass extends PublicConfigClass implements IPrivateCon
|
|||||||
};
|
};
|
||||||
private ConfigLoader: any;
|
private ConfigLoader: any;
|
||||||
|
|
||||||
public setDatabaseType(type: DatabaseType) {
|
public setDatabaseType(type: ServerConfig.DatabaseType) {
|
||||||
this.Server.Database.type = type;
|
this.Server.Database.type = type;
|
||||||
if (type === DatabaseType.memory) {
|
if (type === ServerConfig.DatabaseType.memory) {
|
||||||
this.Client.Search.enabled = false;
|
this.Client.Search.enabled = false;
|
||||||
this.Client.Sharing.enabled = false;
|
this.Client.Sharing.enabled = false;
|
||||||
}
|
}
|
||||||
@ -101,10 +107,10 @@ export class PrivateConfigClass extends PublicConfigClass implements IPrivateCon
|
|||||||
if (Utils.enumToArray(UserRoles).map(r => r.key).indexOf(this.Client.unAuthenticatedUserRole) === -1) {
|
if (Utils.enumToArray(UserRoles).map(r => r.key).indexOf(this.Client.unAuthenticatedUserRole) === -1) {
|
||||||
throw new Error('Unknown user role for Client.unAuthenticatedUserRole, found: ' + this.Client.unAuthenticatedUserRole);
|
throw new Error('Unknown user role for Client.unAuthenticatedUserRole, found: ' + this.Client.unAuthenticatedUserRole);
|
||||||
}
|
}
|
||||||
if (Utils.enumToArray(LogLevel).map(r => r.key).indexOf(this.Server.Log.level) === -1) {
|
if (Utils.enumToArray(ServerConfig.LogLevel).map(r => r.key).indexOf(this.Server.Log.level) === -1) {
|
||||||
throw new Error('Unknown Server.log.level, found: ' + this.Server.Log.level);
|
throw new Error('Unknown Server.log.level, found: ' + this.Server.Log.level);
|
||||||
}
|
}
|
||||||
if (Utils.enumToArray(SQLLogLevel).map(r => r.key).indexOf(this.Server.Log.sqlLevel) === -1) {
|
if (Utils.enumToArray(ServerConfig.SQLLogLevel).map(r => r.key).indexOf(this.Server.Log.sqlLevel) === -1) {
|
||||||
throw new Error('Unknown Server.log.level, found: ' + this.Server.Log.sqlLevel);
|
throw new Error('Unknown Server.log.level, found: ' + this.Server.Log.sqlLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import {UserRoles} from '../../entities/UserDTO';
|
|||||||
export module ClientConfig {
|
export module ClientConfig {
|
||||||
|
|
||||||
export enum MapProviders {
|
export enum MapProviders {
|
||||||
OpenStreetMap, Mapbox, Custom
|
OpenStreetMap = 0, Mapbox = 1, Custom = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AutoCompleteConfig {
|
export interface AutoCompleteConfig {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {ClientConfig} from '../../config/public/ConfigClass';
|
import {ClientConfig} from '../../config/public/ConfigClass';
|
||||||
import {ThreadingConfig} from '../../config/private/IPrivateConfig';
|
import {ServerConfig} from '../../config/private/IPrivateConfig';
|
||||||
|
|
||||||
export interface OtherConfigDTO {
|
export interface OtherConfigDTO {
|
||||||
Server: ThreadingConfig;
|
Server: ServerConfig.ThreadingConfig;
|
||||||
Client: ClientConfig.OtherConfig;
|
Client: ClientConfig.OtherConfig;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ export interface PeriodicTaskTrigger extends TaskTrigger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface TaskScheduleDTO {
|
export interface TaskScheduleDTO {
|
||||||
priority: number;
|
|
||||||
taskName: string;
|
taskName: string;
|
||||||
config: any;
|
config: any;
|
||||||
trigger: NeverTaskTrigger | ScheduledTaskTrigger | PeriodicTaskTrigger;
|
trigger: NeverTaskTrigger | ScheduledTaskTrigger | PeriodicTaskTrigger;
|
||||||
|
@ -47,7 +47,7 @@ import {TooltipModule} from 'ngx-bootstrap/tooltip';
|
|||||||
import {BsDropdownModule} from 'ngx-bootstrap/dropdown';
|
import {BsDropdownModule} from 'ngx-bootstrap/dropdown';
|
||||||
import {CollapseModule} from 'ngx-bootstrap/collapse';
|
import {CollapseModule} from 'ngx-bootstrap/collapse';
|
||||||
import {PopoverModule} from 'ngx-bootstrap/popover';
|
import {PopoverModule} from 'ngx-bootstrap/popover';
|
||||||
import {ThumbnailSettingsComponent} from './ui/settings/thumbnail/thumbanil.settings.component';
|
import {ThumbnailSettingsComponent} from './ui/settings/thumbnail/thumbnail.settings.component';
|
||||||
import {SearchSettingsComponent} from './ui/settings/search/search.settings.component';
|
import {SearchSettingsComponent} from './ui/settings/search/search.settings.component';
|
||||||
import {SettingsService} from './ui/settings/settings.service';
|
import {SettingsService} from './ui/settings/settings.service';
|
||||||
import {ShareSettingsComponent} from './ui/settings/share/share.settings.component';
|
import {ShareSettingsComponent} from './ui/settings/share/share.settings.component';
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {AuthenticationService} from '../../../model/network/authentication.service';
|
import {AuthenticationService} from '../../../model/network/authentication.service';
|
||||||
import {DataBaseConfig, DatabaseType} from '../../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {Utils} from '../../../../../common/Utils';
|
import {Utils} from '../../../../../common/Utils';
|
||||||
import {NotificationService} from '../../../model/notification.service';
|
import {NotificationService} from '../../../model/notification.service';
|
||||||
import {NavigationService} from '../../../model/navigation.service';
|
import {NavigationService} from '../../../model/navigation.service';
|
||||||
import {SettingsComponent} from '../_abstract/abstract.settings.component';
|
import {SettingsComponent} from '../_abstract/abstract.settings.component';
|
||||||
import {DatabaseSettingsService} from './database.settings.service';
|
import {DatabaseSettingsService} from './database.settings.service';
|
||||||
import {I18n} from '@ngx-translate/i18n-polyfill';
|
import {I18n} from '@ngx-translate/i18n-polyfill';
|
||||||
|
import {ServerConfig} from '../../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-settings-database',
|
selector: 'app-settings-database',
|
||||||
@ -15,7 +15,7 @@ import {I18n} from '@ngx-translate/i18n-polyfill';
|
|||||||
'./../_abstract/abstract.settings.component.css'],
|
'./../_abstract/abstract.settings.component.css'],
|
||||||
providers: [DatabaseSettingsService],
|
providers: [DatabaseSettingsService],
|
||||||
})
|
})
|
||||||
export class DatabaseSettingsComponent extends SettingsComponent<DataBaseConfig> implements OnInit {
|
export class DatabaseSettingsComponent extends SettingsComponent<ServerConfig.DataBaseConfig> implements OnInit {
|
||||||
|
|
||||||
public types: { key: number, value: string }[] = [];
|
public types: { key: number, value: string }[] = [];
|
||||||
public DatabaseType: any;
|
public DatabaseType: any;
|
||||||
@ -30,8 +30,8 @@ export class DatabaseSettingsComponent extends SettingsComponent<DataBaseConfig>
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
this.types = Utils.enumToArray(DatabaseType);
|
this.types = Utils.enumToArray(ServerConfig.DatabaseType);
|
||||||
this.DatabaseType = DatabaseType;
|
this.DatabaseType = ServerConfig.DatabaseType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {NetworkService} from '../../../model/network/network.service';
|
import {NetworkService} from '../../../model/network/network.service';
|
||||||
import {DataBaseConfig} from '../../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {AbstractSettingsService} from '../_abstract/abstract.settings.service';
|
import {AbstractSettingsService} from '../_abstract/abstract.settings.service';
|
||||||
import {SettingsService} from '../settings.service';
|
import {SettingsService} from '../settings.service';
|
||||||
|
import {ServerConfig} from '../../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DatabaseSettingsService extends AbstractSettingsService<DataBaseConfig> {
|
export class DatabaseSettingsService extends AbstractSettingsService<ServerConfig.DataBaseConfig> {
|
||||||
constructor(private _networkService: NetworkService,
|
constructor(private _networkService: NetworkService,
|
||||||
_settingsService: SettingsService) {
|
_settingsService: SettingsService) {
|
||||||
super(_settingsService);
|
super(_settingsService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public updateSettings(settings: DataBaseConfig): Promise<void> {
|
public updateSettings(settings: ServerConfig.DataBaseConfig): Promise<void> {
|
||||||
return this._networkService.putJson('/settings/database', {settings: settings});
|
return this._networkService.putJson('/settings/database', {settings: settings});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {NetworkService} from '../../../model/network/network.service';
|
import {NetworkService} from '../../../model/network/network.service';
|
||||||
import {DatabaseType} from '../../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {ClientConfig} from '../../../../../common/config/public/ConfigClass';
|
import {ClientConfig} from '../../../../../common/config/public/ConfigClass';
|
||||||
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 {ServerConfig} from '../../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FacesSettingsService extends AbstractSettingsService<ClientConfig.FacesConfig> {
|
export class FacesSettingsService extends AbstractSettingsService<ClientConfig.FacesConfig> {
|
||||||
@ -13,7 +13,7 @@ export class FacesSettingsService extends AbstractSettingsService<ClientConfig.F
|
|||||||
}
|
}
|
||||||
|
|
||||||
public isSupported(): boolean {
|
public isSupported(): boolean {
|
||||||
return this._settingsService.settings.value.Server.Database.type !== DatabaseType.memory &&
|
return this._settingsService.settings.value.Server.Database.type !== ServerConfig.DatabaseType.memory &&
|
||||||
this._settingsService.settings.value.Client.Search.enabled === true;
|
this._settingsService.settings.value.Client.Search.enabled === true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,12 +4,12 @@ import {AuthenticationService} from '../../../model/network/authentication.servi
|
|||||||
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 {ErrorDTO} from '../../../../../common/entities/Error';
|
import {ErrorDTO} from '../../../../../common/entities/Error';
|
||||||
import {IndexingConfig, ReIndexingSensitivity} from '../../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {SettingsComponent} from '../_abstract/abstract.settings.component';
|
import {SettingsComponent} from '../_abstract/abstract.settings.component';
|
||||||
import {Utils} from '../../../../../common/Utils';
|
import {Utils} from '../../../../../common/Utils';
|
||||||
import {I18n} from '@ngx-translate/i18n-polyfill';
|
import {I18n} from '@ngx-translate/i18n-polyfill';
|
||||||
import {ScheduledTasksService} from '../scheduled-tasks.service';
|
import {ScheduledTasksService} from '../scheduled-tasks.service';
|
||||||
import {DefaultsTasks} from '../../../../../common/entities/task/TaskDTO';
|
import {DefaultsTasks} from '../../../../../common/entities/task/TaskDTO';
|
||||||
|
import {ServerConfig} from '../../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-settings-indexing',
|
selector: 'app-settings-indexing',
|
||||||
@ -18,7 +18,7 @@ import {DefaultsTasks} from '../../../../../common/entities/task/TaskDTO';
|
|||||||
'./../_abstract/abstract.settings.component.css'],
|
'./../_abstract/abstract.settings.component.css'],
|
||||||
providers: [IndexingSettingsService],
|
providers: [IndexingSettingsService],
|
||||||
})
|
})
|
||||||
export class IndexingSettingsComponent extends SettingsComponent<IndexingConfig, IndexingSettingsService>
|
export class IndexingSettingsComponent extends SettingsComponent<ServerConfig.IndexingConfig, IndexingSettingsService>
|
||||||
implements OnInit, OnDestroy {
|
implements OnInit, OnDestroy {
|
||||||
|
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ export class IndexingSettingsComponent extends SettingsComponent<IndexingConfig,
|
|||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
this.tasksService.subscribeToProgress();
|
this.tasksService.subscribeToProgress();
|
||||||
this.types = Utils
|
this.types = Utils
|
||||||
.enumToArray(ReIndexingSensitivity);
|
.enumToArray(ServerConfig.ReIndexingSensitivity);
|
||||||
this.types.forEach(v => {
|
this.types.forEach(v => {
|
||||||
switch (v.value) {
|
switch (v.value) {
|
||||||
case 'low':
|
case 'low':
|
||||||
|
@ -2,14 +2,14 @@ import {Injectable} from '@angular/core';
|
|||||||
import {NetworkService} from '../../../model/network/network.service';
|
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 {DatabaseType, IndexingConfig} from '../../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {BehaviorSubject} from 'rxjs';
|
import {BehaviorSubject} from 'rxjs';
|
||||||
import {StatisticDTO} from '../../../../../common/entities/settings/StatisticDTO';
|
import {StatisticDTO} from '../../../../../common/entities/settings/StatisticDTO';
|
||||||
import {ScheduledTasksService} from '../scheduled-tasks.service';
|
import {ScheduledTasksService} from '../scheduled-tasks.service';
|
||||||
import {DefaultsTasks} from '../../../../../common/entities/task/TaskDTO';
|
import {DefaultsTasks} from '../../../../../common/entities/task/TaskDTO';
|
||||||
|
import {ServerConfig} from '../../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class IndexingSettingsService extends AbstractSettingsService<IndexingConfig> {
|
export class IndexingSettingsService extends AbstractSettingsService<ServerConfig.IndexingConfig> {
|
||||||
|
|
||||||
|
|
||||||
public statistic: BehaviorSubject<StatisticDTO>;
|
public statistic: BehaviorSubject<StatisticDTO>;
|
||||||
@ -35,13 +35,13 @@ export class IndexingSettingsService extends AbstractSettingsService<IndexingCon
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateSettings(settings: IndexingConfig): Promise<void> {
|
public updateSettings(settings: ServerConfig.IndexingConfig): Promise<void> {
|
||||||
return this._networkService.putJson('/settings/indexing', {settings: settings});
|
return this._networkService.putJson('/settings/indexing', {settings: settings});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public isSupported(): boolean {
|
public isSupported(): boolean {
|
||||||
return this._settingsService.settings.value.Server.Database.type !== DatabaseType.memory;
|
return this._settingsService.settings.value.Server.Database.type !== ServerConfig.DatabaseType.memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {NetworkService} from '../../../model/network/network.service';
|
import {NetworkService} from '../../../model/network/network.service';
|
||||||
import {DatabaseType} from '../../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {ClientConfig} from '../../../../../common/config/public/ConfigClass';
|
import {ClientConfig} from '../../../../../common/config/public/ConfigClass';
|
||||||
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 {ServerConfig} from '../../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RandomPhotoSettingsService extends AbstractSettingsService<ClientConfig.SharingConfig> {
|
export class RandomPhotoSettingsService extends AbstractSettingsService<ClientConfig.SharingConfig> {
|
||||||
@ -19,7 +19,7 @@ export class RandomPhotoSettingsService extends AbstractSettingsService<ClientCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public isSupported(): boolean {
|
public isSupported(): boolean {
|
||||||
return this._settingsService.settings.value.Server.Database.type !== DatabaseType.memory;
|
return this._settingsService.settings.value.Server.Database.type !== ServerConfig.DatabaseType.memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateSettings(settings: ClientConfig.SharingConfig): Promise<void> {
|
public updateSettings(settings: ClientConfig.SharingConfig): Promise<void> {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {NetworkService} from '../../../model/network/network.service';
|
import {NetworkService} from '../../../model/network/network.service';
|
||||||
import {DatabaseType} from '../../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {ClientConfig} from '../../../../../common/config/public/ConfigClass';
|
import {ClientConfig} from '../../../../../common/config/public/ConfigClass';
|
||||||
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 {ServerConfig} from '../../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SearchSettingsService extends AbstractSettingsService<ClientConfig.SearchConfig> {
|
export class SearchSettingsService extends AbstractSettingsService<ClientConfig.SearchConfig> {
|
||||||
@ -13,7 +13,7 @@ export class SearchSettingsService extends AbstractSettingsService<ClientConfig.
|
|||||||
}
|
}
|
||||||
|
|
||||||
public isSupported(): boolean {
|
public isSupported(): boolean {
|
||||||
return this._settingsService.settings.value.Server.Database.type !== DatabaseType.memory;
|
return this._settingsService.settings.value.Server.Database.type !== ServerConfig.DatabaseType.memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateSettings(settings: ClientConfig.SearchConfig): Promise<void> {
|
public updateSettings(settings: ClientConfig.SearchConfig): Promise<void> {
|
||||||
|
@ -1,17 +1,10 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {BehaviorSubject} from 'rxjs';
|
import {BehaviorSubject} from 'rxjs';
|
||||||
import {
|
|
||||||
DatabaseType,
|
|
||||||
IPrivateConfig,
|
|
||||||
LogLevel,
|
|
||||||
ReIndexingSensitivity,
|
|
||||||
SQLLogLevel,
|
|
||||||
ThumbnailProcessingLib
|
|
||||||
} from '../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {NetworkService} from '../../model/network/network.service';
|
import {NetworkService} from '../../model/network/network.service';
|
||||||
import {SortingMethods} from '../../../../common/entities/SortingMethods';
|
import {SortingMethods} from '../../../../common/entities/SortingMethods';
|
||||||
import {UserRoles} from '../../../../common/entities/UserDTO';
|
import {UserRoles} from '../../../../common/entities/UserDTO';
|
||||||
import {ClientConfig} from '../../../../common/config/public/ConfigClass';
|
import {ClientConfig} from '../../../../common/config/public/ConfigClass';
|
||||||
|
import {IPrivateConfig, ServerConfig} from '../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SettingsService {
|
export class SettingsService {
|
||||||
@ -83,11 +76,11 @@ export class SettingsService {
|
|||||||
},
|
},
|
||||||
Server: {
|
Server: {
|
||||||
Database: {
|
Database: {
|
||||||
type: DatabaseType.memory
|
type: ServerConfig.DatabaseType.memory
|
||||||
},
|
},
|
||||||
Log: {
|
Log: {
|
||||||
level: LogLevel.info,
|
level: ServerConfig.LogLevel.info,
|
||||||
sqlLevel: SQLLogLevel.error
|
sqlLevel: ServerConfig.SQLLogLevel.error
|
||||||
},
|
},
|
||||||
Sharing: {
|
Sharing: {
|
||||||
updateTimeout: 2000
|
updateTimeout: 2000
|
||||||
@ -99,7 +92,7 @@ export class SettingsService {
|
|||||||
personFaceMargin: 0.1,
|
personFaceMargin: 0.1,
|
||||||
folder: '',
|
folder: '',
|
||||||
qualityPriority: true,
|
qualityPriority: true,
|
||||||
processingLibrary: ThumbnailProcessingLib.sharp
|
processingLibrary: ServerConfig.ThumbnailProcessingLib.sharp
|
||||||
},
|
},
|
||||||
Threading: {
|
Threading: {
|
||||||
enable: true,
|
enable: true,
|
||||||
@ -109,7 +102,7 @@ export class SettingsService {
|
|||||||
Indexing: {
|
Indexing: {
|
||||||
cachedFolderTimeout: 0,
|
cachedFolderTimeout: 0,
|
||||||
folderPreviewSize: 0,
|
folderPreviewSize: 0,
|
||||||
reIndexingSensitivity: ReIndexingSensitivity.medium,
|
reIndexingSensitivity: ServerConfig.ReIndexingSensitivity.medium,
|
||||||
excludeFolderList: [],
|
excludeFolderList: [],
|
||||||
excludeFileList: []
|
excludeFileList: []
|
||||||
},
|
},
|
||||||
@ -134,7 +127,7 @@ export class SettingsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getSettings(): Promise<void> {
|
public async getSettings(): Promise<void> {
|
||||||
this.settings.next(await <Promise<IPrivateConfig>>this._networkService.getJson('/settings'));
|
this.settings.next(await this._networkService.getJson<Promise<IPrivateConfig>>('/settings'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {NetworkService} from '../../../model/network/network.service';
|
import {NetworkService} from '../../../model/network/network.service';
|
||||||
import {DatabaseType} from '../../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {ClientConfig} from '../../../../../common/config/public/ConfigClass';
|
import {ClientConfig} from '../../../../../common/config/public/ConfigClass';
|
||||||
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 {ServerConfig} from '../../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ShareSettingsService extends AbstractSettingsService<ClientConfig.SharingConfig> {
|
export class ShareSettingsService extends AbstractSettingsService<ClientConfig.SharingConfig> {
|
||||||
@ -15,7 +15,7 @@ export class ShareSettingsService extends AbstractSettingsService<ClientConfig.S
|
|||||||
|
|
||||||
|
|
||||||
public isSupported(): boolean {
|
public isSupported(): boolean {
|
||||||
return this._settingsService.settings.value.Server.Database.type !== DatabaseType.memory &&
|
return this._settingsService.settings.value.Server.Database.type !== ServerConfig.DatabaseType.memory &&
|
||||||
this._settingsService.settings.value.Client.authenticationRequired === true;
|
this._settingsService.settings.value.Client.authenticationRequired === true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ import {TasksSettingsService} from './tasks.settings.service';
|
|||||||
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 {TaskConfig} from '../../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {SettingsComponent} from '../_abstract/abstract.settings.component';
|
import {SettingsComponent} from '../_abstract/abstract.settings.component';
|
||||||
import {I18n} from '@ngx-translate/i18n-polyfill';
|
import {I18n} from '@ngx-translate/i18n-polyfill';
|
||||||
import {ErrorDTO} from '../../../../../common/entities/Error';
|
import {ErrorDTO} from '../../../../../common/entities/Error';
|
||||||
@ -16,6 +15,7 @@ import {
|
|||||||
TaskTriggerType
|
TaskTriggerType
|
||||||
} from '../../../../../common/entities/task/TaskScheduleDTO';
|
} from '../../../../../common/entities/task/TaskScheduleDTO';
|
||||||
import {Utils} from '../../../../../common/Utils';
|
import {Utils} from '../../../../../common/Utils';
|
||||||
|
import {ServerConfig} from '../../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-settings-tasks',
|
selector: 'app-settings-tasks',
|
||||||
@ -24,7 +24,7 @@ import {Utils} from '../../../../../common/Utils';
|
|||||||
'./../_abstract/abstract.settings.component.css'],
|
'./../_abstract/abstract.settings.component.css'],
|
||||||
providers: [TasksSettingsService]
|
providers: [TasksSettingsService]
|
||||||
})
|
})
|
||||||
export class TasksSettingsComponent extends SettingsComponent<TaskConfig, TasksSettingsService>
|
export class TasksSettingsComponent extends SettingsComponent<ServerConfig.TaskConfig, TasksSettingsService>
|
||||||
implements OnInit, OnDestroy, OnChanges {
|
implements OnInit, OnDestroy, OnChanges {
|
||||||
|
|
||||||
disableButtons = false;
|
disableButtons = false;
|
||||||
@ -152,7 +152,6 @@ export class TasksSettingsComponent extends SettingsComponent<TaskConfig, TasksS
|
|||||||
this.settings.scheduled.push({
|
this.settings.scheduled.push({
|
||||||
taskName: this._settingsService.availableTasks.value[0].Name,
|
taskName: this._settingsService.availableTasks.value[0].Name,
|
||||||
config: {},
|
config: {},
|
||||||
priority: 0,
|
|
||||||
trigger: {
|
trigger: {
|
||||||
type: TaskTriggerType.never
|
type: TaskTriggerType.never
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,12 @@ import {Injectable} from '@angular/core';
|
|||||||
import {NetworkService} from '../../../model/network/network.service';
|
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 {TaskConfig} from '../../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {BehaviorSubject} from 'rxjs';
|
import {BehaviorSubject} from 'rxjs';
|
||||||
import {TaskDTO} from '../../../../../common/entities/task/TaskDTO';
|
import {TaskDTO} from '../../../../../common/entities/task/TaskDTO';
|
||||||
|
import {ServerConfig} from '../../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TasksSettingsService extends AbstractSettingsService<TaskConfig> {
|
export class TasksSettingsService extends AbstractSettingsService<ServerConfig.TaskConfig> {
|
||||||
|
|
||||||
|
|
||||||
public availableTasks: BehaviorSubject<TaskDTO[]>;
|
public availableTasks: BehaviorSubject<TaskDTO[]>;
|
||||||
@ -18,7 +18,7 @@ export class TasksSettingsService extends AbstractSettingsService<TaskConfig> {
|
|||||||
this.availableTasks = new BehaviorSubject([]);
|
this.availableTasks = new BehaviorSubject([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateSettings(settings: TaskConfig): Promise<void> {
|
public updateSettings(settings: ServerConfig.TaskConfig): Promise<void> {
|
||||||
return this._networkService.putJson('/settings/tasks', {settings: settings});
|
return this._networkService.putJson('/settings/tasks', {settings: settings});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,21 +3,21 @@ import {SettingsComponent} from '../_abstract/abstract.settings.component';
|
|||||||
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 {ThumbnailConfig, ThumbnailProcessingLib} from '../../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {ClientConfig} from '../../../../../common/config/public/ConfigClass';
|
import {ClientConfig} from '../../../../../common/config/public/ConfigClass';
|
||||||
import {ThumbnailSettingsService} from './thumbanil.settings.service';
|
import {ThumbnailSettingsService} from './thumbnail.settings.service';
|
||||||
import {Utils} from '../../../../../common/Utils';
|
import {Utils} from '../../../../../common/Utils';
|
||||||
import {I18n} from '@ngx-translate/i18n-polyfill';
|
import {I18n} from '@ngx-translate/i18n-polyfill';
|
||||||
|
import {ServerConfig} from '../../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-settings-thumbnail',
|
selector: 'app-settings-thumbnail',
|
||||||
templateUrl: './thumbanil.settings.component.html',
|
templateUrl: './thumbnail.settings.component.html',
|
||||||
styleUrls: ['./thumbanil.settings.component.css',
|
styleUrls: ['./thumbnail.settings.component.css',
|
||||||
'./../_abstract/abstract.settings.component.css'],
|
'./../_abstract/abstract.settings.component.css'],
|
||||||
providers: [ThumbnailSettingsService],
|
providers: [ThumbnailSettingsService],
|
||||||
})
|
})
|
||||||
export class ThumbnailSettingsComponent
|
export class ThumbnailSettingsComponent
|
||||||
extends SettingsComponent<{ server: ThumbnailConfig, client: ClientConfig.ThumbnailConfig }>
|
extends SettingsComponent<{ server: ServerConfig.ThumbnailConfig, client: ClientConfig.ThumbnailConfig }>
|
||||||
implements OnInit {
|
implements OnInit {
|
||||||
types: Array<any> = [];
|
types: Array<any> = [];
|
||||||
ThumbnailProcessingLib: any;
|
ThumbnailProcessingLib: any;
|
||||||
@ -48,7 +48,7 @@ export class ThumbnailSettingsComponent
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
this.types = Utils
|
this.types = Utils
|
||||||
.enumToArray(ThumbnailProcessingLib).map((v) => {
|
.enumToArray(ServerConfig.ThumbnailProcessingLib).map((v) => {
|
||||||
if (v.value.toLowerCase() === 'sharp') {
|
if (v.value.toLowerCase() === 'sharp') {
|
||||||
v.value += ' ' + this.i18n('(recommended)');
|
v.value += ' ' + this.i18n('(recommended)');
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ export class ThumbnailSettingsComponent
|
|||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
});
|
});
|
||||||
this.ThumbnailProcessingLib = ThumbnailProcessingLib;
|
this.ThumbnailProcessingLib = ServerConfig.ThumbnailProcessingLib;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,19 +1,20 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {NetworkService} from '../../../model/network/network.service';
|
import {NetworkService} from '../../../model/network/network.service';
|
||||||
import {ClientConfig} from '../../../../../common/config/public/ConfigClass';
|
import {ClientConfig} from '../../../../../common/config/public/ConfigClass';
|
||||||
import {ThumbnailConfig} from '../../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {AbstractSettingsService} from '../_abstract/abstract.settings.service';
|
import {AbstractSettingsService} from '../_abstract/abstract.settings.service';
|
||||||
import {SettingsService} from '../settings.service';
|
import {SettingsService} from '../settings.service';
|
||||||
|
import {ServerConfig} from '../../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ThumbnailSettingsService extends AbstractSettingsService<{ server: ThumbnailConfig, client: ClientConfig.ThumbnailConfig }> {
|
export class ThumbnailSettingsService
|
||||||
|
extends AbstractSettingsService<{ server: ServerConfig.ThumbnailConfig, client: ClientConfig.ThumbnailConfig }> {
|
||||||
constructor(private _networkService: NetworkService,
|
constructor(private _networkService: NetworkService,
|
||||||
_settingsService: SettingsService) {
|
_settingsService: SettingsService) {
|
||||||
super(_settingsService);
|
super(_settingsService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public updateSettings(settings: { server: ThumbnailConfig, client: ClientConfig.ThumbnailConfig }): Promise<void> {
|
public updateSettings(settings: { server: ServerConfig.ThumbnailConfig, client: ClientConfig.ThumbnailConfig }): Promise<void> {
|
||||||
return this._networkService.putJson('/settings/thumbnail', {settings: settings});
|
return this._networkService.putJson('/settings/thumbnail', {settings: settings});
|
||||||
}
|
}
|
||||||
|
|
@ -15,7 +15,7 @@ export class UserManagerSettingsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getSettings(): Promise<boolean> {
|
public async getSettings(): Promise<boolean> {
|
||||||
return (await <Promise<IPrivateConfig>>this._networkService.getJson('/settings')).Client.authenticationRequired;
|
return (await this._networkService.getJson<Promise<IPrivateConfig>>('/settings')).Client.authenticationRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateSettings(settings: boolean): Promise<void> {
|
public updateSettings(settings: boolean): Promise<void> {
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
<p class="title" i18n>Video transcoding:</p>
|
<p class="title" i18n>Video transcoding:</p>
|
||||||
<div class="form-group row" [hidden]="simplifiedMode">
|
<div class="form-group row" [hidden]="simplifiedMode">
|
||||||
<label class="col-md-2 control-label" for="format" i18n>Format</label>
|
<label class="col-md-2 control-label" for="format" i18n>Format</label>
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<select id="format" class="form-control" [(ngModel)]="settings.server.transcoding.format"
|
<select id="format" class="form-control" [(ngModel)]="settings.server.transcoding.format"
|
||||||
@ -40,7 +40,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group row" [hidden]="simplifiedMode">
|
<div class="form-group row" [hidden]="simplifiedMode">
|
||||||
<label class="col-md-2 control-label" for="codec" i18n>Codec</label>
|
<label class="col-md-2 control-label" for="codec" i18n>Codec</label>
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<select id="codec" class="form-control" [(ngModel)]="settings.server.transcoding.codec"
|
<select id="codec" class="form-control" [(ngModel)]="settings.server.transcoding.codec"
|
||||||
@ -60,11 +60,12 @@
|
|||||||
<option *ngFor="let resolution of resolutions" [ngValue]="resolution">{{resolution}}p
|
<option *ngFor="let resolution of resolutions" [ngValue]="resolution">{{resolution}}p
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<small class="form-text text-muted" i18n>The height of the output video will be scaled down to this, while keeping the aspect ratio.</small>
|
<small class="form-text text-muted" i18n>The height of the output video will be scaled down to this, while
|
||||||
|
keeping the aspect ratio.</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group row" [hidden]="simplifiedMode">
|
<div class="form-group row" [hidden]="simplifiedMode">
|
||||||
<label class="col-md-2 control-label" for="fps" i18n>FPS</label>
|
<label class="col-md-2 control-label" for="fps" i18n>FPS</label>
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<select id="fps" class="form-control" [(ngModel)]="settings.server.transcoding.fps"
|
<select id="fps" class="form-control" [(ngModel)]="settings.server.transcoding.fps"
|
||||||
@ -73,24 +74,28 @@
|
|||||||
<option *ngFor="let fps of fps" [ngValue]="fps">{{fps}}
|
<option *ngFor="let fps of fps" [ngValue]="fps">{{fps}}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<small class="form-text text-muted" i18n>Target frame per second (fps) of the output video will be scaled down this this.</small>
|
<small class="form-text text-muted" i18n>Target frame per second (fps) of the output video will be scaled down
|
||||||
|
this this.</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-md-2 control-label" for="bitRate" i18n>Bit rate</label>
|
<label class="col-md-2 control-label" for="bitRate" i18n>Bit rate</label>
|
||||||
<div class="input-group col-md-10">
|
<div class="col-md-10">
|
||||||
<input type="number" class="form-control" placeholder="2"
|
<div class="input-group">
|
||||||
id="bitRate"
|
<input type="number" class="form-control" placeholder="2"
|
||||||
min="0"
|
id="bitRate"
|
||||||
step="0.1"
|
min="0"
|
||||||
max="1000"
|
step="0.1"
|
||||||
[(ngModel)]="bitRate"
|
max="1000"
|
||||||
name="bitRate" required>
|
[(ngModel)]="bitRate"
|
||||||
<div class="input-group-append">
|
name="bitRate" required>
|
||||||
<span class="input-group-text">mbps</span>
|
<div class="input-group-append">
|
||||||
|
<span class="input-group-text">mbps</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<small class="form-text text-muted" i18n>Target bit rate of the output video will be scaled down this this. This should be less than the
|
<small class="form-text text-muted" i18n>Target bit rate of the output video will be scaled down this this.
|
||||||
|
This should be less than the
|
||||||
upload rate of your home server.</small>
|
upload rate of your home server.</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -136,7 +141,7 @@
|
|||||||
<ng-container *ngIf="Progress != null">
|
<ng-container *ngIf="Progress != null">
|
||||||
<br/>
|
<br/>
|
||||||
<hr/>
|
<hr/>
|
||||||
<span class="progress-details" i18n>indexing</span>: {{Progress.comment}} <br/>
|
<span class="progress-details" i18n>status</span>: {{Progress.comment}} <br/>
|
||||||
<span class="progress-details" i18n>elapsed</span>: {{tasksService.calcTimeElapsed(Progress) | duration}}<br/>
|
<span class="progress-details" i18n>elapsed</span>: {{tasksService.calcTimeElapsed(Progress) | duration}}<br/>
|
||||||
<span class="progress-details" i18n>left</span>: {{tasksService.calcTimeLeft(Progress) | duration}}
|
<span class="progress-details" i18n>left</span>: {{tasksService.calcTimeLeft(Progress) | duration}}
|
||||||
<div class="progress">
|
<div class="progress">
|
||||||
|
@ -6,10 +6,10 @@ import {NavigationService} from '../../../model/navigation.service';
|
|||||||
import {NotificationService} from '../../../model/notification.service';
|
import {NotificationService} from '../../../model/notification.service';
|
||||||
import {ClientConfig} from '../../../../../common/config/public/ConfigClass';
|
import {ClientConfig} from '../../../../../common/config/public/ConfigClass';
|
||||||
import {I18n} from '@ngx-translate/i18n-polyfill';
|
import {I18n} from '@ngx-translate/i18n-polyfill';
|
||||||
import {codecType, formatType, resolutionType, VideoConfig} from '../../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {ScheduledTasksService} from '../scheduled-tasks.service';
|
import {ScheduledTasksService} from '../scheduled-tasks.service';
|
||||||
import {DefaultsTasks} from '../../../../../common/entities/task/TaskDTO';
|
import {DefaultsTasks} from '../../../../../common/entities/task/TaskDTO';
|
||||||
import {ErrorDTO} from '../../../../../common/entities/Error';
|
import {ErrorDTO} from '../../../../../common/entities/Error';
|
||||||
|
import {ServerConfig} from '../../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -19,11 +19,11 @@ import {ErrorDTO} from '../../../../../common/entities/Error';
|
|||||||
'./../_abstract/abstract.settings.component.css'],
|
'./../_abstract/abstract.settings.component.css'],
|
||||||
providers: [VideoSettingsService],
|
providers: [VideoSettingsService],
|
||||||
})
|
})
|
||||||
export class VideoSettingsComponent extends SettingsComponent<{ server: VideoConfig, client: ClientConfig.VideoConfig }> {
|
export class VideoSettingsComponent extends SettingsComponent<{ server: ServerConfig.VideoConfig, client: ClientConfig.VideoConfig }> {
|
||||||
|
|
||||||
resolutions: resolutionType[] = [360, 480, 720, 1080, 1440, 2160, 4320];
|
resolutions: ServerConfig.resolutionType[] = [360, 480, 720, 1080, 1440, 2160, 4320];
|
||||||
codecs: { [key: string]: codecType[] } = {webm: ['libvpx', 'libvpx-vp9'], mp4: ['libx264', 'libx265']};
|
codecs: { [key: string]: ServerConfig.codecType[] } = {webm: ['libvpx', 'libvpx-vp9'], mp4: ['libx264', 'libx265']};
|
||||||
formats: formatType[] = ['mp4', 'webm'];
|
formats: ServerConfig.formatType[] = ['mp4', 'webm'];
|
||||||
fps = [24, 25, 30, 48, 50, 60];
|
fps = [24, 25, 30, 48, 50, 60];
|
||||||
|
|
||||||
constructor(_authService: AuthenticationService,
|
constructor(_authService: AuthenticationService,
|
||||||
@ -79,7 +79,7 @@ export class VideoSettingsComponent extends SettingsComponent<{ server: VideoCon
|
|||||||
this.settings.server.transcoding.fps);
|
this.settings.server.transcoding.fps);
|
||||||
}
|
}
|
||||||
|
|
||||||
formatChanged(format: formatType) {
|
formatChanged(format: ServerConfig.formatType) {
|
||||||
this.settings.server.transcoding.codec = this.codecs[format][0];
|
this.settings.server.transcoding.codec = this.codecs[format][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import {Config} from '../../common/config/private/Config';
|
import {Config} from '../../common/config/private/Config';
|
||||||
import {DatabaseType} from '../../common/config/private/IPrivateConfig';
|
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import {SQLConnection} from '../../backend/model/sql/SQLConnection';
|
import {SQLConnection} from '../../backend/model/sql/SQLConnection';
|
||||||
|
import {ServerConfig} from '../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
declare let describe: any;
|
declare let describe: any;
|
||||||
const savedDescribe = describe;
|
const savedDescribe = describe;
|
||||||
@ -17,7 +17,7 @@ export class SQLTestHelper {
|
|||||||
tempDir: string;
|
tempDir: string;
|
||||||
dbPath: string;
|
dbPath: string;
|
||||||
|
|
||||||
constructor(public dbType: DatabaseType) {
|
constructor(public dbType: ServerConfig.DatabaseType) {
|
||||||
this.tempDir = path.join(__dirname, './tmp');
|
this.tempDir = path.join(__dirname, './tmp');
|
||||||
this.dbPath = path.join(__dirname, './tmp', 'test.db');
|
this.dbPath = path.join(__dirname, './tmp', 'test.db');
|
||||||
|
|
||||||
@ -26,13 +26,13 @@ export class SQLTestHelper {
|
|||||||
static describe(name: string, tests: (helper?: SQLTestHelper) => void) {
|
static describe(name: string, tests: (helper?: SQLTestHelper) => void) {
|
||||||
savedDescribe(name, async () => {
|
savedDescribe(name, async () => {
|
||||||
if (SQLTestHelper.enable.sqlite) {
|
if (SQLTestHelper.enable.sqlite) {
|
||||||
const helper = new SQLTestHelper(DatabaseType.sqlite);
|
const helper = new SQLTestHelper(ServerConfig.DatabaseType.sqlite);
|
||||||
savedDescribe('sqlite', () => {
|
savedDescribe('sqlite', () => {
|
||||||
return tests(helper);
|
return tests(helper);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (SQLTestHelper.enable.mysql) {
|
if (SQLTestHelper.enable.mysql) {
|
||||||
const helper = new SQLTestHelper(DatabaseType.mysql);
|
const helper = new SQLTestHelper(ServerConfig.DatabaseType.mysql);
|
||||||
savedDescribe('mysql', function () {
|
savedDescribe('mysql', function () {
|
||||||
this.timeout(99999999);
|
this.timeout(99999999);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@ -43,7 +43,7 @@ export class SQLTestHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async initDB() {
|
public async initDB() {
|
||||||
if (this.dbType === DatabaseType.sqlite) {
|
if (this.dbType === ServerConfig.DatabaseType.sqlite) {
|
||||||
await this.initSQLite();
|
await this.initSQLite();
|
||||||
} else {
|
} else {
|
||||||
await this.initMySQL();
|
await this.initMySQL();
|
||||||
@ -52,7 +52,7 @@ export class SQLTestHelper {
|
|||||||
|
|
||||||
|
|
||||||
public async clearDB() {
|
public async clearDB() {
|
||||||
if (this.dbType === DatabaseType.sqlite) {
|
if (this.dbType === ServerConfig.DatabaseType.sqlite) {
|
||||||
await this.clearUpSQLite();
|
await this.clearUpSQLite();
|
||||||
} else {
|
} else {
|
||||||
await this.clearUpMysql();
|
await this.clearUpMysql();
|
||||||
@ -62,12 +62,12 @@ export class SQLTestHelper {
|
|||||||
private async initSQLite() {
|
private async initSQLite() {
|
||||||
await this.resetSQLite();
|
await this.resetSQLite();
|
||||||
|
|
||||||
Config.Server.Database.type = DatabaseType.sqlite;
|
Config.Server.Database.type = ServerConfig.DatabaseType.sqlite;
|
||||||
Config.Server.Database.sqlite.storage = this.dbPath;
|
Config.Server.Database.sqlite.storage = this.dbPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async initMySQL() {
|
private async initMySQL() {
|
||||||
Config.Server.Database.type = DatabaseType.mysql;
|
Config.Server.Database.type = ServerConfig.DatabaseType.mysql;
|
||||||
Config.Server.Database.mysql.database = 'pigallery2_test';
|
Config.Server.Database.mysql.database = 'pigallery2_test';
|
||||||
|
|
||||||
await this.resetMySQL();
|
await this.resetMySQL();
|
||||||
@ -85,7 +85,7 @@ export class SQLTestHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async resetMySQL() {
|
private async resetMySQL() {
|
||||||
Config.Server.Database.type = DatabaseType.mysql;
|
Config.Server.Database.type = ServerConfig.DatabaseType.mysql;
|
||||||
Config.Server.Database.mysql.database = 'pigallery2_test';
|
Config.Server.Database.mysql.database = 'pigallery2_test';
|
||||||
const conn = await SQLConnection.getConnection();
|
const conn = await SQLConnection.getConnection();
|
||||||
await conn.query('DROP DATABASE IF EXISTS ' + conn.options.database);
|
await conn.query('DROP DATABASE IF EXISTS ' + conn.options.database);
|
||||||
@ -94,7 +94,7 @@ export class SQLTestHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async clearUpMysql() {
|
private async clearUpMysql() {
|
||||||
Config.Server.Database.type = DatabaseType.mysql;
|
Config.Server.Database.type = ServerConfig.DatabaseType.mysql;
|
||||||
Config.Server.Database.mysql.database = 'pigallery2_test';
|
Config.Server.Database.mysql.database = 'pigallery2_test';
|
||||||
const conn = await SQLConnection.getConnection();
|
const conn = await SQLConnection.getConnection();
|
||||||
await conn.query('DROP DATABASE IF EXISTS ' + conn.options.database);
|
await conn.query('DROP DATABASE IF EXISTS ' + conn.options.database);
|
||||||
|
@ -2,7 +2,6 @@ import {expect} from 'chai';
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import {Config} from '../../../../../common/config/private/Config';
|
import {Config} from '../../../../../common/config/private/Config';
|
||||||
import {DatabaseType} from '../../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {SQLConnection} from '../../../../../backend/model/sql/SQLConnection';
|
import {SQLConnection} from '../../../../../backend/model/sql/SQLConnection';
|
||||||
import {UserEntity} from '../../../../../backend/model/sql/enitites/UserEntity';
|
import {UserEntity} from '../../../../../backend/model/sql/enitites/UserEntity';
|
||||||
import {UserRoles} from '../../../../../common/entities/UserDTO';
|
import {UserRoles} from '../../../../../common/entities/UserDTO';
|
||||||
@ -17,6 +16,7 @@ import {
|
|||||||
} from '../../../../../backend/model/sql/enitites/PhotoEntity';
|
} from '../../../../../backend/model/sql/enitites/PhotoEntity';
|
||||||
import {MediaDimensionEntity} from '../../../../../backend/model/sql/enitites/MediaEntity';
|
import {MediaDimensionEntity} from '../../../../../backend/model/sql/enitites/MediaEntity';
|
||||||
import {VersionEntity} from '../../../../../backend/model/sql/enitites/VersionEntity';
|
import {VersionEntity} from '../../../../../backend/model/sql/enitites/VersionEntity';
|
||||||
|
import {ServerConfig} from '../../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
describe('Typeorm integration', () => {
|
describe('Typeorm integration', () => {
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ describe('Typeorm integration', () => {
|
|||||||
fs.mkdirSync(tempDir);
|
fs.mkdirSync(tempDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
Config.Server.Database.type = DatabaseType.sqlite;
|
Config.Server.Database.type = ServerConfig.DatabaseType.sqlite;
|
||||||
Config.Server.Database.sqlite.storage = dbPath;
|
Config.Server.Database.sqlite.storage = dbPath;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import {expect} from 'chai';
|
import {expect} from 'chai';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import {Config} from '../../../../../common/config/private/Config';
|
import {Config} from '../../../../../common/config/private/Config';
|
||||||
import {ReIndexingSensitivity} from '../../../../../common/config/private/IPrivateConfig';
|
|
||||||
import {SQLConnection} from '../../../../../backend/model/sql/SQLConnection';
|
import {SQLConnection} from '../../../../../backend/model/sql/SQLConnection';
|
||||||
import {GalleryManager} from '../../../../../backend/model/sql/GalleryManager';
|
import {GalleryManager} from '../../../../../backend/model/sql/GalleryManager';
|
||||||
import {DirectoryDTO} from '../../../../../common/entities/DirectoryDTO';
|
import {DirectoryDTO} from '../../../../../common/entities/DirectoryDTO';
|
||||||
@ -17,6 +16,7 @@ import {PersonManager} from '../../../../../backend/model/sql/PersonManager';
|
|||||||
import {SQLTestHelper} from '../../../SQLTestHelper';
|
import {SQLTestHelper} from '../../../SQLTestHelper';
|
||||||
import {VersionManager} from '../../../../../backend/model/sql/VersionManager';
|
import {VersionManager} from '../../../../../backend/model/sql/VersionManager';
|
||||||
import {DiskMangerWorker} from '../../../../../backend/model/threading/DiskMangerWorker';
|
import {DiskMangerWorker} from '../../../../../backend/model/threading/DiskMangerWorker';
|
||||||
|
import {ServerConfig} from '../../../../../common/config/private/IPrivateConfig';
|
||||||
|
|
||||||
class GalleryManagerTest extends GalleryManager {
|
class GalleryManagerTest extends GalleryManager {
|
||||||
|
|
||||||
@ -457,7 +457,7 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('with re indexing severity low', async () => {
|
it('with re indexing severity low', async () => {
|
||||||
Config.Server.Indexing.reIndexingSensitivity = ReIndexingSensitivity.low;
|
Config.Server.Indexing.reIndexingSensitivity = ServerConfig.ReIndexingSensitivity.low;
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
fs.statSync = () => ({ctime: new Date(dirTime), mtime: new Date(dirTime)});
|
fs.statSync = () => ({ctime: new Date(dirTime), mtime: new Date(dirTime)});
|
||||||
|
Loading…
Reference in New Issue
Block a user