-
Notifications
You must be signed in to change notification settings - Fork 0
feat: supported query variable, better default settings #8
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
96fd6ab
feat: supported query variable
ye11ow 40e08ea
supported value and label
ye11ow 8ee7f4f
lint
ye11ow 8118160
better error
ye11ow b54ccaf
feat: better default config values
ye11ow 20d4c41
updated carsharing
ye11ow d8587d9
default user, default dashboard
ye11ow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,36 @@ | ||
import { CodeEditor, Field } from '@grafana/ui'; | ||
import React, { useState } from 'react'; | ||
|
||
import { VariableQueryProps } from '../types'; | ||
|
||
export const VariableQueryEditor = ({ onChange, query }: VariableQueryProps) => { | ||
const [state, setState] = useState(query); | ||
|
||
const saveQuery = () => { | ||
onChange(state, `${state.query}`); | ||
}; | ||
|
||
const onSQLChange = (sql: string) => { | ||
setState({ | ||
query: sql, | ||
}); | ||
}; | ||
|
||
return ( | ||
<Field | ||
label="" | ||
description="Make sure your query returns either 1 or 2 columns. If your query returns 1 column only, it will be used as the value and label. If it returns 2 columns, the first column will be used as the value while the second column will be used as the label." | ||
> | ||
<CodeEditor | ||
onChange={onSQLChange} | ||
onBlur={saveQuery} | ||
width={600} | ||
height={100} | ||
language="sql" | ||
showLineNumbers={true} | ||
showMiniMap={false} | ||
value={state.query} | ||
/> | ||
</Field> | ||
); | ||
}; |
This file contains hidden or 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 hidden or 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,9 +1,12 @@ | ||
import { DataSourcePlugin } from '@grafana/data'; | ||
import { DataSource } from './datasource'; | ||
import { TpDataSourceOptions, TpQuery } from './types'; | ||
|
||
import { ConfigEditor } from './components/ConfigEditor'; | ||
import { DataSource } from './datasource'; | ||
import { DataSourcePlugin } from '@grafana/data'; | ||
import { QueryEditor } from './components/QueryEditor'; | ||
import { TpQuery, TpDataSourceOptions } from './types'; | ||
import { VariableQueryEditor } from './components/VariableQueryEditor'; | ||
|
||
export const plugin = new DataSourcePlugin<DataSource, TpQuery, TpDataSourceOptions>(DataSource) | ||
.setConfigEditor(ConfigEditor) | ||
.setQueryEditor(QueryEditor); | ||
.setQueryEditor(QueryEditor) | ||
.setVariableQueryEditor(VariableQueryEditor) | ||
Check warning on line 12 in src/module.ts
|
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.