feat(i18n): add Transloco translation framework with EN/ES and 7 language scaffolds (#2681)
* feat(i18n): add Transloco translation framework and translate all settings tabs (EN/ES) * feat(i18n): translate shared, layout, dashboard, library-creator, and app-root components (EN/ES) and scaffold 7 new languages * feat(i18n): translate bookdrop and metadata components (EN/ES), remove i18n-audit from tracking * fix(i18n): deep-merge English as fallback base for incomplete language translations
This commit is contained in:
+29
-28
@@ -1,11 +1,12 @@
|
||||
<ng-container *transloco="let t; prefix: 'settingsEmail.provider.create'">
|
||||
<div class="email-provider-creator">
|
||||
<div class="panel-header">
|
||||
<div class="header-icon-wrapper">
|
||||
<i class="pi pi-envelope header-icon"></i>
|
||||
</div>
|
||||
<div class="header-text">
|
||||
<h2 class="panel-title">Create Email Provider</h2>
|
||||
<p class="panel-description">Configure a new email provider for sending notifications</p>
|
||||
<h2 class="panel-title">{{ t('title') }}</h2>
|
||||
<p class="panel-description">{{ t('description') }}</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
@@ -14,8 +15,7 @@
|
||||
[text]="true"
|
||||
[rounded]="true"
|
||||
class="close-button"
|
||||
pTooltip="Close"
|
||||
tooltipPosition="left"/>
|
||||
/>
|
||||
</div>
|
||||
|
||||
<form [formGroup]="emailProviderForm" (ngSubmit)="createEmailProvider()">
|
||||
@@ -23,7 +23,7 @@
|
||||
<div class="form-group highlight-group">
|
||||
<label for="providerName" class="form-label">
|
||||
<i class="pi pi-tag label-icon"></i>
|
||||
Provider Name
|
||||
{{ t('providerName') }}
|
||||
<span class="required-indicator">*</span>
|
||||
</label>
|
||||
<div class="input-wrapper">
|
||||
@@ -33,16 +33,16 @@
|
||||
pInputText
|
||||
formControlName="name"
|
||||
class="input-full"
|
||||
placeholder="e.g., Gmail SMTP, SendGrid"
|
||||
[placeholder]="t('providerNamePlaceholder')"
|
||||
[class.filled]="emailProviderForm.get('name')?.value"
|
||||
|
||||
|
||||
/>
|
||||
@if (emailProviderForm.get('name')?.value && emailProviderForm.get('name')?.valid) {
|
||||
<i class="pi pi-check-circle input-icon success"></i>
|
||||
}
|
||||
</div>
|
||||
@if (emailProviderForm.get('name')?.invalid && (emailProviderForm.get('name')?.dirty || emailProviderForm.get('name')?.touched)) {
|
||||
<small class="field-error">Provider name is required.</small>
|
||||
<small class="field-error">{{ t('providerNameRequired') }}</small>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<div class="form-group highlight-group">
|
||||
<label for="host" class="form-label">
|
||||
<i class="pi pi-server label-icon"></i>
|
||||
Host
|
||||
{{ t('host') }}
|
||||
<span class="required-indicator">*</span>
|
||||
</label>
|
||||
<div class="input-wrapper">
|
||||
@@ -61,7 +61,7 @@
|
||||
pInputText
|
||||
formControlName="host"
|
||||
class="input-full"
|
||||
placeholder="e.g., smtp.gmail.com"
|
||||
[placeholder]="t('hostPlaceholder')"
|
||||
[class.filled]="emailProviderForm.get('host')?.value"
|
||||
/>
|
||||
@if (emailProviderForm.get('host')?.value && emailProviderForm.get('host')?.valid) {
|
||||
@@ -69,14 +69,14 @@
|
||||
}
|
||||
</div>
|
||||
@if (emailProviderForm.get('host')?.invalid && (emailProviderForm.get('host')?.dirty || emailProviderForm.get('host')?.touched)) {
|
||||
<small class="field-error">Host is required.</small>
|
||||
<small class="field-error">{{ t('hostRequired') }}</small>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="form-group highlight-group">
|
||||
<label for="port" class="form-label">
|
||||
<i class="pi pi-hashtag label-icon"></i>
|
||||
Port
|
||||
{{ t('port') }}
|
||||
<span class="required-indicator">*</span>
|
||||
</label>
|
||||
<div class="input-wrapper">
|
||||
@@ -86,7 +86,7 @@
|
||||
pInputText
|
||||
formControlName="port"
|
||||
class="input-full"
|
||||
placeholder="e.g., 587, 465"
|
||||
[placeholder]="t('portPlaceholder')"
|
||||
[class.filled]="emailProviderForm.get('port')?.value"
|
||||
/>
|
||||
@if (emailProviderForm.get('port')?.value && emailProviderForm.get('port')?.valid) {
|
||||
@@ -94,7 +94,7 @@
|
||||
}
|
||||
</div>
|
||||
@if (emailProviderForm.get('port')?.invalid && (emailProviderForm.get('port')?.dirty || emailProviderForm.get('port')?.touched)) {
|
||||
<small class="field-error">Port is required and must be a number.</small>
|
||||
<small class="field-error">{{ t('portRequired') }}</small>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
<div class="form-group highlight-group">
|
||||
<label for="username" class="form-label">
|
||||
<i class="pi pi-user label-icon"></i>
|
||||
Username
|
||||
{{ t('username') }}
|
||||
</label>
|
||||
<input
|
||||
id="username"
|
||||
@@ -111,14 +111,14 @@
|
||||
pInputText
|
||||
formControlName="username"
|
||||
class="input-full"
|
||||
placeholder="Enter username"
|
||||
[placeholder]="t('usernamePlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="form-group highlight-group">
|
||||
<label for="password" class="form-label">
|
||||
<i class="pi pi-lock label-icon"></i>
|
||||
Password
|
||||
{{ t('password') }}
|
||||
</label>
|
||||
<input
|
||||
id="password"
|
||||
@@ -126,14 +126,14 @@
|
||||
pInputText
|
||||
formControlName="password"
|
||||
class="input-full"
|
||||
placeholder="Enter password"
|
||||
[placeholder]="t('passwordPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="form-group highlight-group">
|
||||
<label for="fromAddress" class="form-label">
|
||||
<i class="pi pi-at label-icon"></i>
|
||||
From Address
|
||||
{{ t('fromAddress') }}
|
||||
</label>
|
||||
<input
|
||||
id="fromAddress"
|
||||
@@ -141,7 +141,7 @@
|
||||
pInputText
|
||||
formControlName="fromAddress"
|
||||
class="input-full"
|
||||
placeholder="e.g., noreply@example.com"
|
||||
[placeholder]="t('fromAddressPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -151,8 +151,8 @@
|
||||
<div class="checkbox-row">
|
||||
<p-checkbox formControlName="auth" [binary]="true" inputId="auth"></p-checkbox>
|
||||
<label for="auth" class="checkbox-label">
|
||||
<span class="checkbox-title">Enable Authentication</span>
|
||||
<span class="checkbox-description">Require username and password for SMTP</span>
|
||||
<span class="checkbox-title">{{ t('enableAuth') }}</span>
|
||||
<span class="checkbox-description">{{ t('enableAuthDesc') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -161,8 +161,8 @@
|
||||
<div class="checkbox-row">
|
||||
<p-checkbox formControlName="startTls" [binary]="true" inputId="startTls"></p-checkbox>
|
||||
<label for="startTls" class="checkbox-label">
|
||||
<span class="checkbox-title">Enable StartTLS</span>
|
||||
<span class="checkbox-description">Use TLS encryption for secure connection</span>
|
||||
<span class="checkbox-title">{{ t('enableStartTls') }}</span>
|
||||
<span class="checkbox-description">{{ t('enableStartTlsDesc') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -173,25 +173,25 @@
|
||||
@if (emailProviderForm.invalid) {
|
||||
<div class="validation-message error">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
<span>Please fill in all required fields</span>
|
||||
<span>{{ t('requiredFieldsError') }}</span>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="validation-message success">
|
||||
<i class="pi pi-check-circle"></i>
|
||||
<span>Ready to create provider</span>
|
||||
<span>{{ t('readyToCreate') }}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="footer-actions">
|
||||
<p-button
|
||||
label="Cancel"
|
||||
[label]="'common.cancel' | transloco"
|
||||
severity="secondary"
|
||||
[outlined]="true"
|
||||
(onClick)="closeDialog()"
|
||||
type="button"
|
||||
/>
|
||||
<p-button
|
||||
label="Create Provider"
|
||||
[label]="t('createBtn')"
|
||||
icon="pi pi-plus"
|
||||
severity="success"
|
||||
type="submit"
|
||||
@@ -201,3 +201,4 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+12
-8
@@ -7,6 +7,7 @@ import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from '@angular/
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {EmailV2ProviderService} from '../email-v2-provider/email-v2-provider.service';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-create-email-provider-dialog',
|
||||
@@ -14,7 +15,9 @@ import {EmailV2ProviderService} from '../email-v2-provider/email-v2-provider.ser
|
||||
Button,
|
||||
Checkbox,
|
||||
InputText,
|
||||
ReactiveFormsModule
|
||||
ReactiveFormsModule,
|
||||
TranslocoDirective,
|
||||
TranslocoPipe
|
||||
],
|
||||
templateUrl: './create-email-provider-dialog.component.html',
|
||||
styleUrl: './create-email-provider-dialog.component.scss'
|
||||
@@ -26,6 +29,7 @@ export class CreateEmailProviderDialogComponent implements OnInit {
|
||||
private emailProviderService = inject(EmailV2ProviderService);
|
||||
private messageService = inject(MessageService);
|
||||
private ref = inject(DynamicDialogRef);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
ngOnInit() {
|
||||
this.emailProviderForm = this.fb.group({
|
||||
@@ -44,8 +48,8 @@ export class CreateEmailProviderDialogComponent implements OnInit {
|
||||
if (this.emailProviderForm.invalid) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Validation Error',
|
||||
detail: 'Please correct errors before submitting.'
|
||||
summary: this.t.translate('settingsEmail.provider.create.validationError'),
|
||||
detail: this.t.translate('settingsEmail.provider.create.validationErrorDetail')
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -56,18 +60,18 @@ export class CreateEmailProviderDialogComponent implements OnInit {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Email Provider Created',
|
||||
detail: 'The email provider has been successfully created.'
|
||||
summary: this.t.translate('settingsEmail.provider.create.success'),
|
||||
detail: this.t.translate('settingsEmail.provider.create.successDetail')
|
||||
});
|
||||
this.ref.close(true);
|
||||
},
|
||||
error: (err) => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Email Provider Creation Failed',
|
||||
summary: this.t.translate('settingsEmail.provider.create.failed'),
|
||||
detail: err?.error?.message
|
||||
? `Unable to create email provider: ${err.error.message}`
|
||||
: 'An unexpected error occurred while creating the email provider. Please try again later.'
|
||||
? this.t.translate('settingsEmail.provider.create.failedDetail', {message: err.error.message})
|
||||
: this.t.translate('settingsEmail.provider.create.failedDefault')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
+18
-16
@@ -1,11 +1,12 @@
|
||||
<ng-container *transloco="let t; prefix: 'settingsEmail.recipient.create'">
|
||||
<div class="email-recipient-creator">
|
||||
<div class="panel-header">
|
||||
<div class="header-icon-wrapper">
|
||||
<i class="pi pi-user header-icon"></i>
|
||||
</div>
|
||||
<div class="header-text">
|
||||
<h2 class="panel-title">Create Email Recipient</h2>
|
||||
<p class="panel-description">Add a new recipient for email notifications</p>
|
||||
<h2 class="panel-title">{{ t('title') }}</h2>
|
||||
<p class="panel-description">{{ t('description') }}</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
@@ -14,7 +15,7 @@
|
||||
[text]="true"
|
||||
[rounded]="true"
|
||||
class="close-button"
|
||||
pTooltip="Close"
|
||||
[pTooltip]="'common.close' | transloco"
|
||||
tooltipPosition="left"/>
|
||||
</div>
|
||||
|
||||
@@ -23,7 +24,7 @@
|
||||
<div class="form-group highlight-group">
|
||||
<label for="recipientName" class="form-label">
|
||||
<i class="pi pi-user label-icon"></i>
|
||||
Recipient Name
|
||||
{{ t('recipientName') }}
|
||||
<span class="required-indicator">*</span>
|
||||
</label>
|
||||
<div class="input-wrapper">
|
||||
@@ -33,16 +34,16 @@
|
||||
pInputText
|
||||
formControlName="name"
|
||||
class="input-full"
|
||||
placeholder="Enter recipient name..."
|
||||
[placeholder]="t('recipientNamePlaceholder')"
|
||||
[class.filled]="emailRecipientForm.get('name')?.value"
|
||||
|
||||
|
||||
/>
|
||||
@if (emailRecipientForm.get('name')?.value && emailRecipientForm.get('name')?.valid) {
|
||||
<i class="pi pi-check-circle input-icon success"></i>
|
||||
}
|
||||
</div>
|
||||
@if (emailRecipientForm.get('name')?.invalid && (emailRecipientForm.get('name')?.dirty || emailRecipientForm.get('name')?.touched)) {
|
||||
<small class="field-error">Recipient name is required.</small>
|
||||
<small class="field-error">{{ t('recipientNameRequired') }}</small>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -51,7 +52,7 @@
|
||||
<div class="form-group highlight-group">
|
||||
<label for="email" class="form-label">
|
||||
<i class="pi pi-at label-icon"></i>
|
||||
Email Address
|
||||
{{ t('emailAddress') }}
|
||||
<span class="required-indicator">*</span>
|
||||
</label>
|
||||
<div class="input-wrapper">
|
||||
@@ -61,7 +62,7 @@
|
||||
pInputText
|
||||
formControlName="email"
|
||||
class="input-full"
|
||||
placeholder="Enter email address..."
|
||||
[placeholder]="t('emailAddressPlaceholder')"
|
||||
[class.filled]="emailRecipientForm.get('email')?.value"
|
||||
/>
|
||||
@if (emailRecipientForm.get('email')?.value && emailRecipientForm.get('email')?.valid) {
|
||||
@@ -69,7 +70,7 @@
|
||||
}
|
||||
</div>
|
||||
@if (emailRecipientForm.get('email')?.invalid && (emailRecipientForm.get('email')?.dirty || emailRecipientForm.get('email')?.touched)) {
|
||||
<small class="field-error">Valid email is required.</small>
|
||||
<small class="field-error">{{ t('emailRequired') }}</small>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -79,8 +80,8 @@
|
||||
<div class="checkbox-row">
|
||||
<p-checkbox formControlName="defaultRecipient" [binary]="true" inputId="defaultRecipient"></p-checkbox>
|
||||
<label for="defaultRecipient" class="checkbox-label">
|
||||
<span class="checkbox-title">Default Recipient</span>
|
||||
<span class="checkbox-description">Set as default recipient for all notifications</span>
|
||||
<span class="checkbox-title">{{ t('defaultRecipient') }}</span>
|
||||
<span class="checkbox-description">{{ t('defaultRecipientDesc') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -91,25 +92,25 @@
|
||||
@if (emailRecipientForm.invalid) {
|
||||
<div class="validation-message error">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
<span>Please fill in all required fields</span>
|
||||
<span>{{ t('requiredFieldsError') }}</span>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="validation-message success">
|
||||
<i class="pi pi-check-circle"></i>
|
||||
<span>Ready to add recipient</span>
|
||||
<span>{{ t('readyToAdd') }}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="footer-actions">
|
||||
<p-button
|
||||
label="Cancel"
|
||||
[label]="'common.cancel' | transloco"
|
||||
severity="secondary"
|
||||
[outlined]="true"
|
||||
(onClick)="closeDialog()"
|
||||
type="button"
|
||||
/>
|
||||
<p-button
|
||||
label="Add Recipient"
|
||||
[label]="t('addBtn')"
|
||||
icon="pi pi-plus"
|
||||
severity="success"
|
||||
type="submit"
|
||||
@@ -119,3 +120,4 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+12
-8
@@ -7,6 +7,7 @@ import {Button} from 'primeng/button';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {EmailV2RecipientService} from '../email-v2-recipient/email-v2-recipient.service';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-create-email-recipient-dialog',
|
||||
@@ -15,7 +16,9 @@ import {Tooltip} from 'primeng/tooltip';
|
||||
ReactiveFormsModule,
|
||||
Button,
|
||||
InputText,
|
||||
Tooltip
|
||||
Tooltip,
|
||||
TranslocoDirective,
|
||||
TranslocoPipe
|
||||
],
|
||||
templateUrl: './create-email-recipient-dialog.component.html',
|
||||
styleUrls: ['./create-email-recipient-dialog.component.scss']
|
||||
@@ -26,6 +29,7 @@ export class CreateEmailRecipientDialogComponent {
|
||||
private emailRecipientService = inject(EmailV2RecipientService);
|
||||
private messageService = inject(MessageService);
|
||||
private ref = inject(DynamicDialogRef);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
constructor() {
|
||||
this.emailRecipientForm = this.fb.group({
|
||||
@@ -43,8 +47,8 @@ export class CreateEmailRecipientDialogComponent {
|
||||
if (this.emailRecipientForm.invalid) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Validation Error',
|
||||
detail: 'Please correct errors before submitting.'
|
||||
summary: this.t.translate('settingsEmail.recipient.create.validationError'),
|
||||
detail: this.t.translate('settingsEmail.recipient.create.validationErrorDetail')
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -55,18 +59,18 @@ export class CreateEmailRecipientDialogComponent {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Recipient Added',
|
||||
detail: `${emailRecipientData.name} has been successfully added.`
|
||||
summary: this.t.translate('settingsEmail.recipient.create.success'),
|
||||
detail: this.t.translate('settingsEmail.recipient.create.successDetail', {name: emailRecipientData.name})
|
||||
});
|
||||
this.ref.close(true);
|
||||
},
|
||||
error: (err) => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Recipient Creation Failed',
|
||||
summary: this.t.translate('settingsEmail.recipient.create.failed'),
|
||||
detail: err?.error?.message
|
||||
? `Unable to create recipient: ${err.error.message}`
|
||||
: 'An unexpected error occurred while adding the recipient. Please try again later.'
|
||||
? this.t.translate('settingsEmail.recipient.create.failedDetail', {message: err.error.message})
|
||||
: this.t.translate('settingsEmail.recipient.create.failedDefault')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
+195
-193
@@ -1,209 +1,211 @@
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<div class="section-header-row">
|
||||
<div class="section-header-text">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-server"></i>
|
||||
Email Providers
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
Configure email-sending services like Gmail, Outlook, or custom SMTP servers. The default provider is used for 'Quick Book Send' in the Book Card menu.
|
||||
</p>
|
||||
<ng-container *transloco="let t; prefix: 'settingsEmail.provider'">
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<div class="section-header-row">
|
||||
<div class="section-header-text">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-server"></i>
|
||||
{{ t('title') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
{{ t('description') }}
|
||||
</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-plus"
|
||||
[label]="t('addProvider')"
|
||||
severity="success"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
(onClick)="openCreateProviderDialog()">
|
||||
</p-button>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-plus"
|
||||
label="Add Provider"
|
||||
severity="success"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
(onClick)="openCreateProviderDialog()">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
@if (emailProviders.length === 0) {
|
||||
<div class="empty-state">
|
||||
<i class="pi pi-envelope"></i>
|
||||
<p class="empty-title">No email providers configured</p>
|
||||
<p class="empty-subtitle">Create your first email provider to start sending books</p>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="providers-list">
|
||||
@for (provider of emailProviders; track provider.id) {
|
||||
<div class="provider-item" [class.is-default]="provider.id === defaultProviderId">
|
||||
<div class="provider-header">
|
||||
<div class="provider-info">
|
||||
<div class="provider-name-row">
|
||||
<p-radioButton
|
||||
name="defaultProvider"
|
||||
[value]="provider.id"
|
||||
[(ngModel)]="defaultProviderId"
|
||||
(onClick)="setDefaultProvider(provider)">
|
||||
</p-radioButton>
|
||||
@if (provider.isEditing) {
|
||||
<input type="text" pInputText [(ngModel)]="provider.name" placeholder="Provider name" class="name-input"/>
|
||||
} @else {
|
||||
<span class="provider-name">{{ provider.name }}</span>
|
||||
@if (provider.shared) {
|
||||
<span class="shared-badge" pTooltip="Shared with all users">
|
||||
<i class="pi pi-share-alt"></i>
|
||||
</span>
|
||||
<div class="section-body">
|
||||
@if (emailProviders.length === 0) {
|
||||
<div class="empty-state">
|
||||
<i class="pi pi-envelope"></i>
|
||||
<p class="empty-title">{{ t('emptyTitle') }}</p>
|
||||
<p class="empty-subtitle">{{ t('emptySubtitle') }}</p>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="providers-list">
|
||||
@for (provider of emailProviders; track provider.id) {
|
||||
<div class="provider-item" [class.is-default]="provider.id === defaultProviderId">
|
||||
<div class="provider-header">
|
||||
<div class="provider-info">
|
||||
<div class="provider-name-row">
|
||||
<p-radioButton
|
||||
name="defaultProvider"
|
||||
[value]="provider.id"
|
||||
[(ngModel)]="defaultProviderId"
|
||||
(onClick)="setDefaultProvider(provider)">
|
||||
</p-radioButton>
|
||||
@if (provider.isEditing) {
|
||||
<input type="text" pInputText [(ngModel)]="provider.name" [placeholder]="t('providerNamePlaceholder')" class="name-input"/>
|
||||
} @else {
|
||||
<span class="provider-name">{{ provider.name }}</span>
|
||||
@if (provider.shared) {
|
||||
<span class="shared-badge" [pTooltip]="t('sharedTooltip')">
|
||||
<i class="pi pi-share-alt"></i>
|
||||
</span>
|
||||
}
|
||||
@if (provider.id === defaultProviderId) {
|
||||
<span class="default-badge">{{ t('default') }}</span>
|
||||
}
|
||||
}
|
||||
@if (provider.id === defaultProviderId) {
|
||||
<span class="default-badge">Default</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="provider-actions">
|
||||
@if (!provider.isEditing) {
|
||||
<p-button
|
||||
[icon]="canModifyProvider(provider) ? 'pi pi-pencil' : 'pi pi-lock'"
|
||||
[severity]="canModifyProvider(provider) ? 'info' : 'secondary'"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
[disabled]="!canModifyProvider(provider)"
|
||||
(onClick)="canModifyProvider(provider) && toggleEdit(provider)"
|
||||
[pTooltip]="canModifyProvider(provider) ? t('editProvider') : t('cannotEditShared')"
|
||||
tooltipPosition="left">
|
||||
</p-button>
|
||||
<p-button
|
||||
[icon]="canModifyProvider(provider) ? 'pi pi-trash' : 'pi pi-lock'"
|
||||
[severity]="canModifyProvider(provider) ? 'danger' : 'secondary'"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
[disabled]="!canModifyProvider(provider)"
|
||||
(onClick)="canModifyProvider(provider) && deleteProvider(provider)"
|
||||
[pTooltip]="canModifyProvider(provider) ? t('deleteProvider') : t('cannotDeleteShared')"
|
||||
tooltipPosition="left">
|
||||
</p-button>
|
||||
} @else {
|
||||
<p-button
|
||||
icon="pi pi-check"
|
||||
severity="success"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="saveProvider(provider)"
|
||||
[pTooltip]="t('saveChanges')">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
severity="secondary"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="toggleEdit(provider)"
|
||||
[pTooltip]="'common.cancel' | transloco">
|
||||
</p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="provider-details">
|
||||
<div class="detail-grid">
|
||||
<div class="detail-item">
|
||||
<label class="detail-label">
|
||||
<i class="pi pi-server"></i>
|
||||
{{ t('host') }}
|
||||
</label>
|
||||
@if (provider.isEditing) {
|
||||
<input type="text" pInputText [(ngModel)]="provider.host" [placeholder]="t('hostPlaceholder')"/>
|
||||
} @else {
|
||||
<span class="detail-value">{{ provider.host }}</span>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="provider-actions">
|
||||
@if (!provider.isEditing) {
|
||||
<p-button
|
||||
[icon]="canModifyProvider(provider) ? 'pi pi-pencil' : 'pi pi-lock'"
|
||||
[severity]="canModifyProvider(provider) ? 'info' : 'secondary'"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
[disabled]="!canModifyProvider(provider)"
|
||||
(onClick)="canModifyProvider(provider) && toggleEdit(provider)"
|
||||
[pTooltip]="canModifyProvider(provider) ? 'Edit provider' : 'Cannot edit shared provider'"
|
||||
tooltipPosition="left">
|
||||
</p-button>
|
||||
<p-button
|
||||
[icon]="canModifyProvider(provider) ? 'pi pi-trash' : 'pi pi-lock'"
|
||||
[severity]="canModifyProvider(provider) ? 'danger' : 'secondary'"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
[disabled]="!canModifyProvider(provider)"
|
||||
(onClick)="canModifyProvider(provider) && deleteProvider(provider)"
|
||||
[pTooltip]="canModifyProvider(provider) ? 'Delete provider' : 'Cannot delete shared provider'"
|
||||
tooltipPosition="left">
|
||||
</p-button>
|
||||
} @else {
|
||||
<p-button
|
||||
icon="pi pi-check"
|
||||
severity="success"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="saveProvider(provider)"
|
||||
pTooltip="Save changes">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
severity="secondary"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="toggleEdit(provider)"
|
||||
pTooltip="Cancel">
|
||||
</p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="provider-details">
|
||||
<div class="detail-grid">
|
||||
<div class="detail-item">
|
||||
<label class="detail-label">
|
||||
<i class="pi pi-server"></i>
|
||||
Host
|
||||
</label>
|
||||
@if (provider.isEditing) {
|
||||
<input type="text" pInputText [(ngModel)]="provider.host" placeholder="smtp.example.com"/>
|
||||
} @else {
|
||||
<span class="detail-value">{{ provider.host }}</span>
|
||||
}
|
||||
<div class="detail-item">
|
||||
<label class="detail-label">
|
||||
<i class="pi pi-link"></i>
|
||||
{{ t('port') }}
|
||||
</label>
|
||||
@if (provider.isEditing) {
|
||||
<input type="number" pInputText [(ngModel)]="provider.port" [placeholder]="t('portPlaceholder')"/>
|
||||
} @else {
|
||||
<span class="detail-value">{{ provider.port }}</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="detail-item">
|
||||
<label class="detail-label">
|
||||
<i class="pi pi-user"></i>
|
||||
{{ t('username') }}
|
||||
</label>
|
||||
@if (provider.isEditing) {
|
||||
<input type="text" pInputText [(ngModel)]="provider.username" [placeholder]="t('usernamePlaceholder')"/>
|
||||
} @else {
|
||||
<span class="detail-value">{{ provider.username }}</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="detail-item">
|
||||
<label class="detail-label">
|
||||
<i class="pi pi-lock"></i>
|
||||
{{ t('password') }}
|
||||
</label>
|
||||
@if (provider.isEditing) {
|
||||
<input type="password" pInputText [(ngModel)]="provider.password" [placeholder]="t('passwordPlaceholder')"/>
|
||||
} @else {
|
||||
<span class="detail-value password-hidden">********</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="detail-item detail-item-wide">
|
||||
<label class="detail-label">
|
||||
<i class="pi pi-envelope"></i>
|
||||
{{ t('fromAddress') }}
|
||||
</label>
|
||||
@if (provider.isEditing) {
|
||||
<input type="email" pInputText [(ngModel)]="provider.fromAddress" [placeholder]="t('fromAddressPlaceholder')"/>
|
||||
} @else {
|
||||
<span class="detail-value">{{ provider.fromAddress }}</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="detail-item">
|
||||
<label class="detail-label">
|
||||
<i class="pi pi-link"></i>
|
||||
Port
|
||||
</label>
|
||||
@if (provider.isEditing) {
|
||||
<input type="number" pInputText [(ngModel)]="provider.port" placeholder="587"/>
|
||||
} @else {
|
||||
<span class="detail-value">{{ provider.port }}</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="detail-item">
|
||||
<label class="detail-label">
|
||||
<i class="pi pi-user"></i>
|
||||
Username
|
||||
</label>
|
||||
@if (provider.isEditing) {
|
||||
<input type="text" pInputText [(ngModel)]="provider.username" placeholder="user@example.com"/>
|
||||
} @else {
|
||||
<span class="detail-value">{{ provider.username }}</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="detail-item">
|
||||
<label class="detail-label">
|
||||
<i class="pi pi-lock"></i>
|
||||
Password
|
||||
</label>
|
||||
@if (provider.isEditing) {
|
||||
<input type="password" pInputText [(ngModel)]="provider.password" placeholder="Enter password"/>
|
||||
} @else {
|
||||
<span class="detail-value password-hidden">********</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="detail-item detail-item-wide">
|
||||
<label class="detail-label">
|
||||
<i class="pi pi-envelope"></i>
|
||||
From Address
|
||||
</label>
|
||||
@if (provider.isEditing) {
|
||||
<input type="email" pInputText [(ngModel)]="provider.fromAddress" placeholder="noreply@example.com"/>
|
||||
} @else {
|
||||
<span class="detail-value">{{ provider.fromAddress }}</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toggle-options">
|
||||
<div class="toggle-item">
|
||||
<p-checkbox
|
||||
[(ngModel)]="provider.auth"
|
||||
[binary]="true"
|
||||
[disabled]="!provider.isEditing"
|
||||
inputId="auth-{{provider.id}}">
|
||||
</p-checkbox>
|
||||
<label [for]="'auth-' + provider.id" class="toggle-label">Authentication</label>
|
||||
</div>
|
||||
|
||||
<div class="toggle-item">
|
||||
<p-checkbox
|
||||
[(ngModel)]="provider.startTls"
|
||||
[binary]="true"
|
||||
[disabled]="!provider.isEditing"
|
||||
inputId="starttls-{{provider.id}}">
|
||||
</p-checkbox>
|
||||
<label [for]="'starttls-' + provider.id" class="toggle-label">StartTLS</label>
|
||||
</div>
|
||||
|
||||
@if (isAdmin) {
|
||||
<div class="toggle-options">
|
||||
<div class="toggle-item">
|
||||
<p-checkbox
|
||||
[(ngModel)]="provider.shared"
|
||||
[(ngModel)]="provider.auth"
|
||||
[binary]="true"
|
||||
(onChange)="toggleShared(provider)"
|
||||
inputId="shared-{{provider.id}}"
|
||||
pTooltip="Share this provider with all users">
|
||||
[disabled]="!provider.isEditing"
|
||||
inputId="auth-{{provider.id}}">
|
||||
</p-checkbox>
|
||||
<label [for]="'shared-' + provider.id" class="toggle-label">Shared</label>
|
||||
<label [for]="'auth-' + provider.id" class="toggle-label">{{ t('authentication') }}</label>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="toggle-item">
|
||||
<p-checkbox
|
||||
[(ngModel)]="provider.startTls"
|
||||
[binary]="true"
|
||||
[disabled]="!provider.isEditing"
|
||||
inputId="starttls-{{provider.id}}">
|
||||
</p-checkbox>
|
||||
<label [for]="'starttls-' + provider.id" class="toggle-label">{{ t('startTls') }}</label>
|
||||
</div>
|
||||
|
||||
@if (isAdmin) {
|
||||
<div class="toggle-item">
|
||||
<p-checkbox
|
||||
[(ngModel)]="provider.shared"
|
||||
[binary]="true"
|
||||
(onChange)="toggleShared(provider)"
|
||||
inputId="shared-{{provider.id}}"
|
||||
[pTooltip]="t('shareTooltip')">
|
||||
</p-checkbox>
|
||||
<label [for]="'shared-' + provider.id" class="toggle-label">{{ t('shared') }}</label>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+25
-20
@@ -11,6 +11,7 @@ import {EmailV2ProviderService} from './email-v2-provider.service';
|
||||
import {EmailProvider} from '../email-provider.model';
|
||||
import {UserService} from '../../user-management/user.service';
|
||||
import {DialogLauncherService} from '../../../../shared/services/dialog-launcher.service';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-email-v2-provider',
|
||||
@@ -21,7 +22,9 @@ import {DialogLauncherService} from '../../../../shared/services/dialog-launcher
|
||||
ReactiveFormsModule,
|
||||
TableModule,
|
||||
Tooltip,
|
||||
FormsModule
|
||||
FormsModule,
|
||||
TranslocoDirective,
|
||||
TranslocoPipe
|
||||
],
|
||||
templateUrl: './email-v2-provider.component.html',
|
||||
styleUrl: './email-v2-provider.component.scss'
|
||||
@@ -34,6 +37,7 @@ export class EmailV2ProviderComponent implements OnInit {
|
||||
private emailProvidersService = inject(EmailV2ProviderService);
|
||||
private messageService = inject(MessageService);
|
||||
private userService = inject(UserService);
|
||||
private t = inject(TranslocoService);
|
||||
defaultProviderId: unknown;
|
||||
currentUserId: number | null = null;
|
||||
isAdmin: boolean = false;
|
||||
@@ -62,8 +66,8 @@ export class EmailV2ProviderComponent implements OnInit {
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: 'Failed to load Email Providers',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsEmail.provider.loadError'),
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -84,37 +88,37 @@ export class EmailV2ProviderComponent implements OnInit {
|
||||
provider.isEditing = false;
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Success',
|
||||
detail: 'Provider updated successfully',
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('settingsEmail.provider.updateSuccess'),
|
||||
});
|
||||
this.loadEmailProviders();
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: 'Failed to update provider',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsEmail.provider.updateError'),
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
deleteProvider(provider: EmailProvider): void {
|
||||
if (confirm(`Are you sure you want to delete provider "${provider.name}"?`)) {
|
||||
if (confirm(this.t.translate('settingsEmail.provider.deleteConfirm', {name: provider.name}))) {
|
||||
this.emailProvidersService.deleteProvider(provider.id).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Success',
|
||||
detail: `Provider "${provider.name}" deleted successfully`,
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('settingsEmail.provider.deleteSuccess', {name: provider.name}),
|
||||
});
|
||||
this.loadEmailProviders();
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: 'Failed to delete provider',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsEmail.provider.deleteError'),
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -136,16 +140,16 @@ export class EmailV2ProviderComponent implements OnInit {
|
||||
this.defaultProviderId = provider.id;
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Default Provider Set',
|
||||
detail: `${provider.name} is now the default email provider.`
|
||||
summary: this.t.translate('settingsEmail.provider.defaultSetSummary'),
|
||||
detail: this.t.translate('settingsEmail.provider.defaultSetDetail', {name: provider.name}),
|
||||
});
|
||||
},
|
||||
error: (err) => {
|
||||
console.error('Failed to set default provider', err);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: `Failed to set ${provider.name} as the default provider. Please try again.`
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsEmail.provider.defaultSetError', {name: provider.name}),
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -158,18 +162,19 @@ export class EmailV2ProviderComponent implements OnInit {
|
||||
toggleShared(provider: EmailProvider): void {
|
||||
this.emailProvidersService.updateProvider(provider).subscribe({
|
||||
next: () => {
|
||||
const status = this.t.translate(provider.shared ? 'settingsEmail.provider.sharedStatusOn' : 'settingsEmail.provider.sharedStatusOff');
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Success',
|
||||
detail: `Provider "${provider.name}" is now ${provider.shared ? 'shared' : 'not shared'}`,
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('settingsEmail.provider.sharedSuccess', {name: provider.name, status}),
|
||||
});
|
||||
},
|
||||
error: () => {
|
||||
provider.shared = !provider.shared;
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: 'Failed to update shared status',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsEmail.provider.sharedError'),
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
+120
-118
@@ -1,129 +1,131 @@
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<div class="section-header-row">
|
||||
<div class="section-header-text">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-users"></i>
|
||||
Recipient Emails
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
Manage recipient email addresses for sending books. The default recipient is used for 'Quick Book Send' in the Book Card menu.
|
||||
</p>
|
||||
<ng-container *transloco="let t; prefix: 'settingsEmail.recipient'">
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<div class="section-header-row">
|
||||
<div class="section-header-text">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-users"></i>
|
||||
{{ t('title') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
{{ t('description') }}
|
||||
</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-plus"
|
||||
[label]="t('addRecipient')"
|
||||
severity="success"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
(onClick)="openAddRecipientDialog()">
|
||||
</p-button>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-plus"
|
||||
label="Add Recipient"
|
||||
severity="success"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
(onClick)="openAddRecipientDialog()">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
@if (recipientEmails.length === 0) {
|
||||
<div class="empty-state">
|
||||
<i class="pi pi-users"></i>
|
||||
<p class="empty-title">No recipients configured</p>
|
||||
<p class="empty-subtitle">Add your first email recipient to start sending books</p>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="recipients-list">
|
||||
@for (recipient of recipientEmails; track recipient.id) {
|
||||
<div class="recipient-item" [class.is-default]="recipient.id === defaultRecipientId">
|
||||
<div class="recipient-content">
|
||||
<div class="recipient-select">
|
||||
<p-radioButton
|
||||
name="defaultRecipient"
|
||||
[value]="recipient.id"
|
||||
[(ngModel)]="defaultRecipientId"
|
||||
(onClick)="setDefaultRecipient(recipient)">
|
||||
</p-radioButton>
|
||||
</div>
|
||||
<div class="section-body">
|
||||
@if (recipientEmails.length === 0) {
|
||||
<div class="empty-state">
|
||||
<i class="pi pi-users"></i>
|
||||
<p class="empty-title">{{ t('emptyTitle') }}</p>
|
||||
<p class="empty-subtitle">{{ t('emptySubtitle') }}</p>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="recipients-list">
|
||||
@for (recipient of recipientEmails; track recipient.id) {
|
||||
<div class="recipient-item" [class.is-default]="recipient.id === defaultRecipientId">
|
||||
<div class="recipient-content">
|
||||
<div class="recipient-select">
|
||||
<p-radioButton
|
||||
name="defaultRecipient"
|
||||
[value]="recipient.id"
|
||||
[(ngModel)]="defaultRecipientId"
|
||||
(onClick)="setDefaultRecipient(recipient)">
|
||||
</p-radioButton>
|
||||
</div>
|
||||
|
||||
<div class="recipient-info">
|
||||
@if (recipient.isEditing) {
|
||||
<div class="edit-form">
|
||||
<div class="form-field">
|
||||
<label class="field-label">
|
||||
<div class="recipient-info">
|
||||
@if (recipient.isEditing) {
|
||||
<div class="edit-form">
|
||||
<div class="form-field">
|
||||
<label class="field-label">
|
||||
<i class="pi pi-envelope"></i>
|
||||
{{ t('email') }}
|
||||
</label>
|
||||
<input type="email" pInputText [(ngModel)]="recipient.email" [placeholder]="t('emailPlaceholder')"/>
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label class="field-label">
|
||||
<i class="pi pi-user"></i>
|
||||
{{ t('name') }}
|
||||
</label>
|
||||
<input type="text" pInputText [(ngModel)]="recipient.name" [placeholder]="t('namePlaceholder')"/>
|
||||
</div>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="recipient-details">
|
||||
<div class="recipient-email">
|
||||
<i class="pi pi-envelope"></i>
|
||||
Email
|
||||
</label>
|
||||
<input type="email" pInputText [(ngModel)]="recipient.email" placeholder="recipient@example.com"/>
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label class="field-label">
|
||||
<i class="pi pi-user"></i>
|
||||
Name
|
||||
</label>
|
||||
<input type="text" pInputText [(ngModel)]="recipient.name" placeholder="Recipient name"/>
|
||||
</div>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="recipient-details">
|
||||
<div class="recipient-email">
|
||||
<i class="pi pi-envelope"></i>
|
||||
<span>{{ recipient.email }}</span>
|
||||
@if (recipient.id === defaultRecipientId) {
|
||||
<span class="default-badge">Default</span>
|
||||
<span>{{ recipient.email }}</span>
|
||||
@if (recipient.id === defaultRecipientId) {
|
||||
<span class="default-badge">{{ t('default') }}</span>
|
||||
}
|
||||
</div>
|
||||
@if (recipient.name) {
|
||||
<div class="recipient-name">
|
||||
<i class="pi pi-user"></i>
|
||||
<span>{{ recipient.name }}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@if (recipient.name) {
|
||||
<div class="recipient-name">
|
||||
<i class="pi pi-user"></i>
|
||||
<span>{{ recipient.name }}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="recipient-actions">
|
||||
@if (!recipient.isEditing) {
|
||||
<p-button
|
||||
icon="pi pi-pencil"
|
||||
severity="info"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="toggleEditRecipient(recipient)"
|
||||
pTooltip="Edit recipient">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-trash"
|
||||
severity="danger"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="deleteRecipient(recipient)"
|
||||
pTooltip="Delete recipient">
|
||||
</p-button>
|
||||
} @else {
|
||||
<p-button
|
||||
icon="pi pi-check"
|
||||
severity="success"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="saveRecipient(recipient)"
|
||||
pTooltip="Save changes">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
severity="secondary"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="toggleEditRecipient(recipient)"
|
||||
pTooltip="Cancel">
|
||||
</p-button>
|
||||
}
|
||||
<div class="recipient-actions">
|
||||
@if (!recipient.isEditing) {
|
||||
<p-button
|
||||
icon="pi pi-pencil"
|
||||
severity="info"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="toggleEditRecipient(recipient)"
|
||||
[pTooltip]="t('editRecipient')">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-trash"
|
||||
severity="danger"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="deleteRecipient(recipient)"
|
||||
[pTooltip]="t('deleteRecipient')">
|
||||
</p-button>
|
||||
} @else {
|
||||
<p-button
|
||||
icon="pi pi-check"
|
||||
severity="success"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="saveRecipient(recipient)"
|
||||
[pTooltip]="t('saveChanges')">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
severity="secondary"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="toggleEditRecipient(recipient)"
|
||||
[pTooltip]="'common.cancel' | transloco">
|
||||
</p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+18
-14
@@ -9,6 +9,7 @@ import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {EmailV2RecipientService} from './email-v2-recipient.service';
|
||||
import {EmailRecipient} from '../email-recipient.model';
|
||||
import {DialogLauncherService} from '../../../../shared/services/dialog-launcher.service';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-email-v2-recipient',
|
||||
@@ -18,7 +19,9 @@ import {DialogLauncherService} from '../../../../shared/services/dialog-launcher
|
||||
ReactiveFormsModule,
|
||||
TableModule,
|
||||
Tooltip,
|
||||
FormsModule
|
||||
FormsModule,
|
||||
TranslocoDirective,
|
||||
TranslocoPipe
|
||||
],
|
||||
templateUrl: './email-v2-recipient.component.html',
|
||||
styleUrl: './email-v2-recipient.component.scss'
|
||||
@@ -30,6 +33,7 @@ export class EmailV2RecipientComponent implements OnInit {
|
||||
private dialogLauncherService = inject(DialogLauncherService);
|
||||
private emailRecipientService = inject(EmailV2RecipientService);
|
||||
private messageService = inject(MessageService);
|
||||
private t = inject(TranslocoService);
|
||||
defaultRecipientId: unknown;
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -49,8 +53,8 @@ export class EmailV2RecipientComponent implements OnInit {
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: 'Failed to load recipient emails',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsEmail.recipient.loadError'),
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -71,37 +75,37 @@ export class EmailV2RecipientComponent implements OnInit {
|
||||
recipient.isEditing = false;
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Success',
|
||||
detail: 'Recipient updated successfully',
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('settingsEmail.recipient.updateSuccess'),
|
||||
});
|
||||
this.loadRecipientEmails();
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: 'Failed to update recipient',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsEmail.recipient.updateError'),
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
deleteRecipient(recipient: EmailRecipient): void {
|
||||
if (confirm(`Are you sure you want to delete recipient "${recipient.email}"?`)) {
|
||||
if (confirm(this.t.translate('settingsEmail.recipient.deleteConfirm', {email: recipient.email}))) {
|
||||
this.emailRecipientService.deleteRecipient(recipient.id).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Success',
|
||||
detail: `Recipient "${recipient.email}" deleted successfully`,
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('settingsEmail.recipient.deleteSuccess', {email: recipient.email}),
|
||||
});
|
||||
this.loadRecipientEmails();
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: 'Failed to delete recipient',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsEmail.recipient.deleteError'),
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -122,8 +126,8 @@ export class EmailV2RecipientComponent implements OnInit {
|
||||
this.defaultRecipientId = recipient.id;
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Default Recipient Set',
|
||||
detail: `${recipient.email} is now the default recipient.`
|
||||
summary: this.t.translate('settingsEmail.recipient.defaultSetSummary'),
|
||||
detail: this.t.translate('settingsEmail.recipient.defaultSetDetail', {email: recipient.email}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,30 +1,32 @@
|
||||
<div class="email-settings-container">
|
||||
<div class="settings-header">
|
||||
<h2 class="settings-title">
|
||||
<i class="pi pi-envelope"></i>
|
||||
Email Configuration
|
||||
<app-external-doc-link docType="email"></app-external-doc-link>
|
||||
</h2>
|
||||
<p class="settings-description">
|
||||
Configure email settings to send books directly to your devices or recipients. Set up email providers (like Gmail, Outlook, or custom SMTP servers) and manage recipient email addresses.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@if (hasPermission) {
|
||||
<app-email-v2-provider></app-email-v2-provider>
|
||||
<div class="section-divider"><hr></div>
|
||||
<app-email-v2-recipient></app-email-v2-recipient>
|
||||
} @else {
|
||||
<div class="access-denied-card">
|
||||
<i class="pi pi-lock"></i>
|
||||
<div class="access-denied-content">
|
||||
<h3>Access Restricted</h3>
|
||||
<p>
|
||||
Access to Email Configuration is restricted.
|
||||
<br>
|
||||
Please contact your administrator to request permission.
|
||||
</p>
|
||||
</div>
|
||||
<ng-container *transloco="let t; prefix: 'settingsEmail'">
|
||||
<div class="email-settings-container">
|
||||
<div class="settings-header">
|
||||
<h2 class="settings-title">
|
||||
<i class="pi pi-envelope"></i>
|
||||
{{ t('title') }}
|
||||
<app-external-doc-link docType="email"></app-external-doc-link>
|
||||
</h2>
|
||||
<p class="settings-description">
|
||||
{{ t('description') }}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (hasPermission) {
|
||||
<app-email-v2-provider></app-email-v2-provider>
|
||||
<div class="section-divider"><hr></div>
|
||||
<app-email-v2-recipient></app-email-v2-recipient>
|
||||
} @else {
|
||||
<div class="access-denied-card">
|
||||
<i class="pi pi-lock"></i>
|
||||
<div class="access-denied-content">
|
||||
<h3>{{ t('accessRestricted') }}</h3>
|
||||
<p>
|
||||
{{ t('accessDenied') }}
|
||||
<br>
|
||||
{{ t('contactAdmin') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
@@ -7,6 +7,7 @@ import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-
|
||||
import {UserService} from '../user-management/user.service';
|
||||
import {Subject} from 'rxjs';
|
||||
import {filter, takeUntil, tap} from 'rxjs/operators';
|
||||
import {TranslocoDirective} from '@jsverse/transloco';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -16,7 +17,8 @@ import {filter, takeUntil, tap} from 'rxjs/operators';
|
||||
TableModule,
|
||||
EmailV2ProviderComponent,
|
||||
EmailV2RecipientComponent,
|
||||
ExternalDocLinkComponent
|
||||
ExternalDocLinkComponent,
|
||||
TranslocoDirective
|
||||
],
|
||||
templateUrl: './email-v2.component.html',
|
||||
styleUrls: ['./email-v2.component.scss'],
|
||||
|
||||
Reference in New Issue
Block a user