mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-23 01:27:14 +02:00
Refactoring Job config and exposing it to messenger #753
This commit is contained in:
parent
9f5257626f
commit
7208a3b4fe
@ -1,10 +1,11 @@
|
||||
import {ObjectManagers} from '../../ObjectManagers';
|
||||
import {ConfigTemplateEntry, DefaultsJobs,} from '../../../../common/entities/job/JobDTO';
|
||||
import {DefaultsJobs} from '../../../../common/entities/job/JobDTO';
|
||||
import {Job} from './Job';
|
||||
import {DynamicConfig} from '../../../../common/entities/DynamicConfig';
|
||||
|
||||
export class AlbumCoverFillingJob extends Job {
|
||||
public readonly Name = DefaultsJobs[DefaultsJobs['Album Cover Filling']];
|
||||
public readonly ConfigTemplate: ConfigTemplateEntry[] = null;
|
||||
public readonly ConfigTemplate: DynamicConfig[] = null;
|
||||
directoryToSetCover: { id: number; name: string; path: string }[] = null;
|
||||
status: 'Persons' | 'Albums' | 'Directory' = 'Persons';
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
import {ObjectManagers} from '../../ObjectManagers';
|
||||
import {ConfigTemplateEntry, DefaultsJobs,} from '../../../../common/entities/job/JobDTO';
|
||||
import {DefaultsJobs} from '../../../../common/entities/job/JobDTO';
|
||||
import {Job} from './Job';
|
||||
import {DynamicConfig} from '../../../../common/entities/DynamicConfig';
|
||||
|
||||
export class AlbumCoverRestJob extends Job {
|
||||
public readonly Name = DefaultsJobs[DefaultsJobs['Album Cover Reset']];
|
||||
public readonly ConfigTemplate: ConfigTemplateEntry[] = null;
|
||||
public readonly ConfigTemplate: DynamicConfig[] = null;
|
||||
protected readonly IsInstant = true;
|
||||
|
||||
public get Supported(): boolean {
|
||||
|
@ -1,10 +1,11 @@
|
||||
import {ObjectManagers} from '../../ObjectManagers';
|
||||
import {ConfigTemplateEntry, DefaultsJobs,} from '../../../../common/entities/job/JobDTO';
|
||||
import {DefaultsJobs,} from '../../../../common/entities/job/JobDTO';
|
||||
import {Job} from './Job';
|
||||
import {DynamicConfig} from '../../../../common/entities/DynamicConfig';
|
||||
|
||||
export class AlbumRestJob extends Job {
|
||||
public readonly Name = DefaultsJobs[DefaultsJobs['Album Reset']];
|
||||
public readonly ConfigTemplate: ConfigTemplateEntry[] = null;
|
||||
public readonly ConfigTemplate: DynamicConfig[] = null;
|
||||
protected readonly IsInstant = true;
|
||||
|
||||
public get Supported(): boolean {
|
||||
|
@ -1,4 +1,3 @@
|
||||
import {ConfigTemplateEntry} from '../../../../common/entities/job/JobDTO';
|
||||
import {Job} from './Job';
|
||||
import * as path from 'path';
|
||||
import {Logger} from '../../../Logger';
|
||||
@ -13,6 +12,7 @@ import {ProjectPath} from '../../../ProjectPath';
|
||||
import {FileEntity} from '../../database/enitites/FileEntity';
|
||||
import {DirectoryBaseDTO, DirectoryDTOUtils} from '../../../../common/entities/DirectoryDTO';
|
||||
import {DirectoryScanSettings, DiskManager} from '../../fileaccess/DiskManager';
|
||||
import {DynamicConfig} from '../../../../common/entities/DynamicConfig';
|
||||
|
||||
const LOG_TAG = '[FileJob]';
|
||||
|
||||
@ -20,7 +20,7 @@ const LOG_TAG = '[FileJob]';
|
||||
* Abstract class for thumbnail creation, file deleting etc.
|
||||
*/
|
||||
export abstract class FileJob<S extends { indexedOnly?: boolean } = { indexedOnly?: boolean }> extends Job<S> {
|
||||
public readonly ConfigTemplate: ConfigTemplateEntry[] = [];
|
||||
public readonly ConfigTemplate: DynamicConfig[] = [];
|
||||
directoryQueue: string[] = [];
|
||||
fileQueue: string[] = [];
|
||||
DBProcessing = {
|
||||
|
@ -1,10 +1,11 @@
|
||||
import {ObjectManagers} from '../../ObjectManagers';
|
||||
import {ConfigTemplateEntry, DefaultsJobs,} from '../../../../common/entities/job/JobDTO';
|
||||
import {DefaultsJobs} from '../../../../common/entities/job/JobDTO';
|
||||
import {Job} from './Job';
|
||||
import {DynamicConfig} from '../../../../common/entities/DynamicConfig';
|
||||
|
||||
export class GalleryRestJob extends Job {
|
||||
public readonly Name = DefaultsJobs[DefaultsJobs['Gallery Reset']];
|
||||
public readonly ConfigTemplate: ConfigTemplateEntry[] = null;
|
||||
public readonly ConfigTemplate: DynamicConfig[] = null;
|
||||
protected readonly IsInstant = true;
|
||||
|
||||
public get Supported(): boolean {
|
||||
|
@ -2,7 +2,7 @@ import {ObjectManagers} from '../../ObjectManagers';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import {Job} from './Job';
|
||||
import {ConfigTemplateEntry, DefaultsJobs,} from '../../../../common/entities/job/JobDTO';
|
||||
import {DefaultsJobs} from '../../../../common/entities/job/JobDTO';
|
||||
import {JobProgressStates} from '../../../../common/entities/job/JobProgressDTO';
|
||||
import {ProjectPath} from '../../../ProjectPath';
|
||||
import {backendTexts} from '../../../../common/BackendTexts';
|
||||
@ -10,6 +10,7 @@ import {ParentDirectoryDTO} from '../../../../common/entities/DirectoryDTO';
|
||||
import {Logger} from '../../../Logger';
|
||||
import {FileDTO} from '../../../../common/entities/FileDTO';
|
||||
import {DiskManager} from '../../fileaccess/DiskManager';
|
||||
import {DynamicConfig} from '../../../../common/entities/DynamicConfig';
|
||||
|
||||
const LOG_TAG = '[IndexingJob]';
|
||||
|
||||
@ -18,7 +19,7 @@ export class IndexingJob<
|
||||
> extends Job<S> {
|
||||
public readonly Name = DefaultsJobs[DefaultsJobs.Indexing];
|
||||
directoriesToIndex: string[] = [];
|
||||
public readonly ConfigTemplate: ConfigTemplateEntry[] = [
|
||||
public readonly ConfigTemplate: DynamicConfig[] = [
|
||||
{
|
||||
id: 'indexChangesOnly',
|
||||
type: 'boolean',
|
||||
|
@ -1,9 +1,10 @@
|
||||
import {Logger} from '../../../Logger';
|
||||
import {IJob} from './IJob';
|
||||
import {ConfigTemplateEntry, JobDTO, JobDTOUtils,} from '../../../../common/entities/job/JobDTO';
|
||||
import {JobDTO, JobDTOUtils} from '../../../../common/entities/job/JobDTO';
|
||||
import {JobProgress} from './JobProgress';
|
||||
import {IJobListener} from './IJobListener';
|
||||
import {JobProgressStates} from '../../../../common/entities/job/JobProgressDTO';
|
||||
import {DynamicConfig} from '../../../../common/entities/DynamicConfig';
|
||||
|
||||
declare const process: { nextTick: (_: unknown) => void };
|
||||
declare const global: { gc: () => void };
|
||||
@ -27,7 +28,7 @@ export abstract class Job<T extends Record<string, unknown> = Record<string, unk
|
||||
|
||||
public abstract get Name(): string;
|
||||
|
||||
public abstract get ConfigTemplate(): ConfigTemplateEntry[];
|
||||
public abstract get ConfigTemplate(): DynamicConfig[];
|
||||
|
||||
public get Progress(): JobProgress {
|
||||
return this.progress;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {ConfigTemplateEntry, DefaultsJobs,} from '../../../../common/entities/job/JobDTO';
|
||||
import {DefaultsJobs} from '../../../../common/entities/job/JobDTO';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import {Job} from './Job';
|
||||
@ -6,10 +6,11 @@ import {ProjectPath} from '../../../ProjectPath';
|
||||
import {GPXProcessing} from '../../fileaccess/fileprocessing/GPXProcessing';
|
||||
import {PhotoProcessing} from '../../fileaccess/fileprocessing/PhotoProcessing';
|
||||
import {VideoProcessing} from '../../fileaccess/fileprocessing/VideoProcessing';
|
||||
import { DynamicConfig } from '../../../../common/entities/DynamicConfig';
|
||||
|
||||
export class TempFolderCleaningJob extends Job {
|
||||
public readonly Name = DefaultsJobs[DefaultsJobs['Temp Folder Cleaning']];
|
||||
public readonly ConfigTemplate: ConfigTemplateEntry[] = null;
|
||||
public readonly ConfigTemplate: DynamicConfig[] = null;
|
||||
public readonly Supported: boolean = true;
|
||||
directoryQueue: string[] = [];
|
||||
private tempRootCleaned = false;
|
||||
|
@ -8,6 +8,7 @@ import {PhotoEntity} from '../../database/enitites/PhotoEntity';
|
||||
import {EmailMediaMessenger} from '../../mediamessengers/EmailMediaMessenger';
|
||||
import {MediaPickDTO} from '../../../../common/entities/MediaPickDTO';
|
||||
import {MediaDTOUtils} from '../../../../common/entities/MediaDTO';
|
||||
import {DynamicConfig} from '../../../../common/entities/DynamicConfig';
|
||||
|
||||
|
||||
export class TopPickSendJob extends Job<{
|
||||
@ -19,7 +20,7 @@ export class TopPickSendJob extends Job<{
|
||||
}> {
|
||||
public readonly Name = DefaultsJobs[DefaultsJobs['Top Pick Sending']];
|
||||
public readonly Supported: boolean = true;
|
||||
public readonly ConfigTemplate: ConfigTemplateEntry[] = [
|
||||
public readonly ConfigTemplate: DynamicConfig[] = [
|
||||
{
|
||||
id: 'mediaPick',
|
||||
type: 'MediaPickDTO-array',
|
||||
|
17
src/common/entities/DynamicConfig.ts
Normal file
17
src/common/entities/DynamicConfig.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import {backendText} from '../BackendTexts';
|
||||
import {fieldType} from './job/JobDTO';
|
||||
|
||||
/**
|
||||
* Dynamic configs are not part of the typeconfig maintained config.
|
||||
* Pigallery uses them to dynamically define configuration
|
||||
* on the serverside so the client can parse and render it.
|
||||
* It is mostly used for configuring jobs
|
||||
*/
|
||||
export interface DynamicConfig {
|
||||
id: string;
|
||||
// Use a predefined and localized backend text id or explicitly define the text
|
||||
name: backendText | string;
|
||||
description: backendText | string;
|
||||
type: fieldType;
|
||||
defaultValue: unknown;
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import {backendText} from '../../BackendTexts';
|
||||
import {DynamicConfig} from '../DynamicConfig';
|
||||
|
||||
export type fieldType = 'string' | 'string-array' | 'number' | 'boolean' | 'number-array' | 'MediaPickDTO-array';
|
||||
|
||||
@ -17,17 +18,10 @@ export enum DefaultsJobs {
|
||||
'Top Pick Sending' = 12
|
||||
}
|
||||
|
||||
export interface ConfigTemplateEntry {
|
||||
id: string;
|
||||
name: backendText;
|
||||
description: backendText;
|
||||
type: fieldType;
|
||||
defaultValue: any;
|
||||
}
|
||||
|
||||
export interface JobDTO {
|
||||
Name: string;
|
||||
ConfigTemplate: ConfigTemplateEntry[];
|
||||
ConfigTemplate: DynamicConfig[];
|
||||
}
|
||||
|
||||
export const JobDTOUtils = {
|
||||
|
Loading…
Reference in New Issue
Block a user