Skip to content

Commit

Permalink
feat: remove adhocFilters property from request (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod committed Jun 26, 2024
1 parent 65dbf7a commit bee87dd
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Example request:
{ "target": "Packets", "refId": "A", "payload": { "additional": "optional json" } },
{ "target": "Errors", "refId": "B" }
],
"adhocFilters": [{
"filters": [{
"key": "City",
"operator": "=",
"value": "Berlin"
Expand Down
2 changes: 1 addition & 1 deletion openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ paths:
example:
__interval: {'text': '1s', 'value': '1s'}
__interval_ms: {'text': 1000, 'value': 1000}
adhocFilters:
filters:
type: array
items:
type: object
Expand Down
5 changes: 0 additions & 5 deletions spec/lib/TemplateSrvStub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default class TemplateSrvStub implements TemplateSrv {
templateSettings = { interpolate: /\[\[([\s\S]+?)\]\]/g };
data = {};
variables: TypedVariableModel[] | [] = [];
adhocFilters = [];
// tslint:disable-next-line:max-line-length
// https://github.com/grafana/grafana/blob/ab5a3820d5fff4f0f042024b0aee0632e6a4ca08/public/app/features/variables/utils.ts#L24
/*
Expand Down Expand Up @@ -61,9 +60,5 @@ export default class TemplateSrvStub implements TemplateSrv {
return this.variables;
}

getAdhocFilters(datasourceName: string) {
return this.adhocFilters;
}

updateTemplateData() {}
}
5 changes: 1 addition & 4 deletions src/DataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ export class DataSource extends DataSourceApi<GrafanaQuery, GenericOptions> {
return Promise.resolve({ data: [] });
}

// @ts-ignore
request.adhocFilters = getTemplateSrv().getAdhocFilters(this.name);

options.scopedVars = { ...this.getVariables(), ...options.scopedVars };

return lastValueFrom(
Expand Down Expand Up @@ -298,7 +295,7 @@ export class DataSource extends DataSourceApi<GrafanaQuery, GenericOptions> {

Object.values(getTemplateSrv().getVariables()).forEach((variable) => {
if (variable.type === 'adhoc') {
// These belong to request.adhocFilters
// These belong to request.filters
return;
}

Expand Down
11 changes: 1 addition & 10 deletions src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import { DataQueryRequest, DataSourceJsonData, MetricFindValue, SelectableValue } from '@grafana/data';
import { TemplateSrv as GrafanaTemplateSrv } from '@grafana/runtime';
import { DataQuery } from '@grafana/schema';

declare module '@grafana/runtime' {
export interface TemplateSrv extends GrafanaTemplateSrv {
getAdhocFilters(datasourceName: string): any;
}
}

export interface QueryRequest extends DataQueryRequest<GrafanaQuery> {
adhocFilters?: any[];
}
export interface QueryRequest extends DataQueryRequest<GrafanaQuery> {}

export interface GrafanaQuery extends DataQuery {
editorMode?: QueryEditorMode;
Expand Down

0 comments on commit bee87dd

Please sign in to comment.