Kavita/UI/Web/src/app/admin/settings.service.ts
Joe Milazzo 21a9f28923
Random Cleanup + OPDS Base Url Support (#1926)
* Updated a ton of dependencies. PDFs reader got a big update from PDF.js 2.6 -> 3.x

* Rolled back fontawesome update

* Updated to latest angular patch. Fixed search being too long instead of just to the end of the browser screen.

* Fixed alignment on download icon for download indicator in cards

* Include progress information on Want To Read API and when marking something as Read, perform cleanup service on want to read.

* Removed mark-read updating want to read. As there are series restrictions and it could be misleading.

* Tweaked login page spacing when form is dirty

* Replaced an object instantiation

* Commented out a few tests that always break when updating NetVips (but always work)

* Updated ngx-toastr

* Added styles for alerts to Kavita. They were somehow missing. Fixed an issue where when OPDS was disabled, user preferences wouldn't tell them.

* Wired up a reset base url button to match Ip Addresses

* Disable ipAddress and port for docker users

* Removed cache dir since it's kinda pointless currently

* Started the update for OPDS BaseUrl support

* Fixed OPDS url not reflecting base url on localhost

* Added extra plumbing to allow sending a real email when testing a custom service.

* Implemented OPDS support under Base Url. Added pagination to all APIs where applicable.

* Added a swallowing of permission denied on Updating baseurl in index.html for inapplicable users.

* Fixed a bad test
2023-04-14 17:44:35 -07:00

68 lines
1.9 KiB
TypeScript

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { map } from 'rxjs';
import { environment } from 'src/environments/environment';
import { TextResonse } from '../_types/text-response';
import { ServerSettings } from './_models/server-settings';
/**
* Used only for the Test Email Service call
*/
export interface EmailTestResult {
successful: boolean;
errorMessage: string;
}
@Injectable({
providedIn: 'root'
})
export class SettingsService {
baseUrl = environment.apiUrl;
constructor(private http: HttpClient) { }
getServerSettings() {
return this.http.get<ServerSettings>(this.baseUrl + 'settings');
}
updateServerSettings(model: ServerSettings) {
return this.http.post<ServerSettings>(this.baseUrl + 'settings', model);
}
resetServerSettings() {
return this.http.post<ServerSettings>(this.baseUrl + 'settings/reset', {});
}
resetIPAddressesSettings() {
return this.http.post<ServerSettings>(this.baseUrl + 'settings/reset-ip-addresses', {});
}
resetBaseUrl() {
return this.http.post<ServerSettings>(this.baseUrl + 'settings/reset-base-url', {});
}
resetEmailServerSettings() {
return this.http.post<ServerSettings>(this.baseUrl + 'settings/reset-email-url', {});
}
testEmailServerSettings(emailUrl: string) {
return this.http.post<EmailTestResult>(this.baseUrl + 'settings/test-email-url', {url: emailUrl});
}
getTaskFrequencies() {
return this.http.get<string[]>(this.baseUrl + 'settings/task-frequencies');
}
getLoggingLevels() {
return this.http.get<string[]>(this.baseUrl + 'settings/log-levels');
}
getLibraryTypes() {
return this.http.get<string[]>(this.baseUrl + 'settings/library-types');
}
getOpdsEnabled() {
return this.http.get<string>(this.baseUrl + 'settings/opds-enabled', TextResonse).pipe(map(d => d === 'true'));
}
}