All files / src/app/shared/api prometheus.service.ts

100% Statements 19/19
76.92% Branches 10/13
100% Functions 4/4
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 3310x 10x         10x 10x         10x 29x   29x   10x 3x     10x 1x     10x 2x     2x   10x  
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
 
import { Observable } from 'rxjs';
 
import { PrometheusAlert, PrometheusNotification } from '../models/prometheus-alerts';
import { ApiModule } from './api.module';
import { SettingsService } from './settings.service';
 
@Injectable({
  providedIn: ApiModule
})
export class PrometheusService {
  private baseURL = 'api/prometheus';
 
  constructor(private http: HttpClient, private settingsService: SettingsService) {}
 
  ifAlertmanagerConfigured(fn): void {
    this.settingsService.ifSettingConfigured('api/settings/alertmanager-api-host', fn);
  }
 
  list(Eparams = {}): Observable<PrometheusAlert[]> {
    return this.http.get<PrometheusAlert[]>(this.baseURL, { params });
  }
 
  getNotifications(notification?: PrometheusNotification): Observable<PrometheusNotification[]> {
    const url = `${this.baseURL}/notifications?from=${
      notification && notification.id ? notification.id : 'last'
    }`;
    return this.http.get<PrometheusNotification[]>(url);
  }
}