feat: add setup/logging page

This commit is contained in:
2024-06-11 00:27:18 +03:00
parent d764e84726
commit 99a77999fb
2 changed files with 108 additions and 0 deletions

View File

@ -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
}
);
};
}
}