1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/frontend/app/ui/settings/settings.service.ts

130 lines
3.5 KiB
TypeScript
Raw Normal View History

2018-03-31 03:30:30 +08:00
import {Injectable} from '@angular/core';
2018-05-23 08:27:07 +08:00
import {BehaviorSubject} from 'rxjs';
import {
DatabaseType,
IPrivateConfig,
LogLevel,
ReIndexingSensitivity,
SQLLogLevel,
ThumbnailProcessingLib
} from '../../../../common/config/private/IPrivateConfig';
import {NetworkService} from '../../model/network/network.service';
import {SortingMethods} from '../../../../common/entities/SortingMethods';
import {UserRoles} from '../../../../common/entities/UserDTO';
import {ClientConfig} from '../../../../common/config/public/ConfigClass';
2017-07-28 05:10:16 +08:00
2017-07-15 20:27:12 +08:00
@Injectable()
export class SettingsService {
public settings: BehaviorSubject<IPrivateConfig>;
constructor(private _networkService: NetworkService) {
2017-07-28 05:10:16 +08:00
this.settings = new BehaviorSubject<IPrivateConfig>({
2017-07-15 20:27:12 +08:00
Client: {
appVersion: '',
2017-07-15 20:27:12 +08:00
Search: {
enabled: true,
AutoComplete: {
enabled: true,
cacheTimeout: 1000 * 60 * 60,
maxItemsPerCategory: 5
},
2017-07-28 05:10:16 +08:00
instantSearchEnabled: true,
2017-07-30 05:39:06 +08:00
InstantSearchTimeout: 0,
2017-07-30 15:06:12 +08:00
searchCacheTimeout: 1000 * 60 * 60,
instantSearchCacheTimeout: 1000 * 60 * 60,
2017-07-15 20:27:12 +08:00
},
Thumbnail: {
concurrentThumbnailGenerations: null,
2017-07-15 20:27:12 +08:00
iconSize: 30,
2019-02-15 07:25:55 +08:00
personThumbnailSize: 200,
2017-07-15 20:27:12 +08:00
thumbnailSizes: []
},
Sharing: {
enabled: true,
passwordProtected: true
},
Map: {
enabled: true,
2019-07-21 17:23:08 +08:00
useImageMarkers: true,
mapProvider: ClientConfig.MapProviders.OpenStreetMap,
2018-12-08 18:28:56 +08:00
mapboxAccessToken: '',
customLayers: [{name: 'street', url: ''}]
2017-07-15 22:09:48 +08:00
},
RandomPhoto: {
enabled: true
},
2018-11-19 03:26:29 +08:00
Video: {
enabled: true
},
2018-12-01 00:19:37 +08:00
MetaFile: {
enabled: true
},
Other: {
captionFirstNaming: false,
enableCache: true,
enableOnScrollRendering: true,
enableOnScrollThumbnailPrioritising: true,
defaultPhotoSortingMethod: SortingMethods.ascDate,
NavBar: {
showItemCount: true
}
},
2019-02-05 06:46:27 +08:00
Faces: {
enabled: true,
2019-03-04 04:17:42 +08:00
keywordsToPersons: true,
writeAccessMinRole: UserRoles.Admin
2019-02-05 06:46:27 +08:00
},
urlBase: '',
2018-03-31 03:30:30 +08:00
publicUrl: '',
applicationTitle: '',
authenticationRequired: true,
unAuthenticatedUserRole: UserRoles.Admin,
languages: []
2017-07-15 22:09:48 +08:00
},
Server: {
2017-07-15 20:27:12 +08:00
database: {
type: DatabaseType.memory
},
log: {
level: LogLevel.info,
sqlLevel: SQLLogLevel.error
},
2017-07-15 20:27:12 +08:00
sharing: {
updateTimeout: 2000
},
2018-03-31 03:30:30 +08:00
imagesFolder: '',
2019-01-19 07:18:20 +08:00
port: 80,
host: '0.0.0.0',
2017-07-15 20:27:12 +08:00
thumbnail: {
2019-02-15 07:25:55 +08:00
personFaceMargin: 0.1,
2018-03-31 03:30:30 +08:00
folder: '',
2017-07-15 20:27:12 +08:00
qualityPriority: true,
processingLibrary: ThumbnailProcessingLib.sharp
2017-07-28 05:10:16 +08:00
},
threading: {
enable: true,
thumbnailThreads: 0
},
2017-07-28 05:10:16 +08:00
sessionTimeout: 0,
indexing: {
cachedFolderTimeout: 0,
folderPreviewSize: 0,
reIndexingSensitivity: ReIndexingSensitivity.medium,
excludeFolderList: [],
excludeFileList: []
2018-12-04 20:52:49 +08:00
},
2019-01-19 07:18:20 +08:00
photoMetadataSize: 512 * 1024,
duplicates: {
listingLimit: 1000
}
2017-07-15 20:27:12 +08:00
}
});
}
2017-07-28 05:10:16 +08:00
public async getSettings(): Promise<void> {
2018-03-31 03:30:30 +08:00
this.settings.next(await <Promise<IPrivateConfig>>this._networkService.getJson('/settings'));
2017-07-15 20:27:12 +08:00
}
}