mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-04-10 19:21:46 -04:00
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>
38 lines
1.3 KiB
TypeScript
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'));
|
|
}
|
|
}
|