@@ -13,6 +13,8 @@ export class ZabbixVariableQueryEditor extends PureComponent<VariableQueryProps,
1313 { value : VariableQueryTypes . ItemTag , label : 'Item tag' } ,
1414 { value : VariableQueryTypes . Item , label : 'Item' } ,
1515 { value : VariableQueryTypes . ItemValues , label : 'Item values' } ,
16+ { value : VariableQueryTypes . UserMacroName , label : 'User macro Name' } ,
17+ { value : VariableQueryTypes . UserMacroValue , label : 'User macro Value' } ,
1618 ] ;
1719
1820 defaults : VariableQueryData = {
@@ -23,6 +25,8 @@ export class ZabbixVariableQueryEditor extends PureComponent<VariableQueryProps,
2325 application : '' ,
2426 itemTag : '' ,
2527 item : '' ,
28+ userMacroName : '' ,
29+ userMacroValue : '' ,
2630 } ;
2731
2832 constructor ( props : VariableQueryProps ) {
@@ -69,8 +73,8 @@ export class ZabbixVariableQueryEditor extends PureComponent<VariableQueryProps,
6973 } ;
7074
7175 handleQueryChange = ( ) => {
72- const { queryType, group, host, application, itemTag, item } = this . state ;
73- const queryModel = { queryType, group, host, application, itemTag, item } ;
76+ const { queryType, group, host, application, itemTag, item, userMacroName , userMacroValue } = this . state ;
77+ const queryModel = { queryType, group, host, application, itemTag, item, userMacroName , userMacroValue } ;
7478 this . props . onChange ( queryModel , `Zabbix - ${ queryType } ` ) ;
7579 } ;
7680
@@ -81,14 +85,14 @@ export class ZabbixVariableQueryEditor extends PureComponent<VariableQueryProps,
8185 queryType : selectedItem . value ,
8286 } ) ;
8387
84- const { group, host, application, itemTag, item } = this . state ;
88+ const { group, host, application, itemTag, item, userMacroName , userMacroValue } = this . state ;
8589 const queryType = selectedItem . value ;
86- const queryModel = { queryType, group, host, application, itemTag, item } ;
90+ const queryModel = { queryType, group, host, application, itemTag, item, userMacroName , userMacroValue } ;
8791 this . props . onChange ( queryModel , `Zabbix - ${ queryType } ` ) ;
8892 } ;
8993
9094 render ( ) {
91- const { selectedQueryType, legacyQuery, group, host, application, itemTag, item } = this . state ;
95+ const { selectedQueryType, legacyQuery, group, host, application, itemTag, item, userMacroName , userMacroValue } = this . state ;
9296 const { datasource } = this . props ;
9397 const supportsItemTags = datasource ?. zabbix ?. isZabbix54OrHigherSync ( ) || false ;
9498
@@ -116,7 +120,11 @@ export class ZabbixVariableQueryEditor extends PureComponent<VariableQueryProps,
116120 </ InlineField >
117121 </ InlineFieldRow >
118122
119- { selectedQueryType . value !== VariableQueryTypes . Group && (
123+ { ( selectedQueryType . value === VariableQueryTypes . Application ||
124+ selectedQueryType . value === VariableQueryTypes . ItemTag ||
125+ selectedQueryType . value === VariableQueryTypes . Item ||
126+ selectedQueryType . value === VariableQueryTypes . ItemValues ||
127+ selectedQueryType . value === VariableQueryTypes . Host ) && (
120128 < InlineFieldRow >
121129 < InlineField label = "Host" labelWidth = { 16 } >
122130 < ZabbixInput
@@ -129,10 +137,12 @@ export class ZabbixVariableQueryEditor extends PureComponent<VariableQueryProps,
129137 </ InlineFieldRow >
130138 ) }
131139
140+
141+
132142 { ( selectedQueryType . value === VariableQueryTypes . Application ||
133143 selectedQueryType . value === VariableQueryTypes . ItemTag ||
134144 selectedQueryType . value === VariableQueryTypes . Item ||
135- selectedQueryType . value === VariableQueryTypes . ItemValues ) && (
145+ selectedQueryType . value === VariableQueryTypes . ItemValues ) && (
136146 < >
137147 { supportsItemTags && (
138148 < InlineFieldRow >
@@ -173,6 +183,75 @@ export class ZabbixVariableQueryEditor extends PureComponent<VariableQueryProps,
173183 </ InlineField >
174184 </ InlineFieldRow >
175185 ) }
186+
187+ </ >
188+ ) }
189+
190+ { selectedQueryType . value === VariableQueryTypes . UserMacroName && (
191+ < InlineFieldRow >
192+ < InlineField label = "Macro Name" labelWidth = { 16 } >
193+ < Input
194+ width = { 30 }
195+ value = { userMacroName }
196+ onChange = { ( evt ) => this . handleQueryUpdate ( evt , 'userMacroName' ) }
197+ onBlur = { this . handleQueryChange }
198+ />
199+ </ InlineField >
200+ </ InlineFieldRow >
201+ ) }
202+
203+ { selectedQueryType . value === VariableQueryTypes . UserMacroValue && (
204+ < >
205+
206+ < InlineFieldRow >
207+ < InlineField label = "Macro Name" labelWidth = { 16 } >
208+ < Input
209+ width = { 30 }
210+ value = { userMacroName }
211+ onChange = { ( evt ) => this . handleQueryUpdate ( evt , 'userMacroName' ) }
212+ onBlur = { this . handleQueryChange }
213+ />
214+ </ InlineField >
215+ </ InlineFieldRow >
216+
217+ < InlineFieldRow >
218+ < InlineField label = "Macro Value" labelWidth = { 16 } >
219+ < Input
220+ width = { 30 }
221+ value = { userMacroValue }
222+ onChange = { ( evt ) => this . handleQueryUpdate ( evt , 'userMacroValue' ) }
223+ onBlur = { this . handleQueryChange }
224+ />
225+ </ InlineField >
226+ </ InlineFieldRow >
227+
228+ </ >
229+
230+ ) }
231+
232+ { selectedQueryType . value === VariableQueryTypes . Host && (
233+ < >
234+ < InlineFieldRow >
235+ < InlineField label = "Macro Name" labelWidth = { 16 } >
236+ < Input
237+ width = { 30 }
238+ value = { userMacroName }
239+ onChange = { ( evt ) => this . handleQueryUpdate ( evt , 'userMacroName' ) }
240+ onBlur = { this . handleQueryChange }
241+ />
242+ </ InlineField >
243+ </ InlineFieldRow >
244+
245+ < InlineFieldRow >
246+ < InlineField label = "Macro Value" labelWidth = { 16 } >
247+ < Input
248+ width = { 30 }
249+ value = { userMacroValue }
250+ onChange = { ( evt ) => this . handleQueryUpdate ( evt , 'userMacroValue' ) }
251+ onBlur = { this . handleQueryChange }
252+ />
253+ </ InlineField >
254+ </ InlineFieldRow >
176255 </ >
177256 ) }
178257
@@ -188,3 +267,4 @@ export class ZabbixVariableQueryEditor extends PureComponent<VariableQueryProps,
188267 ) ;
189268 }
190269}
270+
0 commit comments