Skip to content

Commit

Permalink
Improved notification sending
Browse files Browse the repository at this point in the history
* 2 target emails
* configure SMTP host/port
  • Loading branch information
gkovacs81 committed Feb 5, 2023
1 parent cd158d0 commit 34b4401
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
27 changes: 23 additions & 4 deletions src/app/config/notifications/notifications.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,20 @@
<input type="password" matInput formControlName="smtpPassword" i18n-placeholder="@@notifications stmp password" placeholder="SMTP password">
</mat-form-field>

<mat-form-field class="half-width">
<input matInput formControlName="smtpHostname" i18n-placeholder="@@notifications smtp username" placeholder="SMTP hostname">
</mat-form-field>

<mat-form-field class="half-width">
<input matInput formControlName="smtpPort" i18n-placeholder="@@notifications smtp username" placeholder="SMTP port">
</mat-form-field>

<mat-form-field class="full-width">
<input matInput formControlName="emailAddress" i18n-placeholder="@@notifications smtp email" placeholder="Email address">
<input matInput formControlName="email1Address" i18n-placeholder="@@notifications smtp email" placeholder="Email address 1">
</mat-form-field>

<mat-form-field class="full-width">
<input matInput formControlName="email2Address" i18n-placeholder="@@notifications smtp email" placeholder="Email address 2">
</mat-form-field>
</mat-expansion-panel>

Expand Down Expand Up @@ -47,13 +59,17 @@
<div class="mat-table">
<div class="mat-header-row">
<div class="mat-header-cell" i18n="@@notifications source">Event</div>
<div class="mat-header-cell" i18n="@@notifications send email">Send Email</div>
<div class="mat-header-cell" i18n="@@notifications send email1">Send Email 1</div>
<div class="mat-header-cell" i18n="@@notifications send email2">Send Email 2</div>
<div class="mat-header-cell" i18n="@@notifications send sms">Send SMS</div>
</div>
<div class="mat-row">
<div class="mat-cell" i18n="@@notifications alert started">Alert started</div>
<div class="mat-cell">
<mat-checkbox formControlName="alertStartedEmail"></mat-checkbox>
<mat-checkbox formControlName="alertStartedEmail1"></mat-checkbox>
</div>
<div class="mat-cell">
<mat-checkbox formControlName="alertStartedEmail2"></mat-checkbox>
</div>
<div class="mat-cell">
<mat-checkbox formControlName="alertStartedSms"></mat-checkbox>
Expand All @@ -62,7 +78,10 @@
<div class="mat-row">
<div class="mat-cell" i18n="@@notifications alert stopped">Alert stopped</div>
<div class="mat-cell">
<mat-checkbox formControlName="alertStoppedEmail"></mat-checkbox>
<mat-checkbox formControlName="alertStoppedEmail1"></mat-checkbox>
</div>
<div class="mat-cell">
<mat-checkbox formControlName="alertStoppedEmail2"></mat-checkbox>
</div>
<div class="mat-cell">
<mat-checkbox formControlName="alertStoppedSms"></mat-checkbox>
Expand Down
26 changes: 19 additions & 7 deletions src/app/config/notifications/notifications.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,18 @@ export class NotificationsComponent extends ConfigurationBaseComponent implement
this.notificationsForm = this.fb.group({
smtpUsername: getValue(email.value, 'smtp_username'),
smtpPassword: getValue(email.value, 'smtp_password'),
emailAddress: getValue(email.value, 'email_address'),
smtpHostname: getValue(email.value, 'smtp_hostname'),
smtpPort: getValue(email.value, 'smtp_port'),
email1Address: getValue(email.value, 'email1_address'),
email2Address: getValue(email.value, 'email2_address'),

pinCode: getValue(gsm.value, 'pin_code'),
phoneNumber: getValue(gsm.value, 'phone_number'),

alertStartedEmail: getValue(getValue(subscriptions.value, 'email'), 'alert_started'),
alertStoppedEmail: getValue(getValue(subscriptions.value, 'email'), 'alert_stopped'),
alertStartedEmail1: getValue(getValue(subscriptions.value, 'email1'), 'alert_started'),
alertStoppedEmail1: getValue(getValue(subscriptions.value, 'email1'), 'alert_stopped'),
alertStartedEmail2: getValue(getValue(subscriptions.value, 'email2'), 'alert_started'),
alertStoppedEmail2: getValue(getValue(subscriptions.value, 'email2'), 'alert_stopped'),
alertStartedSms: getValue(getValue(subscriptions.value, 'sms'), 'alert_started'),
alertStoppedSms: getValue(getValue(subscriptions.value, 'sms'), 'alert_stopped')
});
Expand Down Expand Up @@ -95,7 +100,10 @@ export class NotificationsComponent extends ConfigurationBaseComponent implement
const formModel = this.notificationsForm.value;
const email: any = {
smtp_username: formModel.smtpUsername,
email_address: formModel.emailAddress,
smtp_hostname: formModel.smtpHostname,
smtp_port: formModel.smtpPort,
email1_address: formModel.email1Address,
email2_address: formModel.email2Address
};

if (formModel.smtpPassword) {
Expand All @@ -116,9 +124,13 @@ export class NotificationsComponent extends ConfigurationBaseComponent implement
prepareSubscriptions(): any {
const formModel = this.notificationsForm.value;
return {
email: {
alert_started: formModel.alertStartedEmail,
alert_stopped: formModel.alertStoppedEmail,
email1: {
alert_started: formModel.alertStartedEmail1,
alert_stopped: formModel.alertStoppedEmail1,
},
email2: {
alert_started: formModel.alertStartedEmail2,
alert_stopped: formModel.alertStoppedEmail2,
},
sms: {
alert_started: formModel.alertStartedSms,
Expand Down

0 comments on commit 34b4401

Please sign in to comment.