mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
added test query feature to grafana datasource to generate a test graph on first login
This commit is contained in:
parent
34427f34e8
commit
49b18e17d7
@ -9,4 +9,5 @@ define([
|
||||
'./dashboard/all',
|
||||
'./admin/accountCtrl',
|
||||
'./admin/datasourcesCtrl',
|
||||
'./grafanaDatasource/datasource',
|
||||
], function () {});
|
||||
|
@ -1,8 +1,9 @@
|
||||
define([
|
||||
'angular',
|
||||
'lodash',
|
||||
'kbn',
|
||||
],
|
||||
function (angular, _) {
|
||||
function (angular, _, kbn) {
|
||||
'use strict';
|
||||
|
||||
var module = angular.module('grafana.services');
|
||||
@ -12,6 +13,9 @@ function (angular, _) {
|
||||
function GrafanaDatasource() {
|
||||
this.type = 'grafana';
|
||||
this.grafanaDB = true;
|
||||
this.name = "grafana";
|
||||
this.supportMetrics = true;
|
||||
this.editorSrc = 'app/features/grafanaDatasource/partials/query.editor.html';
|
||||
}
|
||||
|
||||
GrafanaDatasource.prototype.getDashboard = function(id, isTemp) {
|
||||
@ -31,6 +35,14 @@ function (angular, _) {
|
||||
});
|
||||
};
|
||||
|
||||
GrafanaDatasource.prototype.query = function(options) {
|
||||
// get from & to in seconds
|
||||
var from = kbn.parseDate(options.range.from).getTime();
|
||||
var to = kbn.parseDate(options.range.to).getTime();
|
||||
|
||||
return backendSrv.get('/api/metrics/test', { from: from, to: to, maxDataPoints: options.maxDataPoints });
|
||||
};
|
||||
|
||||
GrafanaDatasource.prototype.saveDashboard = function(dashboard) {
|
||||
// remove id if title has changed
|
||||
if (dashboard.title !== dashboard.originalTitle) {
|
@ -0,0 +1,17 @@
|
||||
|
||||
<div class="fluid-row" style="margin-top: 20px">
|
||||
<div class="span2"></div>
|
||||
<div class="grafana-info-box span8">
|
||||
<h5>Test graph</h5>
|
||||
|
||||
<p>
|
||||
This is just a test data source that generates random walk series. If this is your only data source
|
||||
open the left side menu and goto data sources admin screen and add your data sources. You can change
|
||||
data source using the button to the left of the <strong>Add query</strong> button.
|
||||
</p>
|
||||
</div>
|
||||
<div class="span2"></div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
|
@ -6,6 +6,5 @@ define([
|
||||
'./keyboardManager',
|
||||
'./popoverSrv',
|
||||
'./backendSrv',
|
||||
'./grafanaDatasource',
|
||||
],
|
||||
function () {});
|
||||
|
@ -10,8 +10,8 @@ function (angular, _, config) {
|
||||
|
||||
module.service('backendSrv', function($http, alertSrv) {
|
||||
|
||||
this.get = function(url) {
|
||||
return this.request({ method: 'GET', url: url });
|
||||
this.get = function(url, params) {
|
||||
return this.request({ method: 'GET', url: url, params: params });
|
||||
};
|
||||
|
||||
this.delete = function(url) {
|
||||
@ -30,7 +30,8 @@ function (angular, _, config) {
|
||||
var httpOptions = {
|
||||
url: config.appSubUrl + options.url,
|
||||
method: options.method,
|
||||
data: options.data
|
||||
data: options.data,
|
||||
params: options.params,
|
||||
};
|
||||
|
||||
return $http(httpOptions).then(function(results) {
|
||||
@ -54,7 +55,7 @@ function (angular, _, config) {
|
||||
}
|
||||
|
||||
if (data.message) {
|
||||
alertSrv.set("Error", data.message, data.severity, 10000);
|
||||
alertSrv.set("Problem!", data.message, data.severity, 10000);
|
||||
}
|
||||
|
||||
throw data;
|
||||
|
Loading…
Reference in New Issue
Block a user