mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-23 01:27:14 +02:00
Adding Album Reset Job and renaming DB reset to Gallery reset job
This commit is contained in:
parent
64432799d5
commit
4e6922054e
@ -7,6 +7,7 @@ import {SearchQueryDTO} from '../../../common/entities/SearchQueryDTO';
|
||||
import {SavedSearchEntity} from './enitites/album/SavedSearchEntity';
|
||||
import {Logger} from '../../Logger';
|
||||
import {IObjectManager} from './IObjectManager';
|
||||
import {DirectoryEntity} from './enitites/DirectoryEntity';
|
||||
|
||||
const LOG_TAG = '[AlbumManager]';
|
||||
|
||||
@ -110,4 +111,13 @@ export class AlbumManager implements IObjectManager {
|
||||
}
|
||||
this.isDBValid = true;
|
||||
}
|
||||
|
||||
async deleteAll() {
|
||||
const connection = await SQLConnection.getConnection();
|
||||
await connection
|
||||
.getRepository(AlbumBaseEntity)
|
||||
.createQueryBuilder('album')
|
||||
.delete()
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import * as path from 'path';
|
||||
import {Utils} from '../../../common/Utils';
|
||||
import {PreviewPhotoDTO} from '../../../common/entities/PhotoDTO';
|
||||
import {IObjectManager} from './IObjectManager';
|
||||
import {Logger} from '../../Logger';
|
||||
|
||||
const LOG_TAG = '[PreviewManager]';
|
||||
|
||||
@ -121,7 +122,6 @@ export class PreviewManager implements IObjectManager {
|
||||
PreviewManager.setSorting(query);
|
||||
return query;
|
||||
};
|
||||
|
||||
let previewMedia = null;
|
||||
if (
|
||||
Config.Preview.SearchQuery &&
|
||||
@ -130,16 +130,26 @@ export class PreviewManager implements IObjectManager {
|
||||
text: '',
|
||||
} as TextSearch)
|
||||
) {
|
||||
try {
|
||||
const previewFilterQuery = await
|
||||
ObjectManagers.getInstance().SearchManager.prepareAndBuildWhereQuery(Config.Preview.SearchQuery);
|
||||
previewMedia = await previewQuery()
|
||||
.andWhere(previewFilterQuery)
|
||||
.limit(1)
|
||||
.getOne();
|
||||
} catch (e) {
|
||||
Logger.error('Cant get album preview using:', JSON.stringify(album.searchQuery), JSON.stringify(Config.Preview.SearchQuery));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
if (!previewMedia) {
|
||||
try {
|
||||
previewMedia = await previewQuery().limit(1).getOne();
|
||||
} catch (e) {
|
||||
Logger.error('Cant get album preview using:', JSON.stringify(album.searchQuery));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return previewMedia || null;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {IJob} from './jobs/IJob';
|
||||
import {IndexingJob} from './jobs/IndexingJob';
|
||||
import { DBRestJob } from './jobs/DBResetJob';
|
||||
import {GalleryRestJob} from './jobs/GalleryResetJob';
|
||||
import {VideoConvertingJob} from './jobs/VideoConvertingJob';
|
||||
import {PhotoConvertingJob} from './jobs/PhotoConvertingJob';
|
||||
import {ThumbnailGenerationJob} from './jobs/ThumbnailGenerationJob';
|
||||
@ -8,6 +8,7 @@ import { TempFolderCleaningJob } from './jobs/TempFolderCleaningJob';
|
||||
import {PreviewFillingJob} from './jobs/PreviewFillingJob';
|
||||
import {PreviewRestJob} from './jobs/PreviewResetJob';
|
||||
import {GPXCompressionJob} from './jobs/GPXCompressionJob';
|
||||
import {AlbumRestJob} from './jobs/AlbumResetJob';
|
||||
|
||||
export class JobRepository {
|
||||
private static instance: JobRepository = null;
|
||||
@ -33,7 +34,7 @@ export class JobRepository {
|
||||
}
|
||||
|
||||
JobRepository.Instance.register(new IndexingJob());
|
||||
JobRepository.Instance.register(new DBRestJob());
|
||||
JobRepository.Instance.register(new GalleryRestJob());
|
||||
JobRepository.Instance.register(new PreviewFillingJob());
|
||||
JobRepository.Instance.register(new PreviewRestJob());
|
||||
JobRepository.Instance.register(new VideoConvertingJob());
|
||||
@ -41,3 +42,4 @@ JobRepository.Instance.register(new PhotoConvertingJob());
|
||||
JobRepository.Instance.register(new ThumbnailGenerationJob());
|
||||
JobRepository.Instance.register(new GPXCompressionJob());
|
||||
JobRepository.Instance.register(new TempFolderCleaningJob());
|
||||
JobRepository.Instance.register(new AlbumRestJob());
|
||||
|
24
src/backend/model/jobs/jobs/AlbumResetJob.ts
Normal file
24
src/backend/model/jobs/jobs/AlbumResetJob.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import {ObjectManagers} from '../../ObjectManagers';
|
||||
import {ConfigTemplateEntry, DefaultsJobs,} from '../../../../common/entities/job/JobDTO';
|
||||
import {Job} from './Job';
|
||||
|
||||
export class AlbumRestJob extends Job {
|
||||
public readonly Name = DefaultsJobs[DefaultsJobs['Album Reset']];
|
||||
public readonly ConfigTemplate: ConfigTemplateEntry[] = null;
|
||||
protected readonly IsInstant = true;
|
||||
|
||||
public get Supported(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected async init(): Promise<void> {
|
||||
// abstract function
|
||||
}
|
||||
|
||||
protected async step(): Promise<boolean> {
|
||||
this.Progress.Left = 1;
|
||||
this.Progress.Processed++;
|
||||
await ObjectManagers.getInstance().AlbumManager.deleteAll();
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
import { ObjectManagers } from '../../ObjectManagers';
|
||||
import { Config } from '../../../../common/config/private/Config';
|
||||
import {
|
||||
ConfigTemplateEntry,
|
||||
DefaultsJobs,
|
||||
} from '../../../../common/entities/job/JobDTO';
|
||||
import { Job } from './Job';
|
||||
import { DatabaseType } from '../../../../common/config/private/PrivateConfig';
|
||||
|
||||
export class DBRestJob extends Job {
|
||||
public readonly Name = DefaultsJobs[DefaultsJobs['Database Reset']];
|
||||
public readonly ConfigTemplate: ConfigTemplateEntry[] = null;
|
||||
protected readonly IsInstant = true;
|
||||
|
||||
public get Supported(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected async init(): Promise<void> {
|
||||
// abstract function
|
||||
}
|
||||
|
||||
protected async step(): Promise<boolean> {
|
||||
this.Progress.Left = 1;
|
||||
this.Progress.Processed++;
|
||||
await ObjectManagers.getInstance().IndexingManager.resetDB();
|
||||
return false;
|
||||
}
|
||||
}
|
24
src/backend/model/jobs/jobs/GalleryResetJob.ts
Normal file
24
src/backend/model/jobs/jobs/GalleryResetJob.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import {ObjectManagers} from '../../ObjectManagers';
|
||||
import {ConfigTemplateEntry, DefaultsJobs,} from '../../../../common/entities/job/JobDTO';
|
||||
import {Job} from './Job';
|
||||
|
||||
export class GalleryRestJob extends Job {
|
||||
public readonly Name = DefaultsJobs[DefaultsJobs['Gallery Reset']];
|
||||
public readonly ConfigTemplate: ConfigTemplateEntry[] = null;
|
||||
protected readonly IsInstant = true;
|
||||
|
||||
public get Supported(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected async init(): Promise<void> {
|
||||
// abstract function
|
||||
}
|
||||
|
||||
protected async step(): Promise<boolean> {
|
||||
this.Progress.Left = 1;
|
||||
this.Progress.Processed++;
|
||||
await ObjectManagers.getInstance().IndexingManager.resetDB();
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1049,7 +1049,7 @@ export class ServerConfig extends ClientConfig {
|
||||
job: DefaultsJobs[DefaultsJobs.Indexing],
|
||||
description: $localize`If you add a new folder to your gallery, the site indexes it automatically. If you would like to trigger indexing manually, click index button. (Note: search only works among the indexed directories.)`
|
||||
}, {
|
||||
job: DefaultsJobs[DefaultsJobs['Database Reset']],
|
||||
job: DefaultsJobs[DefaultsJobs['Gallery Reset']],
|
||||
hideProgress: true
|
||||
}]
|
||||
} as TAGS
|
||||
|
@ -4,6 +4,7 @@ import {SortingMethods} from '../../entities/SortingMethods';
|
||||
import {UserRoles} from '../../entities/UserDTO';
|
||||
import {ConfigProperty, SubConfigClass} from 'typeconfig/common';
|
||||
import {SearchQueryDTO} from '../../entities/SearchQueryDTO';
|
||||
import { DefaultsJobs } from '../../entities/job/JobDTO';
|
||||
|
||||
declare let $localize: (s: TemplateStringsArray) => string;
|
||||
if (typeof $localize === 'undefined') {
|
||||
@ -855,7 +856,11 @@ export class ClientConfig {
|
||||
@ConfigProperty({
|
||||
tags: {
|
||||
name: $localize`Album`,
|
||||
uiIcon: 'grid-two-up'
|
||||
uiIcon: 'grid-two-up',
|
||||
uiJob: [ {
|
||||
job: DefaultsJobs[DefaultsJobs['Album Reset']],
|
||||
hideProgress: true
|
||||
}]
|
||||
} as TAGS,
|
||||
})
|
||||
Album: ClientAlbumConfig = new ClientAlbumConfig();
|
||||
|
@ -4,7 +4,7 @@ export type fieldType = 'string' | 'number' | 'boolean' | 'number-array';
|
||||
|
||||
export enum DefaultsJobs {
|
||||
Indexing = 1,
|
||||
'Database Reset' = 2,
|
||||
'Gallery Reset' = 2,
|
||||
'Video Converting' = 3,
|
||||
'Photo Converting' = 4,
|
||||
'Thumbnail Generation' = 5,
|
||||
@ -12,6 +12,7 @@ export enum DefaultsJobs {
|
||||
'Preview Filling' = 7,
|
||||
'Preview Reset' = 8,
|
||||
'GPX Compression' = 9,
|
||||
'Album Reset' = 10,
|
||||
}
|
||||
|
||||
export interface ConfigTemplateEntry {
|
||||
|
@ -31,8 +31,10 @@ export class BackendtextService {
|
||||
switch (job as DefaultsJobs) {
|
||||
case DefaultsJobs.Indexing:
|
||||
return $localize`Indexing`;
|
||||
case DefaultsJobs['Database Reset']:
|
||||
return $localize`Database reset`;
|
||||
case DefaultsJobs['Gallery Reset']:
|
||||
return $localize`Gallery reset`;
|
||||
case DefaultsJobs['Album Reset']:
|
||||
return $localize`Album reset`;
|
||||
case DefaultsJobs['Thumbnail Generation']:
|
||||
return $localize`Thumbnail generation`;
|
||||
case DefaultsJobs['Photo Converting']:
|
||||
|
@ -38,7 +38,7 @@ export class SettingsService {
|
||||
this.jobsService.onJobFinish.subscribe((jobName: string) => {
|
||||
if (
|
||||
jobName === DefaultsJobs[DefaultsJobs.Indexing] ||
|
||||
jobName === DefaultsJobs[DefaultsJobs['Database Reset']]
|
||||
jobName === DefaultsJobs[DefaultsJobs['Gallery Reset']]
|
||||
) {
|
||||
this.loadStatistic();
|
||||
}
|
||||
|
@ -127,7 +127,7 @@
|
||||
[soloRun]="true"
|
||||
(jobError)="error=$event"
|
||||
[allowParallelRun]="false"
|
||||
[danger]="i>0"
|
||||
[danger]="job.job.includes('Reset')"
|
||||
[jobName]="job.job"></app-settings-job-button>
|
||||
</ng-container>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user