From 99a77999fbb897e1929acd38545d6012eb467a64 Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Tue, 11 Jun 2024 00:27:18 +0300 Subject: [PATCH] feat: add setup/logging page --- .../setup/logging/logging.component.html | 39 +++++++++++ src/pages/setup/logging/logging.component.ts | 69 +++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 src/pages/setup/logging/logging.component.html create mode 100644 src/pages/setup/logging/logging.component.ts diff --git a/src/pages/setup/logging/logging.component.html b/src/pages/setup/logging/logging.component.html new file mode 100644 index 0000000..4c18367 --- /dev/null +++ b/src/pages/setup/logging/logging.component.html @@ -0,0 +1,39 @@ +

Настройка логирования

+
+

+ Настройте систему логирования как будет удобно для отображения. + Можно настроить путь к файлу, имена файлов или вовсе отключить логирование в файл. +

+ +
+

+ Введите данные для настройки системы логирования: +

+ +
+ + Включить логирование в файл + + + + Путь к логам + + + + + Название файла + + +
+
+ +
+ +
diff --git a/src/pages/setup/logging/logging.component.ts b/src/pages/setup/logging/logging.component.ts new file mode 100644 index 0000000..2c6ca69 --- /dev/null +++ b/src/pages/setup/logging/logging.component.ts @@ -0,0 +1,69 @@ +import {Component} from '@angular/core'; +import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms"; +import {NavigationService} from "@service/navigation.service"; +import SetupService from "@api/v1/setup.service"; +import {MatFormFieldModule} from "@angular/material/form-field"; +import {MatSelectModule} from "@angular/material/select"; +import {MatInput} from "@angular/material/input"; +import {MatTooltip} from "@angular/material/tooltip"; +import {MatButton, MatIconButton} from "@angular/material/button"; +import {MatCheckbox} from "@angular/material/checkbox"; + +@Component({ + selector: 'app-logging', + standalone: true, + imports: [ + ReactiveFormsModule, + MatFormFieldModule, + MatSelectModule, + MatInput, + MatTooltip, + MatIconButton, + MatCheckbox, + MatButton + + ], + templateUrl: './logging.component.html' +}) + +export class LoggingComponent { + protected loggingSettings!: FormGroup; + + protected isEnabledLoggingChange(check: boolean) { + if (check) { + this.loggingSettings.get('logPath')?.enable(); + this.loggingSettings.get('logName')?.enable(); + } else { + this.loggingSettings.get('logPath')?.disable(); + this.loggingSettings.get('logName')?.disable(); + } + } + + protected skipButton() { + this.navigationService.skipNavigation.emit(() => this.api.setLogging(null)); + } + + constructor( + private navigationService: NavigationService, private formBuilder: FormBuilder, private api: SetupService) { + this.loggingSettings = this.formBuilder.group({ + enabled: [true, Validators.required], + logPath: [''], + logName: [''] + } + ); + + this.navigationService.setNextButtonState(this.loggingSettings.valid); + this.loggingSettings.valueChanges.subscribe(() => { + this.navigationService.setNextButtonState(this.loggingSettings.valid); + }); + + this.navigationService.nextButtonAction = () => { + return this.api.setLogging({ + "enableLogToFile": this.loggingSettings.get('cron')?.value, + "logFileName": this.loggingSettings.get('logName')?.value, + "logFilePath": this.loggingSettings.get('logPath')?.value + } + ); + }; + } +}