influxdb: validate database exist when saving data source, fixes #7864

pull/8095/head
Torkel Ödegaard 9 years ago
parent 83e0f69cde
commit 89a7c2c686
  1. 2
      public/app/core/components/query_part/query_part.ts
  2. 11
      public/app/plugins/datasource/influxdb/datasource.ts
  3. 1
      public/app/plugins/datasource/influxdb/query_part.ts

@ -119,5 +119,3 @@ export function identityRenderer(part, innerExpr) {
export function quotedIdentityRenderer(part, innerExpr) {
return '"' + part.params[0] + '"';
}

@ -193,8 +193,17 @@ export default class InfluxDatasource {
}
testDatasource() {
return this.metricFindQuery('SHOW MEASUREMENTS LIMIT 1').then(() => {
return this.metricFindQuery('SHOW DATABASES').then(res => {
let found = _.find(res, {text: this.database});
if (!found) {
return { status: "error", message: "Could not find the specified database name.", title: "DB Not found" };
}
return { status: "success", message: "Data source is working", title: "Success" };
}).catch(err => {
if (err.data && err.message) {
return { status: "error", message: err.data.message, title: "InfluxDB Error" };
}
return { status: "error", message: err.toString(), title: "InfluxDB Error" };
});
}

@ -292,7 +292,6 @@ register({
renderer: functionRenderer,
});
debugger;
register({
type: 'holt_winters_with_fit',
addStrategy: addTransformationStrategy,

Loading…
Cancel
Save