added proxy ui for mail-server

This commit is contained in:
YevhenBondarenko 2020-06-01 01:34:26 +03:00
parent fe36f91890
commit 3c13b84ef4
4 changed files with 68 additions and 12 deletions

View File

@ -1428,7 +1428,7 @@
}, },
"enabled": { "enabled": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz", "resolved": "http://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz",
"integrity": "sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M=", "integrity": "sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M=",
"requires": { "requires": {
"env-variable": "0.0.x" "env-variable": "0.0.x"
@ -1779,7 +1779,7 @@
}, },
"fecha": { "fecha": {
"version": "2.3.3", "version": "2.3.3",
"resolved": "https://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz", "resolved": "http://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz",
"integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg==" "integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg=="
}, },
"file-stream-rotator": { "file-stream-rotator": {
@ -2472,7 +2472,7 @@
}, },
"get-stream": { "get-stream": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=",
"dev": true "dev": true
}, },
@ -2597,7 +2597,7 @@
}, },
"got": { "got": {
"version": "6.7.1", "version": "6.7.1",
"resolved": "https://registry.npmjs.org/got/-/got-6.7.1.tgz", "resolved": "http://registry.npmjs.org/got/-/got-6.7.1.tgz",
"integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -2920,7 +2920,7 @@
}, },
"is-obj": { "is-obj": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz",
"integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=",
"dev": true "dev": true
}, },
@ -3276,7 +3276,7 @@
}, },
"minimist": { "minimist": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
"dev": true "dev": true
}, },
@ -3604,7 +3604,7 @@
}, },
"path-is-absolute": { "path-is-absolute": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true "dev": true
}, },
@ -4161,7 +4161,7 @@
}, },
"safe-regex": { "safe-regex": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
"integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -4574,7 +4574,7 @@
}, },
"strip-eof": { "strip-eof": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", "resolved": "http://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
"integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=",
"dev": true "dev": true
}, },

View File

@ -87,6 +87,40 @@
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<tb-checkbox formControlName="enableProxy" style="display: block; padding-bottom: 16px;">
{{ 'admin.enable-proxy' | translate }}
</tb-checkbox>
<div fxLayout.gt-sm="row">
<mat-form-field class="mat-block" *ngIf="enableProxy()" fxFlex="100" fxFlex.gt-sm="60">
<mat-label translate>admin.proxy-host</mat-label>
<input matInput required formControlName="proxyHost">
<mat-error *ngIf="mailSettings.get('proxyHost').hasError('required')">
{{ 'admin.proxy-host-required' | translate }}
</mat-error>
</mat-form-field>
<mat-form-field class="mat-block" *ngIf="enableProxy()" fxFlex="100" fxFlex.gt-sm="40">
<mat-label translate>admin.proxy-port</mat-label>
<input matInput required formControlName="proxyPort" maxlength="5">
<mat-error *ngIf="mailSettings.get('proxyPort').hasError('required')">
{{ 'admin.proxy-port-required' | translate }}
</mat-error>
<mat-error *ngIf="mailSettings.get('proxyPort').hasError('pattern') || mailSettings.get('proxyPort').hasError('maxlength')">
{{ 'admin.proxy-port-invalid' | translate }}
</mat-error>
</mat-form-field>
</div>
<mat-form-field class="mat-block" *ngIf="enableProxy()">
<mat-label translate>admin.proxy-user</mat-label>
<input matInput formControlName="proxyUser">
</mat-form-field>
<mat-form-field class="mat-block" *ngIf="enableProxy()">
<mat-label translate>admin.proxy-password</mat-label>
<input matInput formControlName="proxyPassword">
</mat-form-field>
<mat-form-field class="mat-block"> <mat-form-field class="mat-block">
<mat-label translate>common.username</mat-label> <mat-label translate>common.username</mat-label>
<input matInput formControlName="username" placeholder="{{ 'common.enter-username' | translate }}"/> <input matInput formControlName="username" placeholder="{{ 'common.enter-username' | translate }}"/>

View File

@ -20,7 +20,7 @@ import { AppState } from '@core/core.state';
import { PageComponent } from '@shared/components/page.component'; import { PageComponent } from '@shared/components/page.component';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AdminSettings, MailServerSettings, smtpPortPattern } from '@shared/models/settings.models'; import { AdminSettings, MailServerSettings, portPattern } from '@shared/models/settings.models';
import { AdminService } from '@core/http/admin.service'; import { AdminService } from '@core/http/admin.service';
import { ActionNotificationShow } from '@core/notification/notification.actions'; import { ActionNotificationShow } from '@core/notification/notification.actions';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
@ -63,13 +63,18 @@ export class MailServerComponent extends PageComponent implements OnInit, HasCon
smtpProtocol: ['smtp'], smtpProtocol: ['smtp'],
smtpHost: ['localhost', [Validators.required]], smtpHost: ['localhost', [Validators.required]],
smtpPort: ['25', [Validators.required, smtpPort: ['25', [Validators.required,
Validators.pattern(smtpPortPattern), Validators.pattern(portPattern),
Validators.maxLength(5)]], Validators.maxLength(5)]],
timeout: ['10000', [Validators.required, timeout: ['10000', [Validators.required,
Validators.pattern(/^[0-9]{1,6}$/), Validators.pattern(/^[0-9]{1,6}$/),
Validators.maxLength(6)]], Validators.maxLength(6)]],
enableTls: ['false'], enableTls: ['false'],
tlsVersion: [], tlsVersion: [],
enableProxy: ['false', []],
proxyHost: ['', [Validators.required]],
proxyPort: ['', [Validators.required, Validators.maxLength(5), Validators.pattern(portPattern)]],
proxyUser: [''],
proxyPassword: [''],
username: [''], username: [''],
password: [''] password: ['']
}); });
@ -77,6 +82,18 @@ export class MailServerComponent extends PageComponent implements OnInit, HasCon
this.registerDisableOnLoadFormControl(this.mailSettings.get('enableTls')); this.registerDisableOnLoadFormControl(this.mailSettings.get('enableTls'));
} }
enableProxy(): boolean {
let enableProxy: boolean = this.mailSettings.get('enableProxy').value;
if (enableProxy) {
this.mailSettings.get('proxyHost').enable();
this.mailSettings.get('proxyPort').enable();
} else {
this.mailSettings.get('proxyHost').disable();
this.mailSettings.get('proxyPort').disable();
}
return enableProxy;
}
sendTestMail(): void { sendTestMail(): void {
this.adminSettings.jsonValue = {...this.adminSettings.jsonValue, ...this.mailSettings.value}; this.adminSettings.jsonValue = {...this.adminSettings.jsonValue, ...this.mailSettings.value};
this.adminService.sendTestMail(this.adminSettings).subscribe( this.adminService.sendTestMail(this.adminSettings).subscribe(

View File

@ -14,7 +14,7 @@
/// limitations under the License. /// limitations under the License.
/// ///
export const smtpPortPattern: RegExp = /^([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$/; export const portPattern: RegExp = /^([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$/;
export interface AdminSettings<T> { export interface AdminSettings<T> {
key: string; key: string;
@ -32,6 +32,11 @@ export interface MailServerSettings {
enableTls: boolean; enableTls: boolean;
username: string; username: string;
password: string; password: string;
enableProxy: boolean;
proxyHost: string;
proxyPort: number;
proxyUser?: string;
proxyPassword?: string;
} }
export interface GeneralSettings { export interface GeneralSettings {