src/app/shared/grafana/grafana.service.ts
Grafana Service.
Methods |
constructor(sharedAboutService: SharedAboutService)
|
||||||||
Defined in src/app/shared/grafana/grafana.service.ts:16
|
||||||||
Constructor
Parameters :
|
getDashboardApplication |
getDashboardApplication(streamName: string, appName: string)
|
Defined in src/app/shared/grafana/grafana.service.ts:70
|
Return an observable which contains the URL to the application dashboard
Returns :
Observable<string>
|
getDashboardApplicationInstance |
getDashboardApplicationInstance(streamName: string, appName: string, guid: string)
|
Defined in src/app/shared/grafana/grafana.service.ts:88
|
Return an observable which contains the URL to the application instance dashboard
Returns :
Observable<string>
|
getDashboardStream | ||||||||
getDashboardStream(stream: StreamDefinition)
|
||||||||
Defined in src/app/shared/grafana/grafana.service.ts:53
|
||||||||
Return an observable which contains the URL to the stream dashboard
Parameters :
Returns :
Observable<string>
|
getDashboardStreams |
getDashboardStreams()
|
Defined in src/app/shared/grafana/grafana.service.ts:38
|
Return an observable which contains the URL to the streams dashboard
Returns :
Observable<string>
|
isAllowed |
isAllowed()
|
Defined in src/app/shared/grafana/grafana.service.ts:29
|
Return an observable which contains a boolean True if Grafana is enabled
Returns :
Observable<boolean>
|
import { Injectable } from '@angular/core';
import { StreamDefinition } from '../../streams/model/stream-definition';
import { Observable, of } from 'rxjs';
import { SharedAboutService } from '../services/shared-about.service';
import { map } from 'rxjs/operators';
import { FeatureInfo } from '../model/about/feature-info.model';
import { AboutInfo } from '../model/about/about-info.model';
import { GrafanaInfo } from '../model/about/grafana.model';
/**
* Grafana Service.
*
* @author Damien Vitrac
*/
@Injectable()
export class GrafanaService {
/**
* Constructor
* @param sharedAboutService
*/
constructor(private sharedAboutService: SharedAboutService) {
}
/**
* Return an observable which contains a boolean
* True if Grafana is enabled
*/
isAllowed(): Observable<boolean> {
return this.sharedAboutService
.getFeatureInfo()
.pipe(map((featuredInfo: FeatureInfo) => featuredInfo.grafanaEnabled));
}
/**
* Return an observable which contains the URL to the streams dashboard
*/
getDashboardStreams(): Observable<string> {
return this.sharedAboutService
.getAboutInfo()
.pipe(
map((aboutInfo: AboutInfo): GrafanaInfo => aboutInfo.grafanaInfo),
map((grafanaInfo: GrafanaInfo): string => {
return grafanaInfo.url + '/d/scdf-streams/streams?refresh=' + grafanaInfo.refreshInterval + 's';
})
);
}
/**
* Return an observable which contains the URL to the stream dashboard
* @param {StreamDefinition} stream
*/
getDashboardStream(stream: StreamDefinition): Observable<string> {
return this.sharedAboutService
.getAboutInfo()
.pipe(
map((aboutInfo: AboutInfo): GrafanaInfo => aboutInfo.grafanaInfo),
map((grafanaInfo: GrafanaInfo): string => {
return grafanaInfo.url + '/d/scdf-applications/applications?refresh=' + grafanaInfo.refreshInterval +
's&var-stream_name=' + stream.name + '&var-application_name=All';
})
);
}
/**
* Return an observable which contains the URL to the application dashboard
* @param streamName
* @param appName
*/
getDashboardApplication(streamName: string, appName: string): Observable<string> {
return this.sharedAboutService
.getAboutInfo()
.pipe(
map((aboutInfo: AboutInfo): GrafanaInfo => aboutInfo.grafanaInfo),
map((grafanaInfo: GrafanaInfo): string => {
return grafanaInfo.url + '/d/scdf-applications/applications?refresh=' + grafanaInfo.refreshInterval +
's&var-stream_name=' + streamName + '&var-application_name=' + appName + '&var-name=All';
})
);
}
/**
* Return an observable which contains the URL to the application instance dashboard
* @param streamName
* @param appName
* @param guid
*/
getDashboardApplicationInstance(streamName: string, appName: string, guid: string): Observable<string> {
return this.sharedAboutService
.getAboutInfo()
.pipe(
map((aboutInfo: AboutInfo): GrafanaInfo => aboutInfo.grafanaInfo),
map((grafanaInfo: GrafanaInfo): string => {
return grafanaInfo.url + '/d/scdf-applications/applications?refresh=' + grafanaInfo.refreshInterval +
's&var-stream_name=' + streamName + '&var-application_name=' + appName +
'&var-name=All&var-application_guid=' + guid;
})
);
}
}