-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tag): add support for history queries (#18)
- Loading branch information
Showing
10 changed files
with
317 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,5 @@ e2e-results/ | |
.idea | ||
|
||
.eslintcache | ||
|
||
provisioning/datasources/datasources.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
module.exports = { | ||
// Prettier configuration provided by Grafana scaffolding | ||
...require("./.config/.prettierrc.js") | ||
...require("./.config/.prettierrc.js"), | ||
|
||
arrowParens: 'avoid' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Do not edit this file directly - it is a template! Copy it to | ||
# provisioning/datasources/datasources.yaml and fill in the SystemLink server | ||
# url and your API key. | ||
|
||
apiVersion: 1 | ||
|
||
config: &config | ||
access: proxy | ||
url: MY_SYSTEMLINK_API_URL | ||
jsonData: | ||
httpHeaderName1: 'x-ni-api-key' | ||
secureJsonData: | ||
httpHeaderValue1: MY_SYSTEMLINK_API_KEY | ||
|
||
datasources: | ||
- name: SystemLink Tags | ||
type: ni-sltag-datasource-prerelease | ||
uid: tag | ||
<<: *config | ||
- name: SystemLink Data Frames | ||
type: ni-sldataframe-datasource | ||
uid: dataframe | ||
<<: *config | ||
- name: SystemLink Notebooks | ||
type: ni-slnotebook-datasource | ||
uid: notebook | ||
<<: *config | ||
- name: SystemLink Systems | ||
type: ni-slsystem-datasource | ||
uid: system | ||
<<: *config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { | ||
DataFrameDTO, | ||
DataQueryRequest, | ||
DataQueryResponse, | ||
DataSourceApi | ||
} from '@grafana/data'; | ||
import { TestingStatus } from '@grafana/runtime'; | ||
import { DataQuery } from '@grafana/schema'; | ||
|
||
export abstract class DataSourceBase<TQuery extends DataQuery> extends DataSourceApi<TQuery> { | ||
query(request: DataQueryRequest<TQuery>): Promise<DataQueryResponse> { | ||
const promises = request.targets | ||
.map(this.prepareQuery, this) | ||
.filter(this.shouldRunQuery, this) | ||
.map(q => this.runQuery(q, request), this); | ||
|
||
return Promise.all(promises).then(data => ({ data })); | ||
} | ||
|
||
prepareQuery(query: TQuery): TQuery { | ||
return { ...this.defaultQuery, ...query }; | ||
} | ||
|
||
abstract defaultQuery: Partial<TQuery> & Omit<TQuery, 'refId'>; | ||
abstract runQuery(query: TQuery, options: DataQueryRequest): Promise<DataFrameDTO>; | ||
abstract shouldRunQuery(query: TQuery): boolean; | ||
abstract testDatasource(): Promise<TestingStatus>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.