refactor(frontend): rename booklore-ui to frontend
- Frontend path: - rename the tracked Angular app tree from `booklore-ui/` to `frontend/` - preserve file contents during the move so this commit stays focused on the path change itself - Frontend docs: - update the moved frontend README and contribution guide where they refer to the renamed folder - keep those edits limited to path references introduced by the directory rename
This commit is contained in:
@@ -0,0 +1,378 @@
|
||||
<ng-container *transloco="let t; prefix: 'settingsOpds'">
|
||||
<div class="main-container">
|
||||
<div class="settings-header">
|
||||
<h2 class="settings-title">
|
||||
<i class="pi pi-server"></i>
|
||||
{{ t('title') }}
|
||||
<app-external-doc-link docType="opds"></app-external-doc-link>
|
||||
</h2>
|
||||
<p class="settings-description">
|
||||
{{ t('description') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@if (hasPermission) {
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-sliders-h"></i>
|
||||
{{ t('server.sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
{{ t('server.sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
<div class="toggle-list">
|
||||
<div class="toggle-item" [class.is-active]="opdsEnabled">
|
||||
<div class="toggle-content">
|
||||
<div class="toggle-header">
|
||||
<div class="toggle-icon">
|
||||
<i class="pi pi-globe"></i>
|
||||
</div>
|
||||
<div class="toggle-info">
|
||||
<span class="toggle-label">{{ t('server.opdsLabel') }}</span>
|
||||
<span class="toggle-status" [class.active]="opdsEnabled">
|
||||
{{ opdsEnabled ? t('server.enabled') : t('server.disabled') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="toggle-description">
|
||||
{{ t('server.opdsDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="opdsEnabled"
|
||||
(onChange)="toggleOpdsServer()">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
|
||||
<div class="toggle-item" [class.is-active]="komgaApiEnabled">
|
||||
<div class="toggle-content">
|
||||
<div class="toggle-header">
|
||||
<div class="toggle-icon">
|
||||
<i class="pi pi-box"></i>
|
||||
</div>
|
||||
<div class="toggle-info">
|
||||
<span class="toggle-label">{{ t('server.komgaLabel') }}</span>
|
||||
<span class="toggle-status" [class.active]="komgaApiEnabled">
|
||||
{{ komgaApiEnabled ? t('server.enabled') : t('server.disabled') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="toggle-description">
|
||||
{{ t('server.komgaDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="komgaApiEnabled"
|
||||
(onChange)="toggleKomgaApi()">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
|
||||
@if (komgaApiEnabled) {
|
||||
<div class="toggle-item sub-item" [class.is-active]="komgaGroupUnknown">
|
||||
<div class="toggle-content">
|
||||
<div class="toggle-header">
|
||||
<div class="toggle-icon sub-icon">
|
||||
<i class="pi pi-folder"></i>
|
||||
</div>
|
||||
<div class="toggle-info">
|
||||
<span class="toggle-label">{{ t('server.groupUnknownLabel') }}</span>
|
||||
<span class="toggle-status" [class.active]="komgaGroupUnknown">
|
||||
{{ komgaGroupUnknown ? t('server.grouped') : t('server.individual') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="toggle-description">
|
||||
{{ t('server.groupUnknownDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="komgaGroupUnknown"
|
||||
(onChange)="toggleKomgaGroupUnknown()">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (opdsEnabled || komgaApiEnabled) {
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-link"></i>
|
||||
{{ t('endpoints.sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
{{ t('endpoints.sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
<div class="endpoints-list">
|
||||
@if (opdsEnabled) {
|
||||
<div class="endpoint-item">
|
||||
<div class="endpoint-header">
|
||||
<div class="endpoint-icon">
|
||||
<i class="pi pi-globe"></i>
|
||||
</div>
|
||||
<div class="endpoint-info">
|
||||
<span class="endpoint-label">{{ t('endpoints.opdsCatalog') }}</span>
|
||||
<span class="endpoint-hint">{{ t('endpoints.opdsHint') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="endpoint-url-row">
|
||||
<input
|
||||
id="endpoint-url"
|
||||
class="endpoint-input"
|
||||
type="text"
|
||||
pInputText
|
||||
[value]="opdsEndpoint"
|
||||
readonly/>
|
||||
<p-button
|
||||
icon="pi pi-copy"
|
||||
severity="info"
|
||||
[outlined]="true"
|
||||
size="small"
|
||||
(onClick)="copyEndpoint()"
|
||||
[pTooltip]="t('endpoints.copyUrl')">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (komgaApiEnabled) {
|
||||
<div class="endpoint-item">
|
||||
<div class="endpoint-header">
|
||||
<div class="endpoint-icon">
|
||||
<i class="pi pi-box"></i>
|
||||
</div>
|
||||
<div class="endpoint-info">
|
||||
<span class="endpoint-label">{{ t('endpoints.komgaBase') }}</span>
|
||||
<span class="endpoint-hint">{{ t('endpoints.komgaHint') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="endpoint-url-row">
|
||||
<input
|
||||
id="komga-endpoint-url"
|
||||
class="endpoint-input"
|
||||
type="text"
|
||||
pInputText
|
||||
[value]="komgaEndpoint"
|
||||
readonly/>
|
||||
<p-button
|
||||
icon="pi pi-copy"
|
||||
severity="info"
|
||||
[outlined]="true"
|
||||
size="small"
|
||||
(onClick)="copyKomgaEndpoint()"
|
||||
[pTooltip]="t('endpoints.copyUrl')">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (opdsEnabled) {
|
||||
<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('users.sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
{{ t('users.sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-plus"
|
||||
[label]="t('users.addUser')"
|
||||
severity="success"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
(onClick)="showCreateUserDialog = true">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
@if (users.length === 0) {
|
||||
<div class="empty-state">
|
||||
<i class="pi pi-users"></i>
|
||||
<p class="empty-title">{{ t('users.emptyTitle') }}</p>
|
||||
<p class="empty-subtitle">{{ t('users.emptySubtitle') }}</p>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="users-list">
|
||||
@for (user of users; track user.id) {
|
||||
<div class="user-item">
|
||||
<div class="user-info">
|
||||
<div class="user-avatar">
|
||||
{{ user.username.charAt(0).toUpperCase() }}
|
||||
</div>
|
||||
<div class="user-details">
|
||||
<span class="username">{{ user.username }}</span>
|
||||
<div class="user-meta">
|
||||
<i class="pi pi-sort-alt"></i>
|
||||
@if (editingUserId === user.id) {
|
||||
<p-select
|
||||
[options]="sortOrderOptions"
|
||||
[(ngModel)]="editingSortOrder"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
[style]="{width: '160px'}"
|
||||
size="small"
|
||||
[appendTo]="'body'">
|
||||
<ng-template pTemplate="selectedItem" let-selected>
|
||||
{{ selected.translationKey | transloco }}
|
||||
</ng-template>
|
||||
<ng-template pTemplate="item" let-option>
|
||||
{{ option.translationKey | transloco }}
|
||||
</ng-template>
|
||||
</p-select>
|
||||
} @else {
|
||||
<span class="sort-order-badge">{{ getSortOrderLabel(user.sortOrder) }}</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="user-actions">
|
||||
@if (editingUserId === user.id) {
|
||||
<p-button
|
||||
icon="pi pi-check"
|
||||
severity="success"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="saveSortOrder(user)"
|
||||
[pTooltip]="'common.save' | transloco">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
severity="secondary"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="cancelEdit()"
|
||||
[pTooltip]="'common.cancel' | transloco">
|
||||
</p-button>
|
||||
} @else {
|
||||
<p-button
|
||||
icon="pi pi-pencil"
|
||||
severity="info"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="startEdit(user)"
|
||||
[pTooltip]="t('users.editSortOrder')">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-trash"
|
||||
severity="danger"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="confirmDelete(user)"
|
||||
[pTooltip]="t('users.deleteUser')">
|
||||
</p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<p-dialog
|
||||
[header]="t('createDialog.title')"
|
||||
[(visible)]="showCreateUserDialog"
|
||||
[modal]="true"
|
||||
class="user-dialog"
|
||||
[style]="{width: '400px'}">
|
||||
<div class="dialog-form">
|
||||
<div class="form-field">
|
||||
<label for="username">{{ t('createDialog.username') }}</label>
|
||||
<input
|
||||
id="username"
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="newUser.username"
|
||||
[placeholder]="t('createDialog.enterUsername')"/>
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label for="password">{{ t('createDialog.password') }}</label>
|
||||
<input
|
||||
id="password"
|
||||
type="password"
|
||||
pInputText
|
||||
[(ngModel)]="newUser.password"
|
||||
[placeholder]="t('createDialog.enterPassword')"/>
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label for="sortOrder">{{ t('createDialog.sortOrder') }}</label>
|
||||
<p-select
|
||||
id="sortOrder"
|
||||
[options]="sortOrderOptions"
|
||||
[(ngModel)]="newUser.sortOrder"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
[style]="{width: '100%'}"
|
||||
[placeholder]="t('createDialog.selectSortOrder')"
|
||||
[appendTo]="'body'">
|
||||
<ng-template pTemplate="selectedItem" let-selected>
|
||||
{{ selected.translationKey | transloco }}
|
||||
</ng-template>
|
||||
<ng-template pTemplate="item" let-option>
|
||||
{{ option.translationKey | transloco }}
|
||||
</ng-template>
|
||||
</p-select>
|
||||
<small class="form-hint">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
{{ t('createDialog.sortHint') }}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<ng-template pTemplate="footer">
|
||||
<div class="dialog-actions">
|
||||
<p-button
|
||||
[label]="'common.cancel' | transloco"
|
||||
severity="secondary"
|
||||
outlined="true"
|
||||
(onClick)="cancelCreateUser()">
|
||||
</p-button>
|
||||
<p-button
|
||||
[label]="t('createDialog.create')"
|
||||
severity="success"
|
||||
[disabled]="!newUser.username || !newUser.password"
|
||||
(onClick)="createUser()">
|
||||
</p-button>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-dialog>
|
||||
|
||||
<p-confirmDialog></p-confirmDialog>
|
||||
} @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>
|
||||
@@ -0,0 +1,485 @@
|
||||
@use '../../../shared/styles/settings-shared' as settings;
|
||||
|
||||
.main-container {
|
||||
@include settings.settings-page-container;
|
||||
}
|
||||
|
||||
@include settings.settings-page-header;
|
||||
|
||||
.settings-title {
|
||||
@include settings.settings-page-title;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.settings-description {
|
||||
@include settings.settings-page-description;
|
||||
}
|
||||
|
||||
.settings-card {
|
||||
@include settings.settings-card;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
@include settings.settings-section-header;
|
||||
}
|
||||
|
||||
.section-header-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
|
||||
@media (max-width: 767px) {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
p-button {
|
||||
align-self: flex-end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.section-header-text {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
@include settings.settings-section-title;
|
||||
}
|
||||
|
||||
.section-description {
|
||||
@include settings.settings-section-description;
|
||||
}
|
||||
|
||||
.section-body {
|
||||
@include settings.settings-section-body;
|
||||
}
|
||||
|
||||
// Toggle list (Server Settings)
|
||||
.toggle-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.toggle-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-left: 3px solid var(--p-content-border-color);
|
||||
border-radius: 6px;
|
||||
padding: 1rem;
|
||||
transition: border-color 0.2s ease, background 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: color-mix(in srgb, var(--ground-background) 40%, var(--p-surface-800) 60%);
|
||||
}
|
||||
|
||||
&.is-active {
|
||||
border-left-color: var(--p-green-500);
|
||||
}
|
||||
|
||||
&.sub-item {
|
||||
margin-left: 1.5rem;
|
||||
border-left-color: var(--p-orange-500);
|
||||
|
||||
&.is-active {
|
||||
border-left-color: var(--p-green-500);
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.toggle-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.toggle-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.toggle-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
background: color-mix(in srgb, var(--p-primary-color) 15%, transparent);
|
||||
color: var(--p-primary-color);
|
||||
border-radius: 8px;
|
||||
flex-shrink: 0;
|
||||
|
||||
.pi {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
&.sub-icon {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
background: color-mix(in srgb, var(--p-orange-500) 15%, transparent);
|
||||
color: var(--p-orange-500);
|
||||
border-radius: 6px;
|
||||
|
||||
.pi {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.toggle-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.125rem;
|
||||
}
|
||||
|
||||
.toggle-label {
|
||||
font-weight: 600;
|
||||
font-size: 0.9375rem;
|
||||
color: var(--p-text-color);
|
||||
}
|
||||
|
||||
.toggle-status {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: var(--p-text-muted-color);
|
||||
|
||||
&.active {
|
||||
color: var(--p-green-400);
|
||||
}
|
||||
}
|
||||
|
||||
.toggle-description {
|
||||
font-size: settings.$settings-description-size;
|
||||
color: var(--p-text-muted-color);
|
||||
line-height: 1.5;
|
||||
margin: 0;
|
||||
padding-left: calc(36px + 0.75rem);
|
||||
|
||||
@media (max-width: 600px) {
|
||||
padding-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Endpoints list
|
||||
.endpoints-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.endpoint-item {
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-left: 3px solid var(--p-primary-color);
|
||||
border-radius: 6px;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.endpoint-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.endpoint-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background: color-mix(in srgb, var(--p-primary-color) 15%, transparent);
|
||||
color: var(--p-primary-color);
|
||||
border-radius: 6px;
|
||||
flex-shrink: 0;
|
||||
|
||||
.pi {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
|
||||
.endpoint-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.125rem;
|
||||
}
|
||||
|
||||
.endpoint-label {
|
||||
font-weight: 600;
|
||||
font-size: 0.875rem;
|
||||
color: var(--p-text-color);
|
||||
}
|
||||
|
||||
.endpoint-hint {
|
||||
font-size: settings.$settings-description-size;
|
||||
color: var(--p-text-muted-color);
|
||||
}
|
||||
|
||||
.endpoint-url-row {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
|
||||
@media (max-width: 600px) {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
p-button {
|
||||
align-self: flex-end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.endpoint-input {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
font-family: monospace;
|
||||
font-size: settings.$settings-description-size;
|
||||
}
|
||||
|
||||
// Empty state
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 3rem 2rem;
|
||||
text-align: center;
|
||||
color: var(--p-text-muted-color);
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
border-radius: 6px;
|
||||
|
||||
.pi {
|
||||
font-size: 2.5rem;
|
||||
margin-bottom: 1rem;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.empty-title {
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
margin: 0 0 0.5rem 0;
|
||||
color: var(--p-text-color);
|
||||
}
|
||||
|
||||
.empty-subtitle {
|
||||
font-size: settings.$settings-section-description-size;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Users list
|
||||
.users-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.user-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-left: 3px solid var(--p-primary-color);
|
||||
border-radius: 6px;
|
||||
padding: 0.875rem 1rem;
|
||||
transition: background 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: color-mix(in srgb, var(--ground-background) 40%, var(--p-surface-800) 60%);
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.user-avatar {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
background: var(--p-primary-color);
|
||||
color: var(--p-primary-contrast-color);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: 600;
|
||||
font-size: 1rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.user-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.username {
|
||||
font-weight: 600;
|
||||
font-size: 0.9375rem;
|
||||
color: var(--p-text-color);
|
||||
}
|
||||
|
||||
.user-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: settings.$settings-description-size;
|
||||
color: var(--p-text-muted-color);
|
||||
|
||||
.pi {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
|
||||
.sort-order-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 0.125rem 0.5rem;
|
||||
background: color-mix(in srgb, var(--p-primary-color) 15%, transparent);
|
||||
color: var(--p-primary-color);
|
||||
border-radius: 12px;
|
||||
font-size: 0.6875rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.user-actions {
|
||||
display: flex;
|
||||
gap: 0.375rem;
|
||||
flex-shrink: 0;
|
||||
|
||||
@media (max-width: 600px) {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
// Dialog styles
|
||||
.user-dialog {
|
||||
.p-dialog-content {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.p-dialog-footer {
|
||||
padding: 1rem 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.form-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
label {
|
||||
font-weight: 600;
|
||||
color: var(--p-text-color);
|
||||
font-size: settings.$settings-section-description-size;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 0.75rem;
|
||||
transition: border-color 0.2s;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--p-primary-color);
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--p-primary-color) 20%, transparent);
|
||||
}
|
||||
|
||||
&::placeholder {
|
||||
color: var(--p-text-muted-color);
|
||||
}
|
||||
}
|
||||
|
||||
.form-hint {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.375rem;
|
||||
color: var(--p-text-muted-color);
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.4;
|
||||
margin-top: 0.25rem;
|
||||
|
||||
.pi {
|
||||
font-size: 0.625rem;
|
||||
margin-top: 0.125rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
// Access denied card
|
||||
.access-denied-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
padding: 1.5rem;
|
||||
border-radius: settings.$settings-card-border-radius;
|
||||
background: color-mix(in srgb, var(--ground-background) 85%, var(--p-red-600) 15%);
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-left: 3px solid var(--p-red-500);
|
||||
max-width: 500px;
|
||||
|
||||
> .pi {
|
||||
font-size: 1.5rem;
|
||||
flex-shrink: 0;
|
||||
color: var(--p-red-400);
|
||||
}
|
||||
|
||||
.access-denied-content {
|
||||
h3 {
|
||||
margin: 0 0 0.5rem 0;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
color: var(--p-red-300);
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-size: settings.$settings-section-description-size;
|
||||
line-height: 1.5;
|
||||
color: var(--p-text-muted-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
import {Component, effect, inject, OnDestroy, OnInit} from '@angular/core';
|
||||
|
||||
import {Button} from 'primeng/button';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {API_CONFIG} from '../../../core/config/api-config';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {TableModule} from 'primeng/table';
|
||||
import {Dialog} from 'primeng/dialog';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {ConfirmDialog} from 'primeng/confirmdialog';
|
||||
import {ConfirmationService, MessageService} from 'primeng/api';
|
||||
import {OpdsService, OpdsSortOrder, OpdsUserV2, OpdsUserV2CreateRequest} from './opds.service';
|
||||
import {catchError, takeUntil} from 'rxjs/operators';
|
||||
import {UserService} from '../user-management/user.service';
|
||||
import {of, Subject} from 'rxjs';
|
||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||
import {AppSettingsService} from '../../../shared/service/app-settings.service';
|
||||
import {AppSettingKey} from '../../../shared/model/app-settings.model';
|
||||
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
|
||||
import {Select} from 'primeng/select';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-opds-settings',
|
||||
imports: [
|
||||
Button,
|
||||
InputText,
|
||||
Tooltip,
|
||||
Dialog,
|
||||
FormsModule,
|
||||
ConfirmDialog,
|
||||
TableModule,
|
||||
ToggleSwitch,
|
||||
ExternalDocLinkComponent,
|
||||
Select,
|
||||
TranslocoDirective,
|
||||
TranslocoPipe
|
||||
],
|
||||
providers: [ConfirmationService],
|
||||
templateUrl: './opds-settings.html',
|
||||
styleUrl: './opds-settings.scss'
|
||||
})
|
||||
export class OpdsSettings implements OnInit, OnDestroy {
|
||||
|
||||
opdsEndpoint = `${API_CONFIG.BASE_URL}/api/v1/opds`;
|
||||
komgaEndpoint = `${API_CONFIG.BASE_URL}/komga`;
|
||||
opdsEnabled = false;
|
||||
komgaApiEnabled = false;
|
||||
komgaGroupUnknown = true;
|
||||
|
||||
private opdsService = inject(OpdsService);
|
||||
private confirmationService = inject(ConfirmationService);
|
||||
private messageService = inject(MessageService);
|
||||
private userService = inject(UserService);
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private t = inject(TranslocoService);
|
||||
|
||||
users: OpdsUserV2[] = [];
|
||||
loading = false;
|
||||
showCreateUserDialog = false;
|
||||
newUser: OpdsUserV2CreateRequest = {username: '', password: '', sortOrder: 'RECENT'};
|
||||
passwordVisibility: boolean[] = [];
|
||||
hasPermission = false;
|
||||
|
||||
editingUserId: number | null = null;
|
||||
editingSortOrder: OpdsSortOrder | null = null;
|
||||
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
dummyPassword: string = "***********************";
|
||||
|
||||
sortOrderOptions = [
|
||||
{label: 'Recently Added', value: 'RECENT' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.recent'},
|
||||
{label: 'Title (A-Z)', value: 'TITLE_ASC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.titleAsc'},
|
||||
{label: 'Title (Z-A)', value: 'TITLE_DESC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.titleDesc'},
|
||||
{label: 'Author (A-Z)', value: 'AUTHOR_ASC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.authorAsc'},
|
||||
{label: 'Author (Z-A)', value: 'AUTHOR_DESC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.authorDesc'},
|
||||
{label: 'Series (A-Z)', value: 'SERIES_ASC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.seriesAsc'},
|
||||
{label: 'Series (Z-A)', value: 'SERIES_DESC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.seriesDesc'},
|
||||
{label: 'Rating (Low to High)', value: 'RATING_ASC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.ratingAsc'},
|
||||
{label: 'Rating (High to Low)', value: 'RATING_DESC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.ratingDesc'}
|
||||
];
|
||||
|
||||
private prevHasPermission = false;
|
||||
|
||||
private readonly syncPermissionEffect = effect(() => {
|
||||
const user = this.userService.currentUser();
|
||||
if (!user) return;
|
||||
|
||||
this.hasPermission = !!(user.permissions.canAccessOpds || user.permissions.admin);
|
||||
if (this.hasPermission && !this.prevHasPermission) {
|
||||
this.loadAppSettings();
|
||||
}
|
||||
this.prevHasPermission = this.hasPermission;
|
||||
});
|
||||
|
||||
ngOnInit(): void {
|
||||
this.loading = true;
|
||||
}
|
||||
|
||||
private loadAppSettings(): void {
|
||||
const settings = this.appSettingsService.appSettings();
|
||||
if (settings) {
|
||||
this.opdsEnabled = settings.opdsServerEnabled ?? false;
|
||||
this.komgaApiEnabled = settings.komgaApiEnabled ?? false;
|
||||
this.komgaGroupUnknown = settings.komgaGroupUnknown ?? true;
|
||||
if (this.opdsEnabled || this.komgaApiEnabled) {
|
||||
this.loadUsers();
|
||||
} else {
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private loadUsers(): void {
|
||||
this.opdsService.getUser().pipe(
|
||||
takeUntil(this.destroy$),
|
||||
catchError(err => {
|
||||
console.error('Error loading users:', err);
|
||||
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.loadError'));
|
||||
return of([]);
|
||||
})
|
||||
).subscribe(users => {
|
||||
this.users = users;
|
||||
this.passwordVisibility = new Array(users.length).fill(false);
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
createUser(): void {
|
||||
if (!this.newUser.username || !this.newUser.password) return;
|
||||
|
||||
this.opdsService.createUser(this.newUser).pipe(
|
||||
takeUntil(this.destroy$)
|
||||
).subscribe({
|
||||
next: user => {
|
||||
this.users.push(user);
|
||||
this.resetCreateUserDialog();
|
||||
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsOpds.createSuccess'));
|
||||
},
|
||||
error: err => {
|
||||
console.error('Error creating user:', err);
|
||||
const message = err?.error?.message || this.t.translate('settingsOpds.createError');
|
||||
this.showMessage('error', this.t.translate('common.error'), message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
confirmDelete(user: OpdsUserV2): void {
|
||||
this.confirmationService.confirm({
|
||||
message: this.t.translate('settingsOpds.deleteConfirm', {username: user.username}),
|
||||
header: this.t.translate('settingsOpds.deleteHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptButtonStyleClass: 'p-button-danger',
|
||||
accept: () => this.deleteUser(user)
|
||||
});
|
||||
}
|
||||
|
||||
deleteUser(user: OpdsUserV2): void {
|
||||
if (!user.id) return;
|
||||
|
||||
this.opdsService.deleteCredential(user.id).pipe(
|
||||
takeUntil(this.destroy$),
|
||||
catchError(err => {
|
||||
console.error('Error deleting user:', err);
|
||||
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.deleteError'));
|
||||
return of(null);
|
||||
})
|
||||
).subscribe(() => {
|
||||
this.users = this.users.filter(u => u.id !== user.id);
|
||||
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsOpds.deleteSuccess'));
|
||||
});
|
||||
}
|
||||
|
||||
cancelCreateUser(): void {
|
||||
this.resetCreateUserDialog();
|
||||
}
|
||||
|
||||
copyEndpoint(): void {
|
||||
navigator.clipboard.writeText(this.opdsEndpoint).then(() => {
|
||||
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsOpds.opdsCopied'));
|
||||
});
|
||||
}
|
||||
|
||||
toggleOpdsServer(): void {
|
||||
this.saveSetting(AppSettingKey.OPDS_SERVER_ENABLED, this.opdsEnabled);
|
||||
if (this.opdsEnabled || this.komgaApiEnabled) {
|
||||
this.loadUsers();
|
||||
} else {
|
||||
this.users = [];
|
||||
}
|
||||
}
|
||||
|
||||
toggleKomgaApi(): void {
|
||||
this.saveKomgaSetting(AppSettingKey.KOMGA_API_ENABLED, this.komgaApiEnabled);
|
||||
if (this.opdsEnabled || this.komgaApiEnabled) {
|
||||
this.loadUsers();
|
||||
} else {
|
||||
this.users = [];
|
||||
}
|
||||
}
|
||||
|
||||
copyKomgaEndpoint(): void {
|
||||
navigator.clipboard.writeText(this.komgaEndpoint).then(() => {
|
||||
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsOpds.komgaCopied'));
|
||||
});
|
||||
}
|
||||
|
||||
toggleKomgaGroupUnknown(): void {
|
||||
this.appSettingsService.saveSettings([{key: AppSettingKey.KOMGA_GROUP_UNKNOWN, newValue: this.komgaGroupUnknown}]).subscribe({
|
||||
next: () => {
|
||||
const successMessage = (this.komgaGroupUnknown === true)
|
||||
? this.t.translate('settingsOpds.groupEnabled')
|
||||
: this.t.translate('settingsOpds.groupDisabled');
|
||||
this.showMessage('success', this.t.translate('settingsOpds.settingsSaved'), successMessage);
|
||||
},
|
||||
error: () => {
|
||||
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.settingsError'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private saveSetting(key: string, value: unknown): void {
|
||||
this.appSettingsService.saveSettings([{key, newValue: value}]).subscribe({
|
||||
next: () => {
|
||||
const successMessage = (value === true)
|
||||
? this.t.translate('settingsOpds.opdsEnabled')
|
||||
: this.t.translate('settingsOpds.opdsDisabled');
|
||||
this.showMessage('success', this.t.translate('settingsOpds.settingsSaved'), successMessage);
|
||||
},
|
||||
error: () => {
|
||||
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.settingsError'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private saveKomgaSetting(key: string, value: unknown): void {
|
||||
this.appSettingsService.saveSettings([{key, newValue: value}]).subscribe({
|
||||
next: () => {
|
||||
const successMessage = (value === true)
|
||||
? this.t.translate('settingsOpds.komgaEnabled')
|
||||
: this.t.translate('settingsOpds.komgaDisabled');
|
||||
this.showMessage('success', this.t.translate('settingsOpds.settingsSaved'), successMessage);
|
||||
},
|
||||
error: () => {
|
||||
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.settingsError'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private resetCreateUserDialog(): void {
|
||||
this.showCreateUserDialog = false;
|
||||
this.newUser = {username: '', password: '', sortOrder: 'RECENT'};
|
||||
}
|
||||
|
||||
private showMessage(severity: string, summary: string, detail: string): void {
|
||||
this.messageService.add({severity, summary, detail});
|
||||
}
|
||||
|
||||
getSortOrderLabel(sortOrder?: OpdsSortOrder): string {
|
||||
if (!sortOrder) return this.t.translate('settingsOpds.sortOrders.recent');
|
||||
const option = this.sortOrderOptions.find(o => o.value === sortOrder);
|
||||
return option ? this.t.translate(option.translationKey) : this.t.translate('settingsOpds.sortOrders.recent');
|
||||
}
|
||||
|
||||
startEdit(user: OpdsUserV2): void {
|
||||
this.editingUserId = user.id;
|
||||
this.editingSortOrder = user.sortOrder || 'RECENT';
|
||||
}
|
||||
|
||||
cancelEdit(): void {
|
||||
this.editingUserId = null;
|
||||
this.editingSortOrder = null;
|
||||
}
|
||||
|
||||
saveSortOrder(user: OpdsUserV2): void {
|
||||
if (!this.editingSortOrder || !user.id) return;
|
||||
|
||||
this.opdsService.updateUser(user.id, this.editingSortOrder).pipe(
|
||||
takeUntil(this.destroy$),
|
||||
catchError(err => {
|
||||
console.error('Error updating sort order:', err);
|
||||
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.sortUpdateError'));
|
||||
return of(null);
|
||||
})
|
||||
).subscribe(updatedUser => {
|
||||
if (updatedUser) {
|
||||
const index = this.users.findIndex(u => u.id === user.id);
|
||||
if (index !== -1) {
|
||||
this.users[index] = updatedUser;
|
||||
}
|
||||
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsOpds.sortUpdateSuccess'));
|
||||
}
|
||||
this.cancelEdit();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Observable} from 'rxjs';
|
||||
import {API_CONFIG} from '../../../core/config/api-config';
|
||||
|
||||
export type OpdsSortOrder = 'RECENT' | 'TITLE_ASC' | 'TITLE_DESC' | 'AUTHOR_ASC' | 'AUTHOR_DESC' | 'SERIES_ASC' | 'SERIES_DESC' | 'RATING_ASC' | 'RATING_DESC';
|
||||
|
||||
export interface OpdsUserV2CreateRequest {
|
||||
username: string;
|
||||
password: string;
|
||||
sortOrder?: OpdsSortOrder;
|
||||
}
|
||||
|
||||
export interface OpdsUserV2 {
|
||||
id: number;
|
||||
userId: number;
|
||||
username: string;
|
||||
sortOrder?: OpdsSortOrder;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class OpdsService {
|
||||
|
||||
private readonly baseUrl = `${API_CONFIG.BASE_URL}/api/v2/opds-users`;
|
||||
private http = inject(HttpClient);
|
||||
|
||||
getUser(): Observable<OpdsUserV2[]> {
|
||||
return this.http.get<OpdsUserV2[]>(this.baseUrl);
|
||||
}
|
||||
|
||||
createUser(user: OpdsUserV2CreateRequest): Observable<OpdsUserV2> {
|
||||
return this.http.post<OpdsUserV2>(this.baseUrl, user);
|
||||
}
|
||||
|
||||
updateUser(id: number, sortOrder: OpdsSortOrder): Observable<OpdsUserV2> {
|
||||
return this.http.patch<OpdsUserV2>(`${this.baseUrl}/${id}`, {sortOrder});
|
||||
}
|
||||
|
||||
deleteCredential(id: number): Observable<void> {
|
||||
return this.http.delete<void>(`${this.baseUrl}/${id}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user