mirror of
https://github.com/immich-app/immich.git
synced 2025-01-10 13:56:47 +01:00
a147dee4b6
* maplibre on web, custom styles from server Actually use new vector tile server, custom style.json support multiple style files, light/dark mode cleanup, use new map everywhere send file directly instead of loading first better light/dark mode switching remove leaflet fix mapstyles dto, first draft of map settings delete and add styles fix delete default styles fix tests only allow one light and one dark style url revert config core changes fix server config store fix tests move axios fetches to repo fix package-lock fix tests * open api * add assets to docker container * web: use mapSettings color for style * style: add unique ids to map styles * mobile: use style json for vector / raster * do not use svelte-material-icons * add click events to markers, simplify asset detail map * improve map performance by using asset thumbnails for markers instead of original file * Remove custom attribution (by request) * mobile: update map attribution * style: map dark mode * style: map light mode * zoom level for state * styling * overflow gradient * Limit maxZoom to 14 * mobile: listen for mapStyle changes in MapThumbnail * mobile: update concurrency --------- Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: bo0tzz <git@bo0tzz.me> Co-authored-by: Alex <alex.tran1502@gmail.com>
90 lines
2.9 KiB
TypeScript
90 lines
2.9 KiB
TypeScript
import { Inject, Injectable } from '@nestjs/common';
|
|
import { JobName } from '../job';
|
|
import { CommunicationEvent, ICommunicationRepository, IJobRepository, ISystemConfigRepository } from '../repositories';
|
|
import { SystemConfigThemeDto } from './dto/system-config-theme.dto';
|
|
import { SystemConfigDto, mapConfig } from './dto/system-config.dto';
|
|
import { SystemConfigTemplateStorageOptionDto } from './response-dto/system-config-template-storage-option.dto';
|
|
import {
|
|
supportedDayTokens,
|
|
supportedHourTokens,
|
|
supportedMinuteTokens,
|
|
supportedMonthTokens,
|
|
supportedPresetTokens,
|
|
supportedSecondTokens,
|
|
supportedWeekTokens,
|
|
supportedYearTokens,
|
|
} from './system-config.constants';
|
|
import { SystemConfigCore, SystemConfigValidator } from './system-config.core';
|
|
|
|
@Injectable()
|
|
export class SystemConfigService {
|
|
private core: SystemConfigCore;
|
|
constructor(
|
|
@Inject(ISystemConfigRepository) private repository: ISystemConfigRepository,
|
|
@Inject(ICommunicationRepository) private communicationRepository: ICommunicationRepository,
|
|
@Inject(IJobRepository) private jobRepository: IJobRepository,
|
|
) {
|
|
this.core = SystemConfigCore.create(repository);
|
|
}
|
|
|
|
get config$() {
|
|
return this.core.config$;
|
|
}
|
|
|
|
async getTheme(): Promise<SystemConfigThemeDto> {
|
|
const { theme } = await this.core.getConfig();
|
|
return theme;
|
|
}
|
|
|
|
async getConfig(): Promise<SystemConfigDto> {
|
|
const config = await this.core.getConfig();
|
|
return mapConfig(config);
|
|
}
|
|
|
|
getDefaults(): SystemConfigDto {
|
|
const config = this.core.getDefaults();
|
|
return mapConfig(config);
|
|
}
|
|
|
|
async updateConfig(dto: SystemConfigDto): Promise<SystemConfigDto> {
|
|
const config = await this.core.updateConfig(dto);
|
|
await this.jobRepository.queue({ name: JobName.SYSTEM_CONFIG_CHANGE });
|
|
this.communicationRepository.broadcast(CommunicationEvent.CONFIG_UPDATE, {});
|
|
return mapConfig(config);
|
|
}
|
|
|
|
async refreshConfig() {
|
|
await this.core.refreshConfig();
|
|
return true;
|
|
}
|
|
|
|
addValidator(validator: SystemConfigValidator) {
|
|
this.core.addValidator(validator);
|
|
}
|
|
|
|
getStorageTemplateOptions(): SystemConfigTemplateStorageOptionDto {
|
|
const options = new SystemConfigTemplateStorageOptionDto();
|
|
|
|
options.dayOptions = supportedDayTokens;
|
|
options.weekOptions = supportedWeekTokens;
|
|
options.monthOptions = supportedMonthTokens;
|
|
options.yearOptions = supportedYearTokens;
|
|
options.hourOptions = supportedHourTokens;
|
|
options.secondOptions = supportedSecondTokens;
|
|
options.minuteOptions = supportedMinuteTokens;
|
|
options.presetOptions = supportedPresetTokens;
|
|
|
|
return options;
|
|
}
|
|
|
|
async getMapStyle(theme: 'light' | 'dark') {
|
|
const { map } = await this.getConfig();
|
|
const styleUrl = theme === 'dark' ? map.darkStyle : map.lightStyle;
|
|
|
|
if (styleUrl) {
|
|
return this.repository.fetchStyle(styleUrl);
|
|
}
|
|
|
|
return JSON.parse(await this.repository.readFile(`./assets/style-${theme}.json`));
|
|
}
|
|
}
|