-
-
-
-
-
+
+
+
+
-
-
diff --git a/apps/red-ui/src/app/modules/admin/screens/smtp-config/smtp-config-screen.component.scss b/apps/red-ui/src/app/modules/admin/screens/general-config/general-config-screen.component.scss
similarity index 96%
rename from apps/red-ui/src/app/modules/admin/screens/smtp-config/smtp-config-screen.component.scss
rename to apps/red-ui/src/app/modules/admin/screens/general-config/general-config-screen.component.scss
index 71129224b..581e22a78 100644
--- a/apps/red-ui/src/app/modules/admin/screens/smtp-config/smtp-config-screen.component.scss
+++ b/apps/red-ui/src/app/modules/admin/screens/general-config/general-config-screen.component.scss
@@ -21,6 +21,7 @@
height: 38px;
border-radius: 4px;
padding: 1px 11px;
+ margin-top: 20px;
}
.dialog {
diff --git a/apps/red-ui/src/app/modules/admin/screens/general-config/general-config-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/general-config/general-config-screen.component.ts
new file mode 100644
index 000000000..750e0741d
--- /dev/null
+++ b/apps/red-ui/src/app/modules/admin/screens/general-config/general-config-screen.component.ts
@@ -0,0 +1,149 @@
+import { Component, OnInit } from '@angular/core';
+import { PermissionsService } from '@services/permissions.service';
+import { FormBuilder, FormGroup, Validators } from '@angular/forms';
+import { AdminDialogService } from '../../services/admin-dialog.service';
+import {
+ GeneralConfigurationModel,
+ GeneralSettingsControllerService,
+ SmtpConfigurationControllerService,
+ SMTPConfigurationModel
+} from '@redaction/red-ui-http';
+import { AppConfigService } from '../../../app-config/app-config.service';
+import { AutoUnsubscribeComponent } from '../../../shared/base/auto-unsubscribe.component';
+import { Toaster } from '../../../../services/toaster.service';
+import { LoadingService } from '../../../../services/loading.service';
+
+@Component({
+ selector: 'redaction-general-config-screen',
+ templateUrl: './general-config-screen.component.html',
+ styleUrls: ['./general-config-screen.component.scss']
+})
+export class GeneralConfigScreenComponent extends AutoUnsubscribeComponent implements OnInit {
+ configForm: FormGroup;
+ smtpForm: FormGroup;
+
+ private _initialGeneralConfiguration: GeneralConfigurationModel;
+ private _initialSMTPConfiguration: SMTPConfigurationModel;
+
+ constructor(
+ readonly permissionsService: PermissionsService,
+ private readonly _smtpConfigService: SmtpConfigurationControllerService,
+ private readonly _appConfigService: AppConfigService,
+ private readonly _formBuilder: FormBuilder,
+ private readonly _toaster: Toaster,
+ private readonly _dialogService: AdminDialogService,
+ private readonly _generalSettingsControllerService: GeneralSettingsControllerService,
+ private readonly _loadingService: LoadingService
+ ) {
+ super();
+
+ this.configForm = this._formBuilder.group({
+ forgotPasswordFunctionEnabled: [false],
+ displayName: [undefined]
+ });
+
+ this.smtpForm = this._formBuilder.group({
+ host: [undefined, Validators.required],
+ port: [25],
+ from: [undefined, [Validators.required, Validators.email]],
+ fromDisplayName: [undefined],
+ replyTo: [undefined],
+ replyToDisplayName: [undefined],
+ envelopeFrom: [undefined],
+ ssl: [false],
+ starttls: [false],
+ auth: [false],
+ user: [undefined],
+ password: [undefined]
+ });
+
+ this.addSubscription = this.smtpForm.controls.auth.valueChanges.subscribe(auth => {
+ if (auth) {
+ this.openAuthConfigDialog();
+ }
+ });
+ }
+
+ get smtpConfigurationChanged(): boolean {
+ if (!this._initialSMTPConfiguration) return true;
+
+ for (const key of Object.keys(this.smtpForm.getRawValue())) {
+ if (this._initialSMTPConfiguration[key] !== this.smtpForm.get(key).value) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ get generalConfigurationChanged(): boolean {
+ if (!this._initialGeneralConfiguration) return true;
+
+ for (const key of Object.keys(this.configForm.getRawValue())) {
+ if (this._initialGeneralConfiguration[key] !== this.configForm.get(key).value) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ async ngOnInit() {
+ await this._loadData();
+ }
+
+ async save() {
+ this._loadingService.start();
+ await this._smtpConfigService.updateSMTPConfiguration(this.smtpForm.getRawValue()).toPromise();
+ this._initialSMTPConfiguration = this.smtpForm.getRawValue();
+ this._loadingService.stop();
+ }
+
+ async saveGeneralConfig() {
+ this._loadingService.start();
+
+ const configFormValues = this.configForm.getRawValue();
+ configFormValues.displayName = configFormValues.displayName || 'RedactManager';
+
+ await this._generalSettingsControllerService.updateGeneralConfigurations(configFormValues).toPromise();
+ this._appConfigService.updateDisplayName(configFormValues.displayName);
+ this._loadingService.stop();
+ }
+
+ openAuthConfigDialog(skipDisableOnCancel?: boolean) {
+ this._dialogService.openDialog('smtpAuthConfig', null, this.smtpForm.getRawValue(), null, authConfig => {
+ if (authConfig) {
+ this.smtpForm.patchValue(authConfig);
+ } else if (!skipDisableOnCancel) {
+ this.smtpForm.patchValue({ auth: false }, { emitEvent: false });
+ }
+ });
+ }
+
+ async testConnection() {
+ this._loadingService.start();
+ try {
+ await this._smtpConfigService.testSMTPConfiguration(this.smtpForm.getRawValue()).toPromise();
+ this._toaster.success('smtp-config-screen.test.success');
+ } catch (e) {
+ this._toaster.error('smtp-config-screen.test.error');
+ } finally {
+ this._loadingService.stop();
+ }
+ }
+
+ private async _loadData() {
+ this._loadingService.start();
+ try {
+ this._initialGeneralConfiguration = await this._generalSettingsControllerService.getGeneralConfigurations().toPromise();
+ this.configForm.patchValue(this._initialGeneralConfiguration, { emitEvent: false });
+ } catch (e) {}
+
+ try {
+ this._initialSMTPConfiguration = await this._smtpConfigService.getCurrentSMTPConfiguration().toPromise();
+ this.smtpForm.patchValue(this._initialSMTPConfiguration, { emitEvent: false });
+ } catch (e) {}
+
+ this._loadingService.stop();
+ }
+}
diff --git a/apps/red-ui/src/app/modules/admin/screens/rules/rules-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/rules/rules-screen.component.html
index 95c117176..6952262fc 100644
--- a/apps/red-ui/src/app/modules/admin/screens/rules/rules-screen.component.html
+++ b/apps/red-ui/src/app/modules/admin/screens/rules/rules-screen.component.html
@@ -33,5 +33,3 @@
-
-