v0.8.6.2 - General Settings Hotfix (#3756)
Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com> Co-authored-by: Weblate (bot) <hosted@weblate.org> Co-authored-by: Lyrq <lyrq.ku@gmail.com> Co-authored-by: Ricky Tigg <ricky.tigg@gmail.com> Co-authored-by: 無情天 <kofzhanganguo@126.com>
This commit is contained in:
parent
d3f8a503c2
commit
14bf4400a9
9 changed files with 28 additions and 10 deletions
|
@ -64,7 +64,7 @@
|
|||
@if (settingsForm.get('ipAddresses'); as formControl) {
|
||||
<app-setting-item [title]="t('ip-address-label')" [subtitle]="t('ip-address-tooltip')">
|
||||
<ng-template #view>
|
||||
{{formControl.value}}
|
||||
{{formControl.value | defaultValue}}
|
||||
</ng-template>
|
||||
<ng-template #edit>
|
||||
<div class="input-group">
|
||||
|
@ -75,7 +75,7 @@
|
|||
|
||||
@if(settingsForm.dirty || !settingsForm.untouched) {
|
||||
<div id="ipaddresses-validations" class="invalid-feedback">
|
||||
@if (formControl.errors?.pattern) {
|
||||
@if (formControl.errors?.emptyOrPattern) {
|
||||
<div>{{t('ip-address-validation')}}</div>
|
||||
}
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms';
|
||||
import {FormControl, FormGroup, ReactiveFormsModule, ValidatorFn, Validators} from '@angular/forms';
|
||||
import {ToastrService} from 'ngx-toastr';
|
||||
import {take} from 'rxjs/operators';
|
||||
import {ServerService} from 'src/app/_services/server.service';
|
||||
|
@ -62,7 +62,7 @@ export class ManageSettingsComponent implements OnInit {
|
|||
this.settingsForm.addControl('taskScan', new FormControl(this.serverSettings.taskScan, [Validators.required]));
|
||||
this.settingsForm.addControl('taskBackup', new FormControl(this.serverSettings.taskBackup, [Validators.required]));
|
||||
this.settingsForm.addControl('taskCleanup', new FormControl(this.serverSettings.taskCleanup, [Validators.required]));
|
||||
this.settingsForm.addControl('ipAddresses', new FormControl(this.serverSettings.ipAddresses, [Validators.required, Validators.pattern(ValidIpAddress)]));
|
||||
this.settingsForm.addControl('ipAddresses', new FormControl(this.serverSettings.ipAddresses, [this.emptyOrPattern(ValidIpAddress)]));
|
||||
this.settingsForm.addControl('port', new FormControl(this.serverSettings.port, [Validators.required]));
|
||||
this.settingsForm.addControl('loggingLevel', new FormControl(this.serverSettings.loggingLevel, [Validators.required]));
|
||||
this.settingsForm.addControl('allowStatCollection', new FormControl(this.serverSettings.allowStatCollection, [Validators.required]));
|
||||
|
@ -77,6 +77,7 @@ export class ManageSettingsComponent implements OnInit {
|
|||
this.settingsForm.addControl('onDeckProgressDays', new FormControl(this.serverSettings.onDeckProgressDays, [Validators.required]));
|
||||
this.settingsForm.addControl('onDeckUpdateDays', new FormControl(this.serverSettings.onDeckUpdateDays, [Validators.required]));
|
||||
|
||||
|
||||
// Automatically save settings as we edit them
|
||||
this.settingsForm.valueChanges.pipe(
|
||||
distinctUntilChanged(),
|
||||
|
@ -186,4 +187,19 @@ export class ManageSettingsComponent implements OnInit {
|
|||
console.error('error: ', err);
|
||||
});
|
||||
}
|
||||
|
||||
emptyOrPattern(pattern: RegExp): ValidatorFn {
|
||||
return (control) => {
|
||||
if (!control.value || control.value.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (pattern.test(control.value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return { 'emptyOrPattern': { 'requiredPattern': pattern.toString(), 'actualValue': control.value } };
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue