rdt-client/client/src/app/settings.service.ts
Roger Far fc15569e1b Rewrote the setting store, retrieve and displaying on the settings page to make maintenance a lot easier.
Added settings to set defaults for the provider import, sonarr, gui and watch folders.
2022-05-13 14:39:52 -06:00

43 lines
1.2 KiB
TypeScript

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Profile } from './models/profile.model';
import { Setting } from './models/setting.model';
@Injectable({
providedIn: 'root',
})
export class SettingsService {
constructor(private http: HttpClient) {}
public get(): Observable<Setting[]> {
return this.http.get<Setting[]>(`/Api/Settings`);
}
public update(settings: Setting[]): Observable<void> {
return this.http.put<void>(`/Api/Settings`, settings);
}
public getProfile(): Observable<Profile> {
return this.http.get<Profile>(`/Api/Settings/Profile`);
}
public testPath(path: string): Observable<void> {
return this.http.post<void>(`/Api/Settings/TestPath`, { path });
}
public testDownloadSpeed(): Observable<number> {
return this.http.get<number>(`/Api/Settings/TestDownloadSpeed`);
}
public testWriteSpeed(): Observable<number> {
return this.http.get<number>(`/Api/Settings/TestWriteSpeed`);
}
public testAria2cConnection(url: string, secret: string): Observable<{ version: string }> {
return this.http.post<{ version: string }>(`/Api/Settings/TestAria2cConnection`, {
url,
secret,
});
}
}