Commit afede880 by Torkel Ödegaard

added url validation when adding data source, Fixes #2043

parent e2f6633d
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment