9 files changed +169
-122
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ data from within Grafana.
10
10
For detailed instructions on how to install the plugin on Grafana Cloud or
11
11
locally, please check out the [ Plugin installation docs] ( https://grafana.com/docs/grafana/latest/plugins/installation/ ) .
12
12
13
+ Read the guide on QuestDB website: [ Third-party Tools - Grafana] ( https://questdb.io/docs/third-party-tools/grafana/ ) .
14
+
13
15
## Configuration
14
16
15
17
### QuestDB user for the data source
@@ -179,3 +181,4 @@ You may choose to hide this variable from view as it serves no further purpose.
179
181
- Configure and use [ Templates and variables] ( https://grafana.com/docs/grafana/latest/variables/ ) .
180
182
- Add [ Transformations] ( https://grafana.com/docs/grafana/latest/panels/transformations/ ) .
181
183
- Set up alerting; refer to [ Alerts overview] ( https://grafana.com/docs/grafana/latest/alerting/ ) .
184
+ - Read the [ Plugin guide] ( https://questdb.io/docs/third-party-tools/grafana/ ) on QuestDB website
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import { render } from '@testing-library/react' ;
3
3
import { GroupByEditor } from './GroupBy' ;
4
- import { selectors } from " ../../selectors" ;
4
+ import { selectors } from ' ../../selectors' ;
5
5
6
6
describe ( 'GroupByEditor' , ( ) => {
7
7
it ( 'renders correctly' , ( ) => {
8
- const result = render ( < GroupByEditor fieldsList = { [ ] } groupBy = { [ ] } onGroupByChange = { ( ) => { } } labelAndTooltip = { selectors . components . QueryEditor . QueryBuilder . SAMPLE_BY } /> ) ;
8
+ const result = render (
9
+ < GroupByEditor
10
+ fieldsList = { [ ] }
11
+ groupBy = { [ ] }
12
+ onGroupByChange = { ( ) => { } }
13
+ isDisabled = { false }
14
+ labelAndTooltip = { selectors . components . QueryEditor . QueryBuilder . SAMPLE_BY }
15
+ />
16
+ ) ;
9
17
expect ( result . container . firstChild ) . not . toBeNull ( ) ;
10
18
} ) ;
11
19
} ) ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ interface GroupByEditorProps {
10
10
groupBy : string [ ] ;
11
11
onGroupByChange : ( groupBy : string [ ] ) => void ;
12
12
labelAndTooltip : typeof selectors . components . QueryEditor . QueryBuilder . GROUP_BY ;
13
+ isDisabled : boolean ;
13
14
}
14
15
export const GroupByEditor = ( props : GroupByEditorProps ) => {
15
16
const columns : SelectableValue [ ] = ( props . fieldsList || [ ] ) . map ( ( f ) => ( { label : f . label , value : f . name } ) ) ;
@@ -34,7 +35,7 @@ export const GroupByEditor = (props: GroupByEditorProps) => {
34
35
< EditorField tooltip = { tooltip } label = { label } >
35
36
< MultiSelect
36
37
options = { columns }
37
- placeholder = " Choose"
38
+ placeholder = { props . isDisabled ? 'Table is missing designated timestamp' : ' Choose' }
38
39
isOpen = { isOpen }
39
40
onOpenMenu = { ( ) => setIsOpen ( true ) }
40
41
onCloseMenu = { ( ) => setIsOpen ( false ) }
@@ -43,6 +44,7 @@ export const GroupByEditor = (props: GroupByEditorProps) => {
43
44
value = { groupBy }
44
45
allowCustomValue = { true }
45
46
width = { 50 }
47
+ disabled = { props . isDisabled }
46
48
/>
47
49
</ EditorField >
48
50
) ;
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ interface LimitEditorProps {
8
8
onLimitChange : ( limit : string ) => void ;
9
9
}
10
10
export const LimitEditor = ( props : LimitEditorProps ) => {
11
- const [ limit , setLimit ] = useState ( props . limit || '100' ) ;
11
+ const [ limit , setLimit ] = useState ( props . limit ) ;
12
12
const { label, tooltip } = selectors . components . QueryEditor . QueryBuilder . LIMIT ;
13
13
14
14
return (
Original file line number Diff line number Diff line change @@ -230,6 +230,7 @@ export const QueryBuilder = (props: QueryBuilderProps) => {
230
230
onGroupByChange = { onGroupByChange }
231
231
fieldsList = { fieldsList }
232
232
labelAndTooltip = { selectors . components . QueryEditor . QueryBuilder . SAMPLE_BY }
233
+ isDisabled = { builder . timeField . length === 0 }
233
234
/>
234
235
</ EditorRow >
235
236
) }
@@ -264,7 +265,11 @@ export const QueryBuilder = (props: QueryBuilderProps) => {
264
265
265
266
{ builder . mode === BuilderMode . Trend && (
266
267
< EditorRow >
267
- < SampleByFillEditor fills = { builder . sampleByFill || [ ] } onFillsChange = { onFillChange } />
268
+ < SampleByFillEditor
269
+ fills = { builder . sampleByFill || [ ] }
270
+ onFillsChange = { onFillChange }
271
+ isDisabled = { builder . timeField . length === 0 }
272
+ />
268
273
</ EditorRow >
269
274
) }
270
275
@@ -275,6 +280,7 @@ export const QueryBuilder = (props: QueryBuilderProps) => {
275
280
onGroupByChange = { onGroupByChange }
276
281
fieldsList = { fieldsList }
277
282
labelAndTooltip = { selectors . components . QueryEditor . QueryBuilder . GROUP_BY }
283
+ isDisabled = { builder . timeField . length === 0 }
278
284
/>
279
285
</ EditorRow >
280
286
) }
@@ -295,7 +301,7 @@ export const QueryBuilder = (props: QueryBuilderProps) => {
295
301
fieldsList = { getOrderByFields ( builder , fieldsList ) }
296
302
/>
297
303
< EditorRow >
298
- < LimitEditor limit = { builder . limit || 100 } onLimitChange = { onLimitChange } />
304
+ < LimitEditor limit = { builder . limit } onLimitChange = { onLimitChange } />
299
305
</ EditorRow >
300
306
</ EditorRows >
301
307
) : null ;
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { GroupBase, OptionsOrGroups } from 'react-select';
9
9
interface FillEditorProps {
10
10
fills : string [ ] ;
11
11
onFillsChange : ( fills : string [ ] ) => void ;
12
+ isDisabled : boolean ;
12
13
}
13
14
14
15
const fillModes : SelectableValue [ ] = [ ] ;
@@ -85,6 +86,8 @@ export const SampleByFillEditor = (props: FillEditorProps) => {
85
86
width = { 50 }
86
87
isClearable = { true }
87
88
hideSelectedOptions = { true }
89
+ placeholder = { props . isDisabled ? 'Table is missing designated timestamp' : 'Choose' }
90
+ disabled = { props . isDisabled }
88
91
/>
89
92
</ EditorField >
90
93
) ;
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export const TableSelect = (props: Props) => {
21
21
22
22
useEffect ( ( ) => {
23
23
async function fetchTables ( ) {
24
- const tables = await datasource . fetchTables ( ) ;
24
+ const tables = ( await datasource . fetchTables ( ) ) . sort ( ( a , b ) => a . tableName . localeCompare ( b . tableName ) ) ;
25
25
const values = tables . map ( ( t ) => ( { label : t . tableName , value : t . tableName } ) ) ;
26
26
// Add selected value to the list if it does not exist.
27
27
if ( table && ! tables . find ( ( x ) => x . tableName === table ) && props . mode !== BuilderMode . Trend ) {
0 commit comments