diff --git a/src/Ombi/ClientApp/app/settings/notifications/discord.component.html b/src/Ombi/ClientApp/app/settings/notifications/discord.component.html new file mode 100644 index 000000000..20582e666 --- /dev/null +++ b/src/Ombi/ClientApp/app/settings/notifications/discord.component.html @@ -0,0 +1,99 @@ + + +
+
+ Email Notifications +
+
+ +
+
+ + +
+
+ +
+
+ +
+
+
+
Host is required
+
The Port is required
+
The Email Sender is required
+
The Email Sender needs to be a valid email address
+
The Email Sender is required
+
The Admin Email needs to be a valid email address
+
The Username is required
+
The Password is required
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+ + + +
+
+ +
+
+
+
+ + +
+ +
+
+
\ No newline at end of file diff --git a/src/Ombi/ClientApp/app/settings/notifications/discord.component.ts b/src/Ombi/ClientApp/app/settings/notifications/discord.component.ts new file mode 100644 index 000000000..0d3d217d3 --- /dev/null +++ b/src/Ombi/ClientApp/app/settings/notifications/discord.component.ts @@ -0,0 +1,87 @@ +import { Component, OnInit } from '@angular/core'; +import { FormGroup, Validators, FormBuilder } from '@angular/forms'; + +import { INotificationTemplates, IEmailNotificationSettings, NotificationType } from '../../interfaces/INotifcationSettings'; +import { SettingsService } from '../../services/settings.service'; +import { NotificationService } from "../../services/notification.service"; +import { ValidationService } from "../../services/helpers/validation.service"; + +@Component({ + templateUrl: './discord.component.html', +}) +export class DiscordComponent implements OnInit { + constructor(private settingsService: SettingsService, + private notificationService: NotificationService, + private fb: FormBuilder, + private validationService: ValidationService) { } + + NotificationType = NotificationType; + templates: INotificationTemplates[]; + + emailForm: FormGroup; + + ngOnInit(): void { + this.settingsService.getEmailNotificationSettings().subscribe(x => { + this.templates = x.notificationTemplates; + + this.emailForm = this.fb.group({ + enabled: [x.enabled], + authentication: [x.authentication], + host: [x.host, [Validators.required]], + password: [x.password], + port: [x.port, [Validators.required]], + sender: [x.sender, [Validators.required, Validators.email]], + username: [x.username], + adminEmail: [x.adminEmail, [Validators.required, Validators.email]], + }); + + if (x.authentication) { + this.validationService.enableValidation(this.emailForm, 'username'); + this.validationService.enableValidation(this.emailForm, 'password'); + } + + this.subscribeToAuthChanges(); + }); + } + + onSubmit(form: FormGroup) { + console.log(form.value, form.valid); + + if (form.invalid) { + this.notificationService.error("Validation", "Please check your entered values"); + return + } + + var settings = form.value; + settings.notificationTemplates = this.templates; + + this.settingsService.saveEmailNotificationSettings(settings).subscribe(x => { + if (x) { + this.notificationService.success("Settings Saved", "Successfully saved Email settings"); + } else { + this.notificationService.success("Settings Saved", "There was an error when saving the Email settings"); + } + }); + + } + + save() { + + } + + private subscribeToAuthChanges() { + const authCtrl = this.emailForm.controls.authentication; + const changes$ = authCtrl.valueChanges; + + changes$.subscribe((auth: boolean) => { + + if (auth) { + this.validationService.enableValidation(this.emailForm, 'username'); + this.validationService.enableValidation(this.emailForm, 'password'); + } else { + this.validationService.disableValidation(this.emailForm, 'username'); + this.validationService.disableValidation(this.emailForm, 'password'); + } + }); + } +} \ No newline at end of file diff --git a/src/Ombi/Ombi.csproj b/src/Ombi/Ombi.csproj index afe1830bc..b44d0b559 100644 --- a/src/Ombi/Ombi.csproj +++ b/src/Ombi/Ombi.csproj @@ -31,7 +31,7 @@ - + %(DistFiles.Identity) PreserveNewest