mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
added url validation when adding data source, Fixes #2043
This commit is contained in:
parent
e2f6633d57
commit
afede880e6
@ -6,7 +6,7 @@
|
||||
Url
|
||||
</li>
|
||||
<li>
|
||||
<input type="text" class="tight-form-input input-xlarge" ng-model='current.url' placeholder="http://my.server.com:8080" required></input>
|
||||
<input type="text" class="tight-form-input input-xlarge" ng-model='current.url' placeholder="http://my.server.com:8080" ng-pattern="/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/" required></input>
|
||||
</li>
|
||||
<li class="tight-form-item">
|
||||
Access <tip>Direct = url is used directly from browser, Proxy = Grafana backend will proxy the request</label>
|
||||
|
@ -126,6 +126,22 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
|
||||
return this._influxRequest('GET', '/query', {q: query});
|
||||
};
|
||||
|
||||
InfluxDatasource.prototype.testDatasource = function() {
|
||||
return this.metricFindQuery('SHOW MEASUREMENTS LIMIT 1').then(function () {
|
||||
return { status: "success", message: "Data source is working", title: "Success" };
|
||||
}, function(err) {
|
||||
var message, title;
|
||||
if (err.statusText) {
|
||||
message = err.statusText;
|
||||
title = "HTTP Error";
|
||||
} else {
|
||||
message = err;
|
||||
title = "Unknown error";
|
||||
}
|
||||
return { status: "error", message: message, title: title };
|
||||
});
|
||||
};
|
||||
|
||||
InfluxDatasource.prototype._influxRequest = function(method, url, data) {
|
||||
var self = this;
|
||||
var deferred = $q.defer();
|
||||
|
Loading…
Reference in New Issue
Block a user