src/app/shared/api/settings.service.ts
Properties |
|
Methods |
constructor(http: HttpClient)
|
||||||
Defined in src/app/shared/api/settings.service.ts:10
|
||||||
Parameters :
|
Private getSettingsValue | ||||||
getSettingsValue(data: any)
|
||||||
Defined in src/app/shared/api/settings.service.ts:27
|
||||||
Parameters :
Returns :
string
|
ifSettingConfigured |
ifSettingConfigured(url: string, fn: (value: string) => void)
|
Defined in src/app/shared/api/settings.service.ts:15
|
Returns :
void
|
validateGrafanaDashboardUrl | ||||
validateGrafanaDashboardUrl(uid)
|
||||
Defined in src/app/shared/api/settings.service.ts:31
|
||||
Parameters :
Returns :
any
|
Private settings |
Type : literal type
|
Default value : {}
|
Defined in src/app/shared/api/settings.service.ts:13
|
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import * as _ from 'lodash';
import { ApiModule } from './api.module';
@Injectable({
providedIn: ApiModule
})
export class SettingsService {
constructor(private http: HttpClient) {}
private settings: { [url: string]: string } = {};
ifSettingConfigured(url: string, fn: (value?: string) => void): void {
const setting = this.settings[url];
if (setting === undefined) {
this.http.get(url).subscribe((data: any) => {
this.settings[url] = this.getSettingsValue(data);
this.ifSettingConfigured(url, fn);
});
} else if (setting !== '') {
fn(setting);
}
}
private getSettingsValue(data: any): string {
return data.value || data.instance || '';
}
validateGrafanaDashboardUrl(uid) {
return this.http.get(`api/grafana/validation/${uid}`);
}
}