Merge pull request #2888 from YevhenBondarenko/feature/ui-proxy

[WIP]mail proxy ui
This commit is contained in:
Igor Kulikov 2020-06-01 12:36:11 +03:00 committed by GitHub
commit 15c65dc16a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 12 deletions

View File

@ -1428,7 +1428,7 @@
},
"enabled": {
"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=",
"requires": {
"env-variable": "0.0.x"
@ -1779,7 +1779,7 @@
},
"fecha": {
"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=="
},
"file-stream-rotator": {
@ -2472,7 +2472,7 @@
},
"get-stream": {
"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=",
"dev": true
},
@ -2597,7 +2597,7 @@
},
"got": {
"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=",
"dev": true,
"requires": {
@ -2920,7 +2920,7 @@
},
"is-obj": {
"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=",
"dev": true
},
@ -3276,7 +3276,7 @@
},
"minimist": {
"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=",
"dev": true
},
@ -3604,7 +3604,7 @@
},
"path-is-absolute": {
"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=",
"dev": true
},
@ -4161,7 +4161,7 @@
},
"safe-regex": {
"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=",
"dev": true,
"requires": {
@ -4574,7 +4574,7 @@
},
"strip-eof": {
"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=",
"dev": true
},

View File

@ -87,6 +87,36 @@
</mat-option>
</mat-select>
</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-label translate>common.username</mat-label>
<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 { Router } from '@angular/router';
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 { ActionNotificationShow } from '@core/notification/notification.actions';
import { TranslateService } from '@ngx-translate/core';
@ -63,13 +63,18 @@ export class MailServerComponent extends PageComponent implements OnInit, HasCon
smtpProtocol: ['smtp'],
smtpHost: ['localhost', [Validators.required]],
smtpPort: ['25', [Validators.required,
Validators.pattern(smtpPortPattern),
Validators.pattern(portPattern),
Validators.maxLength(5)]],
timeout: ['10000', [Validators.required,
Validators.pattern(/^[0-9]{1,6}$/),
Validators.maxLength(6)]],
enableTls: ['false'],
tlsVersion: [],
enableProxy: ['false', []],
proxyHost: ['', [Validators.required]],
proxyPort: ['', [Validators.required, Validators.maxLength(5), Validators.pattern(portPattern)]],
proxyUser: [''],
proxyPassword: [''],
username: [''],
password: ['']
});
@ -77,6 +82,18 @@ export class MailServerComponent extends PageComponent implements OnInit, HasCon
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 {
this.adminSettings.jsonValue = {...this.adminSettings.jsonValue, ...this.mailSettings.value};
this.adminService.sendTestMail(this.adminSettings).subscribe(

View File

@ -14,7 +14,7 @@
/// 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> {
key: string;
@ -32,6 +32,11 @@ export interface MailServerSettings {
enableTls: boolean;
username: string;
password: string;
enableProxy: boolean;
proxyHost: string;
proxyPort: number;
proxyUser: string;
proxyPassword: string;
}
export interface GeneralSettings {