Refactored Test email service to provide the error message if it fails to the end user. (#1051)
This commit is contained in:
parent
9ce0aa39ce
commit
edbb985405
5 changed files with 50 additions and 21 deletions
|
@ -4,10 +4,11 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
|||
import { ToastrService } from 'ngx-toastr';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { ConfirmService } from 'src/app/shared/confirm.service';
|
||||
import { SettingsService } from '../settings.service';
|
||||
import { EmailTestResult, SettingsService } from '../settings.service';
|
||||
import { DirectoryPickerComponent, DirectoryPickerResult } from '../_modals/directory-picker/directory-picker.component';
|
||||
import { ServerSettings } from '../_models/server-settings';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-manage-settings',
|
||||
templateUrl: './manage-settings.component.html',
|
||||
|
@ -103,11 +104,11 @@ export class ManageSettingsComponent implements OnInit {
|
|||
}
|
||||
|
||||
testEmailServiceUrl() {
|
||||
this.settingsService.testEmailServerSettings(this.settingsForm.get('emailServiceUrl')?.value || '').pipe(take(1)).subscribe(async (successful: boolean) => {
|
||||
if (successful) {
|
||||
this.settingsService.testEmailServerSettings(this.settingsForm.get('emailServiceUrl')?.value || '').pipe(take(1)).subscribe(async (result: EmailTestResult) => {
|
||||
if (result.successful) {
|
||||
this.toastr.success('Email Service Url validated');
|
||||
} else {
|
||||
this.toastr.error('Email Service Url did not respond');
|
||||
this.toastr.error('Email Service Url did not respond. ' + result.errorMessage);
|
||||
}
|
||||
|
||||
}, (err: any) => {
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { ServerSettings } from './_models/server-settings';
|
||||
|
||||
/**
|
||||
* Used only for the Test Email Service call
|
||||
*/
|
||||
export interface EmailTestResult {
|
||||
successful: boolean;
|
||||
errorMessage: string;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
|
@ -30,7 +37,7 @@ export class SettingsService {
|
|||
}
|
||||
|
||||
testEmailServerSettings(emailUrl: string) {
|
||||
return this.http.post<boolean>(this.baseUrl + 'settings/test-email-url', {url: emailUrl}, {responseType: 'text' as 'json'});
|
||||
return this.http.post<EmailTestResult>(this.baseUrl + 'settings/test-email-url', {url: emailUrl});
|
||||
}
|
||||
|
||||
getTaskFrequencies() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue