Live: check logged-in-user for grafana live (#27436)

This commit is contained in:
Ryan McKinley
2020-09-15 00:01:14 -07:00
committed by GitHub
parent a587bf4f56
commit aa40320b45
6 changed files with 33 additions and 182 deletions
+2 -5
View File
@@ -7,7 +7,7 @@ import Centrifuge, {
SubscribeErrorContext,
} from 'centrifuge/dist/centrifuge.protobuf';
import SockJS from 'sockjs-client';
import { GrafanaLiveSrv, setGrafanaLiveSrv, ChannelHandler } from '@grafana/runtime';
import { GrafanaLiveSrv, setGrafanaLiveSrv, ChannelHandler, config } from '@grafana/runtime';
import { Observable, Subject, BehaviorSubject } from 'rxjs';
import { KeyValue } from '@grafana/data';
@@ -23,13 +23,10 @@ class CentrifugeSrv implements GrafanaLiveSrv {
standardCallbacks: SubscriptionEvents;
constructor() {
console.log('connecting....');
// TODO: better pick this from the URL
this.centrifuge = new Centrifuge(`http://${location.host}/live/sockjs`, {
this.centrifuge = new Centrifuge(`${config.appUrl}live/sockjs`, {
debug: true,
sockjs: SockJS,
});
this.centrifuge.setToken('ABCD');
this.centrifuge.connect(); // do connection
this.connectionState = new BehaviorSubject<boolean>(this.centrifuge.isConnected());