Display OPDS Server Endpoint in the Application UI

This commit is contained in:
adityachandelgit
2025-04-28 18:07:03 -06:00
committed by Aditya Chandel
parent 866daced58
commit 3f12d5994f
2 changed files with 53 additions and 23 deletions
@@ -20,6 +20,25 @@
</p-toggleButton> </p-toggleButton>
</div> </div>
<div *ngIf="opdsEnabled" class="flex flex-col gap-2 mt-4 rounded-lg">
<p class="text-lg py-1">OPDS Endpoint:</p>
<div class="flex items-center gap-4">
<input
class="min-w-[500px] max-w-[800px]"
type="text"
pInputText
[value]="opdsEndpoint"
readonly/>
<p-button
icon="pi pi-copy"
severity="info"
(onClick)="copyOpdsEndpoint()"
label="Copy"
outlined="true">
</p-button>
</div>
</div>
<div *ngIf="opdsEnabled" class="mt-6"> <div *ngIf="opdsEnabled" class="mt-6">
<p-button <p-button
label="Create New User" label="Create New User"
@@ -44,7 +63,7 @@
<td>{{ user.username }}</td> <td>{{ user.username }}</td>
<td class="flex items-center gap-2"> <td class="flex items-center gap-2">
<p-password <p-password
[(ngModel)]="user.password" [(ngModel)]="dummyPassword"
[disabled]="true"> [disabled]="true">
</p-password> </p-password>
<i <i
@@ -14,6 +14,7 @@ import { OpdsUser, OpdsUserService } from '../opds-user.service';
import {AppSettingsService} from '../core/service/app-settings.service'; import {AppSettingsService} from '../core/service/app-settings.service';
import {AppSettings} from '../core/model/app-settings.model'; import {AppSettings} from '../core/model/app-settings.model';
import {Password} from 'primeng/password'; import {Password} from 'primeng/password';
import {API_CONFIG} from '../config/api-config';
@Component({ @Component({
selector: 'app-opds-settings', selector: 'app-opds-settings',
@@ -40,6 +41,8 @@ export class OpdsSettingsComponent implements OnInit {
resetPasswordDialogVisible = false; resetPasswordDialogVisible = false;
newUser = {username: '', password: ''}; newUser = {username: '', password: ''};
newPassword = ''; newPassword = '';
opdsEndpoint: string = `${API_CONFIG.BASE_URL}/api/v1/opds/catalog`;
dummyPassword: string = '********************************';
private readonly appSettings$ = inject(AppSettingsService).appSettings$; private readonly appSettings$ = inject(AppSettingsService).appSettings$;
private readonly opdsUserService = inject(OpdsUserService); private readonly opdsUserService = inject(OpdsUserService);
@@ -117,6 +120,14 @@ export class OpdsSettingsComponent implements OnInit {
this.newPassword = ''; this.newPassword = '';
} }
copyOpdsEndpoint() {
navigator.clipboard.writeText(this.opdsEndpoint)
.then(() => {
})
.catch(err => {
});
}
confirmResetPassword(): void { confirmResetPassword(): void {
if (this.selectedUser && this.newPassword.trim()) { if (this.selectedUser && this.newPassword.trim()) {
this.opdsUserService.resetPassword(this.selectedUser.id, this.newPassword).subscribe({ this.opdsUserService.resetPassword(this.selectedUser.id, this.newPassword).subscribe({