|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
import { PlatformLocation } from "@angular/common";
|
|
|
|
|
import { HttpClient } from "@angular/common/http";
|
|
|
|
|
import { Injectable } from "@angular/core";
|
|
|
|
|
import { Http } from "@angular/http";
|
|
|
|
|
import { AuthHttp } from "angular2-jwt";
|
|
|
|
|
import { Observable } from "rxjs/Rx";
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
@ -30,236 +29,208 @@ import {
|
|
|
|
|
IUserManagementSettings,
|
|
|
|
|
} from "../interfaces";
|
|
|
|
|
|
|
|
|
|
import { ServiceAuthHelpers } from "./service.helpers";
|
|
|
|
|
import { ServiceHelpers } from "./service.helpers";
|
|
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
|
export class SettingsService extends ServiceAuthHelpers {
|
|
|
|
|
constructor(public httpAuth: AuthHttp, private nonAuthHttp: Http,
|
|
|
|
|
public platformLocation: PlatformLocation) {
|
|
|
|
|
super(httpAuth, "/api/v1/Settings", platformLocation);
|
|
|
|
|
export class SettingsService extends ServiceHelpers {
|
|
|
|
|
constructor(public http: HttpClient, public platformLocation: PlatformLocation) {
|
|
|
|
|
super(http, "/api/v1/Settings", platformLocation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public about(): Observable<IAbout> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/About/`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<IAbout>(`${this.url}/About/`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getOmbi(): Observable<IOmbiSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/Ombi/`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<IOmbiSettings>(`${this.url}/Ombi/`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveOmbi(settings: IOmbiSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth.post(`${this.url}/Ombi/`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.post<boolean>(`${this.url}/Ombi/`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public resetOmbiApi(): Observable<string> {
|
|
|
|
|
return this.httpAuth.post(`${this.url}/Ombi/resetApi`, { headers: this.headers }).map(this.extractData)
|
|
|
|
|
.catch(this.handleError);
|
|
|
|
|
return this.http.post<string>(`${this.url}/Ombi/resetApi`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getEmby(): Observable<IEmbySettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/Emby/`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<IEmbySettings>(`${this.url}/Emby/`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveEmby(settings: IEmbySettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth.post(`${this.url}/Emby/`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.post<boolean>(`${this.url}/Emby/`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getPlex(): Observable<IPlexSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/Plex/`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<IPlexSettings>(`${this.url}/Plex/`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public savePlex(settings: IPlexSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth.post(`${this.url}/Plex/`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.post<boolean>(`${this.url}/Plex/`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getSonarr(): Observable<ISonarrSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/Sonarr`).map(this.extractData)
|
|
|
|
|
.catch(this.handleError);
|
|
|
|
|
return this.http.get<ISonarrSettings>(`${this.url}/Sonarr`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveSonarr(settings: ISonarrSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth.post(`${this.url}/Sonarr`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.post<boolean>(`${this.url}/Sonarr`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getRadarr(): Observable<IRadarrSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/Radarr`).map(this.extractData)
|
|
|
|
|
.catch(this.handleError);
|
|
|
|
|
return this.http.get<IRadarrSettings>(`${this.url}/Radarr`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveRadarr(settings: IRadarrSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth.post(`${this.url}/Radarr`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.post<boolean>(`${this.url}/Radarr`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getAuthentication(): Observable<IAuthenticationSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/Authentication`).map(this.extractData)
|
|
|
|
|
.catch(this.handleError);
|
|
|
|
|
return this.http.get<IAuthenticationSettings>(`${this.url}/Authentication`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveAuthentication(settings: IAuthenticationSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth.post(`${this.url}/Authentication`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.post<boolean>(`${this.url}/Authentication`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Using http since we need it not to be authenticated to get the landing page settings
|
|
|
|
|
public getLandingPage(): Observable<ILandingPageSettings> {
|
|
|
|
|
return this.nonAuthHttp.get(`${this.url}/LandingPage`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<ILandingPageSettings>(`${this.url}/LandingPage`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveLandingPage(settings: ILandingPageSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth.post(`${this.url}/LandingPage`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.post<boolean>(`${this.url}/LandingPage`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Using http since we need it not to be authenticated to get the customization settings
|
|
|
|
|
public getCustomization(): Observable<ICustomizationSettings> {
|
|
|
|
|
return this.nonAuthHttp.get(`${this.url}/customization`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<ICustomizationSettings>(`${this.url}/customization`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveCustomization(settings: ICustomizationSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth.post(`${this.url}/customization`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.post<boolean>(`${this.url}/customization`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getThemes(): Observable<IThemes[]> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/themes`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<IThemes[]>(`${this.url}/themes`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getThemeContent(themeUrl: string): Observable<string> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/themecontent?url=${themeUrl}`).map(this.extractContentData).catch(this.handleError);
|
|
|
|
|
return this.http.get<string>(`${this.url}/themecontent?url=${themeUrl}`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getEmailNotificationSettings(): Observable<IEmailNotificationSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/notifications/email`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<IEmailNotificationSettings>(`${this.url}/notifications/email`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
public getEmailSettingsEnabled(): Observable<boolean> {
|
|
|
|
|
return this.nonAuthHttp.get(`${this.url}/notifications/email/enabled`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<boolean>(`${this.url}/notifications/email/enabled`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveEmailNotificationSettings(settings: IEmailNotificationSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth
|
|
|
|
|
.post(`${this.url}/notifications/email`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.post<boolean>(`${this.url}/notifications/email`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getDiscordNotificationSettings(): Observable<IDiscordNotifcationSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/notifications/discord`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<IDiscordNotifcationSettings>(`${this.url}/notifications/discord`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getMattermostNotificationSettings(): Observable<IMattermostNotifcationSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/notifications/mattermost`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<IMattermostNotifcationSettings>(`${this.url}/notifications/mattermost`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveDiscordNotificationSettings(settings: IDiscordNotifcationSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth
|
|
|
|
|
.post(`${this.url}/notifications/discord`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http
|
|
|
|
|
.post<boolean>(`${this.url}/notifications/discord`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveMattermostNotificationSettings(settings: IMattermostNotifcationSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth
|
|
|
|
|
.post(`${this.url}/notifications/mattermost`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.post<boolean>(`${this.url}/notifications/mattermost`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
public getPushbulletNotificationSettings(): Observable<IPushbulletNotificationSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/notifications/pushbullet`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<IPushbulletNotificationSettings>(`${this.url}/notifications/pushbullet`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
public getPushoverNotificationSettings(): Observable<IPushoverNotificationSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/notifications/pushover`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<IPushoverNotificationSettings>(`${this.url}/notifications/pushover`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public savePushbulletNotificationSettings(settings: IPushbulletNotificationSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth
|
|
|
|
|
.post(`${this.url}/notifications/pushbullet`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http
|
|
|
|
|
.post<boolean>(`${this.url}/notifications/pushbullet`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
public savePushoverNotificationSettings(settings: IPushoverNotificationSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth
|
|
|
|
|
.post(`${this.url}/notifications/pushover`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http
|
|
|
|
|
.post<boolean>(`${this.url}/notifications/pushover`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getSlackNotificationSettings(): Observable<ISlackNotificationSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/notifications/slack`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<ISlackNotificationSettings>(`${this.url}/notifications/slack`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveSlackNotificationSettings(settings: ISlackNotificationSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth
|
|
|
|
|
.post(`${this.url}/notifications/slack`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http
|
|
|
|
|
.post<boolean>(`${this.url}/notifications/slack`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getUpdateSettings(): Observable<IUpdateSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/update`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<IUpdateSettings>(`${this.url}/update`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveUpdateSettings(settings: IUpdateSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth
|
|
|
|
|
.post(`${this.url}/update`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http
|
|
|
|
|
.post<boolean>(`${this.url}/update`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getUserManagementSettings(): Observable<IUserManagementSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/UserManagement`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<IUserManagementSettings>(`${this.url}/UserManagement`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveUserManagementSettings(settings: IUserManagementSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth
|
|
|
|
|
.post(`${this.url}/UserManagement`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http
|
|
|
|
|
.post<boolean>(`${this.url}/UserManagement`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getCouchPotatoSettings(): Observable<ICouchPotatoSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/CouchPotato`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<ICouchPotatoSettings>(`${this.url}/CouchPotato`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveCouchPotatoSettings(settings: ICouchPotatoSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth
|
|
|
|
|
.post(`${this.url}/CouchPotato`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http
|
|
|
|
|
.post<boolean>(`${this.url}/CouchPotato`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getDogNzbSettings(): Observable<IDogNzbSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/DogNzb`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<IDogNzbSettings>(`${this.url}/DogNzb`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveDogNzbSettings(settings: IDogNzbSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth
|
|
|
|
|
.post(`${this.url}/DogNzb`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http
|
|
|
|
|
.post<boolean>(`${this.url}/DogNzb`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getTelegramNotificationSettings(): Observable<ITelegramNotifcationSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/notifications/telegram`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<ITelegramNotifcationSettings>(`${this.url}/notifications/telegram`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveTelegramNotificationSettings(settings: ITelegramNotifcationSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth
|
|
|
|
|
.post(`${this.url}/notifications/telegram`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http
|
|
|
|
|
.post<boolean>(`${this.url}/notifications/telegram`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getJobSettings(): Observable<IJobSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/jobs`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<IJobSettings>(`${this.url}/jobs`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveJobSettings(settings: IJobSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth
|
|
|
|
|
.post(`${this.url}/jobs`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http
|
|
|
|
|
.post<boolean>(`${this.url}/jobs`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getSickRageSettings(): Observable<ISickRageSettings> {
|
|
|
|
|
return this.httpAuth.get(`${this.url}/sickrage`).map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http.get<ISickRageSettings>(`${this.url}/sickrage`, {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public saveSickRageSettings(settings: ISickRageSettings): Observable<boolean> {
|
|
|
|
|
return this.httpAuth
|
|
|
|
|
.post(`${this.url}/sickrage`, JSON.stringify(settings), { headers: this.headers })
|
|
|
|
|
.map(this.extractData).catch(this.handleError);
|
|
|
|
|
return this.http
|
|
|
|
|
.post<boolean>(`${this.url}/sickrage`, JSON.stringify(settings), {headers: this.headers});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|