@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.
@@ -1,718 +0,0 @@
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, { optional: true });
30
- translateAdapter = inject(TRANSLATE_ADAPTER, { optional: true });
31
- // Route params as signal
32
- routeParams = toSignal(this.route.paramMap);
33
- providerEnum = EmailProviderEnum;
34
- showCompanyInfo = computed(() => this.appConfig.enableCompanyFeature && !!this.companyContext, ...(ngDevMode ? [{ debugName: "showCompanyInfo" }] : []));
35
- currentCompanyName = computed(() => this.companyContext?.currentCompanyInfo()?.name ?? DEFAULT_APP_NAME, ...(ngDevMode ? [{ debugName: "currentCompanyName" }] : []));
36
- isLoading = signal(false, ...(ngDevMode ? [{ debugName: "isLoading" }] : []));
37
- existingConfig = signal(null, ...(ngDevMode ? [{ debugName: "existingConfig" }] : []));
38
- isEditMode = computed(() => !!this.existingConfig(), ...(ngDevMode ? [{ debugName: "isEditMode" }] : []));
39
- providerOptions = computed(() => [
40
- { label: this.translate('email.provider.smtp'), value: EmailProviderEnum.SMTP },
41
- { label: this.translate('email.provider.sendgrid'), value: EmailProviderEnum.SENDGRID },
42
- { label: this.translate('email.provider.mailgun'), value: EmailProviderEnum.MAILGUN },
43
- ], ...(ngDevMode ? [{ debugName: "providerOptions" }] : []));
44
- regionOptions = computed(() => [
45
- { label: this.translate('email.region.us'), value: 'us' },
46
- { label: this.translate('email.region.eu'), value: 'eu' },
47
- ], ...(ngDevMode ? [{ debugName: "regionOptions" }] : []));
48
- /** Form model as signal for zoneless change detection */
49
- _formModel = signal({
50
- id: '',
51
- name: '',
52
- provider: EmailProviderEnum.SMTP,
53
- fromEmail: '',
54
- fromName: '',
55
- isActive: true,
56
- isDefault: false,
57
- // SMTP
58
- smtpHost: '',
59
- smtpPort: 587,
60
- smtpUser: '',
61
- smtpPass: '',
62
- smtpSecure: false,
63
- // SendGrid
64
- sendgridApiKey: '',
65
- // Mailgun
66
- mailgunApiKey: '',
67
- mailgunDomain: '',
68
- mailgunRegion: 'us',
69
- }, ...(ngDevMode ? [{ debugName: "_formModel" }] : []));
70
- /** Expose form model for template binding */
71
- get formModel() {
72
- return this._formModel();
73
- }
74
- /** Update form model field - triggers change detection */
75
- updateFormModel(field, value) {
76
- this._formModel.update((m) => ({ ...m, [field]: value }));
77
- }
78
- constructor() {
79
- // Effect to handle route-based initialization
80
- effect(() => {
81
- const params = this.routeParams();
82
- if (!params)
83
- return;
84
- const id = params.get('id');
85
- if (id) {
86
- this.loadConfig(id);
87
- }
88
- });
89
- }
90
- async loadConfig(id) {
91
- this.isLoading.set(true);
92
- try {
93
- const response = await this.configService.findByIdAsync(id);
94
- if (response.success && response.data) {
95
- const emailConfig = response.data;
96
- this.existingConfig.set(emailConfig);
97
- this._formModel.set(this.mapConfigToFormModel(emailConfig));
98
- }
99
- }
100
- catch {
101
- // Error toast handled by global interceptor
102
- }
103
- finally {
104
- this.isLoading.set(false);
105
- }
106
- }
107
- mapConfigToFormModel(emailConfig) {
108
- const providerConfig = emailConfig.config;
109
- return {
110
- id: emailConfig.id,
111
- name: emailConfig.name,
112
- provider: emailConfig.provider,
113
- fromEmail: emailConfig.fromEmail || '',
114
- fromName: emailConfig.fromName || '',
115
- isActive: emailConfig.isActive,
116
- isDefault: emailConfig.isDefault ?? false,
117
- // SMTP fields
118
- smtpHost: this.isSmtpConfig(providerConfig) ? providerConfig.host : '',
119
- smtpPort: this.isSmtpConfig(providerConfig) ? providerConfig.port : 587,
120
- smtpUser: this.isSmtpConfig(providerConfig) ? providerConfig.auth.user : '',
121
- smtpPass: this.isSmtpConfig(providerConfig) ? providerConfig.auth.pass : '',
122
- smtpSecure: this.isSmtpConfig(providerConfig) ? providerConfig.secure ?? false : false,
123
- // SendGrid fields
124
- sendgridApiKey: this.isSendGridConfig(providerConfig) ? providerConfig.apiKey : '',
125
- // Mailgun fields
126
- mailgunApiKey: this.isMailgunConfig(providerConfig) ? providerConfig.apiKey : '',
127
- mailgunDomain: this.isMailgunConfig(providerConfig) ? providerConfig.domain : '',
128
- mailgunRegion: this.isMailgunConfig(providerConfig) ? providerConfig.region ?? 'us' : 'us',
129
- };
130
- }
131
- isSmtpConfig(config) {
132
- return 'host' in config && 'auth' in config;
133
- }
134
- isSendGridConfig(config) {
135
- return 'apiKey' in config && !('domain' in config);
136
- }
137
- isMailgunConfig(config) {
138
- return 'apiKey' in config && 'domain' in config;
139
- }
140
- buildProviderConfig() {
141
- const form = this.formModel;
142
- switch (form.provider) {
143
- case EmailProviderEnum.SMTP:
144
- return {
145
- host: form.smtpHost,
146
- port: form.smtpPort,
147
- secure: form.smtpSecure,
148
- auth: { user: form.smtpUser, pass: form.smtpPass },
149
- };
150
- case EmailProviderEnum.SENDGRID:
151
- return { apiKey: form.sendgridApiKey };
152
- case EmailProviderEnum.MAILGUN:
153
- return {
154
- apiKey: form.mailgunApiKey,
155
- domain: form.mailgunDomain,
156
- region: form.mailgunRegion,
157
- };
158
- }
159
- }
160
- async onSave() {
161
- if (!this.formModel.name || !this.formModel.provider) {
162
- this.messageService.add({
163
- severity: 'warn',
164
- summary: this.translate('common.validation'),
165
- detail: this.translate('common.fill.required.fields'),
166
- });
167
- return;
168
- }
169
- this.isLoading.set(true);
170
- try {
171
- const dto = this.buildSaveDto();
172
- if (this.isEditMode()) {
173
- await this.configService.updateAsync({ id: this.formModel.id, ...dto });
174
- }
175
- else {
176
- await this.configService.insertAsync(dto);
177
- }
178
- this.messageService.add({
179
- severity: 'success',
180
- summary: this.translate('common.success'),
181
- detail: this.translate(this.isEditMode() ? 'email.config.updated' : 'email.config.created'),
182
- });
183
- this.router.navigate(['../'], { relativeTo: this.route });
184
- }
185
- catch {
186
- // Error toast handled by global interceptor
187
- }
188
- finally {
189
- this.isLoading.set(false);
190
- }
191
- }
192
- translate(key, variables) {
193
- return this.translateAdapter?.translate(key, variables) ?? key;
194
- }
195
- buildSaveDto() {
196
- return {
197
- name: this.formModel.name,
198
- provider: this.formModel.provider,
199
- config: this.buildProviderConfig(),
200
- fromEmail: this.formModel.fromEmail || undefined,
201
- fromName: this.formModel.fromName || undefined,
202
- isActive: this.formModel.isActive,
203
- isDefault: this.formModel.isDefault,
204
- };
205
- }
206
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: EmailConfigFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
207
- 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: `
208
- <div class="card">
209
- <!-- Header -->
210
- <div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-3 mb-4">
211
- <div>
212
- <h3 class="text-lg sm:text-xl font-semibold m-0">
213
- {{ (isEditMode() ? 'email.config.edit.title' : 'email.config.new.title') | translate }}
214
- </h3>
215
- @if (showCompanyInfo()) {
216
- <p class="text-sm text-muted-color mt-1">
217
- {{ 'common.company' | translate }}: {{ currentCompanyName() }}
218
- </p>
219
- }
220
- </div>
221
- </div>
222
-
223
- <!-- Form Fields -->
224
- <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
225
- <!-- Common Fields -->
226
- <div class="field">
227
- <label for="name" class="block font-medium mb-2"
228
- >{{ 'email.config.name' | translate }} *</label
229
- >
230
- <input
231
- pInputText
232
- id="name"
233
- [ngModel]="formModel.name"
234
- (ngModelChange)="updateFormModel('name', $event)"
235
- class="w-full"
236
- [placeholder]="'email.config.name.example' | translate"
237
- />
238
- </div>
239
-
240
- <div class="field">
241
- <label for="provider" class="block font-medium mb-2"
242
- >{{ 'email.config.provider' | translate }} *</label
243
- >
244
- <p-select
245
- id="provider"
246
- [options]="providerOptions()"
247
- [ngModel]="formModel.provider"
248
- (ngModelChange)="updateFormModel('provider', $event)"
249
- optionLabel="label"
250
- optionValue="value"
251
- [placeholder]="'email.config.select.provider' | translate"
252
- class="w-full"
253
- />
254
- </div>
255
-
256
- <div class="field">
257
- <label for="fromEmail" class="block font-medium mb-2"
258
- >{{ 'email.config.from.email' | translate }}</label
259
- >
260
- <input
261
- pInputText
262
- id="fromEmail"
263
- [ngModel]="formModel.fromEmail"
264
- (ngModelChange)="updateFormModel('fromEmail', $event)"
265
- class="w-full"
266
- [placeholder]="'email.config.from.email.example' | translate"
267
- />
268
- </div>
269
-
270
- <div class="field">
271
- <label for="fromName" class="block font-medium mb-2"
272
- >{{ 'email.config.from.name' | translate }}</label
273
- >
274
- <input
275
- pInputText
276
- id="fromName"
277
- [ngModel]="formModel.fromName"
278
- (ngModelChange)="updateFormModel('fromName', $event)"
279
- class="w-full"
280
- [placeholder]="'email.config.from.name.example' | translate"
281
- />
282
- </div>
283
-
284
- <div class="field flex items-center gap-2">
285
- <p-toggleswitch [ngModel]="formModel.isActive" (ngModelChange)="updateFormModel('isActive', $event)" />
286
- <label>{{ 'common.active' | translate }}</label>
287
- </div>
288
-
289
- <div class="field flex items-center gap-2">
290
- <p-toggleswitch [ngModel]="formModel.isDefault" (ngModelChange)="updateFormModel('isDefault', $event)" />
291
- <label>{{ 'email.config.set.as.default' | translate }}</label>
292
- </div>
293
- </div>
294
-
295
- <!-- SMTP Fields -->
296
- @if (formModel.provider === providerEnum.SMTP) {
297
- <div class="border-t border-surface mt-4 pt-4">
298
- <h3 class="font-semibold mb-4">{{ 'email.config.smtp.settings' | translate }}</h3>
299
- <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
300
- <div class="field">
301
- <label for="smtpHost" class="block font-medium mb-2"
302
- >{{ 'email.config.smtp.host' | translate }} *</label
303
- >
304
- <input
305
- pInputText
306
- id="smtpHost"
307
- [ngModel]="formModel.smtpHost"
308
- (ngModelChange)="updateFormModel('smtpHost', $event)"
309
- class="w-full"
310
- [placeholder]="'email.config.smtp.host.example' | translate"
311
- />
312
- </div>
313
- <div class="field">
314
- <label for="smtpPort" class="block font-medium mb-2"
315
- >{{ 'email.config.port' | translate }} *</label
316
- >
317
- <p-inputNumber
318
- id="smtpPort"
319
- [ngModel]="formModel.smtpPort"
320
- (ngModelChange)="updateFormModel('smtpPort', $event)"
321
- [useGrouping]="false"
322
- class="w-full"
323
- [placeholder]="'email.config.smtp.port.example' | translate"
324
- />
325
- </div>
326
- <div class="field">
327
- <label for="smtpUser" class="block font-medium mb-2"
328
- >{{ 'email.config.username' | translate }} *</label
329
- >
330
- <input
331
- pInputText
332
- id="smtpUser"
333
- [ngModel]="formModel.smtpUser"
334
- (ngModelChange)="updateFormModel('smtpUser', $event)"
335
- class="w-full"
336
- [placeholder]="'email.config.smtp.user.example' | translate"
337
- />
338
- </div>
339
- <div class="field">
340
- <label for="smtpPass" class="block font-medium mb-2"
341
- >{{ 'email.config.password' | translate }} *</label
342
- >
343
- <p-password
344
- id="smtpPass"
345
- [ngModel]="formModel.smtpPass"
346
- (ngModelChange)="updateFormModel('smtpPass', $event)"
347
- [feedback]="false"
348
- [toggleMask]="true"
349
- styleClass="w-full"
350
- inputStyleClass="w-full"
351
- [placeholder]="'email.config.smtp.password.example' | translate"
352
- />
353
- </div>
354
- <div class="field flex items-center gap-2">
355
- <p-toggleswitch [ngModel]="formModel.smtpSecure" (ngModelChange)="updateFormModel('smtpSecure', $event)" />
356
- <label>{{ 'email.config.use.ssl.tls' | translate }}</label>
357
- </div>
358
- </div>
359
- </div>
360
- }
361
-
362
- <!-- SendGrid Fields -->
363
- @if (formModel.provider === providerEnum.SENDGRID) {
364
- <div class="border-t border-surface mt-4 pt-4">
365
- <h3 class="font-semibold mb-4">{{ 'email.config.sendgrid.settings' | translate }}</h3>
366
- <div class="grid grid-cols-1 gap-4">
367
- <div class="field">
368
- <label for="sendgridApiKey" class="block font-medium mb-2"
369
- >{{ 'email.config.api.key' | translate }} *</label
370
- >
371
- <p-password
372
- id="sendgridApiKey"
373
- [ngModel]="formModel.sendgridApiKey"
374
- (ngModelChange)="updateFormModel('sendgridApiKey', $event)"
375
- [feedback]="false"
376
- [toggleMask]="true"
377
- styleClass="w-full"
378
- inputStyleClass="w-full"
379
- [placeholder]="'email.config.sendgrid.api.key.example' | translate"
380
- />
381
- </div>
382
- </div>
383
- </div>
384
- }
385
-
386
- <!-- Mailgun Fields -->
387
- @if (formModel.provider === providerEnum.MAILGUN) {
388
- <div class="border-t border-surface mt-4 pt-4">
389
- <h3 class="font-semibold mb-4">{{ 'email.config.mailgun.settings' | translate }}</h3>
390
- <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
391
- <div class="field">
392
- <label for="mailgunApiKey" class="block font-medium mb-2"
393
- >{{ 'email.config.api.key' | translate }} *</label
394
- >
395
- <p-password
396
- id="mailgunApiKey"
397
- [ngModel]="formModel.mailgunApiKey"
398
- (ngModelChange)="updateFormModel('mailgunApiKey', $event)"
399
- [feedback]="false"
400
- [toggleMask]="true"
401
- styleClass="w-full"
402
- inputStyleClass="w-full"
403
- [placeholder]="'email.config.mailgun.api.key.example' | translate"
404
- />
405
- </div>
406
- <div class="field">
407
- <label for="mailgunDomain" class="block font-medium mb-2"
408
- >{{ 'email.config.domain' | translate }} *</label
409
- >
410
- <input
411
- pInputText
412
- id="mailgunDomain"
413
- [ngModel]="formModel.mailgunDomain"
414
- (ngModelChange)="updateFormModel('mailgunDomain', $event)"
415
- class="w-full"
416
- [placeholder]="'email.config.mailgun.domain.example' | translate"
417
- />
418
- </div>
419
- <div class="field">
420
- <label for="mailgunRegion" class="block font-medium mb-2"
421
- >{{ 'email.config.region' | translate }}</label
422
- >
423
- <p-select
424
- id="mailgunRegion"
425
- [options]="regionOptions()"
426
- [ngModel]="formModel.mailgunRegion"
427
- (ngModelChange)="updateFormModel('mailgunRegion', $event)"
428
- optionLabel="label"
429
- optionValue="value"
430
- [placeholder]="'email.config.select.region' | translate"
431
- class="w-full"
432
- />
433
- </div>
434
- </div>
435
- </div>
436
- }
437
-
438
- <!-- Form Actions -->
439
- <div class="flex justify-end gap-2 mt-6 pt-4 border-t border-surface">
440
- <p-button
441
- [label]="'common.cancel' | translate"
442
- severity="secondary"
443
- [outlined]="true"
444
- routerLink="../"
445
- />
446
- <p-button
447
- [label]="(isEditMode() ? 'common.update' : 'common.create') | translate"
448
- icon="pi pi-save"
449
- [loading]="isLoading()"
450
- (onClick)="onSave()"
451
- />
452
- </div>
453
- </div>
454
-
455
- <p-toast />
456
- `, 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" }] });
457
- }
458
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: EmailConfigFormComponent, decorators: [{
459
- type: Component,
460
- args: [{
461
- selector: 'lib-email-config-form',
462
- imports: [AngularModule, PrimeModule, TranslatePipe],
463
- providers: [MessageService],
464
- template: `
465
- <div class="card">
466
- <!-- Header -->
467
- <div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-3 mb-4">
468
- <div>
469
- <h3 class="text-lg sm:text-xl font-semibold m-0">
470
- {{ (isEditMode() ? 'email.config.edit.title' : 'email.config.new.title') | translate }}
471
- </h3>
472
- @if (showCompanyInfo()) {
473
- <p class="text-sm text-muted-color mt-1">
474
- {{ 'common.company' | translate }}: {{ currentCompanyName() }}
475
- </p>
476
- }
477
- </div>
478
- </div>
479
-
480
- <!-- Form Fields -->
481
- <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
482
- <!-- Common Fields -->
483
- <div class="field">
484
- <label for="name" class="block font-medium mb-2"
485
- >{{ 'email.config.name' | translate }} *</label
486
- >
487
- <input
488
- pInputText
489
- id="name"
490
- [ngModel]="formModel.name"
491
- (ngModelChange)="updateFormModel('name', $event)"
492
- class="w-full"
493
- [placeholder]="'email.config.name.example' | translate"
494
- />
495
- </div>
496
-
497
- <div class="field">
498
- <label for="provider" class="block font-medium mb-2"
499
- >{{ 'email.config.provider' | translate }} *</label
500
- >
501
- <p-select
502
- id="provider"
503
- [options]="providerOptions()"
504
- [ngModel]="formModel.provider"
505
- (ngModelChange)="updateFormModel('provider', $event)"
506
- optionLabel="label"
507
- optionValue="value"
508
- [placeholder]="'email.config.select.provider' | translate"
509
- class="w-full"
510
- />
511
- </div>
512
-
513
- <div class="field">
514
- <label for="fromEmail" class="block font-medium mb-2"
515
- >{{ 'email.config.from.email' | translate }}</label
516
- >
517
- <input
518
- pInputText
519
- id="fromEmail"
520
- [ngModel]="formModel.fromEmail"
521
- (ngModelChange)="updateFormModel('fromEmail', $event)"
522
- class="w-full"
523
- [placeholder]="'email.config.from.email.example' | translate"
524
- />
525
- </div>
526
-
527
- <div class="field">
528
- <label for="fromName" class="block font-medium mb-2"
529
- >{{ 'email.config.from.name' | translate }}</label
530
- >
531
- <input
532
- pInputText
533
- id="fromName"
534
- [ngModel]="formModel.fromName"
535
- (ngModelChange)="updateFormModel('fromName', $event)"
536
- class="w-full"
537
- [placeholder]="'email.config.from.name.example' | translate"
538
- />
539
- </div>
540
-
541
- <div class="field flex items-center gap-2">
542
- <p-toggleswitch [ngModel]="formModel.isActive" (ngModelChange)="updateFormModel('isActive', $event)" />
543
- <label>{{ 'common.active' | translate }}</label>
544
- </div>
545
-
546
- <div class="field flex items-center gap-2">
547
- <p-toggleswitch [ngModel]="formModel.isDefault" (ngModelChange)="updateFormModel('isDefault', $event)" />
548
- <label>{{ 'email.config.set.as.default' | translate }}</label>
549
- </div>
550
- </div>
551
-
552
- <!-- SMTP Fields -->
553
- @if (formModel.provider === providerEnum.SMTP) {
554
- <div class="border-t border-surface mt-4 pt-4">
555
- <h3 class="font-semibold mb-4">{{ 'email.config.smtp.settings' | translate }}</h3>
556
- <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
557
- <div class="field">
558
- <label for="smtpHost" class="block font-medium mb-2"
559
- >{{ 'email.config.smtp.host' | translate }} *</label
560
- >
561
- <input
562
- pInputText
563
- id="smtpHost"
564
- [ngModel]="formModel.smtpHost"
565
- (ngModelChange)="updateFormModel('smtpHost', $event)"
566
- class="w-full"
567
- [placeholder]="'email.config.smtp.host.example' | translate"
568
- />
569
- </div>
570
- <div class="field">
571
- <label for="smtpPort" class="block font-medium mb-2"
572
- >{{ 'email.config.port' | translate }} *</label
573
- >
574
- <p-inputNumber
575
- id="smtpPort"
576
- [ngModel]="formModel.smtpPort"
577
- (ngModelChange)="updateFormModel('smtpPort', $event)"
578
- [useGrouping]="false"
579
- class="w-full"
580
- [placeholder]="'email.config.smtp.port.example' | translate"
581
- />
582
- </div>
583
- <div class="field">
584
- <label for="smtpUser" class="block font-medium mb-2"
585
- >{{ 'email.config.username' | translate }} *</label
586
- >
587
- <input
588
- pInputText
589
- id="smtpUser"
590
- [ngModel]="formModel.smtpUser"
591
- (ngModelChange)="updateFormModel('smtpUser', $event)"
592
- class="w-full"
593
- [placeholder]="'email.config.smtp.user.example' | translate"
594
- />
595
- </div>
596
- <div class="field">
597
- <label for="smtpPass" class="block font-medium mb-2"
598
- >{{ 'email.config.password' | translate }} *</label
599
- >
600
- <p-password
601
- id="smtpPass"
602
- [ngModel]="formModel.smtpPass"
603
- (ngModelChange)="updateFormModel('smtpPass', $event)"
604
- [feedback]="false"
605
- [toggleMask]="true"
606
- styleClass="w-full"
607
- inputStyleClass="w-full"
608
- [placeholder]="'email.config.smtp.password.example' | translate"
609
- />
610
- </div>
611
- <div class="field flex items-center gap-2">
612
- <p-toggleswitch [ngModel]="formModel.smtpSecure" (ngModelChange)="updateFormModel('smtpSecure', $event)" />
613
- <label>{{ 'email.config.use.ssl.tls' | translate }}</label>
614
- </div>
615
- </div>
616
- </div>
617
- }
618
-
619
- <!-- SendGrid Fields -->
620
- @if (formModel.provider === providerEnum.SENDGRID) {
621
- <div class="border-t border-surface mt-4 pt-4">
622
- <h3 class="font-semibold mb-4">{{ 'email.config.sendgrid.settings' | translate }}</h3>
623
- <div class="grid grid-cols-1 gap-4">
624
- <div class="field">
625
- <label for="sendgridApiKey" class="block font-medium mb-2"
626
- >{{ 'email.config.api.key' | translate }} *</label
627
- >
628
- <p-password
629
- id="sendgridApiKey"
630
- [ngModel]="formModel.sendgridApiKey"
631
- (ngModelChange)="updateFormModel('sendgridApiKey', $event)"
632
- [feedback]="false"
633
- [toggleMask]="true"
634
- styleClass="w-full"
635
- inputStyleClass="w-full"
636
- [placeholder]="'email.config.sendgrid.api.key.example' | translate"
637
- />
638
- </div>
639
- </div>
640
- </div>
641
- }
642
-
643
- <!-- Mailgun Fields -->
644
- @if (formModel.provider === providerEnum.MAILGUN) {
645
- <div class="border-t border-surface mt-4 pt-4">
646
- <h3 class="font-semibold mb-4">{{ 'email.config.mailgun.settings' | translate }}</h3>
647
- <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
648
- <div class="field">
649
- <label for="mailgunApiKey" class="block font-medium mb-2"
650
- >{{ 'email.config.api.key' | translate }} *</label
651
- >
652
- <p-password
653
- id="mailgunApiKey"
654
- [ngModel]="formModel.mailgunApiKey"
655
- (ngModelChange)="updateFormModel('mailgunApiKey', $event)"
656
- [feedback]="false"
657
- [toggleMask]="true"
658
- styleClass="w-full"
659
- inputStyleClass="w-full"
660
- [placeholder]="'email.config.mailgun.api.key.example' | translate"
661
- />
662
- </div>
663
- <div class="field">
664
- <label for="mailgunDomain" class="block font-medium mb-2"
665
- >{{ 'email.config.domain' | translate }} *</label
666
- >
667
- <input
668
- pInputText
669
- id="mailgunDomain"
670
- [ngModel]="formModel.mailgunDomain"
671
- (ngModelChange)="updateFormModel('mailgunDomain', $event)"
672
- class="w-full"
673
- [placeholder]="'email.config.mailgun.domain.example' | translate"
674
- />
675
- </div>
676
- <div class="field">
677
- <label for="mailgunRegion" class="block font-medium mb-2"
678
- >{{ 'email.config.region' | translate }}</label
679
- >
680
- <p-select
681
- id="mailgunRegion"
682
- [options]="regionOptions()"
683
- [ngModel]="formModel.mailgunRegion"
684
- (ngModelChange)="updateFormModel('mailgunRegion', $event)"
685
- optionLabel="label"
686
- optionValue="value"
687
- [placeholder]="'email.config.select.region' | translate"
688
- class="w-full"
689
- />
690
- </div>
691
- </div>
692
- </div>
693
- }
694
-
695
- <!-- Form Actions -->
696
- <div class="flex justify-end gap-2 mt-6 pt-4 border-t border-surface">
697
- <p-button
698
- [label]="'common.cancel' | translate"
699
- severity="secondary"
700
- [outlined]="true"
701
- routerLink="../"
702
- />
703
- <p-button
704
- [label]="(isEditMode() ? 'common.update' : 'common.create') | translate"
705
- icon="pi pi-save"
706
- [loading]="isLoading()"
707
- (onClick)="onSave()"
708
- />
709
- </div>
710
- </div>
711
-
712
- <p-toast />
713
- `,
714
- }]
715
- }], ctorParameters: () => [] });
716
-
717
- export { EmailConfigFormComponent };
718
- //# sourceMappingURL=flusys-ng-email-email-config-form.component-Cj2U6Tgf.mjs.map