export class PhilDatasource{
private type: any;
private url: any;
private name: any;
private q: any;
private backendSrv: any;
private templateSrv: any;
/** @ngInject */
constructor(instanceSettings, $q, backendSrv, templateSrv) {
this.type = instanceSettings.type;
this.url = instanceSettings.url;
this.name = instanceSettings.name;
this.q = $q;
this.backendSrv = backendSrv;
this.templateSrv = templateSrv;
}
query(options): any {
....
}
testDatasource(): boolean {
return true; // to be developed, just want testDatasource to be called for now
}
}
Module.ts is exporting this. So everything builds and deploys, all good, as it follows the example. However, when I click on Save and Test I get the following error within Grafana:
TestDB plugin failed
Plugin module is missing Datasource constructor
Am I doing something wrong? I’ve checked other datasources code and my constructor looks okay to me, I’m new to typescript maybe I’m doing something wrong.
I took your code and built it with tsc and loaded it into Grafana without any problems. How are you building your code? Have you transpiled the code into JavaScript?
A very basic setup for building TypeScript (might need sudo for the npm install to install it as a global package):
Yes I have, and it loads everything works until I click on Save and Test. It does say the error is coming from SystemJS. Should I be using something else?