Skip to content

Commit

Permalink
Merge pull request #70 from axiomhq/fix-repeat-panels-values
Browse files Browse the repository at this point in the history
Fix repeat panels values
  • Loading branch information
dasfmi authored Aug 29, 2024
2 parents ed68b97 + 7e19679 commit 1ed6952
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright {yyyy} {name of copyright owner}
Copyright 2023 axiom.co

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -198,4 +198,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
11 changes: 7 additions & 4 deletions src/datasource.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataFrame, DataQueryRequest, DataQueryResponse, DataSourceInstanceSettings } from '@grafana/data';
import { DataFrame, DataQueryRequest, DataQueryResponse, DataSourceInstanceSettings, ScopedVars } from '@grafana/data';
import { DataSourceWithBackend, getTemplateSrv } from '@grafana/runtime';

import { AxiomQuery, AxiomDataSourceOptions } from './types';
Expand All @@ -11,11 +11,12 @@ export class DataSource extends DataSourceWithBackend<AxiomQuery, AxiomDataSourc
this.url = instanceSettings.url;
}

applyTemplateVariables(query: AxiomQuery) {
applyTemplateVariables(query: AxiomQuery, scopedVars: ScopedVars) {
const templateSrv = getTemplateSrv();

return {
...query,
apl: query.apl ? templateSrv.replace(query.apl) : '',
apl: query.apl ? templateSrv.replace(query.apl, scopedVars) : '',
};
}

Expand Down Expand Up @@ -43,7 +44,9 @@ export class DataSource extends DataSourceWithBackend<AxiomQuery, AxiomDataSourc
return [];
}

return res ? (res.data[0] as DataFrame).fields[0].values.toArray().map((_) => ({ text: _.toString() })) : [];
return res
? (res.data[0] as DataFrame).fields[0].values.map((v) => ({ text: v != null ? v.toString() : null }))
: [];
}

async lookupSchema() {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataQuery, DataSourceJsonData } from '@grafana/data';
import { DataQuery, DataSourceJsonData } from '@grafana/schema';

export interface AxiomQuery extends DataQuery {
apl: string;
Expand Down

0 comments on commit 1ed6952

Please sign in to comment.