2023-11-09 17:10:56 +01:00
|
|
|
import { Body, Controller, Get, Put, Query } from '@nestjs/common';
|
2023-02-24 17:01:10 +01:00
|
|
|
import { ApiTags } from '@nestjs/swagger';
|
2024-03-20 19:32:04 +01:00
|
|
|
import { MapThemeDto } from 'src/domain/system-config/system-config-map-theme.dto';
|
|
|
|
|
import { SystemConfigService } from 'src/domain/system-config/system-config.service';
|
2024-03-20 23:53:07 +01:00
|
|
|
import { SystemConfigTemplateStorageOptionDto } from 'src/dtos/system-config-storage-template.dto';
|
|
|
|
|
import { SystemConfigDto } from 'src/dtos/system-config.dto';
|
2024-03-20 15:15:01 -05:00
|
|
|
import { AdminRoute, Authenticated } from 'src/middleware/auth.guard';
|
2022-11-14 23:39:32 -05:00
|
|
|
|
|
|
|
|
@ApiTags('System Config')
|
|
|
|
|
@Controller('system-config')
|
2023-03-24 00:53:56 -04:00
|
|
|
@Authenticated({ admin: true })
|
2022-11-14 23:39:32 -05:00
|
|
|
export class SystemConfigController {
|
2023-03-24 00:53:56 -04:00
|
|
|
constructor(private readonly service: SystemConfigService) {}
|
2022-11-14 23:39:32 -05:00
|
|
|
|
|
|
|
|
@Get()
|
2023-03-24 00:53:56 -04:00
|
|
|
getConfig(): Promise<SystemConfigDto> {
|
|
|
|
|
return this.service.getConfig();
|
2022-11-14 23:39:32 -05:00
|
|
|
}
|
|
|
|
|
|
2022-12-09 15:51:42 -05:00
|
|
|
@Get('defaults')
|
2023-11-03 21:33:15 -04:00
|
|
|
getConfigDefaults(): SystemConfigDto {
|
2023-03-24 00:53:56 -04:00
|
|
|
return this.service.getDefaults();
|
2022-12-09 15:51:42 -05:00
|
|
|
}
|
|
|
|
|
|
2022-11-14 23:39:32 -05:00
|
|
|
@Put()
|
2023-03-31 17:14:01 +02:00
|
|
|
updateConfig(@Body() dto: SystemConfigDto): Promise<SystemConfigDto> {
|
2023-03-24 00:53:56 -04:00
|
|
|
return this.service.updateConfig(dto);
|
2022-11-14 23:39:32 -05:00
|
|
|
}
|
2022-12-16 14:26:12 -06:00
|
|
|
|
|
|
|
|
@Get('storage-template-options')
|
2023-03-24 00:53:56 -04:00
|
|
|
getStorageTemplateOptions(): SystemConfigTemplateStorageOptionDto {
|
|
|
|
|
return this.service.getStorageTemplateOptions();
|
2022-12-16 14:26:12 -06:00
|
|
|
}
|
2023-11-09 17:10:56 +01:00
|
|
|
|
2023-11-09 13:52:10 -06:00
|
|
|
@AdminRoute(false)
|
2023-11-09 17:10:56 +01:00
|
|
|
@Get('map/style.json')
|
|
|
|
|
getMapStyle(@Query() dto: MapThemeDto) {
|
|
|
|
|
return this.service.getMapStyle(dto.theme);
|
|
|
|
|
}
|
2022-11-14 23:39:32 -05:00
|
|
|
}
|