Drop legacy OPDS and keep only the new implementation (#1236)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<div class="settings-header">
|
||||
<h2 class="settings-title">
|
||||
<i class="pi pi-server"></i>
|
||||
OPDS Settings v2
|
||||
OPDS Settings (New)
|
||||
</h2>
|
||||
<p class="settings-description">
|
||||
Manage your OPDS credentials and control how your book collection is shared with reading apps.
|
||||
@@ -44,7 +44,7 @@
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-link"></i>
|
||||
OPDS Endpoint
|
||||
OPDS Endpoints
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
@@ -52,28 +52,59 @@
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Endpoint URL</label>
|
||||
<label class="setting-label">OPDS v1 Catalog</label>
|
||||
<div class="input-group">
|
||||
<input
|
||||
id="endpoint-url"
|
||||
id="endpoint-url-v1"
|
||||
class="endpoint-input"
|
||||
fluid
|
||||
type="text"
|
||||
pInputText
|
||||
[value]="opdsEndpoint"
|
||||
[value]="opdsV1Endpoint"
|
||||
readonly/>
|
||||
<p-button
|
||||
icon="pi pi-copy"
|
||||
severity="info"
|
||||
outlined
|
||||
size="small"
|
||||
(onClick)="copyEndpoint()">
|
||||
(onClick)="copyV1Endpoint()">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
Use this URL to connect your reading apps to your OPDS catalog.
|
||||
OPDS v1 specification - Compatible with most reading apps and OPDS clients.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="endpoint-divider"></div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">OPDS v2 Catalog</label>
|
||||
<div class="input-group">
|
||||
<input
|
||||
id="endpoint-url-v2"
|
||||
class="endpoint-input"
|
||||
fluid
|
||||
type="text"
|
||||
pInputText
|
||||
[value]="opdsV2Endpoint"
|
||||
readonly/>
|
||||
<p-button
|
||||
icon="pi pi-copy"
|
||||
severity="info"
|
||||
outlined
|
||||
size="small"
|
||||
(onClick)="copyV2Endpoint()">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-exclamation-triangle"></i>
|
||||
OPDS v2 specification - Note: Not all clients support v2. Use v1 for better compatibility.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -132,13 +132,14 @@
|
||||
.setting-label {
|
||||
margin-bottom: 0;
|
||||
flex-shrink: 0;
|
||||
min-width: 180px;
|
||||
min-width: 150px;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
flex: 1;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
@@ -182,6 +183,18 @@
|
||||
min-width: 25rem;
|
||||
}
|
||||
|
||||
.endpoint-divider {
|
||||
height: 1px;
|
||||
background: var(--p-content-border-color);
|
||||
margin: 1.5rem 0;
|
||||
}
|
||||
|
||||
.setting-description {
|
||||
.pi-exclamation-triangle {
|
||||
color: var(--p-orange-500);
|
||||
}
|
||||
}
|
||||
|
||||
.table-card {
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-radius: 8px;
|
||||
|
||||
@@ -39,6 +39,8 @@ import {AppSettingKey} from '../../core/model/app-settings.model';
|
||||
export class OpdsSettingsV2 implements OnInit, OnDestroy {
|
||||
|
||||
opdsEndpoint = `${API_CONFIG.BASE_URL}/api/v2/opds/catalog`;
|
||||
opdsV1Endpoint = `${API_CONFIG.BASE_URL}/api/v2/opds/catalog`;
|
||||
opdsV2Endpoint = `${API_CONFIG.BASE_URL}/api/v2/opds`;
|
||||
opdsEnabled = false;
|
||||
|
||||
private opdsService = inject(OpdsV2Service);
|
||||
@@ -157,6 +159,18 @@ export class OpdsSettingsV2 implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
copyV1Endpoint(): void {
|
||||
navigator.clipboard.writeText(this.opdsV1Endpoint).then(() => {
|
||||
this.showMessage('success', 'Copied', 'OPDS v1 endpoint copied to clipboard');
|
||||
});
|
||||
}
|
||||
|
||||
copyV2Endpoint(): void {
|
||||
navigator.clipboard.writeText(this.opdsV2Endpoint).then(() => {
|
||||
this.showMessage('success', 'Copied', 'OPDS v2 endpoint copied to clipboard');
|
||||
});
|
||||
}
|
||||
|
||||
toggleOpdsServer(): void {
|
||||
this.saveSetting(AppSettingKey.OPDS_SERVER_ENABLED, this.opdsEnabled);
|
||||
if (this.opdsEnabled) {
|
||||
|
||||
@@ -1,288 +0,0 @@
|
||||
<div class="main-container enclosing-container">
|
||||
<div class="settings-header">
|
||||
<h2 class="settings-title">
|
||||
<i class="pi pi-server"></i>
|
||||
OPDS Settings v1 (Legacy)
|
||||
</h2>
|
||||
<p class="settings-description">
|
||||
Legacy OPDS server settings for managing your book collection access.
|
||||
</p>
|
||||
|
||||
<div class="deprecation-notice">
|
||||
<i class="pi pi-exclamation-triangle"></i>
|
||||
<div>
|
||||
<p class="notice-title">Deprecated:</p>
|
||||
<p class="notice-text">
|
||||
OPDS v1 support will be removed in a future release.
|
||||
Please migrate to <strong>OPDS v2</strong> for continued support and improvements.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-content">
|
||||
<div class="preferences-section">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-power-off"></i>
|
||||
Server Control
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">OPDS Server Enabled</label>
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="opdsEnabled"
|
||||
(onChange)="toggleOpdsServer()">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
Enable or disable the OPDS server to control access to your book collection through reading apps.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (opdsEnabled) {
|
||||
<div class="preferences-section">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-link"></i>
|
||||
OPDS Endpoint
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Endpoint URL</label>
|
||||
<div class="input-group">
|
||||
<input
|
||||
id="endpoint-url"
|
||||
class="endpoint-input"
|
||||
type="text"
|
||||
pInputText
|
||||
[value]="opdsEndpoint"
|
||||
readonly/>
|
||||
<p-button
|
||||
icon="pi pi-copy"
|
||||
severity="info"
|
||||
outlined
|
||||
size="small"
|
||||
(onClick)="copyOpdsEndpoint()">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
Use this URL to connect your reading apps to your OPDS catalog.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="preferences-section">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-users"></i>
|
||||
OPDS Users
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="table-card">
|
||||
<p-table [value]="users">
|
||||
<ng-template pTemplate="header">
|
||||
<tr>
|
||||
<th>
|
||||
<div class="header-content">
|
||||
<i class="pi pi-user"></i>
|
||||
<span>Username</span>
|
||||
</div>
|
||||
</th>
|
||||
<th>
|
||||
<div class="header-content">
|
||||
<i class="pi pi-key"></i>
|
||||
<span>Password</span>
|
||||
</div>
|
||||
</th>
|
||||
<th class="actions-header">
|
||||
<div class="header-content">
|
||||
<i class="pi pi-cog"></i>
|
||||
<span>Actions</span>
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
</ng-template>
|
||||
<ng-template pTemplate="body" let-user>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="user-info">
|
||||
<div class="user-avatar">
|
||||
{{ user.username.charAt(0).toUpperCase() }}
|
||||
</div>
|
||||
<span class="username">{{ user.username }}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="flex items-center gap-2">
|
||||
<p-password
|
||||
fluid
|
||||
class="w-32 md:w-56"
|
||||
[(ngModel)]="dummyPassword"
|
||||
[feedback]="false"
|
||||
size="small"
|
||||
[disabled]="true"
|
||||
[toggleMask]="false">
|
||||
</p-password>
|
||||
<i
|
||||
class="pi pi-info-circle text-gray-400"
|
||||
pTooltip="The password is hidden for security reasons and is only visible once during creation. You can reset the password if needed."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</div>
|
||||
</td>
|
||||
<td class="actions-cell">
|
||||
<div class="action-buttons">
|
||||
<p-button
|
||||
icon="pi pi-key"
|
||||
severity="warn"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="openResetPasswordDialog(user)"
|
||||
pTooltip="Reset password">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-trash"
|
||||
severity="danger"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="deleteUser(user.id)"
|
||||
pTooltip="Delete user">
|
||||
</p-button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</ng-template>
|
||||
<ng-template pTemplate="emptymessage">
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<div class="empty-message">
|
||||
<i class="pi pi-users"></i>
|
||||
<p class="empty-title">No users found</p>
|
||||
<p class="empty-subtitle">Create your first OPDS user to get started</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</ng-template>
|
||||
</p-table>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<p-dialog
|
||||
header="Create User"
|
||||
[(visible)]="createUserDialogVisible"
|
||||
[modal]="true"
|
||||
styleClass="user-dialog"
|
||||
[style]="{width: '400px'}">
|
||||
<div class="dialog-form">
|
||||
<div class="form-field">
|
||||
<label for="username">Username</label>
|
||||
<input
|
||||
id="username"
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="newUser.username"
|
||||
placeholder="Enter username"/>
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<div class="label-with-info">
|
||||
<label for="password">Password</label>
|
||||
<i
|
||||
class="pi pi-info-circle text-yellow-500"
|
||||
pTooltip="Password can only be seen now. It won't be retrievable later. Please save it securely."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</div>
|
||||
<input
|
||||
id="password"
|
||||
type="password"
|
||||
pInputText
|
||||
[(ngModel)]="newUser.password"
|
||||
placeholder="Enter password"/>
|
||||
</div>
|
||||
</div>
|
||||
<ng-template pTemplate="footer">
|
||||
<div class="dialog-actions">
|
||||
<p-button
|
||||
label="Cancel"
|
||||
severity="secondary"
|
||||
outlined="true"
|
||||
(onClick)="cancelCreateUser()">
|
||||
</p-button>
|
||||
<p-button
|
||||
label="Create"
|
||||
severity="success"
|
||||
[disabled]="!newUser.username || !newUser.password"
|
||||
(onClick)="saveNewUser()">
|
||||
</p-button>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-dialog>
|
||||
|
||||
<p-dialog
|
||||
header="Reset User Password"
|
||||
[(visible)]="resetPasswordDialogVisible"
|
||||
[modal]="true"
|
||||
styleClass="user-dialog"
|
||||
[style]="{width: '400px'}">
|
||||
<div class="dialog-form">
|
||||
<p class="reset-info">Reset password for: <strong>{{ selectedUser?.username }}</strong></p>
|
||||
<div class="form-field">
|
||||
<div class="label-with-info">
|
||||
<label for="newPassword">New Password</label>
|
||||
<i
|
||||
class="pi pi-info-circle text-yellow-500"
|
||||
pTooltip="Password can only be seen now. It won't be retrievable later. Please save it securely."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</div>
|
||||
<input
|
||||
id="newPassword"
|
||||
type="password"
|
||||
pInputText
|
||||
[(ngModel)]="newPassword"
|
||||
placeholder="Enter new password"/>
|
||||
</div>
|
||||
</div>
|
||||
<ng-template pTemplate="footer">
|
||||
<div class="dialog-actions">
|
||||
<p-button
|
||||
label="Cancel"
|
||||
severity="secondary"
|
||||
outlined="true"
|
||||
(onClick)="cancelResetPassword()">
|
||||
</p-button>
|
||||
<p-button
|
||||
label="Reset"
|
||||
severity="success"
|
||||
[disabled]="!newPassword"
|
||||
(onClick)="confirmResetPassword()">
|
||||
</p-button>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-dialog>
|
||||
</div>
|
||||
@@ -1,377 +0,0 @@
|
||||
.main-container {
|
||||
width: 100%;
|
||||
padding: 1rem;
|
||||
height: calc(100dvh - 10.5rem);
|
||||
overflow-y: auto;
|
||||
border-width: 1px;
|
||||
border-radius: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
height: calc(100dvh - 11.65rem);
|
||||
}
|
||||
}
|
||||
|
||||
.enclosing-container {
|
||||
border-color: var(--p-content-border-color);
|
||||
background: var(--p-content-background);
|
||||
}
|
||||
|
||||
.settings-header {
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.settings-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: var(--p-text-color);
|
||||
margin: 0 0 0.75rem 0;
|
||||
|
||||
.pi {
|
||||
color: var(--p-primary-color);
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-description {
|
||||
color: var(--p-text-muted-color);
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.5;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.deprecation-notice {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.75rem;
|
||||
padding: 1rem;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--p-red-500);
|
||||
background: rgba(239, 68, 68, 0.1);
|
||||
color: var(--p-red-400);
|
||||
|
||||
.pi {
|
||||
color: var(--p-red-500);
|
||||
margin-top: 0.125rem;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.notice-title {
|
||||
font-weight: 600;
|
||||
color: var(--p-red-500);
|
||||
margin: 0 0 0.25rem 0;
|
||||
}
|
||||
|
||||
.notice-text {
|
||||
font-size: 0.875rem;
|
||||
margin: 0;
|
||||
line-height: 1.4;
|
||||
|
||||
strong {
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.settings-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
.preferences-section {
|
||||
@media (min-width: 768px) {
|
||||
padding: 0 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: 1.125rem;
|
||||
font-weight: 600;
|
||||
color: var(--p-text-color);
|
||||
margin: 0;
|
||||
|
||||
.pi {
|
||||
color: var(--p-primary-color);
|
||||
}
|
||||
}
|
||||
|
||||
.settings-card {
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-radius: 8px;
|
||||
background: var(--p-content-background);
|
||||
padding: 1.5rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.setting-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 2rem;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
.setting-label {
|
||||
display: block;
|
||||
font-weight: 600;
|
||||
color: var(--p-text-color);
|
||||
font-size: 1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.setting-label-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.setting-label {
|
||||
margin-bottom: 0;
|
||||
flex-shrink: 0;
|
||||
min-width: 180px;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.setting-description {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.5rem;
|
||||
color: var(--p-text-muted-color);
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.5;
|
||||
margin: 0;
|
||||
|
||||
.pi {
|
||||
color: var(--p-primary-color);
|
||||
margin-top: 0.125rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.input-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.endpoint-input {
|
||||
min-width: 9rem;
|
||||
max-width: 30rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.table-card {
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
background: var(--p-content-background);
|
||||
}
|
||||
|
||||
.p-datatable {
|
||||
.p-datatable-table {
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
.p-datatable-thead > tr > th {
|
||||
background: var(--p-surface-100);
|
||||
border-bottom: 2px solid var(--p-content-border-color);
|
||||
padding: 1rem;
|
||||
font-weight: 600;
|
||||
color: var(--p-text-color);
|
||||
}
|
||||
|
||||
.p-datatable-tbody > tr {
|
||||
transition: background-color 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: var(--p-surface-50);
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.p-datatable-tbody > tr > td {
|
||||
padding: 1rem;
|
||||
border: none;
|
||||
text-align: left;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
|
||||
.p-datatable th .header-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.user-avatar {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
background: var(--p-primary-color);
|
||||
color: white;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: 600;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.username {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.actions-cell {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.empty-message {
|
||||
text-align: center;
|
||||
padding: 2rem 1rem;
|
||||
color: var(--p-text-muted-color);
|
||||
|
||||
.pi {
|
||||
font-size: 2rem;
|
||||
margin-bottom: 1rem;
|
||||
color: var(--p-surface-400);
|
||||
}
|
||||
|
||||
.empty-title {
|
||||
font-size: 1.125rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.empty-subtitle {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
|
||||
.user-dialog {
|
||||
.p-dialog-content {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.p-dialog-footer {
|
||||
padding: 1rem 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.form-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
label {
|
||||
font-weight: 600;
|
||||
color: var(--p-text-color);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
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 var(--p-primary-color-alpha-20);
|
||||
}
|
||||
|
||||
&::placeholder {
|
||||
color: var(--p-text-muted-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.label-with-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.dialog-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.reset-info {
|
||||
color: var(--p-text-color);
|
||||
margin-bottom: 1rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.custom-border {
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--card-border);
|
||||
}
|
||||
@@ -1,187 +0,0 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
|
||||
import {TableModule} from 'primeng/table';
|
||||
import {Button} from 'primeng/button';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Dialog} from 'primeng/dialog';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {filter, take} from 'rxjs/operators';
|
||||
|
||||
import {OpdsUser, OpdsUserService} from './opds-user.service';
|
||||
import {AppSettingsService} from '../../core/service/app-settings.service';
|
||||
import {AppSettingKey, AppSettings} from '../../core/model/app-settings.model';
|
||||
import {Password} from 'primeng/password';
|
||||
import {API_CONFIG} from '../../config/api-config';
|
||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||
|
||||
@Component({
|
||||
selector: 'app-opds-settings',
|
||||
standalone: true,
|
||||
imports: [
|
||||
FormsModule,
|
||||
TableModule,
|
||||
Button,
|
||||
InputText,
|
||||
Dialog,
|
||||
Tooltip,
|
||||
Password,
|
||||
ToggleSwitch
|
||||
],
|
||||
templateUrl: './opds-settings.component.html',
|
||||
styleUrl: './opds-settings.component.scss'
|
||||
})
|
||||
export class OpdsSettingsComponent implements OnInit {
|
||||
opdsEnabled = false;
|
||||
users: OpdsUser[] = [];
|
||||
selectedUser: OpdsUser | null = null;
|
||||
createUserDialogVisible = false;
|
||||
resetPasswordDialogVisible = false;
|
||||
newUser = {username: '', password: ''};
|
||||
newPassword = '';
|
||||
opdsEndpoint: string = `${API_CONFIG.BASE_URL}/api/v1/opds/catalog`;
|
||||
dummyPassword: string = '********************************';
|
||||
|
||||
private readonly appSettings$ = inject(AppSettingsService).appSettings$;
|
||||
private readonly opdsUserService = inject(OpdsUserService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly appSettingsService = inject(AppSettingsService);
|
||||
|
||||
ngOnInit(): void {
|
||||
this.appSettings$
|
||||
.pipe(
|
||||
filter((settings): settings is AppSettings => settings != null),
|
||||
take(1)
|
||||
)
|
||||
.subscribe(settings => {
|
||||
this.opdsEnabled = settings.opdsServerEnabled ?? false;
|
||||
if (this.opdsEnabled) {
|
||||
this.loadUsers();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
toggleOpdsServer(): void {
|
||||
this.saveSetting(AppSettingKey.OPDS_SERVER_ENABLED, this.opdsEnabled);
|
||||
if (this.opdsEnabled) {
|
||||
this.loadUsers();
|
||||
} else {
|
||||
this.users = [];
|
||||
}
|
||||
}
|
||||
|
||||
loadUsers(): void {
|
||||
this.opdsUserService.getUsers().subscribe({
|
||||
next: (users) => this.users = users,
|
||||
error: () => this.showError('Load Users Failed', 'Unable to fetch users.')
|
||||
});
|
||||
}
|
||||
|
||||
openCreateUserDialog(): void {
|
||||
this.newUser = {username: '', password: ''};
|
||||
this.createUserDialogVisible = true;
|
||||
}
|
||||
|
||||
cancelCreateUser(): void {
|
||||
this.createUserDialogVisible = false;
|
||||
}
|
||||
|
||||
saveNewUser(): void {
|
||||
const {username, password} = this.newUser;
|
||||
|
||||
if (username.trim() && password.trim()) {
|
||||
this.opdsUserService.createUser(this.newUser).subscribe({
|
||||
next: () => {
|
||||
this.createUserDialogVisible = false;
|
||||
this.loadUsers();
|
||||
this.showSuccess('User Created', 'New OPDS user created successfully.');
|
||||
},
|
||||
error: (err) => {
|
||||
const errorMessage = err?.error?.message || 'Unable to create user.';
|
||||
this.showError('Create User Failed', errorMessage);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.showWarning('Invalid Input', 'Username and Password are required.');
|
||||
}
|
||||
}
|
||||
|
||||
openResetPasswordDialog(user: OpdsUser): void {
|
||||
this.selectedUser = user;
|
||||
this.newPassword = '';
|
||||
this.resetPasswordDialogVisible = true;
|
||||
}
|
||||
|
||||
cancelResetPassword(): void {
|
||||
this.resetPasswordDialogVisible = false;
|
||||
this.selectedUser = null;
|
||||
this.newPassword = '';
|
||||
}
|
||||
|
||||
copyOpdsEndpoint() {
|
||||
navigator.clipboard.writeText(this.opdsEndpoint)
|
||||
.then(() => {
|
||||
})
|
||||
.catch(err => {
|
||||
});
|
||||
}
|
||||
|
||||
confirmResetPassword(): void {
|
||||
if (this.selectedUser && this.newPassword.trim()) {
|
||||
this.opdsUserService.resetPassword(this.selectedUser.id, this.newPassword).subscribe({
|
||||
next: () => {
|
||||
this.resetPasswordDialogVisible = false;
|
||||
this.showSuccess('Password Reset', 'User password reset successfully.');
|
||||
},
|
||||
error: (err) => {
|
||||
const errorMessage = err?.error?.message || 'Unable to reset password.';
|
||||
this.showError('Reset Password Failed', errorMessage);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.showWarning('Invalid Input', 'New password is required.');
|
||||
}
|
||||
}
|
||||
|
||||
deleteUser(userId: number): void {
|
||||
this.opdsUserService.deleteUser(userId).subscribe({
|
||||
next: () => {
|
||||
this.loadUsers();
|
||||
this.showSuccess('User Deleted', 'User deleted successfully.');
|
||||
},
|
||||
error: () => {
|
||||
this.showError('Delete User Failed', 'Unable to delete user.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private saveSetting(key: string, value: unknown): void {
|
||||
this.appSettingsService.saveSettings([{key, newValue: value}]).subscribe({
|
||||
next: () => {
|
||||
let successMessage = 'Settings saved successfully.';
|
||||
if (key === AppSettingKey.OPDS_SERVER_ENABLED) {
|
||||
successMessage = (value === true)
|
||||
? 'OPDS Server Enabled.'
|
||||
: 'OPDS Server Disabled.';
|
||||
}
|
||||
this.showSuccess('Settings Saved', successMessage);
|
||||
},
|
||||
error: () => {
|
||||
this.showError('Error', 'There was an error saving the settings.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private showSuccess(summary: string, detail: string): void {
|
||||
this.messageService.add({severity: 'success', summary, detail});
|
||||
}
|
||||
|
||||
private showError(summary: string, detail: string): void {
|
||||
this.messageService.add({severity: 'error', summary, detail});
|
||||
}
|
||||
|
||||
private showWarning(summary: string, detail: string): void {
|
||||
this.messageService.add({severity: 'warn', summary, detail});
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {API_CONFIG} from '../../config/api-config';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Observable} from 'rxjs';
|
||||
|
||||
export interface OpdsUser {
|
||||
id: number;
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class OpdsUserService {
|
||||
|
||||
private readonly url = `${API_CONFIG.BASE_URL}/api/v1/opds-users`;
|
||||
|
||||
private http = inject(HttpClient);
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
createUser(userData: Omit<OpdsUser, 'id'>): Observable<void> {
|
||||
return this.http.post<void>(this.url, userData);
|
||||
}
|
||||
|
||||
getUsers(): Observable<OpdsUser[]> {
|
||||
return this.http.get<OpdsUser[]>(this.url);
|
||||
}
|
||||
|
||||
deleteUser(userId: number): Observable<void> {
|
||||
return this.http.delete<void>(`${this.url}/${userId}`);
|
||||
}
|
||||
|
||||
resetPassword(resetPasswordUserId: number, newPassword: string): Observable<void> {
|
||||
const resetPayload = {
|
||||
password: newPassword
|
||||
};
|
||||
return this.http.put<void>(`${this.url}/${resetPasswordUserId}/reset-password`, resetPayload);
|
||||
}
|
||||
}
|
||||
@@ -28,12 +28,9 @@
|
||||
<p-tab [value]="SettingsTab.AuthenticationSettings">
|
||||
<i class="pi pi-lock"></i> Authentication
|
||||
</p-tab>
|
||||
<p-tab [value]="SettingsTab.Opds">
|
||||
<i class="pi pi-globe"></i> OPDS (Deprecated)
|
||||
</p-tab>
|
||||
}
|
||||
<p-tab [value]="SettingsTab.OpdsV2">
|
||||
<i class="pi pi-globe"></i> OPDS v2
|
||||
<i class="pi pi-globe"></i> OPDS
|
||||
</p-tab>
|
||||
<p-tab [value]="SettingsTab.DeviceSettings">
|
||||
<i class="pi pi-mobile"></i> Devices
|
||||
@@ -65,9 +62,6 @@
|
||||
<p-tabpanel [value]="SettingsTab.AuthenticationSettings">
|
||||
<app-authentication-settings></app-authentication-settings>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel [value]="SettingsTab.Opds">
|
||||
<app-opds-settings></app-opds-settings>
|
||||
</p-tabpanel>
|
||||
}
|
||||
<p-tabpanel [value]="SettingsTab.OpdsV2">
|
||||
<app-opds-settings-v2></app-opds-settings-v2>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
|
||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||
import {UserService} from './user-management/user.service';
|
||||
import { AsyncPipe } from '@angular/common';
|
||||
import {AsyncPipe} from '@angular/common';
|
||||
import {EmailComponent} from './email/email.component';
|
||||
import {GlobalPreferencesComponent} from './global-preferences/global-preferences.component';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
@@ -11,7 +11,6 @@ import {AuthenticationSettingsComponent} from '../core/security/oauth2-managemen
|
||||
import {ViewPreferencesParentComponent} from './view-preferences-parent/view-preferences-parent.component';
|
||||
import {ReaderPreferences} from './reader-preferences/reader-preferences.component';
|
||||
import {MetadataSettingsComponent} from './metadata-settings-component/metadata-settings-component';
|
||||
import {OpdsSettingsComponent} from './opds-settings/opds-settings.component';
|
||||
import {DeviceSettingsComponent} from './device-settings-component/device-settings-component';
|
||||
import {FileNamingPatternComponent} from './file-naming-pattern/file-naming-pattern.component';
|
||||
import {OpdsSettingsV2} from './opds-settings-v2/opds-settings-v2';
|
||||
@@ -26,8 +25,7 @@ export enum SettingsTab {
|
||||
MetadataSettings = 'metadata',
|
||||
ApplicationSettings = 'application',
|
||||
AuthenticationSettings = 'authentication',
|
||||
OpdsV2 = 'opds-v2',
|
||||
Opds = 'opds'
|
||||
OpdsV2 = 'opds'
|
||||
}
|
||||
|
||||
@Component({
|
||||
@@ -46,7 +44,6 @@ export enum SettingsTab {
|
||||
ViewPreferencesParentComponent,
|
||||
ReaderPreferences,
|
||||
MetadataSettingsComponent,
|
||||
OpdsSettingsComponent,
|
||||
DeviceSettingsComponent,
|
||||
FileNamingPatternComponent,
|
||||
OpdsSettingsV2
|
||||
@@ -75,7 +72,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
||||
this._activeTab = value;
|
||||
this.router.navigate([], {
|
||||
relativeTo: this.route,
|
||||
queryParams: { tab: value },
|
||||
queryParams: {tab: value},
|
||||
queryParamsHandling: 'merge'
|
||||
});
|
||||
}
|
||||
@@ -89,7 +86,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
||||
this._activeTab = SettingsTab.ReaderSettings;
|
||||
this.router.navigate([], {
|
||||
relativeTo: this.route,
|
||||
queryParams: { tab: this._activeTab },
|
||||
queryParams: {tab: this._activeTab},
|
||||
queryParamsHandling: 'merge',
|
||||
replaceUrl: true
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user