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.
46 lines
1.1 KiB
46 lines
1.1 KiB
/*
|
|
* Squidex Headless CMS
|
|
*
|
|
* @license
|
|
* Copyright (c) Sebastian Stehle. All rights reserved
|
|
*/
|
|
|
|
import { HttpClient } from '@angular/common/http';
|
|
import { Injectable } from '@angular/core';
|
|
import { Observable } from 'rxjs';
|
|
|
|
import 'framework/angular/http-extensions';
|
|
|
|
import { ApiUrlConfig } from 'framework';
|
|
|
|
export interface UISettingsDto {
|
|
mapType: string;
|
|
mapKey: string;
|
|
}
|
|
|
|
@Injectable()
|
|
export class UIService {
|
|
private settings: UISettingsDto;
|
|
|
|
constructor(
|
|
private readonly http: HttpClient,
|
|
private readonly apiUrl: ApiUrlConfig
|
|
) {
|
|
}
|
|
|
|
public getSettings(): Observable<UISettingsDto> {
|
|
if (this.settings) {
|
|
return Observable.of(this.settings);
|
|
} else {
|
|
const url = this.apiUrl.buildUrl(`api/ui/settings`);
|
|
|
|
return this.http.get<UISettingsDto>(url)
|
|
.catch(error => {
|
|
return Observable.of({ regexSuggestions: [], mapType: 'OSM', mapKey: '' });
|
|
})
|
|
.do(settings => {
|
|
this.settings = settings;
|
|
});
|
|
}
|
|
}
|
|
}
|