@flusys/ng-email 4.1.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,793 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, computed, signal, effect, Component } from '@angular/core';
3
+ import { toSignal } from '@angular/core/rxjs-interop';
4
+ import * as i2 from '@angular/router';
5
+ import { ActivatedRoute, Router } from '@angular/router';
6
+ import { APP_CONFIG, TRANSLATE_ADAPTER, DEFAULT_APP_NAME } from '@flusys/ng-core';
7
+ import { LAYOUT_AUTH_STATE } from '@flusys/ng-layout';
8
+ import { AngularModule, PrimeModule, TranslatePipe } from '@flusys/ng-shared';
9
+ import { MessageService } from 'primeng/api';
10
+ import { EmailConfigApiService, EmailProviderEnum } from './flusys-ng-email.mjs';
11
+ import * as i1 from '@angular/forms';
12
+ import * as i2$1 from 'primeng/button';
13
+ import * as i4 from 'primeng/inputnumber';
14
+ import * as i5 from 'primeng/inputtext';
15
+ import * as i6 from 'primeng/password';
16
+ import * as i6$1 from 'primeng/select';
17
+ import * as i8 from 'primeng/toast';
18
+ import * as i8$1 from 'primeng/toggleswitch';
19
+
20
+ /**
21
+ * Email configuration form component (create/edit)
22
+ */
23
+ class EmailConfigFormComponent {
24
+ route = inject(ActivatedRoute);
25
+ router = inject(Router);
26
+ configService = inject(EmailConfigApiService);
27
+ messageService = inject(MessageService);
28
+ appConfig = inject(APP_CONFIG);
29
+ companyContext = inject(LAYOUT_AUTH_STATE, {
30
+ optional: true,
31
+ });
32
+ translateAdapter = inject(TRANSLATE_ADAPTER, {
33
+ optional: true,
34
+ });
35
+ // Route params as signal
36
+ routeParams = toSignal(this.route.paramMap);
37
+ providerEnum = EmailProviderEnum;
38
+ showCompanyInfo = computed(() => this.appConfig.enableCompanyFeature && !!this.companyContext, ...(ngDevMode ? [{ debugName: "showCompanyInfo" }] : []));
39
+ currentCompanyName = computed(() => this.companyContext?.currentCompanyInfo()?.name ?? DEFAULT_APP_NAME, ...(ngDevMode ? [{ debugName: "currentCompanyName" }] : []));
40
+ isLoading = signal(false, ...(ngDevMode ? [{ debugName: "isLoading" }] : []));
41
+ existingConfig = signal(null, ...(ngDevMode ? [{ debugName: "existingConfig" }] : []));
42
+ isEditMode = computed(() => !!this.existingConfig(), ...(ngDevMode ? [{ debugName: "isEditMode" }] : []));
43
+ providerOptions = computed(() => [
44
+ {
45
+ label: this.translate('email.provider.smtp'),
46
+ value: EmailProviderEnum.SMTP,
47
+ },
48
+ {
49
+ label: this.translate('email.provider.sendgrid'),
50
+ value: EmailProviderEnum.SENDGRID,
51
+ },
52
+ {
53
+ label: this.translate('email.provider.mailgun'),
54
+ value: EmailProviderEnum.MAILGUN,
55
+ },
56
+ ], ...(ngDevMode ? [{ debugName: "providerOptions" }] : []));
57
+ regionOptions = computed(() => [
58
+ { label: this.translate('email.region.us'), value: 'us' },
59
+ { label: this.translate('email.region.eu'), value: 'eu' },
60
+ ], ...(ngDevMode ? [{ debugName: "regionOptions" }] : []));
61
+ /** Form model as signal for zoneless change detection */
62
+ _formModel = signal({
63
+ id: '',
64
+ name: '',
65
+ provider: EmailProviderEnum.SMTP,
66
+ fromEmail: '',
67
+ fromName: '',
68
+ isActive: true,
69
+ isDefault: false,
70
+ // SMTP
71
+ smtpHost: '',
72
+ smtpPort: 587,
73
+ smtpUser: '',
74
+ smtpPass: '',
75
+ smtpSecure: false,
76
+ // SendGrid
77
+ sendgridApiKey: '',
78
+ // Mailgun
79
+ mailgunApiKey: '',
80
+ mailgunDomain: '',
81
+ mailgunRegion: 'us',
82
+ }, ...(ngDevMode ? [{ debugName: "_formModel" }] : []));
83
+ /** Expose form model for template binding */
84
+ get formModel() {
85
+ return this._formModel();
86
+ }
87
+ /** Update form model field - triggers change detection */
88
+ updateFormModel(field, value) {
89
+ this._formModel.update((m) => ({ ...m, [field]: value }));
90
+ }
91
+ constructor() {
92
+ // Effect to handle route-based initialization
93
+ effect(() => {
94
+ const params = this.routeParams();
95
+ if (!params)
96
+ return;
97
+ const id = params.get('id');
98
+ if (id) {
99
+ this.loadConfig(id);
100
+ }
101
+ });
102
+ }
103
+ async loadConfig(id) {
104
+ this.isLoading.set(true);
105
+ try {
106
+ const response = await this.configService.findById(id);
107
+ if (response.success && response.data) {
108
+ const emailConfig = response.data;
109
+ this.existingConfig.set(emailConfig);
110
+ this._formModel.set(this.mapConfigToFormModel(emailConfig));
111
+ }
112
+ }
113
+ catch {
114
+ // Error toast handled by global interceptor
115
+ }
116
+ finally {
117
+ this.isLoading.set(false);
118
+ }
119
+ }
120
+ mapConfigToFormModel(emailConfig) {
121
+ const providerConfig = emailConfig.config;
122
+ return {
123
+ id: emailConfig.id,
124
+ name: emailConfig.name,
125
+ provider: emailConfig.provider,
126
+ fromEmail: emailConfig.fromEmail || '',
127
+ fromName: emailConfig.fromName || '',
128
+ isActive: emailConfig.isActive,
129
+ isDefault: emailConfig.isDefault ?? false,
130
+ // SMTP fields
131
+ smtpHost: this.isSmtpConfig(providerConfig) ? providerConfig.host : '',
132
+ smtpPort: this.isSmtpConfig(providerConfig) ? providerConfig.port : 587,
133
+ smtpUser: this.isSmtpConfig(providerConfig)
134
+ ? providerConfig.auth.user
135
+ : '',
136
+ smtpPass: this.isSmtpConfig(providerConfig)
137
+ ? providerConfig.auth.pass
138
+ : '',
139
+ smtpSecure: this.isSmtpConfig(providerConfig)
140
+ ? (providerConfig.secure ?? false)
141
+ : false,
142
+ // SendGrid fields
143
+ sendgridApiKey: this.isSendGridConfig(providerConfig)
144
+ ? providerConfig.apiKey
145
+ : '',
146
+ // Mailgun fields
147
+ mailgunApiKey: this.isMailgunConfig(providerConfig)
148
+ ? providerConfig.apiKey
149
+ : '',
150
+ mailgunDomain: this.isMailgunConfig(providerConfig)
151
+ ? providerConfig.domain
152
+ : '',
153
+ mailgunRegion: this.isMailgunConfig(providerConfig)
154
+ ? (providerConfig.region ?? 'us')
155
+ : 'us',
156
+ };
157
+ }
158
+ isSmtpConfig(config) {
159
+ return 'host' in config && 'auth' in config;
160
+ }
161
+ isSendGridConfig(config) {
162
+ return 'apiKey' in config && !('domain' in config);
163
+ }
164
+ isMailgunConfig(config) {
165
+ return 'apiKey' in config && 'domain' in config;
166
+ }
167
+ buildProviderConfig() {
168
+ const form = this.formModel;
169
+ switch (form.provider) {
170
+ case EmailProviderEnum.SMTP:
171
+ return {
172
+ host: form.smtpHost,
173
+ port: form.smtpPort,
174
+ secure: form.smtpSecure,
175
+ auth: { user: form.smtpUser, pass: form.smtpPass },
176
+ };
177
+ case EmailProviderEnum.SENDGRID:
178
+ return { apiKey: form.sendgridApiKey };
179
+ case EmailProviderEnum.MAILGUN:
180
+ return {
181
+ apiKey: form.mailgunApiKey,
182
+ domain: form.mailgunDomain,
183
+ region: form.mailgunRegion,
184
+ };
185
+ }
186
+ }
187
+ async onSave() {
188
+ if (!this.formModel.name || !this.formModel.provider) {
189
+ this.messageService.add({
190
+ severity: 'warn',
191
+ summary: this.translate('shared.validation'),
192
+ detail: this.translate('shared.fill.required.fields'),
193
+ });
194
+ return;
195
+ }
196
+ this.isLoading.set(true);
197
+ try {
198
+ const dto = this.buildSaveDto();
199
+ const response = this.isEditMode()
200
+ ? await this.configService.update({ id: this.formModel.id, ...dto })
201
+ : await this.configService.insert(dto);
202
+ const r = response;
203
+ this.messageService.add({
204
+ severity: 'success',
205
+ summary: this.translate('shared.success'),
206
+ detail: r?.messageKey
207
+ ? this.translate(r.messageKey, r.messageVariables)
208
+ : (r?.message ?? ''),
209
+ });
210
+ this.router.navigate(['../'], { relativeTo: this.route });
211
+ }
212
+ catch {
213
+ // Error toast handled by global interceptor
214
+ }
215
+ finally {
216
+ this.isLoading.set(false);
217
+ }
218
+ }
219
+ translate(key, variables) {
220
+ return this.translateAdapter?.translate(key, variables) ?? key;
221
+ }
222
+ buildSaveDto() {
223
+ return {
224
+ name: this.formModel.name,
225
+ provider: this.formModel.provider,
226
+ config: this.buildProviderConfig(),
227
+ fromEmail: this.formModel.fromEmail || undefined,
228
+ fromName: this.formModel.fromName || undefined,
229
+ isActive: this.formModel.isActive,
230
+ isDefault: this.formModel.isDefault,
231
+ };
232
+ }
233
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: EmailConfigFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
234
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.5", type: EmailConfigFormComponent, isStandalone: true, selector: "lib-email-config-form", providers: [MessageService], ngImport: i0, template: `
235
+ <div class="card">
236
+ <!-- Header -->
237
+ <div
238
+ class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-3 mb-4"
239
+ >
240
+ <div>
241
+ <h3 class="text-lg sm:text-xl font-semibold m-0">
242
+ {{
243
+ (isEditMode()
244
+ ? 'email.config.edit.title'
245
+ : 'email.config.new.title'
246
+ ) | translate
247
+ }}
248
+ </h3>
249
+ @if (showCompanyInfo()) {
250
+ <p class="text-sm text-muted-color mt-1">
251
+ {{ 'shared.company' | translate }}: {{ currentCompanyName() }}
252
+ </p>
253
+ }
254
+ </div>
255
+ </div>
256
+
257
+ <!-- Form Fields -->
258
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
259
+ <!-- Common Fields -->
260
+ <div class="field">
261
+ <label for="name" class="block font-medium mb-2"
262
+ >{{ 'email.config.name' | translate }} *</label
263
+ >
264
+ <input
265
+ pInputText
266
+ id="name"
267
+ [ngModel]="formModel.name"
268
+ (ngModelChange)="updateFormModel('name', $event)"
269
+ class="w-full"
270
+ [placeholder]="'email.config.name.example' | translate"
271
+ />
272
+ </div>
273
+
274
+ <div class="field">
275
+ <label for="provider" class="block font-medium mb-2"
276
+ >{{ 'email.config.provider' | translate }} *</label
277
+ >
278
+ <p-select
279
+ id="provider"
280
+ [options]="providerOptions()"
281
+ [ngModel]="formModel.provider"
282
+ (ngModelChange)="updateFormModel('provider', $event)"
283
+ optionLabel="label"
284
+ optionValue="value"
285
+ [placeholder]="'email.config.select.provider' | translate"
286
+ class="w-full"
287
+ />
288
+ </div>
289
+
290
+ <div class="field">
291
+ <label for="fromEmail" class="block font-medium mb-2">{{
292
+ 'email.config.from.email' | translate
293
+ }}</label>
294
+ <input
295
+ pInputText
296
+ id="fromEmail"
297
+ [ngModel]="formModel.fromEmail"
298
+ (ngModelChange)="updateFormModel('fromEmail', $event)"
299
+ class="w-full"
300
+ [placeholder]="'email.config.from.email.example' | translate"
301
+ />
302
+ </div>
303
+
304
+ <div class="field">
305
+ <label for="fromName" class="block font-medium mb-2">{{
306
+ 'email.config.from.name' | translate
307
+ }}</label>
308
+ <input
309
+ pInputText
310
+ id="fromName"
311
+ [ngModel]="formModel.fromName"
312
+ (ngModelChange)="updateFormModel('fromName', $event)"
313
+ class="w-full"
314
+ [placeholder]="'email.config.from.name.example' | translate"
315
+ />
316
+ </div>
317
+
318
+ <div class="field flex items-center gap-2">
319
+ <p-toggleswitch
320
+ [ngModel]="formModel.isActive"
321
+ (ngModelChange)="updateFormModel('isActive', $event)"
322
+ />
323
+ <label>{{ 'shared.active' | translate }}</label>
324
+ </div>
325
+
326
+ <div class="field flex items-center gap-2">
327
+ <p-toggleswitch
328
+ [ngModel]="formModel.isDefault"
329
+ (ngModelChange)="updateFormModel('isDefault', $event)"
330
+ />
331
+ <label>{{ 'email.config.set.as.default' | translate }}</label>
332
+ </div>
333
+ </div>
334
+
335
+ <!-- SMTP Fields -->
336
+ @if (formModel.provider === providerEnum.SMTP) {
337
+ <div class="border-t border-surface mt-4 pt-4">
338
+ <h3 class="font-semibold mb-4">
339
+ {{ 'email.config.smtp.settings' | translate }}
340
+ </h3>
341
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
342
+ <div class="field">
343
+ <label for="smtpHost" class="block font-medium mb-2"
344
+ >{{ 'email.config.smtp.host' | translate }} *</label
345
+ >
346
+ <input
347
+ pInputText
348
+ id="smtpHost"
349
+ [ngModel]="formModel.smtpHost"
350
+ (ngModelChange)="updateFormModel('smtpHost', $event)"
351
+ class="w-full"
352
+ [placeholder]="'email.config.smtp.host.example' | translate"
353
+ />
354
+ </div>
355
+ <div class="field">
356
+ <label for="smtpPort" class="block font-medium mb-2"
357
+ >{{ 'email.config.port' | translate }} *</label
358
+ >
359
+ <p-inputNumber
360
+ id="smtpPort"
361
+ [ngModel]="formModel.smtpPort"
362
+ (ngModelChange)="updateFormModel('smtpPort', $event)"
363
+ [useGrouping]="false"
364
+ class="w-full"
365
+ [placeholder]="'email.config.smtp.port.example' | translate"
366
+ />
367
+ </div>
368
+ <div class="field">
369
+ <label for="smtpUser" class="block font-medium mb-2"
370
+ >{{ 'email.config.username' | translate }} *</label
371
+ >
372
+ <input
373
+ pInputText
374
+ id="smtpUser"
375
+ [ngModel]="formModel.smtpUser"
376
+ (ngModelChange)="updateFormModel('smtpUser', $event)"
377
+ class="w-full"
378
+ [placeholder]="'email.config.smtp.user.example' | translate"
379
+ />
380
+ </div>
381
+ <div class="field">
382
+ <label for="smtpPass" class="block font-medium mb-2"
383
+ >{{ 'email.config.password' | translate }} *</label
384
+ >
385
+ <p-password
386
+ id="smtpPass"
387
+ [ngModel]="formModel.smtpPass"
388
+ (ngModelChange)="updateFormModel('smtpPass', $event)"
389
+ [feedback]="false"
390
+ [toggleMask]="true"
391
+ styleClass="w-full"
392
+ inputStyleClass="w-full"
393
+ [placeholder]="'email.config.smtp.password.example' | translate"
394
+ />
395
+ </div>
396
+ <div class="field flex items-center gap-2">
397
+ <p-toggleswitch
398
+ [ngModel]="formModel.smtpSecure"
399
+ (ngModelChange)="updateFormModel('smtpSecure', $event)"
400
+ />
401
+ <label>{{ 'email.config.use.ssl.tls' | translate }}</label>
402
+ </div>
403
+ </div>
404
+ </div>
405
+ }
406
+
407
+ <!-- SendGrid Fields -->
408
+ @if (formModel.provider === providerEnum.SENDGRID) {
409
+ <div class="border-t border-surface mt-4 pt-4">
410
+ <h3 class="font-semibold mb-4">
411
+ {{ 'email.config.sendgrid.settings' | translate }}
412
+ </h3>
413
+ <div class="grid grid-cols-1 gap-4">
414
+ <div class="field">
415
+ <label for="sendgridApiKey" class="block font-medium mb-2"
416
+ >{{ 'email.config.api.key' | translate }} *</label
417
+ >
418
+ <p-password
419
+ id="sendgridApiKey"
420
+ [ngModel]="formModel.sendgridApiKey"
421
+ (ngModelChange)="updateFormModel('sendgridApiKey', $event)"
422
+ [feedback]="false"
423
+ [toggleMask]="true"
424
+ styleClass="w-full"
425
+ inputStyleClass="w-full"
426
+ [placeholder]="'email.config.api.key.example' | translate"
427
+ />
428
+ </div>
429
+ </div>
430
+ </div>
431
+ }
432
+
433
+ <!-- Mailgun Fields -->
434
+ @if (formModel.provider === providerEnum.MAILGUN) {
435
+ <div class="border-t border-surface mt-4 pt-4">
436
+ <h3 class="font-semibold mb-4">
437
+ {{ 'email.config.mailgun.settings' | translate }}
438
+ </h3>
439
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
440
+ <div class="field">
441
+ <label for="mailgunApiKey" class="block font-medium mb-2"
442
+ >{{ 'email.config.api.key' | translate }} *</label
443
+ >
444
+ <p-password
445
+ id="mailgunApiKey"
446
+ [ngModel]="formModel.mailgunApiKey"
447
+ (ngModelChange)="updateFormModel('mailgunApiKey', $event)"
448
+ [feedback]="false"
449
+ [toggleMask]="true"
450
+ styleClass="w-full"
451
+ inputStyleClass="w-full"
452
+ [placeholder]="'email.config.api.key.example' | translate"
453
+ />
454
+ </div>
455
+ <div class="field">
456
+ <label for="mailgunDomain" class="block font-medium mb-2"
457
+ >{{ 'email.config.domain' | translate }} *</label
458
+ >
459
+ <input
460
+ pInputText
461
+ id="mailgunDomain"
462
+ [ngModel]="formModel.mailgunDomain"
463
+ (ngModelChange)="updateFormModel('mailgunDomain', $event)"
464
+ class="w-full"
465
+ [placeholder]="'email.config.domain.example' | translate"
466
+ />
467
+ </div>
468
+ <div class="field">
469
+ <label for="mailgunRegion" class="block font-medium mb-2">{{
470
+ 'email.config.region' | translate
471
+ }}</label>
472
+ <p-select
473
+ id="mailgunRegion"
474
+ [options]="regionOptions()"
475
+ [ngModel]="formModel.mailgunRegion"
476
+ (ngModelChange)="updateFormModel('mailgunRegion', $event)"
477
+ optionLabel="label"
478
+ optionValue="value"
479
+ [placeholder]="'email.config.select.region' | translate"
480
+ class="w-full"
481
+ />
482
+ </div>
483
+ </div>
484
+ </div>
485
+ }
486
+
487
+ <!-- Form Actions -->
488
+ <div class="flex justify-end gap-2 mt-6 pt-4 border-t border-surface">
489
+ <p-button
490
+ [label]="'shared.cancel' | translate"
491
+ severity="secondary"
492
+ [outlined]="true"
493
+ routerLink="../"
494
+ />
495
+ <p-button
496
+ [label]="
497
+ (isEditMode() ? 'shared.update' : 'shared.create') | translate
498
+ "
499
+ icon="pi pi-save"
500
+ [loading]="isLoading()"
501
+ (onClick)="onSave()"
502
+ />
503
+ </div>
504
+ </div>
505
+
506
+ <p-toast />
507
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: AngularModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i2.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "ngmodule", type: PrimeModule }, { kind: "component", type: i2$1.Button, selector: "p-button", inputs: ["hostName", "type", "badge", "disabled", "raised", "rounded", "text", "plain", "outlined", "link", "tabindex", "size", "variant", "style", "styleClass", "badgeClass", "badgeSeverity", "ariaLabel", "autofocus", "iconPos", "icon", "label", "loading", "loadingIcon", "severity", "buttonProps", "fluid"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: i4.InputNumber, selector: "p-inputNumber, p-inputnumber, p-input-number", inputs: ["showButtons", "format", "buttonLayout", "inputId", "styleClass", "placeholder", "tabindex", "title", "ariaLabelledBy", "ariaDescribedBy", "ariaLabel", "ariaRequired", "autocomplete", "incrementButtonClass", "decrementButtonClass", "incrementButtonIcon", "decrementButtonIcon", "readonly", "allowEmpty", "locale", "localeMatcher", "mode", "currency", "currencyDisplay", "useGrouping", "minFractionDigits", "maxFractionDigits", "prefix", "suffix", "inputStyle", "inputStyleClass", "showClear", "autofocus"], outputs: ["onInput", "onFocus", "onBlur", "onKeyDown", "onClear"] }, { kind: "directive", type: i5.InputText, selector: "[pInputText]", inputs: ["hostName", "ptInputText", "pInputTextPT", "pInputTextUnstyled", "pSize", "variant", "fluid", "invalid"] }, { kind: "component", type: i6.Password, selector: "p-password", inputs: ["ariaLabel", "ariaLabelledBy", "label", "promptLabel", "mediumRegex", "strongRegex", "weakLabel", "mediumLabel", "maxLength", "strongLabel", "inputId", "feedback", "toggleMask", "inputStyleClass", "styleClass", "inputStyle", "showTransitionOptions", "hideTransitionOptions", "autocomplete", "placeholder", "showClear", "autofocus", "tabindex", "appendTo", "motionOptions", "overlayOptions"], outputs: ["onFocus", "onBlur", "onClear"] }, { kind: "component", type: i6$1.Select, selector: "p-select", inputs: ["id", "scrollHeight", "filter", "panelStyle", "styleClass", "panelStyleClass", "readonly", "editable", "tabindex", "placeholder", "loadingIcon", "filterPlaceholder", "filterLocale", "inputId", "dataKey", "filterBy", "filterFields", "autofocus", "resetFilterOnHide", "checkmark", "dropdownIcon", "loading", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "group", "showClear", "emptyFilterMessage", "emptyMessage", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "overlayOptions", "ariaFilterLabel", "ariaLabel", "ariaLabelledBy", "filterMatchMode", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "focusOnHover", "selectOnFocus", "autoOptionFocus", "autofocusFilter", "filterValue", "options", "appendTo", "motionOptions"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide", "onClear", "onLazyLoad"] }, { kind: "component", type: i8.Toast, selector: "p-toast", inputs: ["key", "autoZIndex", "baseZIndex", "life", "styleClass", "position", "preventOpenDuplicates", "preventDuplicates", "showTransformOptions", "hideTransformOptions", "showTransitionOptions", "hideTransitionOptions", "motionOptions", "breakpoints"], outputs: ["onClose"] }, { kind: "component", type: i8$1.ToggleSwitch, selector: "p-toggleswitch, p-toggleSwitch, p-toggle-switch", inputs: ["styleClass", "tabindex", "inputId", "readonly", "trueValue", "falseValue", "ariaLabel", "size", "ariaLabelledBy", "autofocus"], outputs: ["onChange"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }] });
508
+ }
509
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: EmailConfigFormComponent, decorators: [{
510
+ type: Component,
511
+ args: [{
512
+ selector: 'lib-email-config-form',
513
+ imports: [AngularModule, PrimeModule, TranslatePipe],
514
+ providers: [MessageService],
515
+ template: `
516
+ <div class="card">
517
+ <!-- Header -->
518
+ <div
519
+ class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-3 mb-4"
520
+ >
521
+ <div>
522
+ <h3 class="text-lg sm:text-xl font-semibold m-0">
523
+ {{
524
+ (isEditMode()
525
+ ? 'email.config.edit.title'
526
+ : 'email.config.new.title'
527
+ ) | translate
528
+ }}
529
+ </h3>
530
+ @if (showCompanyInfo()) {
531
+ <p class="text-sm text-muted-color mt-1">
532
+ {{ 'shared.company' | translate }}: {{ currentCompanyName() }}
533
+ </p>
534
+ }
535
+ </div>
536
+ </div>
537
+
538
+ <!-- Form Fields -->
539
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
540
+ <!-- Common Fields -->
541
+ <div class="field">
542
+ <label for="name" class="block font-medium mb-2"
543
+ >{{ 'email.config.name' | translate }} *</label
544
+ >
545
+ <input
546
+ pInputText
547
+ id="name"
548
+ [ngModel]="formModel.name"
549
+ (ngModelChange)="updateFormModel('name', $event)"
550
+ class="w-full"
551
+ [placeholder]="'email.config.name.example' | translate"
552
+ />
553
+ </div>
554
+
555
+ <div class="field">
556
+ <label for="provider" class="block font-medium mb-2"
557
+ >{{ 'email.config.provider' | translate }} *</label
558
+ >
559
+ <p-select
560
+ id="provider"
561
+ [options]="providerOptions()"
562
+ [ngModel]="formModel.provider"
563
+ (ngModelChange)="updateFormModel('provider', $event)"
564
+ optionLabel="label"
565
+ optionValue="value"
566
+ [placeholder]="'email.config.select.provider' | translate"
567
+ class="w-full"
568
+ />
569
+ </div>
570
+
571
+ <div class="field">
572
+ <label for="fromEmail" class="block font-medium mb-2">{{
573
+ 'email.config.from.email' | translate
574
+ }}</label>
575
+ <input
576
+ pInputText
577
+ id="fromEmail"
578
+ [ngModel]="formModel.fromEmail"
579
+ (ngModelChange)="updateFormModel('fromEmail', $event)"
580
+ class="w-full"
581
+ [placeholder]="'email.config.from.email.example' | translate"
582
+ />
583
+ </div>
584
+
585
+ <div class="field">
586
+ <label for="fromName" class="block font-medium mb-2">{{
587
+ 'email.config.from.name' | translate
588
+ }}</label>
589
+ <input
590
+ pInputText
591
+ id="fromName"
592
+ [ngModel]="formModel.fromName"
593
+ (ngModelChange)="updateFormModel('fromName', $event)"
594
+ class="w-full"
595
+ [placeholder]="'email.config.from.name.example' | translate"
596
+ />
597
+ </div>
598
+
599
+ <div class="field flex items-center gap-2">
600
+ <p-toggleswitch
601
+ [ngModel]="formModel.isActive"
602
+ (ngModelChange)="updateFormModel('isActive', $event)"
603
+ />
604
+ <label>{{ 'shared.active' | translate }}</label>
605
+ </div>
606
+
607
+ <div class="field flex items-center gap-2">
608
+ <p-toggleswitch
609
+ [ngModel]="formModel.isDefault"
610
+ (ngModelChange)="updateFormModel('isDefault', $event)"
611
+ />
612
+ <label>{{ 'email.config.set.as.default' | translate }}</label>
613
+ </div>
614
+ </div>
615
+
616
+ <!-- SMTP Fields -->
617
+ @if (formModel.provider === providerEnum.SMTP) {
618
+ <div class="border-t border-surface mt-4 pt-4">
619
+ <h3 class="font-semibold mb-4">
620
+ {{ 'email.config.smtp.settings' | translate }}
621
+ </h3>
622
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
623
+ <div class="field">
624
+ <label for="smtpHost" class="block font-medium mb-2"
625
+ >{{ 'email.config.smtp.host' | translate }} *</label
626
+ >
627
+ <input
628
+ pInputText
629
+ id="smtpHost"
630
+ [ngModel]="formModel.smtpHost"
631
+ (ngModelChange)="updateFormModel('smtpHost', $event)"
632
+ class="w-full"
633
+ [placeholder]="'email.config.smtp.host.example' | translate"
634
+ />
635
+ </div>
636
+ <div class="field">
637
+ <label for="smtpPort" class="block font-medium mb-2"
638
+ >{{ 'email.config.port' | translate }} *</label
639
+ >
640
+ <p-inputNumber
641
+ id="smtpPort"
642
+ [ngModel]="formModel.smtpPort"
643
+ (ngModelChange)="updateFormModel('smtpPort', $event)"
644
+ [useGrouping]="false"
645
+ class="w-full"
646
+ [placeholder]="'email.config.smtp.port.example' | translate"
647
+ />
648
+ </div>
649
+ <div class="field">
650
+ <label for="smtpUser" class="block font-medium mb-2"
651
+ >{{ 'email.config.username' | translate }} *</label
652
+ >
653
+ <input
654
+ pInputText
655
+ id="smtpUser"
656
+ [ngModel]="formModel.smtpUser"
657
+ (ngModelChange)="updateFormModel('smtpUser', $event)"
658
+ class="w-full"
659
+ [placeholder]="'email.config.smtp.user.example' | translate"
660
+ />
661
+ </div>
662
+ <div class="field">
663
+ <label for="smtpPass" class="block font-medium mb-2"
664
+ >{{ 'email.config.password' | translate }} *</label
665
+ >
666
+ <p-password
667
+ id="smtpPass"
668
+ [ngModel]="formModel.smtpPass"
669
+ (ngModelChange)="updateFormModel('smtpPass', $event)"
670
+ [feedback]="false"
671
+ [toggleMask]="true"
672
+ styleClass="w-full"
673
+ inputStyleClass="w-full"
674
+ [placeholder]="'email.config.smtp.password.example' | translate"
675
+ />
676
+ </div>
677
+ <div class="field flex items-center gap-2">
678
+ <p-toggleswitch
679
+ [ngModel]="formModel.smtpSecure"
680
+ (ngModelChange)="updateFormModel('smtpSecure', $event)"
681
+ />
682
+ <label>{{ 'email.config.use.ssl.tls' | translate }}</label>
683
+ </div>
684
+ </div>
685
+ </div>
686
+ }
687
+
688
+ <!-- SendGrid Fields -->
689
+ @if (formModel.provider === providerEnum.SENDGRID) {
690
+ <div class="border-t border-surface mt-4 pt-4">
691
+ <h3 class="font-semibold mb-4">
692
+ {{ 'email.config.sendgrid.settings' | translate }}
693
+ </h3>
694
+ <div class="grid grid-cols-1 gap-4">
695
+ <div class="field">
696
+ <label for="sendgridApiKey" class="block font-medium mb-2"
697
+ >{{ 'email.config.api.key' | translate }} *</label
698
+ >
699
+ <p-password
700
+ id="sendgridApiKey"
701
+ [ngModel]="formModel.sendgridApiKey"
702
+ (ngModelChange)="updateFormModel('sendgridApiKey', $event)"
703
+ [feedback]="false"
704
+ [toggleMask]="true"
705
+ styleClass="w-full"
706
+ inputStyleClass="w-full"
707
+ [placeholder]="'email.config.api.key.example' | translate"
708
+ />
709
+ </div>
710
+ </div>
711
+ </div>
712
+ }
713
+
714
+ <!-- Mailgun Fields -->
715
+ @if (formModel.provider === providerEnum.MAILGUN) {
716
+ <div class="border-t border-surface mt-4 pt-4">
717
+ <h3 class="font-semibold mb-4">
718
+ {{ 'email.config.mailgun.settings' | translate }}
719
+ </h3>
720
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
721
+ <div class="field">
722
+ <label for="mailgunApiKey" class="block font-medium mb-2"
723
+ >{{ 'email.config.api.key' | translate }} *</label
724
+ >
725
+ <p-password
726
+ id="mailgunApiKey"
727
+ [ngModel]="formModel.mailgunApiKey"
728
+ (ngModelChange)="updateFormModel('mailgunApiKey', $event)"
729
+ [feedback]="false"
730
+ [toggleMask]="true"
731
+ styleClass="w-full"
732
+ inputStyleClass="w-full"
733
+ [placeholder]="'email.config.api.key.example' | translate"
734
+ />
735
+ </div>
736
+ <div class="field">
737
+ <label for="mailgunDomain" class="block font-medium mb-2"
738
+ >{{ 'email.config.domain' | translate }} *</label
739
+ >
740
+ <input
741
+ pInputText
742
+ id="mailgunDomain"
743
+ [ngModel]="formModel.mailgunDomain"
744
+ (ngModelChange)="updateFormModel('mailgunDomain', $event)"
745
+ class="w-full"
746
+ [placeholder]="'email.config.domain.example' | translate"
747
+ />
748
+ </div>
749
+ <div class="field">
750
+ <label for="mailgunRegion" class="block font-medium mb-2">{{
751
+ 'email.config.region' | translate
752
+ }}</label>
753
+ <p-select
754
+ id="mailgunRegion"
755
+ [options]="regionOptions()"
756
+ [ngModel]="formModel.mailgunRegion"
757
+ (ngModelChange)="updateFormModel('mailgunRegion', $event)"
758
+ optionLabel="label"
759
+ optionValue="value"
760
+ [placeholder]="'email.config.select.region' | translate"
761
+ class="w-full"
762
+ />
763
+ </div>
764
+ </div>
765
+ </div>
766
+ }
767
+
768
+ <!-- Form Actions -->
769
+ <div class="flex justify-end gap-2 mt-6 pt-4 border-t border-surface">
770
+ <p-button
771
+ [label]="'shared.cancel' | translate"
772
+ severity="secondary"
773
+ [outlined]="true"
774
+ routerLink="../"
775
+ />
776
+ <p-button
777
+ [label]="
778
+ (isEditMode() ? 'shared.update' : 'shared.create') | translate
779
+ "
780
+ icon="pi pi-save"
781
+ [loading]="isLoading()"
782
+ (onClick)="onSave()"
783
+ />
784
+ </div>
785
+ </div>
786
+
787
+ <p-toast />
788
+ `,
789
+ }]
790
+ }], ctorParameters: () => [] });
791
+
792
+ export { EmailConfigFormComponent };
793
+ //# sourceMappingURL=flusys-ng-email-email-config-form.component-M0g9fxU1.mjs.map