mirror of https://github.com/grafana/grafana
feat(websockets): inital work on websockets, #4355
parent
5b6754ce6c
commit
fbd94fc6ce
@ -0,0 +1,31 @@ |
||||
///<reference path="../../headers/common.d.ts" />
|
||||
|
||||
import config from 'app/core/config'; |
||||
import coreModule from 'app/core/core_module'; |
||||
|
||||
export class LiveSrv { |
||||
conn: any; |
||||
|
||||
init() { |
||||
this.conn = new WebSocket("ws://localhost:3000/ws"); |
||||
this.conn.onclose = function(evt) { |
||||
console.log("WebSocket closed"); |
||||
}; |
||||
this.conn.onmessage = function(evt) { |
||||
console.log("WebSocket message", evt.data); |
||||
}; |
||||
this.conn.onopen = function(evt) { |
||||
console.log("Connection opened"); |
||||
}; |
||||
} |
||||
|
||||
subscribe(name) { |
||||
if (!this.conn) { |
||||
this.init(); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
var instance = new LiveSrv(); |
||||
export {instance as liveSrv}; |
||||
@ -0,0 +1,21 @@ |
||||
///<reference path="../../../headers/common.d.ts" />
|
||||
|
||||
import {liveSrv} from 'app/core/core'; |
||||
|
||||
export class GrafanaStreamDS { |
||||
|
||||
/** @ngInject */ |
||||
constructor(private $q) { |
||||
|
||||
} |
||||
|
||||
query(options) { |
||||
if (options.targets.length === 0) { |
||||
return Promise.resolve({data: []}); |
||||
} |
||||
|
||||
var target = options.targets[0]; |
||||
liveSrv.subscribe(target); |
||||
} |
||||
} |
||||
|
||||
@ -0,0 +1,15 @@ |
||||
///<reference path="../../../headers/common.d.ts" />
|
||||
|
||||
import angular from 'angular'; |
||||
import {GrafanaStreamDS} from './datasource'; |
||||
import {QueryCtrl} from 'app/plugins/sdk'; |
||||
|
||||
class GrafanaQueryCtrl extends QueryCtrl { |
||||
static templateUrl = 'partials/query.editor.html'; |
||||
} |
||||
|
||||
export { |
||||
GrafanaStreamDS as Datasource, |
||||
GrafanaQueryCtrl as QueryCtrl, |
||||
}; |
||||
|
||||
@ -0,0 +1,8 @@ |
||||
<query-editor-row ctrl="ctrl"> |
||||
<li class="tight-form-item"> |
||||
Stream Expression |
||||
</li> |
||||
<li> |
||||
<input type="text" class="tight-form-input input-large" ng-model="ctrl.target.channel"> |
||||
</li> |
||||
</query-editor-row> |
||||
@ -0,0 +1,8 @@ |
||||
{ |
||||
"type": "datasource", |
||||
"name": "Grafana Stream DS", |
||||
"id": "grafana-stream-ds", |
||||
|
||||
"builtIn": true, |
||||
"metrics": true |
||||
} |
||||
Loading…
Reference in new issue