mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.3 KiB
77 lines
2.3 KiB
/*
|
|
* Squidex Headless CMS
|
|
*
|
|
* @license
|
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
|
|
*/
|
|
|
|
import { HttpClient } from '@angular/common/http';
|
|
import { Injectable } from '@angular/core';
|
|
import { Observable, of } from 'rxjs';
|
|
import { catchError } from 'rxjs/operators';
|
|
|
|
import { ApiUrlConfig } from '@app/framework';
|
|
|
|
export interface UISettingsDto {
|
|
readonly canCreateApps: boolean;
|
|
}
|
|
|
|
@Injectable()
|
|
export class UIService {
|
|
constructor(
|
|
private readonly http: HttpClient,
|
|
private readonly apiUrl: ApiUrlConfig
|
|
) {
|
|
}
|
|
|
|
public getCommonSettings(): Observable<UISettingsDto> {
|
|
const url = this.apiUrl.buildUrl(`api/ui/settings`);
|
|
|
|
return this.http.get<UISettingsDto>(url).pipe(
|
|
catchError(() => {
|
|
return of({ mapType: 'OSM', mapKey: '', canCreateApps: true });
|
|
}));
|
|
}
|
|
|
|
public getSharedSettings(appName: string): Observable<object> {
|
|
const url = this.apiUrl.buildUrl(`api/apps/${appName}/ui/settings`);
|
|
|
|
return this.http.get<object>(url).pipe(
|
|
catchError(() => {
|
|
return of({});
|
|
}));
|
|
}
|
|
|
|
public getUserSettings(appName: string): Observable<object> {
|
|
const url = this.apiUrl.buildUrl(`api/apps/${appName}/ui/settings/me`);
|
|
|
|
return this.http.get<object>(url).pipe(
|
|
catchError(() => {
|
|
return of({});
|
|
}));
|
|
}
|
|
|
|
public putSharedSetting(appName: string, key: string, value: any): Observable<any> {
|
|
const url = this.apiUrl.buildUrl(`api/apps/${appName}/ui/settings/${key}`);
|
|
|
|
return this.http.put(url, { value });
|
|
}
|
|
|
|
public putUserSetting(appName: string, key: string, value: any): Observable<any> {
|
|
const url = this.apiUrl.buildUrl(`api/apps/${appName}/ui/settings/me/${key}`);
|
|
|
|
return this.http.put(url, { value });
|
|
}
|
|
|
|
public deleteSharedSetting(appName: string, key: string): Observable<any> {
|
|
const url = this.apiUrl.buildUrl(`api/apps/${appName}/ui/settings/${key}`);
|
|
|
|
return this.http.delete(url);
|
|
}
|
|
|
|
public deleteUserSetting(appName: string, key: string): Observable<any> {
|
|
const url = this.apiUrl.buildUrl(`api/apps/${appName}/ui/settings/me/${key}`);
|
|
|
|
return this.http.delete(url);
|
|
}
|
|
}
|