Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grafana 7: Exporter panel doesn't see datasource #40 #43

Conversation

sblrok
Copy link
Contributor

@sblrok sblrok commented Sep 17, 2020

This PR fixes #40

Probem:

We don`t see default datasource in the exporter panel

Solution:

Send an additional request to get all datasources and find one with the isDefault = true

Changes:

Added _getDefaultDatasource functon
Changaed _getGrafanaAPIInfo function

@@ -122,6 +122,12 @@ class Ctrl extends PanelCtrl {
}
}

private async _getDefaultDatasource() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's specify return type here

src/module.ts Outdated
let datasource = await this._getDatasourceByName(datasourceName);
this._datasourceTypes[panel.id] = datasource.type;

if (!panel.datasource) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's be specific here, e.g.: panel.datasource === undefined or panel.datasouce === null

src/module.ts Outdated
@@ -175,12 +181,19 @@ class Ctrl extends PanelCtrl {
private async _getGrafanaAPIInfo() {
this._user = await this._getCurrentUser();
for(let panel of this.panels) {
let datasourceName = panel.datasource;
if(!datasourceName) {
if (panel.type === 'corpglory-data-exporter-panel') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (panel.type === 'corpglory-data-exporter-panel') {
if(panel.type === 'corpglory-data-exporter-panel') {

we don't add space before brackets in our codestyle

src/module.ts Outdated
let datasource = await this._getDatasourceByName(datasourceName);
this._datasourceTypes[panel.id] = datasource.type;

if (!panel.datasource) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!panel.datasource) {
if(!panel.datasource) {

we don't add space before brackets in our codestyle

@rozetko
Copy link
Member

rozetko commented Sep 17, 2020

btw, it fixes #39, not #40 :)

@rozetko
Copy link
Member

rozetko commented Sep 22, 2020

will be recreated

@rozetko rozetko closed this Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Grafana 7: Exporter panel doesn't see datasource
2 participants