Allow changing listening ip addresses (#1713)
* Allow changing listening ip address * Use Json serialize for appsettings.config saving * BOM * IP Address validation * ip address reset * ValidIpAddress regex
This commit is contained in:
parent
01aed6ad99
commit
11cb2cfb17
13 changed files with 194 additions and 17 deletions
|
@ -4,6 +4,7 @@ export interface ServerSettings {
|
|||
taskBackup: string;
|
||||
loggingLevel: string;
|
||||
port: number;
|
||||
ipAddresses: string;
|
||||
allowStatCollection: boolean;
|
||||
enableOpds: boolean;
|
||||
baseUrl: string;
|
||||
|
|
|
@ -34,14 +34,32 @@
|
|||
</div>
|
||||
|
||||
<div class="row g-0 mb-2">
|
||||
<div class="col-md-3 col-sm-12 pe-2">
|
||||
<div class="col-md-8 col-sm-12 pe-2">
|
||||
<label for="settings-ipaddresses" class="form-label">IP Addresses</label> <i class="fa fa-info-circle" placement="right" [ngbTooltip]="ipAddressesTooltip" role="button" tabindex="0"></i>
|
||||
<ng-template #ipAddressesTooltip>This does not apply to Docker</ng-template>
|
||||
<span class="visually-hidden" id="settings-ipaddresses-help">Comma separated list of Ip addresses the server listens on. This is fixed if you are running on Docker. Requires restart to take effect.</span>
|
||||
<div class="input-group">
|
||||
<input id="settings-ipaddresses" aria-describedby="settings-ipaddresses-help" class="form-control" formControlName="ipAddresses" type="text"
|
||||
[class.is-invalid]="settingsForm.get('ipAddresses')?.invalid && settingsForm.get('ipAddresses')?.touched">
|
||||
<button class="btn btn-outline-secondary" (click)="resetIPAddresses()">Reset</button>
|
||||
</div>
|
||||
<div id="ipaddresses-validations" class="invalid-feedback" *ngIf="settingsForm.dirty || settingsForm.touched">
|
||||
<div *ngIf="settingsForm.get('ipAddresses')?.errors?.pattern">
|
||||
IP addresses can only contain valid IPv4 or IPv6 addresses
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 col-sm-12 pe-2">
|
||||
<label for="settings-port" class="form-label">Port</label> <i class="fa fa-info-circle" placement="right" [ngbTooltip]="portTooltip" role="button" tabindex="0"></i>
|
||||
<ng-template #portTooltip>Port the server listens on. This is fixed if you are running on Docker. Requires restart to take effect.</ng-template>
|
||||
<span class="visually-hidden" id="settings-port-help">Port the server listens on. This is fixed if you are running on Docker. Requires restart to take effect.</span>
|
||||
<input id="settings-port" aria-describedby="settings-port-help" class="form-control" formControlName="port" type="number" step="1" min="1" onkeypress="return event.charCode >= 48 && event.charCode <= 57">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 col-sm-12 pe-2">
|
||||
<div class="row g-0 mb-2">
|
||||
<div class="col-md-4 col-sm-12 pe-2">
|
||||
<label for="backup-tasks" class="form-label">Days of Backups</label> <i class="fa fa-info-circle" placement="right" [ngbTooltip]="backupTasksTooltip" role="button" tabindex="0"></i>
|
||||
<ng-template #backupTasksTooltip>The number of backups to maintain. Default is 30, minumum is 1, maximum is 30.</ng-template>
|
||||
<span class="visually-hidden" id="backup-tasks-help">The number of backups to maintain. Default is 30, minumum is 1, maximum is 30.</span>
|
||||
|
@ -61,7 +79,7 @@
|
|||
</ng-container>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 col-sm-12 pe-2">
|
||||
<div class="col-md-4 col-sm-12 pe-2">
|
||||
<label for="log-tasks" class="form-label">Days of Logs</label> <i class="fa fa-info-circle" placement="right" [ngbTooltip]="logTasksTooltip" role="button" tabindex="0"></i>
|
||||
<ng-template #logTasksTooltip>The number of logs to maintain. Default is 30, minumum is 1, maximum is 30.</ng-template>
|
||||
<span class="visually-hidden" id="log-tasks-help">The number of backups to maintain. Default is 30, minumum is 1, maximum is 30.</span>
|
||||
|
@ -81,7 +99,7 @@
|
|||
</ng-container>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 col-sm-12">
|
||||
<div class="col-md-4 col-sm-12">
|
||||
<label for="logging-level-port" class="form-label">Logging Level</label> <i class="fa fa-info-circle" placement="right" [ngbTooltip]="loggingLevelTooltip" role="button" tabindex="0"></i>
|
||||
<ng-template #loggingLevelTooltip>Use debug to help identify issues. Debug can eat up a lot of disk space.</ng-template>
|
||||
<span class="visually-hidden" id="logging-level-port-help">Port the server listens on.</span>
|
||||
|
|
|
@ -8,6 +8,7 @@ import { SettingsService } from '../settings.service';
|
|||
import { DirectoryPickerComponent, DirectoryPickerResult } from '../_modals/directory-picker/directory-picker.component';
|
||||
import { ServerSettings } from '../_models/server-settings';
|
||||
|
||||
const ValidIpAddress = /^(\s*((([12]?\d{1,2}\.){3}[12]?\d{1,2})|(([\da-f]{0,4}\:){0,7}([\da-f]{0,4})))\s*\,)*\s*((([12]?\d{1,2}\.){3}[12]?\d{1,2})|(([\da-f]{0,4}\:){0,7}([\da-f]{0,4})))\s*$/i;
|
||||
|
||||
@Component({
|
||||
selector: 'app-manage-settings',
|
||||
|
@ -25,7 +26,7 @@ export class ManageSettingsComponent implements OnInit {
|
|||
return TagBadgeCursor;
|
||||
}
|
||||
|
||||
constructor(private settingsService: SettingsService, private toastr: ToastrService,
|
||||
constructor(private settingsService: SettingsService, private toastr: ToastrService,
|
||||
private modalService: NgbModal) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
|
@ -41,6 +42,7 @@ export class ManageSettingsComponent implements OnInit {
|
|||
this.settingsForm.addControl('bookmarksDirectory', new FormControl(this.serverSettings.bookmarksDirectory, [Validators.required]));
|
||||
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('ipAddresses', new FormControl(this.serverSettings.ipAddresses, [Validators.required, Validators.pattern(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]));
|
||||
|
@ -60,6 +62,7 @@ export class ManageSettingsComponent implements OnInit {
|
|||
this.settingsForm.get('bookmarksDirectory')?.setValue(this.serverSettings.bookmarksDirectory);
|
||||
this.settingsForm.get('scanTask')?.setValue(this.serverSettings.taskScan);
|
||||
this.settingsForm.get('taskBackup')?.setValue(this.serverSettings.taskBackup);
|
||||
this.settingsForm.get('ipAddresses')?.setValue(this.serverSettings.ipAddresses);
|
||||
this.settingsForm.get('port')?.setValue(this.serverSettings.port);
|
||||
this.settingsForm.get('loggingLevel')?.setValue(this.serverSettings.loggingLevel);
|
||||
this.settingsForm.get('allowStatCollection')?.setValue(this.serverSettings.allowStatCollection);
|
||||
|
@ -96,6 +99,16 @@ export class ManageSettingsComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
resetIPAddresses() {
|
||||
this.settingsService.resetIPAddressesSettings().pipe(take(1)).subscribe(async (settings: ServerSettings) => {
|
||||
this.serverSettings.ipAddresses = settings.ipAddresses;
|
||||
this.settingsForm.get("ipAddresses")?.setValue(this.serverSettings.ipAddresses);
|
||||
this.toastr.success('IP Addresses Reset');
|
||||
}, (err: any) => {
|
||||
console.error('error: ', err);
|
||||
});
|
||||
}
|
||||
|
||||
openDirectoryChooser(existingDirectory: string, formControl: string) {
|
||||
const modalRef = this.modalService.open(DirectoryPickerComponent, { scrollable: true, size: 'lg' });
|
||||
modalRef.componentInstance.startingFolder = existingDirectory || '';
|
||||
|
|
|
@ -33,6 +33,10 @@ export class SettingsService {
|
|||
return this.http.post<ServerSettings>(this.baseUrl + 'settings/reset', {});
|
||||
}
|
||||
|
||||
resetIPAddressesSettings() {
|
||||
return this.http.post<ServerSettings>(this.baseUrl + 'settings/reset-ip-addresses', {});
|
||||
}
|
||||
|
||||
resetEmailServerSettings() {
|
||||
return this.http.post<ServerSettings>(this.baseUrl + 'settings/reset-email-url', {});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue