2024-05-29 17:51:01 +02:00
|
|
|
import { Body, Controller, Get, Put } from '@nestjs/common';
|
2023-02-24 17:01:10 +01:00
|
|
|
import { ApiTags } from '@nestjs/swagger';
|
2024-05-29 17:51:01 +02:00
|
|
|
import { SystemConfigDto, SystemConfigTemplateStorageOptionDto } from 'src/dtos/system-config.dto';
|
2024-08-16 09:48:43 -04:00
|
|
|
import { Permission } from 'src/enum';
|
2024-05-09 13:58:44 -04:00
|
|
|
import { Authenticated } from 'src/middleware/auth.guard';
|
2024-03-21 00:07:30 +01:00
|
|
|
import { SystemConfigService } from 'src/services/system-config.service';
|
2022-11-14 23:39:32 -05:00
|
|
|
|
|
|
|
|
@ApiTags('System Config')
|
|
|
|
|
@Controller('system-config')
|
|
|
|
|
export class SystemConfigController {
|
2024-04-17 03:00:31 +05:30
|
|
|
constructor(private service: SystemConfigService) {}
|
2022-11-14 23:39:32 -05:00
|
|
|
|
|
|
|
|
@Get()
|
2024-08-16 09:48:43 -04:00
|
|
|
@Authenticated({ permission: Permission.SYSTEM_CONFIG_READ, admin: true })
|
2023-03-24 00:53:56 -04:00
|
|
|
getConfig(): Promise<SystemConfigDto> {
|
2024-09-30 17:31:21 -04:00
|
|
|
return this.service.getSystemConfig();
|
2022-11-14 23:39:32 -05:00
|
|
|
}
|
|
|
|
|
|
2022-12-09 15:51:42 -05:00
|
|
|
@Get('defaults')
|
2024-08-16 09:48:43 -04:00
|
|
|
@Authenticated({ permission: Permission.SYSTEM_CONFIG_READ, admin: true })
|
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()
|
2024-08-16 09:48:43 -04:00
|
|
|
@Authenticated({ permission: Permission.SYSTEM_CONFIG_UPDATE, admin: true })
|
2023-03-31 17:14:01 +02:00
|
|
|
updateConfig(@Body() dto: SystemConfigDto): Promise<SystemConfigDto> {
|
2024-09-30 17:31:21 -04:00
|
|
|
return this.service.updateSystemConfig(dto);
|
2022-11-14 23:39:32 -05:00
|
|
|
}
|
2022-12-16 14:26:12 -06:00
|
|
|
|
|
|
|
|
@Get('storage-template-options')
|
2024-08-16 09:48:43 -04:00
|
|
|
@Authenticated({ permission: Permission.SYSTEM_CONFIG_READ, admin: true })
|
2023-03-24 00:53:56 -04:00
|
|
|
getStorageTemplateOptions(): SystemConfigTemplateStorageOptionDto {
|
|
|
|
|
return this.service.getStorageTemplateOptions();
|
2022-12-16 14:26:12 -06:00
|
|
|
}
|
2022-11-14 23:39:32 -05:00
|
|
|
}
|