Kavita/UI/Web/src/app/_services/external-source.service.ts
Joe Milazzo 26ff71f42b
OPDS Enhancements, Epub fixes, and a lot more (#4035)
Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com>
Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
Co-authored-by: Fabian Pammer <fpammer@mantro.net>
Co-authored-by: Vinícius Licz <vinilicz@gmail.com>
2025-09-20 13:16:21 -07:00

38 lines
1.3 KiB
TypeScript

import { Injectable, inject } from '@angular/core';
import {environment} from "../../environments/environment";
import { HttpClient } from "@angular/common/http";
import {ExternalSource} from "../_models/sidenav/external-source";
import {TextResonse} from "../_types/text-response";
import {map} from "rxjs/operators";
@Injectable({
providedIn: 'root'
})
export class ExternalSourceService {
private httpClient = inject(HttpClient);
baseUrl = environment.apiUrl;
getExternalSources() {
return this.httpClient.get<Array<ExternalSource>>(this.baseUrl + 'stream/external-sources');
}
createSource(source: ExternalSource) {
return this.httpClient.post<ExternalSource>(this.baseUrl + 'stream/create-external-source', source);
}
updateSource(source: ExternalSource) {
return this.httpClient.post<ExternalSource>(this.baseUrl + 'stream/update-external-source', source);
}
deleteSource(externalSourceId: number) {
return this.httpClient.delete(this.baseUrl + 'stream/delete-external-source?externalSourceId=' + externalSourceId);
}
sourceExists(name: string, host: string, apiKey: string) {
return this.httpClient.get<string>(this.baseUrl + `stream/external-source-exists?host=${encodeURIComponent(host)}&name=${name}&apiKey=${apiKey}`, TextResonse)
.pipe(map(s => s == 'true'));
}
}