Display OPDS Server Endpoint in the Application UI
This commit is contained in:
committed by
Aditya Chandel
parent
866daced58
commit
3f12d5994f
@@ -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
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
import { Component, inject, OnInit } from '@angular/core';
|
import {Component, inject, OnInit} from '@angular/core';
|
||||||
import { FormsModule } from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import { NgIf } from '@angular/common';
|
import {NgIf} from '@angular/common';
|
||||||
import { TableModule } from 'primeng/table';
|
import {TableModule} from 'primeng/table';
|
||||||
import { Button } from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import { InputText } from 'primeng/inputtext';
|
import {InputText} from 'primeng/inputtext';
|
||||||
import { Dialog } from 'primeng/dialog';
|
import {Dialog} from 'primeng/dialog';
|
||||||
import { Tooltip } from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import { ToggleButton } from 'primeng/togglebutton';
|
import {ToggleButton} from 'primeng/togglebutton';
|
||||||
import { MessageService } from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import { filter, take } from 'rxjs/operators';
|
import {filter, take} from 'rxjs/operators';
|
||||||
|
|
||||||
import { OpdsUser, OpdsUserService } from '../opds-user.service';
|
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',
|
||||||
@@ -38,8 +39,10 @@ export class OpdsSettingsComponent implements OnInit {
|
|||||||
selectedUser: OpdsUser | null = null;
|
selectedUser: OpdsUser | null = null;
|
||||||
createUserDialogVisible = false;
|
createUserDialogVisible = false;
|
||||||
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);
|
||||||
@@ -77,7 +80,7 @@ export class OpdsSettingsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
openCreateUserDialog(): void {
|
openCreateUserDialog(): void {
|
||||||
this.newUser = { username: '', password: '' };
|
this.newUser = {username: '', password: ''};
|
||||||
this.createUserDialogVisible = true;
|
this.createUserDialogVisible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +89,7 @@ export class OpdsSettingsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
saveNewUser(): void {
|
saveNewUser(): void {
|
||||||
const { username, password } = this.newUser;
|
const {username, password} = this.newUser;
|
||||||
|
|
||||||
if (username.trim() && password.trim()) {
|
if (username.trim() && password.trim()) {
|
||||||
this.opdsUserService.createUser(this.newUser).subscribe({
|
this.opdsUserService.createUser(this.newUser).subscribe({
|
||||||
@@ -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({
|
||||||
@@ -147,7 +158,7 @@ export class OpdsSettingsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private saveSetting(key: string, value: unknown): void {
|
private saveSetting(key: string, value: unknown): void {
|
||||||
this.appSettingsService.saveSettings([{ key, newValue: value }]).subscribe({
|
this.appSettingsService.saveSettings([{key, newValue: value}]).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
let successMessage = 'Settings saved successfully.';
|
let successMessage = 'Settings saved successfully.';
|
||||||
if (key === 'opds_server_enabled') {
|
if (key === 'opds_server_enabled') {
|
||||||
@@ -164,14 +175,14 @@ export class OpdsSettingsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private showSuccess(summary: string, detail: string): void {
|
private showSuccess(summary: string, detail: string): void {
|
||||||
this.messageService.add({ severity: 'success', summary, detail });
|
this.messageService.add({severity: 'success', summary, detail});
|
||||||
}
|
}
|
||||||
|
|
||||||
private showError(summary: string, detail: string): void {
|
private showError(summary: string, detail: string): void {
|
||||||
this.messageService.add({ severity: 'error', summary, detail });
|
this.messageService.add({severity: 'error', summary, detail});
|
||||||
}
|
}
|
||||||
|
|
||||||
private showWarning(summary: string, detail: string): void {
|
private showWarning(summary: string, detail: string): void {
|
||||||
this.messageService.add({ severity: 'warn', summary, detail });
|
this.messageService.add({severity: 'warn', summary, detail});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user