Skip to content

Commit ad75464

Browse files
fix[frontend](federation): added email configuration for federation use
1 parent 2ed6240 commit ad75464

9 files changed

Lines changed: 200 additions & 17 deletions

frontend/src/app/app-routing.module.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import {NgModule} from '@angular/core';
22
import {RouterModule, Routes} from '@angular/router';
33
import {UserRouteAccessService} from './core/auth/user-route-access-service';
4+
import {
5+
FederationEmailConfigPageComponent
6+
} from './federation/pages/email-config/federation-email-config.page.component';
47
import {TeamMembersPageComponent} from './federation/pages/team-members/team-members.page.component';
58
import {WelcomeComponent as FederationWelcomeComponent} from './federation/pages/welcome/welcome.component';
69
import {ConfirmIdentityComponent} from './shared/components/auth/confirm-identity/confirm-identity.component';
@@ -162,7 +165,13 @@ const routes: Routes = [
162165
{path: '', redirectTo: 'welcome', pathMatch: 'full'},
163166
{path: 'welcome', component: FederationWelcomeComponent},
164167
{path: 'instances', component: FederationWelcomeComponent},
165-
{path: 'team-members', component: TeamMembersPageComponent}
168+
{path: 'team-members', component: TeamMembersPageComponent},
169+
{
170+
path: 'email-config',
171+
component: FederationEmailConfigPageComponent,
172+
canActivate: [UserRouteAccessService],
173+
data: {authorities: [ADMIN_ROLE]}
174+
}
166175
]
167176
},
168177
{path: '', component: LoginComponent},

frontend/src/app/federation/components/federation-user-menu/federation-user-menu.component.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
<i class="icon-users"></i>
2121
Team Members
2222
</a>
23+
<a (click)="goToEmailConfig()" class="dropdown-item">
24+
<i class="icon-mail-read"></i>
25+
Email Configuration
26+
</a>
2327
<a (click)="openChangePassword()" class="dropdown-item">
2428
<i class="icon-lock5"></i>
2529
Change Password

frontend/src/app/federation/components/federation-user-menu/federation-user-menu.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ export class FederationUserMenuComponent {
2323
this.router.navigate(['/federation/team-members']);
2424
}
2525

26+
goToEmailConfig(): void {
27+
this.router.navigate(['/federation/email-config']);
28+
}
29+
2630
openProfileSettings(): void {
2731
this.modalService.open(SettingsComponent, {centered: true});
2832
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import {
2+
ConfigDataTypeEnum,
3+
SectionConfigParamType
4+
} from '../../../shared/types/configuration/section-config-param.type';
5+
import {SectionConfigType} from '../../../shared/types/configuration/section-config.type';
6+
7+
const EMAIL_SECTION = ({
8+
id: 2,
9+
section: 'email',
10+
shortName: 'EMAIL',
11+
description: 'Here you can configure all necessary parameters for email notifications'
12+
} as unknown) as SectionConfigType;
13+
14+
export const FEDERATION_EMAIL_CONFIG_SECTION: SectionConfigType = EMAIL_SECTION;
15+
16+
export const FEDERATION_EMAIL_CONFIG_PARAMS: SectionConfigParamType[] = ([
17+
{
18+
id: 4,
19+
sectionId: 2,
20+
confParamShort: 'utmstack.mail.password',
21+
confParamLarge: 'Mail Server Password',
22+
confParamDescription: 'Login password of the SMTP server',
23+
confParamValue: null,
24+
confParamRegexp: null,
25+
confParamRequired: true,
26+
confParamDatatype: ConfigDataTypeEnum.Password,
27+
confParamRestartRequired: false,
28+
confParamOption: null,
29+
section: EMAIL_SECTION
30+
},
31+
{
32+
id: 5,
33+
sectionId: 2,
34+
confParamShort: 'utmstack.mail.from',
35+
confParamLarge: 'Utmstack email address',
36+
confParamDescription: 'Address from which emails are sent',
37+
confParamValue: null,
38+
confParamRegexp: '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$',
39+
confParamRequired: true,
40+
confParamDatatype: ConfigDataTypeEnum.Email,
41+
confParamRestartRequired: false,
42+
confParamOption: null,
43+
section: EMAIL_SECTION
44+
},
45+
{
46+
id: 6,
47+
sectionId: 2,
48+
confParamShort: 'utmstack.mail.baseUrl',
49+
confParamLarge: 'Utmstack base url',
50+
confParamDescription: 'Base url of Utmstack',
51+
confParamValue: 'https://v11dev2.utmstack.com',
52+
confParamRegexp: '^(?:https?:\\/\\/)?(?:\\d{1,3}(?:\\.\\d{1,3}){3}|(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,})(?:\\/[^\\s]*)?$',
53+
confParamRequired: true,
54+
confParamDatatype: ConfigDataTypeEnum.Text,
55+
confParamRestartRequired: false,
56+
confParamOption: null,
57+
section: EMAIL_SECTION
58+
},
59+
{
60+
id: 7,
61+
sectionId: 2,
62+
confParamShort: 'utmstack.mail.host',
63+
confParamLarge: 'Mail Server Host',
64+
confParamDescription: 'SMTP server host. For instance, `smtp.example.com`.',
65+
confParamValue: 'example.hostmail.com',
66+
confParamRegexp: '^(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}|(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$',
67+
confParamRequired: true,
68+
confParamDatatype: ConfigDataTypeEnum.Text,
69+
confParamRestartRequired: false,
70+
confParamOption: null,
71+
section: EMAIL_SECTION
72+
},
73+
{
74+
id: 8,
75+
sectionId: 2,
76+
confParamShort: 'utmstack.mail.port',
77+
confParamLarge: 'Mail Server Port',
78+
confParamDescription: 'SMTP server port',
79+
confParamValue: '587',
80+
confParamRegexp: null,
81+
confParamRequired: true,
82+
confParamDatatype: ConfigDataTypeEnum.Number,
83+
confParamRestartRequired: false,
84+
confParamOption: null,
85+
section: EMAIL_SECTION
86+
},
87+
{
88+
id: 9,
89+
sectionId: 2,
90+
confParamShort: 'utmstack.mail.username',
91+
confParamLarge: 'Mail Server Username',
92+
confParamDescription: 'Login user of the SMTP server',
93+
confParamValue: null,
94+
confParamRegexp: null,
95+
confParamRequired: true,
96+
confParamDatatype: ConfigDataTypeEnum.Text,
97+
confParamRestartRequired: false,
98+
confParamOption: null,
99+
section: EMAIL_SECTION
100+
},
101+
{
102+
id: 10,
103+
sectionId: 2,
104+
confParamShort: 'utmstack.mail.organization',
105+
confParamLarge: 'Organization Name',
106+
confParamDescription: 'This field helps identify the organization name in incident and alert notification emails.',
107+
confParamValue: '',
108+
confParamRegexp: null,
109+
confParamRequired: false,
110+
confParamDatatype: ConfigDataTypeEnum.Text,
111+
confParamRestartRequired: false,
112+
confParamOption: null,
113+
section: EMAIL_SECTION
114+
},
115+
{
116+
id: 13,
117+
sectionId: 2,
118+
confParamShort: 'utmstack.mail.properties.mail.smtp.auth',
119+
confParamLarge: 'Encryption type',
120+
confParamDescription: 'Select the encryption type used by the SMTP server',
121+
confParamValue: 'STARTTLS',
122+
confParamRegexp: null,
123+
confParamRequired: true,
124+
confParamDatatype: ConfigDataTypeEnum.Radio,
125+
confParamRestartRequired: false,
126+
confParamOption: 'STARTTLS,SSL/TLS,NONE',
127+
section: EMAIL_SECTION
128+
}
129+
] as unknown) as SectionConfigParamType[];
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="container-fluid py-3">
2+
<div class="mb-3">
3+
<h4 class="label-header text-uppercase mb-1">Email Configuration</h4>
4+
<p class="text-muted mb-0">Configure SMTP parameters used for federation notifications.</p>
5+
</div>
6+
<app-config-sections [section]="section" [params]="params"></app-config-sections>
7+
</div>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:host {
2+
display: block;
3+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {Component} from '@angular/core';
2+
import {
3+
FEDERATION_EMAIL_CONFIG_PARAMS,
4+
FEDERATION_EMAIL_CONFIG_SECTION
5+
} from './federation-email-config-params.const';
6+
7+
@Component({
8+
selector: 'app-federation-email-config-page',
9+
templateUrl: './federation-email-config.page.component.html',
10+
styleUrls: ['./federation-email-config.page.component.scss']
11+
})
12+
export class FederationEmailConfigPageComponent {
13+
readonly section = FEDERATION_EMAIL_CONFIG_SECTION;
14+
readonly params = FEDERATION_EMAIL_CONFIG_PARAMS;
15+
}

frontend/src/app/shared/components/utm/config/app-config-sections/app-config-sections.component.ts

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {AppConfigDeleteConfirmComponent} from '../app-config-delete-confirm/app-
2929
export class AppConfigSectionsComponent implements OnInit, OnDestroy {
3030

3131
@Input() section: SectionConfigType;
32+
@Input() params?: SectionConfigParamType[];
3233
@Output() validConfigSection = new EventEmitter<boolean>();
3334
@Input() allowDeleteSection = false;
3435
@Output() changesApplied = new EventEmitter<boolean>();
@@ -66,7 +67,12 @@ export class AppConfigSectionsComponent implements OnInit, OnDestroy {
6667

6768

6869
ngOnInit() {
69-
this.getConfigurations();
70+
if (this.params) {
71+
this.applyConfigs(this.params);
72+
this.loading = false;
73+
} else {
74+
this.getConfigurations();
75+
}
7076
this.changesApplied.emit(true);
7177

7278
this.networkService.isOnline$
@@ -89,26 +95,28 @@ export class AppConfigSectionsComponent implements OnInit, OnDestroy {
8995
})
9096
.subscribe(response => {
9197
this.loading = false;
92-
this.configs = response.body;
93-
94-
this.configs = this.configs.map(conf => {
95-
if(conf.confParamDatatype === ConfigDataTypeEnum.Cron) {
96-
conf.confParamValue = JSON.parse(conf.confParamValue);
97-
}
98-
return conf;
99-
});
100-
101-
const countryList = this.configs.find(conf => conf.confParamDatatype === ConfigDataTypeEnum.CountryList);
102-
if (countryList) {
103-
this.loadSelectOptions(this.getName(countryList.confParamShort));
104-
}
105-
this.configToSave=this.configs
106-
this.validConfigSection.emit(this.checkConfigValid());
98+
this.applyConfigs(response.body);
10799
}, error => {
108100
this.toastService.showError('Error', 'Error getting application configurations');
109101
});
110102
}
111103

104+
private applyConfigs(params: SectionConfigParamType[]) {
105+
this.configs = params.map(conf => {
106+
if (conf.confParamDatatype === ConfigDataTypeEnum.Cron) {
107+
conf.confParamValue = JSON.parse(conf.confParamValue);
108+
}
109+
return conf;
110+
});
111+
112+
const countryList = this.configs.find(conf => conf.confParamDatatype === ConfigDataTypeEnum.CountryList);
113+
if (countryList) {
114+
this.loadSelectOptions(this.getName(countryList.confParamShort));
115+
}
116+
this.configToSave = this.configs;
117+
this.validConfigSection.emit(this.checkConfigValid());
118+
}
119+
112120
saveConfig() {
113121
this.checkedEmailConfig(false);
114122
this.saving = true;

frontend/src/app/shared/utm-shared.module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ import {
118118
} from './components/utm/config/app-config-delete-confirm/app-config-delete-confirm.component';
119119
import {AppConfigParamsComponent} from './components/utm/config/app-config-params/app-config-params.component';
120120
import {AppConfigSectionsComponent} from './components/utm/config/app-config-sections/app-config-sections.component';
121+
import {
122+
FederationEmailConfigPageComponent
123+
} from '../federation/pages/email-config/federation-email-config.page.component';
121124
import {
122125
AppModuleDisabledWarningComponent
123126
} from './components/utm/config/app-module-disabled-warning/app-module-disabled-warning.component';
@@ -348,6 +351,7 @@ import {ScheduleConfigComponent} from './components/schedule-config/schedule-con
348351
GenericFilerSortComponent,
349352
AppConfigParamsComponent,
350353
AppConfigSectionsComponent,
354+
FederationEmailConfigPageComponent,
351355
AppModuleDisabledWarningComponent,
352356
AppConfigDeleteConfirmComponent,
353357
UtmScrollTopComponent,

0 commit comments

Comments
 (0)