Align the layout to be consistent throughout all dialogs (#1737)
This commit is contained in:
+77
-76
@@ -1,3 +1,4 @@
|
||||
<p-toast position="top-right"></p-toast>
|
||||
<p-confirmDialog></p-confirmDialog>
|
||||
|
||||
<div class="main-container enclosing-container">
|
||||
@@ -26,33 +27,28 @@
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<form #koboForm="ngForm">
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Enable Kobo Sync</label>
|
||||
<p-toggle-switch
|
||||
id="syncEnabled"
|
||||
name="syncEnabled"
|
||||
[(ngModel)]="koboSyncSettings.syncEnabled"
|
||||
(ngModelChange)="onSyncToggle()">
|
||||
</p-toggle-switch>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Turn on synchronization to automatically sync your library books to your Kobo device.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (koboSyncSettings.syncEnabled) {
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Enable Kobo Sync</label>
|
||||
<p-toggle-switch
|
||||
id="syncEnabled"
|
||||
name="syncEnabled"
|
||||
[(ngModel)]="koboSyncSettings.syncEnabled"
|
||||
(ngModelChange)="onSyncToggle()">
|
||||
</p-toggle-switch>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Turn on synchronization to automatically sync your library books to your Kobo device.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (koboSyncSettings.syncEnabled) {
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<label class="setting-label">Kobo Sync Token</label>
|
||||
<p class="setting-description">
|
||||
Your unique sync token for authenticating with your Kobo device. Keep this secure.
|
||||
</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<div class="token-input-group">
|
||||
<input
|
||||
pInputText
|
||||
@@ -68,27 +64,29 @@
|
||||
outlined="true"
|
||||
severity="info"
|
||||
size="small"
|
||||
(onClick)="copyText(koboSyncSettings.token)">
|
||||
(onClick)="copyText(koboSyncSettings.token, 'Token')"
|
||||
[disabled]="!koboSyncSettings.token">
|
||||
</p-button>
|
||||
<p-button
|
||||
[icon]="showToken ? 'pi pi-eye-slash' : 'pi pi-eye'"
|
||||
outlined="true"
|
||||
severity="info"
|
||||
size="small"
|
||||
(onClick)="toggleShowToken()">
|
||||
(onClick)="toggleShowToken()"
|
||||
[disabled]="!koboSyncSettings.token">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Your unique sync token for authenticating with your Kobo device. Keep this secure.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Token Management</label>
|
||||
<p class="setting-description">
|
||||
Regenerate your sync token if needed. This will invalidate the current token.
|
||||
</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<p-button
|
||||
icon="pi pi-refresh"
|
||||
outlined="true"
|
||||
@@ -99,57 +97,60 @@
|
||||
[disabled]="!credentialsSaved">
|
||||
</p-button>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Regenerate your sync token if needed. This will invalidate the current token.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Mark as Reading at: {{ koboSyncSettings.progressMarkAsReadingThreshold?.toFixed(0) }}%</label>
|
||||
<div class="slider-container">
|
||||
<p-slider
|
||||
id="markAsReadingThreshold"
|
||||
name="markAsReadingThreshold"
|
||||
[(ngModel)]="koboSyncSettings.progressMarkAsReadingThreshold"
|
||||
[min]="1"
|
||||
[max]="10"
|
||||
[step]="1"
|
||||
(ngModelChange)="onProgressThresholdsChange()">
|
||||
</p-slider>
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Mark as Reading at: {{ koboSyncSettings.progressMarkAsReadingThreshold?.toFixed(0) }}%</label>
|
||||
<div class="slider-container">
|
||||
<p-slider
|
||||
id="markAsReadingThreshold"
|
||||
name="markAsReadingThreshold"
|
||||
[(ngModel)]="koboSyncSettings.progressMarkAsReadingThreshold"
|
||||
[min]="1"
|
||||
[max]="10"
|
||||
[step]="1"
|
||||
(ngModelChange)="onProgressThresholdsChange()">
|
||||
</p-slider>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Books are marked as "Reading" when progress exceeds this percentage. This helps automatically track which books you've started.
|
||||
<br>
|
||||
<strong>Recommended:</strong> 1% (default) - marks as reading after the first page or two.
|
||||
</p>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Books are marked as "Reading" when progress exceeds this percentage. This helps automatically track which books you've started.
|
||||
<br>
|
||||
<strong>Recommended:</strong> 1% (default) - marks as reading after the first page or two.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Mark as Finished at: {{ koboSyncSettings.progressMarkAsFinishedThreshold?.toFixed(0) }}%</label>
|
||||
<div class="slider-container">
|
||||
<p-slider
|
||||
id="markAsFinishedThreshold"
|
||||
name="markAsFinishedThreshold"
|
||||
[(ngModel)]="koboSyncSettings.progressMarkAsFinishedThreshold"
|
||||
[min]="90"
|
||||
[max]="100"
|
||||
[step]="1"
|
||||
(ngModelChange)="onProgressThresholdsChange()">
|
||||
</p-slider>
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Mark as Finished at: {{ koboSyncSettings.progressMarkAsFinishedThreshold?.toFixed(0) }}%</label>
|
||||
<div class="slider-container">
|
||||
<p-slider
|
||||
id="markAsFinishedThreshold"
|
||||
name="markAsFinishedThreshold"
|
||||
[(ngModel)]="koboSyncSettings.progressMarkAsFinishedThreshold"
|
||||
[min]="90"
|
||||
[max]="100"
|
||||
[step]="1"
|
||||
(ngModelChange)="onProgressThresholdsChange()">
|
||||
</p-slider>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Books are marked as "Finished" when progress reaches this percentage. Accounts for books where the last few pages are acknowledgments or index.
|
||||
<br>
|
||||
<strong>Recommended:</strong> 99% (default) - marks as finished when nearly complete.
|
||||
</p>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Books are marked as "Finished" when progress reaches this percentage. Accounts for books where the last few pages are acknowledgments or index.
|
||||
<br>
|
||||
<strong>Recommended:</strong> 99% (default) - marks as finished when nearly complete.
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
</form>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -220,13 +221,13 @@
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Force enable hyphenation. Otherwise, hyphenation is only enabled when text alignment on the Kobo
|
||||
device is explicitly set to <i>justified</i>.
|
||||
device is explicitly set to <i>justified</i>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p-divider></p-divider>
|
||||
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
|
||||
+14
-13
@@ -77,22 +77,16 @@
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-radius: 8px;
|
||||
background: var(--p-content-background);
|
||||
padding: 1.5rem;
|
||||
padding: 1.75rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.setting-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 2rem;
|
||||
padding: 0.25rem 0;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
@@ -122,6 +116,7 @@
|
||||
.setting-label {
|
||||
margin-bottom: 0;
|
||||
flex-shrink: 0;
|
||||
min-width: 150px;
|
||||
}
|
||||
|
||||
.slider-container {
|
||||
@@ -134,6 +129,17 @@
|
||||
max-width: 250px;
|
||||
}
|
||||
}
|
||||
|
||||
.token-input-group {
|
||||
flex: 1;
|
||||
min-width: 300px;
|
||||
max-width: 500px;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
min-width: 250px;
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.setting-description {
|
||||
@@ -162,11 +168,6 @@
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.token-input {
|
||||
flex: 1;
|
||||
|
||||
+20
-6
@@ -1,6 +1,5 @@
|
||||
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
|
||||
import {ConfirmationService, MessageService} from 'primeng/api';
|
||||
import {Clipboard} from '@angular/cdk/clipboard';
|
||||
import {KoboService, KoboSyncSettings} from './kobo.service';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Button} from 'primeng/button';
|
||||
@@ -17,20 +16,20 @@ import {SettingsHelperService} from '../../../../../shared/service/settings-help
|
||||
import {AppSettingKey, KoboSettings} from '../../../../../shared/model/app-settings.model';
|
||||
import {ShelfService} from '../../../../book/service/shelf.service';
|
||||
import {ExternalDocLinkComponent} from '../../../../../shared/components/external-doc-link/external-doc-link.component';
|
||||
import {ToastModule} from 'primeng/toast';
|
||||
|
||||
@Component({
|
||||
selector: 'app-kobo-sync-setting-component',
|
||||
standalone: true,
|
||||
templateUrl: './kobo-sync-settings-component.html',
|
||||
styleUrl: './kobo-sync-settings-component.scss',
|
||||
imports: [FormsModule, Button, InputText, ConfirmDialog, ToggleSwitch, Slider, Divider, ExternalDocLinkComponent],
|
||||
imports: [FormsModule, Button, InputText, ConfirmDialog, ToggleSwitch, Slider, Divider, ExternalDocLinkComponent, ToastModule],
|
||||
providers: [MessageService, ConfirmationService]
|
||||
})
|
||||
export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
||||
private koboService = inject(KoboService);
|
||||
private messageService = inject(MessageService);
|
||||
private confirmationService = inject(ConfirmationService);
|
||||
private clipboard = inject(Clipboard);
|
||||
protected userService = inject(UserService);
|
||||
protected appSettingsService = inject(AppSettingsService);
|
||||
protected settingsHelperService = inject(SettingsHelperService);
|
||||
@@ -132,9 +131,24 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
copyText(text: string) {
|
||||
this.clipboard.copy(text);
|
||||
this.messageService.add({severity: 'success', summary: 'Copied', detail: 'Token copied to clipboard'});
|
||||
copyText(text: string, label: string = 'Text') {
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Copied',
|
||||
detail: `${label} copied to clipboard`
|
||||
});
|
||||
}).catch(err => {
|
||||
console.error('Copy failed', err);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Copy Failed',
|
||||
detail: `Unable to copy ${label.toLowerCase()} to clipboard`
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
toggleShowToken() {
|
||||
|
||||
+8
-4
@@ -61,7 +61,8 @@
|
||||
outlined="true"
|
||||
severity="info"
|
||||
size="small"
|
||||
(onClick)="copyText(koreaderEndpoint)">
|
||||
(onClick)="copyText(koreaderEndpoint, 'API Path')"
|
||||
[disabled]="!koreaderEndpoint">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -91,7 +92,8 @@
|
||||
outlined="true"
|
||||
severity="info"
|
||||
size="small"
|
||||
(onClick)="copyText(koReaderUsername)">
|
||||
(onClick)="copyText(koReaderUsername, 'Username')"
|
||||
[disabled]="!koReaderUsername">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -128,14 +130,16 @@
|
||||
outlined="true"
|
||||
severity="info"
|
||||
size="small"
|
||||
(onClick)="copyText(koReaderPassword)">
|
||||
(onClick)="copyText(koReaderPassword, 'Password')"
|
||||
[disabled]="!koReaderPassword">
|
||||
</p-button>
|
||||
<p-button
|
||||
[icon]="showPassword ? 'pi pi-eye-slash' : 'pi pi-eye'"
|
||||
outlined="true"
|
||||
severity="info"
|
||||
size="small"
|
||||
(onClick)="toggleShowPassword()">
|
||||
(onClick)="toggleShowPassword()"
|
||||
[disabled]="!koReaderPassword">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+13
-2
@@ -120,12 +120,23 @@ export class KoreaderSettingsComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
copyText(text: string) {
|
||||
copyText(text: string, label: string = 'Text') {
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
navigator.clipboard.writeText(text).catch(err => {
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Copied',
|
||||
detail: `${label} copied to clipboard`
|
||||
});
|
||||
}).catch(err => {
|
||||
console.error('Copy failed', err);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Copy Failed',
|
||||
detail: `Unable to copy ${label.toLowerCase()} to clipboard`
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -140,6 +140,7 @@
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
flex: 1;
|
||||
max-width: 600px;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
|
||||
@@ -9,7 +9,7 @@ import {Dialog} from 'primeng/dialog';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {ConfirmDialog} from 'primeng/confirmdialog';
|
||||
import {ConfirmationService, MessageService} from 'primeng/api';
|
||||
import {OpdsUserV2, OpdsUserV2CreateRequest, OpdsService} from './opds.service';
|
||||
import {OpdsService, OpdsUserV2, OpdsUserV2CreateRequest} from './opds.service';
|
||||
import {catchError, filter, take, takeUntil, tap} from 'rxjs/operators';
|
||||
import {UserService} from '../user-management/user.service';
|
||||
import {of, Subject} from 'rxjs';
|
||||
|
||||
+247
-117
@@ -1,120 +1,250 @@
|
||||
<form [formGroup]="userForm" (ngSubmit)="createUser()" class="space-y-6 p-6">
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<label class="w-40 text-right font-medium">Full Name:</label>
|
||||
<input type="text" pInputText formControlName="name" placeholder="Enter full name..." class="w-full md:w-80"/>
|
||||
</div>
|
||||
@if (userForm.get('name')?.invalid && (userForm.get('name')?.dirty || userForm.get('name')?.touched)) {
|
||||
<small class="text-red-500 pl-44">
|
||||
Name is required and must be at least 3 characters.
|
||||
</small>
|
||||
}
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<label class="w-40 text-right font-medium">Email:</label>
|
||||
<input type="email" pInputText formControlName="email" placeholder="Enter email..." class="w-full md:w-80"/>
|
||||
</div>
|
||||
@if (userForm.get('email')?.invalid && (userForm.get('email')?.dirty || userForm.get('email')?.touched)) {
|
||||
<small class="text-red-500 pl-44">
|
||||
Enter a valid email address.
|
||||
</small>
|
||||
}
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<label class="w-40 text-right font-medium">Username:</label>
|
||||
<input type="text" pInputText formControlName="username" placeholder="Enter username..." class="w-full md:w-80"/>
|
||||
</div>
|
||||
@if (userForm.get('username')?.invalid && (userForm.get('username')?.dirty || userForm.get('username')?.touched)) {
|
||||
<small class="text-red-500 pl-44">
|
||||
Username is required.
|
||||
</small>
|
||||
}
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<label class="w-40 text-right font-medium">Password:</label>
|
||||
<input type="password" pInputText formControlName="password" placeholder="Enter password..." class="w-full md:w-80"/>
|
||||
</div>
|
||||
@if (userForm.get('password')?.invalid && (userForm.get('password')?.dirty || userForm.get('password')?.touched)) {
|
||||
<small class="text-red-500 pl-44">
|
||||
Password must be at least 6 characters long.
|
||||
</small>
|
||||
}
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<label class="w-40 text-right font-medium">Accessible Libraries:</label>
|
||||
<p-multiselect
|
||||
[options]="libraries"
|
||||
formControlName="selectedLibraries"
|
||||
placeholder="Select Libraries"
|
||||
optionLabel="name"
|
||||
display="chip"
|
||||
class="w-full md:w-80"
|
||||
appendTo="body">
|
||||
</p-multiselect>
|
||||
</div>
|
||||
@if (userForm.get('selectedLibraries')?.invalid && (userForm.get('selectedLibraries')?.dirty || userForm.get('selectedLibraries')?.touched)) {
|
||||
<small class="text-red-500 pl-44">
|
||||
At least one library must be selected.
|
||||
</small>
|
||||
}
|
||||
|
||||
<div>
|
||||
<p class="text-right w-40 font-medium">Permissions:</p>
|
||||
<div class="flex flex-col gap-2 pl-44">
|
||||
<div class="flex items-center gap-2">
|
||||
<p-checkbox formControlName="permissionUpload" [binary]="true"></p-checkbox>
|
||||
<label>Upload Books</label>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<p-checkbox formControlName="permissionDownload" [binary]="true"></p-checkbox>
|
||||
<label>Download Books</label>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<p-checkbox formControlName="permissionEditMetadata" [binary]="true"></p-checkbox>
|
||||
<label>Edit Metadata</label>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<p-checkbox formControlName="permissionManipulateLibrary" [binary]="true"></p-checkbox>
|
||||
<label>Manage Library</label>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<p-checkbox formControlName="permissionEmailBook" [binary]="true"></p-checkbox>
|
||||
<label>Email Book</label>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<p-checkbox formControlName="permissionDeleteBook" [binary]="true"></p-checkbox>
|
||||
<label>Delete Book</label>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<p-checkbox formControlName="permissionAccessOpds" [binary]="true"></p-checkbox>
|
||||
<label>Access OPDS</label>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<p-checkbox formControlName="permissionSyncKoreader" [binary]="true"></p-checkbox>
|
||||
<label>KOReader Sync</label>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<p-checkbox formControlName="permissionSyncKobo" [binary]="true"></p-checkbox>
|
||||
<label>Kobo Sync</label>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<p-checkbox formControlName="permissionAdmin" [binary]="true"></p-checkbox>
|
||||
<label class="text-orange-500 font-bold">Admin</label>
|
||||
</div>
|
||||
<div class="create-user-dialog">
|
||||
<div class="panel-header">
|
||||
<div class="header-icon-wrapper">
|
||||
<i class="pi pi-user-plus header-icon"></i>
|
||||
</div>
|
||||
<div class="header-text">
|
||||
<h2 class="panel-title">Create New User</h2>
|
||||
<p class="panel-description">
|
||||
Set up a new user account with permissions and library access
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end">
|
||||
<p-button label="Create User" [disabled]="userForm.invalid" type="submit">
|
||||
</p-button>
|
||||
</div>
|
||||
</form>
|
||||
<form [formGroup]="userForm" (ngSubmit)="createUser()">
|
||||
<div class="form-container">
|
||||
<div class="form-section">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-id-card"></i>
|
||||
Basic Information
|
||||
</h3>
|
||||
|
||||
<div class="form-field">
|
||||
<label class="field-label">Full Name</label>
|
||||
<input
|
||||
type="text"
|
||||
pInputText
|
||||
formControlName="name"
|
||||
placeholder="Enter full name..."
|
||||
class="field-input"
|
||||
/>
|
||||
@if (userForm.get('name')?.invalid && (userForm.get('name')?.dirty || userForm.get('name')?.touched)) {
|
||||
<small class="field-error">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
Name is required and must be at least 3 characters.
|
||||
</small>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label class="field-label">Email</label>
|
||||
<input
|
||||
type="email"
|
||||
pInputText
|
||||
formControlName="email"
|
||||
placeholder="Enter email..."
|
||||
class="field-input"
|
||||
/>
|
||||
@if (userForm.get('email')?.invalid && (userForm.get('email')?.dirty || userForm.get('email')?.touched)) {
|
||||
<small class="field-error">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
Enter a valid email address.
|
||||
</small>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label class="field-label">Username</label>
|
||||
<input
|
||||
type="text"
|
||||
pInputText
|
||||
formControlName="username"
|
||||
placeholder="Enter username..."
|
||||
class="field-input"
|
||||
/>
|
||||
@if (userForm.get('username')?.invalid && (userForm.get('username')?.dirty || userForm.get('username')?.touched)) {
|
||||
<small class="field-error">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
Username is required.
|
||||
</small>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label class="field-label">Password</label>
|
||||
<input
|
||||
type="password"
|
||||
pInputText
|
||||
formControlName="password"
|
||||
placeholder="Enter password..."
|
||||
class="field-input"
|
||||
/>
|
||||
@if (userForm.get('password')?.invalid && (userForm.get('password')?.dirty || userForm.get('password')?.touched)) {
|
||||
<small class="field-error">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
Password must be at least 6 characters long.
|
||||
</small>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-section">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-book"></i>
|
||||
Library Access
|
||||
</h3>
|
||||
|
||||
<div class="form-field">
|
||||
<label class="field-label">Accessible Libraries</label>
|
||||
<p-multiselect
|
||||
[options]="libraries"
|
||||
formControlName="selectedLibraries"
|
||||
placeholder="Select Libraries"
|
||||
optionLabel="name"
|
||||
display="chip"
|
||||
class="field-input"
|
||||
appendTo="body">
|
||||
</p-multiselect>
|
||||
@if (userForm.get('selectedLibraries')?.invalid && (userForm.get('selectedLibraries')?.dirty || userForm.get('selectedLibraries')?.touched)) {
|
||||
<small class="field-error">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
At least one library must be selected.
|
||||
</small>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-section">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-shield"></i>
|
||||
Permissions
|
||||
</h3>
|
||||
|
||||
<div class="permissions-grid">
|
||||
<div class="permission-item">
|
||||
<p-checkbox formControlName="permissionUpload" [binary]="true" inputId="perm-upload"></p-checkbox>
|
||||
<label for="perm-upload" class="permission-label">
|
||||
<div class="permission-icon-wrapper">
|
||||
<i class="pi pi-upload permission-icon"></i>
|
||||
</div>
|
||||
<span class="permission-name">Upload Books</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="permission-item">
|
||||
<p-checkbox formControlName="permissionDownload" [binary]="true" inputId="perm-download"></p-checkbox>
|
||||
<label for="perm-download" class="permission-label">
|
||||
<div class="permission-icon-wrapper">
|
||||
<i class="pi pi-download permission-icon"></i>
|
||||
</div>
|
||||
<span class="permission-name">Download Books</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="permission-item">
|
||||
<p-checkbox formControlName="permissionEditMetadata" [binary]="true" inputId="perm-edit"></p-checkbox>
|
||||
<label for="perm-edit" class="permission-label">
|
||||
<div class="permission-icon-wrapper">
|
||||
<i class="pi pi-pencil permission-icon"></i>
|
||||
</div>
|
||||
<span class="permission-name">Edit Metadata</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="permission-item">
|
||||
<p-checkbox formControlName="permissionManipulateLibrary" [binary]="true" inputId="perm-library"></p-checkbox>
|
||||
<label for="perm-library" class="permission-label">
|
||||
<div class="permission-icon-wrapper">
|
||||
<i class="pi pi-folder permission-icon"></i>
|
||||
</div>
|
||||
<span class="permission-name">Manage Library</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="permission-item">
|
||||
<p-checkbox formControlName="permissionEmailBook" [binary]="true" inputId="perm-email"></p-checkbox>
|
||||
<label for="perm-email" class="permission-label">
|
||||
<div class="permission-icon-wrapper">
|
||||
<i class="pi pi-envelope permission-icon"></i>
|
||||
</div>
|
||||
<span class="permission-name">Email Book</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="permission-item">
|
||||
<p-checkbox formControlName="permissionDeleteBook" [binary]="true" inputId="perm-delete"></p-checkbox>
|
||||
<label for="perm-delete" class="permission-label">
|
||||
<div class="permission-icon-wrapper">
|
||||
<i class="pi pi-trash permission-icon"></i>
|
||||
</div>
|
||||
<span class="permission-name">Delete Book</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="permission-item">
|
||||
<p-checkbox formControlName="permissionAccessOpds" [binary]="true" inputId="perm-opds"></p-checkbox>
|
||||
<label for="perm-opds" class="permission-label">
|
||||
<div class="permission-icon-wrapper">
|
||||
<i class="pi pi-globe permission-icon"></i>
|
||||
</div>
|
||||
<span class="permission-name">Access OPDS</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="permission-item">
|
||||
<p-checkbox formControlName="permissionSyncKoreader" [binary]="true" inputId="perm-koreader"></p-checkbox>
|
||||
<label for="perm-koreader" class="permission-label">
|
||||
<div class="permission-icon-wrapper">
|
||||
<i class="pi pi-sync permission-icon"></i>
|
||||
</div>
|
||||
<span class="permission-name">KOReader Sync</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="permission-item">
|
||||
<p-checkbox formControlName="permissionSyncKobo" [binary]="true" inputId="perm-kobo"></p-checkbox>
|
||||
<label for="perm-kobo" class="permission-label">
|
||||
<div class="permission-icon-wrapper">
|
||||
<i class="pi pi-tablet permission-icon"></i>
|
||||
</div>
|
||||
<span class="permission-name">Kobo Sync</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="permission-item admin-permission">
|
||||
<p-checkbox formControlName="permissionAdmin" [binary]="true" inputId="perm-admin"></p-checkbox>
|
||||
<label for="perm-admin" class="permission-label">
|
||||
<div class="permission-icon-wrapper admin-icon">
|
||||
<i class="pi pi-shield permission-icon"></i>
|
||||
</div>
|
||||
<span class="permission-name admin-name">Admin</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dialog-footer">
|
||||
<div class="footer-info">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
<span>All fields are required to create a user</span>
|
||||
</div>
|
||||
<div class="footer-actions">
|
||||
<p-button
|
||||
label="Cancel"
|
||||
severity="secondary"
|
||||
[outlined]="true"
|
||||
type="button"
|
||||
(click)="closeDialog()"
|
||||
/>
|
||||
<p-button
|
||||
label="Create User"
|
||||
icon="pi pi-check"
|
||||
severity="success"
|
||||
[disabled]="userForm.invalid"
|
||||
type="submit"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
+331
@@ -0,0 +1,331 @@
|
||||
.create-user-dialog {
|
||||
width: 650px;
|
||||
max-width: 650px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-top: 20px;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.panel-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
padding: 1.25rem;
|
||||
|
||||
border-radius: 10px 10px 0 0;
|
||||
border: 1px solid var(--border-color);
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
|
||||
|
||||
.header-icon-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
background: var(--primary-color);
|
||||
border-radius: 10px;
|
||||
|
||||
|
||||
.header-icon {
|
||||
font-size: 1.5rem;
|
||||
color: var(--primary-contrast-color);
|
||||
}
|
||||
}
|
||||
|
||||
.header-text {
|
||||
flex: 1;
|
||||
|
||||
.panel-title {
|
||||
margin: 0 0 0.25rem 0;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.panel-description {
|
||||
margin: 0;
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-secondary-color);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
padding: 1rem;
|
||||
|
||||
.header-icon-wrapper {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
|
||||
.header-icon {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.header-text {
|
||||
.panel-title {
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
|
||||
.panel-description {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.form-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
padding: 2rem 1.5rem 1.5rem 1.5rem;
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-top: none;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
|
||||
max-height: 60vh;
|
||||
overflow-y: auto;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: var(--overlay-background);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: var(--border-color);
|
||||
border-radius: 3px;
|
||||
transition: background 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: var(--primary-color);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
padding: 1rem;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.form-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
|
||||
.section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin: 0 0 0.5rem 0;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-color);
|
||||
padding-bottom: 0.5rem;
|
||||
border-bottom: 2px solid var(--border-color);
|
||||
|
||||
i {
|
||||
color: var(--primary-color);
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.form-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
.field-label {
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.field-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.field-error {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
color: #ef4444;
|
||||
font-size: 0.8125rem;
|
||||
margin-top: -0.25rem;
|
||||
|
||||
i {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.permissions-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
gap: 0.75rem;
|
||||
|
||||
@media (max-width: 640px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.permission-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 0.5rem 0.95rem;
|
||||
background: var(--ground-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
transition: all 0.3s ease;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--primary-color);
|
||||
transform: translateX(3px);
|
||||
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
|
||||
|
||||
.permission-icon {
|
||||
color: var(--primary-color);
|
||||
transform: scale(1.08);
|
||||
}
|
||||
}
|
||||
|
||||
&.admin-permission {
|
||||
background: rgba(255, 152, 0, 0.05);
|
||||
|
||||
&:hover {
|
||||
border-color: #ff9800;
|
||||
|
||||
.permission-icon {
|
||||
color: #ff9800;
|
||||
}
|
||||
}
|
||||
|
||||
.permission-icon-wrapper.admin-icon {
|
||||
background: rgba(255, 152, 0, 0.1);
|
||||
|
||||
.permission-icon {
|
||||
color: #ff9800;
|
||||
}
|
||||
}
|
||||
|
||||
.admin-name {
|
||||
color: #ff9800;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.permission-label {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
cursor: pointer;
|
||||
min-width: 0;
|
||||
|
||||
.permission-icon-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
background: var(--overlay-background);
|
||||
border-radius: 8px;
|
||||
flex-shrink: 0;
|
||||
|
||||
.permission-icon {
|
||||
font-size: 1rem;
|
||||
color: var(--text-secondary-color);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
}
|
||||
|
||||
.permission-name {
|
||||
font-size: 0.9rem;
|
||||
color: var(--text-color);
|
||||
font-weight: 500;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
padding: 0.75rem;
|
||||
gap: 0.625rem;
|
||||
|
||||
.permission-label {
|
||||
gap: 0.625rem;
|
||||
|
||||
.permission-icon-wrapper {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
|
||||
.permission-icon {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
}
|
||||
|
||||
.permission-name {
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 1rem 1.5rem;
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-top: none;
|
||||
border-radius: 0 0 10px 10px;
|
||||
box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
|
||||
|
||||
.footer-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-secondary-color);
|
||||
|
||||
i {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
}
|
||||
|
||||
.footer-actions {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
flex-direction: column;
|
||||
padding: 1rem;
|
||||
gap: 0.75rem;
|
||||
|
||||
.footer-info {
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.footer-actions {
|
||||
width: 100%;
|
||||
justify-content: flex-end;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -92,4 +92,8 @@ export class CreateUserDialogComponent implements OnInit {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
closeDialog(): void {
|
||||
this.ref.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,9 +107,9 @@ export class UserManagementComponent implements OnInit, OnDestroy {
|
||||
openCreateUserDialog() {
|
||||
this.ref = this.dialogService.open(CreateUserDialogComponent, {
|
||||
header: 'Create New User',
|
||||
showHeader: false,
|
||||
modal: true,
|
||||
closable: true,
|
||||
style: {position: 'absolute', top: '15%'},
|
||||
});
|
||||
this.ref?.onClose.subscribe((result) => {
|
||||
if (result) {
|
||||
|
||||
+154
-89
@@ -1,105 +1,170 @@
|
||||
<p-divider></p-divider>
|
||||
<div class="user-profile-dialog min-w-[300px] md:min-w-[500px]">
|
||||
|
||||
<div class="min-w-[300px] md:min-w-[500px]">
|
||||
<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">User Profile</h2>
|
||||
<p class="panel-description">
|
||||
Manage your account information and security settings
|
||||
</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
[text]="true"
|
||||
[rounded]="true"
|
||||
severity="secondary"
|
||||
(onClick)="closeDialog()"
|
||||
styleClass="close-button">
|
||||
</p-button>
|
||||
</div>
|
||||
|
||||
<section>
|
||||
<div class="flex flex-col gap-4 py-4">
|
||||
<h2 class="text-xl font-semibold">User Profile</h2>
|
||||
<div class="px-4 py-2">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<label class="block text-sm font-medium mb-1">Username</label>
|
||||
@if (!isEditing) {
|
||||
<p class="text-lg">{{ currentUser?.username || 'N/A' }}</p>
|
||||
}
|
||||
@if (isEditing) {
|
||||
<input disabled id="username" type="text" pInputText [(ngModel)]="editUserData.username" class="w-full"/>
|
||||
}
|
||||
<div class="form-container">
|
||||
<div class="form-section">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-id-card"></i>
|
||||
Basic Information
|
||||
</h3>
|
||||
|
||||
<div class="form-field">
|
||||
<label class="field-label">Username</label>
|
||||
<input
|
||||
disabled
|
||||
id="username"
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="editUserData.username"
|
||||
class="field-input"
|
||||
placeholder="Username..."/>
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label class="field-label">Full Name</label>
|
||||
<input
|
||||
[disabled]="!isEditing"
|
||||
id="fullname"
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="editUserData.name"
|
||||
class="field-input"
|
||||
placeholder="Enter full name..."/>
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label class="field-label">Email</label>
|
||||
<input
|
||||
[disabled]="!isEditing"
|
||||
id="email"
|
||||
type="email"
|
||||
pInputText
|
||||
[(ngModel)]="editUserData.email"
|
||||
class="field-input"
|
||||
placeholder="Enter email..."/>
|
||||
</div>
|
||||
|
||||
<div class="edit-actions">
|
||||
@if (!isEditing) {
|
||||
<p-button label="Edit Profile" severity="info" icon="pi pi-pencil" [outlined]="true" (onClick)="toggleEdit()"></p-button>
|
||||
}
|
||||
@if (isEditing) {
|
||||
<div class="edit-buttons">
|
||||
<p-button label="Cancel" severity="secondary" [outlined]="true" icon="pi pi-times" (onClick)="toggleEdit()"></p-button>
|
||||
<p-button label="Save Changes" severity="success" [outlined]="true" icon="pi pi-check" (onClick)="updateProfile()"></p-button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium mb-1">Full Name</label>
|
||||
@if (!isEditing) {
|
||||
<p class="text-lg">{{ currentUser?.name || 'N/A' }}</p>
|
||||
}
|
||||
@if (isEditing) {
|
||||
<input id="fullname" type="text" pInputText [(ngModel)]="editUserData.name" class="w-full"/>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="md:col-span-2">
|
||||
<label class="block text-sm font-medium mb-1">Email</label>
|
||||
@if (!isEditing) {
|
||||
<p class="text-lg">{{ currentUser?.email || 'N/A' }}</p>
|
||||
}
|
||||
@if (isEditing) {
|
||||
<input id="email" type="email" pInputText [(ngModel)]="editUserData.email" class="w-full"/>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-start mt-6">
|
||||
@if (!isEditing) {
|
||||
<div>
|
||||
<p-button label="Edit" severity="info" icon="pi pi-pencil" (onClick)="toggleEdit()"></p-button>
|
||||
</div>
|
||||
}
|
||||
@if (isEditing) {
|
||||
<div class="flex gap-2">
|
||||
<p-button label="Cancel" severity="secondary" icon="pi pi-times" (onClick)="toggleEdit()"></p-button>
|
||||
<p-button label="Save" severity="success" icon="pi pi-check" (onClick)="updateProfile()"></p-button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p-divider></p-divider>
|
||||
<div class="form-section">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-shield"></i>
|
||||
Security Settings
|
||||
</h3>
|
||||
|
||||
<section class="space-y-6 pt-4">
|
||||
<div class="flex flex-col gap-4">
|
||||
<h2 class="text-xl font-semibold">Change Password</h2>
|
||||
<div class="change-password-wrapper">
|
||||
<div class="px-4 py-2">
|
||||
<form [formGroup]="changePasswordForm" (ngSubmit)="submitPasswordChange()">
|
||||
<div class="p-field mb-4">
|
||||
<label for="currentPassword">Current Password</label>
|
||||
<p-password id="currentPassword" formControlName="currentPassword" [feedback]="false" fluid></p-password>
|
||||
@if (changePasswordForm.get('currentPassword')?.invalid && changePasswordForm.get('currentPassword')?.touched) {
|
||||
<p-message severity="error" text="Current password is required."></p-message>
|
||||
<form [formGroup]="changePasswordForm" (ngSubmit)="submitPasswordChange()">
|
||||
<div class="form-field">
|
||||
<label class="field-label" for="currentPassword">Current Password</label>
|
||||
<p-password
|
||||
id="currentPassword"
|
||||
formControlName="currentPassword"
|
||||
[feedback]="false"
|
||||
class="field-input"
|
||||
[inputStyle]="{'width': '100%'}">
|
||||
</p-password>
|
||||
@if (changePasswordForm.get('currentPassword')?.invalid &&
|
||||
(changePasswordForm.get('currentPassword')?.dirty || changePasswordForm.get('currentPassword')?.touched)) {
|
||||
<small class="field-error">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
@if (changePasswordForm.get('currentPassword')?.errors?.['required']) {
|
||||
<span>Current password is required.</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="p-field mb-4">
|
||||
<label for="newPassword">New Password (at least 6 characters)</label>
|
||||
<p-password id="newPassword" formControlName="newPassword" [feedback]="false" fluid></p-password>
|
||||
@if (changePasswordForm.get('newPassword')?.errors?.['minlength'] && changePasswordForm.get('newPassword')?.touched) {
|
||||
<p-message severity="error" text="Password must be at least 6 characters long."></p-message>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="p-field mb-4">
|
||||
<label for="confirmNewPassword">Confirm New Password</label>
|
||||
<p-password id="confirmNewPassword" formControlName="confirmNewPassword" [feedback]="false" fluid></p-password>
|
||||
@if (passwordsMismatch) {
|
||||
<p-message severity="error" text="Passwords do not match."></p-message>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="flex justify-start pt-4">
|
||||
<p-button type="submit" severity="info" label="Change Password" icon="pi pi-key" [disabled]="changePasswordForm.invalid" class="p-fluid"></p-button>
|
||||
</div>
|
||||
</form>
|
||||
</small>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label class="field-label" for="newPassword">New Password</label>
|
||||
<p-password
|
||||
id="newPassword"
|
||||
formControlName="newPassword"
|
||||
[feedback]="false"
|
||||
class="field-input"
|
||||
[inputStyle]="{'width': '100%'}">
|
||||
</p-password>
|
||||
@if (changePasswordForm.get('newPassword')?.invalid &&
|
||||
(changePasswordForm.get('newPassword')?.dirty || changePasswordForm.get('newPassword')?.touched)) {
|
||||
<small class="field-error">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
@if (changePasswordForm.get('newPassword')?.errors?.['required']) {
|
||||
<span>New password is required.</span>
|
||||
}
|
||||
@if (changePasswordForm.get('newPassword')?.errors?.['minlength']) {
|
||||
<span>Password must be at least 6 characters long.</span>
|
||||
}
|
||||
</small>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label class="field-label" for="confirmNewPassword">Confirm New Password</label>
|
||||
<p-password
|
||||
id="confirmNewPassword"
|
||||
formControlName="confirmNewPassword"
|
||||
[feedback]="false"
|
||||
styleClass="field-input"
|
||||
[inputStyle]="{'width': '100%'}">
|
||||
</p-password>
|
||||
@if (changePasswordForm.get('confirmNewPassword')?.invalid &&
|
||||
(changePasswordForm.get('confirmNewPassword')?.dirty || changePasswordForm.get('confirmNewPassword')?.touched)) {
|
||||
<small class="field-error">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
@if (changePasswordForm.get('confirmNewPassword')?.errors?.['required']) {
|
||||
<span>Please confirm your new password.</span>
|
||||
}
|
||||
</small>
|
||||
}
|
||||
@if (changePasswordForm.errors?.['passwordMismatch'] &&
|
||||
changePasswordForm.get('confirmNewPassword')?.touched) {
|
||||
<small class="field-error">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
<span>Passwords do not match.</span>
|
||||
</small>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="password-actions">
|
||||
<p-button type="submit" severity="info" [outlined]="true" label="Change Password" icon="pi pi-key" [disabled]="changePasswordForm.invalid"></p-button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@if (!currentUser) {
|
||||
<div class="flex items-center justify-center min-h-[50vh] text-lg">
|
||||
Loading user data...
|
||||
<div class="loading-state">
|
||||
<i class="pi pi-spin pi-spinner loading-icon"></i>
|
||||
<p>Loading user data...</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
+250
@@ -0,0 +1,250 @@
|
||||
.user-profile-dialog {
|
||||
width: 500px;
|
||||
max-width: 650px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-top: 20px;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.panel-header {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
padding: 1.25rem 3.5rem 1.25rem 1.25rem;
|
||||
|
||||
border-radius: 10px 10px 0 0;
|
||||
border: 1px solid var(--border-color);
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
|
||||
|
||||
.header-icon-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
background: var(--primary-color);
|
||||
border-radius: 10px;
|
||||
|
||||
|
||||
.header-icon {
|
||||
font-size: 1.5rem;
|
||||
color: var(--primary-contrast-color);
|
||||
}
|
||||
}
|
||||
|
||||
.header-text {
|
||||
flex: 1;
|
||||
|
||||
.panel-title {
|
||||
margin: 0 0 0.25rem 0;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.panel-description {
|
||||
margin: 0;
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-secondary-color);
|
||||
}
|
||||
}
|
||||
|
||||
::ng-deep .close-button {
|
||||
position: absolute;
|
||||
top: 0.75rem;
|
||||
right: 0.75rem;
|
||||
|
||||
.p-button {
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
|
||||
&:hover {
|
||||
background: rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
padding: 1rem 3rem 1rem 1rem;
|
||||
|
||||
.header-icon-wrapper {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
|
||||
.header-icon {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.header-text {
|
||||
.panel-title {
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
|
||||
.panel-description {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.form-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3.5rem;
|
||||
padding: 2rem 1.5rem 1.5rem 1.5rem;
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-top: none;
|
||||
border-radius: 0 0 10px 10px;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
|
||||
max-height: 60vh;
|
||||
overflow-y: auto;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: var(--overlay-background);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: var(--border-color);
|
||||
border-radius: 3px;
|
||||
transition: background 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: var(--primary-color);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
padding: 1rem;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.form-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
|
||||
.section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin: 0 0 0.5rem 0;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-color);
|
||||
|
||||
i {
|
||||
color: var(--primary-color);
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
}
|
||||
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.form-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
.field-label {
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.field-input {
|
||||
width: 100%;
|
||||
|
||||
&:disabled {
|
||||
background-color: var(--surface-100);
|
||||
color: var(--text-color-secondary);
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
::ng-deep p-password {
|
||||
width: 100%;
|
||||
|
||||
.p-password {
|
||||
width: 100%;
|
||||
|
||||
.p-inputtext {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.field-value {
|
||||
font-size: 1rem;
|
||||
color: var(--text-color);
|
||||
padding: 0.75rem;
|
||||
background: var(--ground-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 6px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.field-error {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
color: #ef4444;
|
||||
font-size: 0.8125rem;
|
||||
margin-top: -0.25rem;
|
||||
|
||||
i {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.edit-actions {
|
||||
margin-top: 0.5rem;
|
||||
|
||||
.edit-buttons {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.password-actions {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.loading-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 300px;
|
||||
gap: 1rem;
|
||||
|
||||
.loading-icon {
|
||||
font-size: 2rem;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1rem;
|
||||
color: var(--text-secondary-color);
|
||||
}
|
||||
}
|
||||
|
||||
+21
-23
@@ -1,26 +1,33 @@
|
||||
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, Validators} from '@angular/forms';
|
||||
import {AbstractControl, FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, ValidationErrors, ValidatorFn, Validators} from '@angular/forms';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
|
||||
import {Password} from 'primeng/password';
|
||||
import {User, UserService} from '../user-management/user.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Subject} from 'rxjs';
|
||||
import {Message} from 'primeng/message';
|
||||
import {filter, takeUntil} from 'rxjs/operators';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
|
||||
export const passwordMatchValidator: ValidatorFn = (control: AbstractControl): ValidationErrors | null => {
|
||||
const newPassword = control.get('newPassword');
|
||||
const confirmNewPassword = control.get('confirmNewPassword');
|
||||
|
||||
if (!newPassword || !confirmNewPassword) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return newPassword.value === confirmNewPassword.value ? null : {passwordMismatch: true};
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: 'app-user-profile-dialog',
|
||||
imports: [
|
||||
Button,
|
||||
Divider,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
InputText,
|
||||
Password,
|
||||
Message
|
||||
Password
|
||||
],
|
||||
templateUrl: './user-profile-dialog.component.html',
|
||||
styleUrls: ['./user-profile-dialog.component.scss']
|
||||
@@ -37,17 +44,16 @@ export class UserProfileDialogComponent implements OnInit, OnDestroy {
|
||||
protected readonly userService = inject(UserService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly fb = inject(FormBuilder);
|
||||
private readonly dialogRef = inject(DynamicDialogRef);
|
||||
|
||||
constructor() {
|
||||
this.changePasswordForm = this.fb.group(
|
||||
{
|
||||
currentPassword: ['', Validators.required],
|
||||
newPassword: ['', [Validators.required, Validators.minLength(6)]],
|
||||
confirmNewPassword: ['', [Validators.required, Validators.minLength(6)]]
|
||||
confirmNewPassword: ['', Validators.required]
|
||||
},
|
||||
{
|
||||
validators: [UserProfileDialogComponent.passwordsMatchValidator]
|
||||
}
|
||||
{validators: passwordMatchValidator}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -66,17 +72,6 @@ export class UserProfileDialogComponent implements OnInit, OnDestroy {
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
static passwordsMatchValidator(form: FormGroup) {
|
||||
const newPassword = form.get('newPassword')?.value;
|
||||
const confirmPassword = form.get('confirmNewPassword')?.value;
|
||||
return newPassword === confirmPassword ? null : {mismatch: true};
|
||||
}
|
||||
|
||||
get passwordsMismatch() {
|
||||
return this.changePasswordForm.hasError('mismatch') &&
|
||||
this.changePasswordForm.get('confirmNewPassword')?.touched;
|
||||
}
|
||||
|
||||
toggleEdit(): void {
|
||||
this.isEditing = !this.isEditing;
|
||||
if (this.isEditing) {
|
||||
@@ -114,7 +109,6 @@ export class UserProfileDialogComponent implements OnInit, OnDestroy {
|
||||
next: () => {
|
||||
this.messageService.add({severity: 'success', summary: 'Success', detail: 'Profile updated successfully'});
|
||||
this.isEditing = false;
|
||||
this.resetEditForm();
|
||||
},
|
||||
error: (err) => {
|
||||
this.messageService.add({
|
||||
@@ -152,4 +146,8 @@ export class UserProfileDialogComponent implements OnInit, OnDestroy {
|
||||
resetPasswordForm(): void {
|
||||
this.changePasswordForm.reset();
|
||||
}
|
||||
|
||||
closeDialog(): void {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user