@@ -30,6 +30,9 @@ import _ from 'lodash';
3030const triggerConditionToLabel = {
3131 device_disconnected : 'Device Disconnected' ,
3232 device_connected : 'Device Connected' ,
33+ device_registered : 'Device Registered' ,
34+ device_deletion_finished : 'Device Deletion Finished' ,
35+ device_deletion_started : 'Device Deletion Started' ,
3336 device_error : 'Device Error' ,
3437 device_empty_cache_received : 'Empty Cache Received' ,
3538 incoming_data : 'Incoming Data' ,
@@ -99,30 +102,39 @@ const SimpleTriggerForm = ({
99102} : SimpleTriggerFormProps ) : React . ReactElement => {
100103 const endpointList =
101104 simpleTriggerInterface ?. mappings . map ( ( mapping : AstarteMapping ) => mapping . endpoint ) || [ ] ;
105+
102106 const isDeviceTrigger = _ . get ( simpleTrigger , 'type' ) === 'device_trigger' ;
103107 const isDataTrigger = _ . get ( simpleTrigger , 'type' ) === 'data_trigger' ;
104108 const hasTargetDevice = _ . get ( simpleTrigger , 'deviceId' ) != null ;
105109 const hasTargetGroup = _ . get ( simpleTrigger , 'groupName' ) != null ;
110+
106111 // eslint-disable-next-line no-nested-ternary
107112 const triggerTargetType = hasTargetDevice ? 'device' : hasTargetGroup ? 'group' : 'all_devices' ;
113+
108114 const triggerInterfaceName = _ . get ( simpleTrigger , 'interfaceName' ) as string | undefined ;
109115 const hasSelectedInterface = triggerInterfaceName != null && triggerInterfaceName !== '*' ;
116+
110117 const triggerValueMatchOperator : AstarteSimpleDataTrigger [ 'valueMatchOperator' ] | undefined =
111118 _ . get ( simpleTrigger , 'valueMatchOperator' ) ;
119+
112120 const hasSelectedOperator =
113121 triggerValueMatchOperator != null && triggerValueMatchOperator !== '*' ;
122+
114123 const triggerMatchPath : AstarteSimpleDataTrigger [ 'matchPath' ] | undefined = _ . get (
115124 simpleTrigger ,
116125 'matchPath' ,
117126 ) ;
127+
118128 const triggerInterfaceType = useMemo (
119129 ( ) => ( simpleTriggerInterface ? simpleTriggerInterface . type : null ) ,
120130 [ simpleTriggerInterface ] ,
121131 ) ;
132+
122133 const triggerInterfaceAggregation = useMemo (
123134 ( ) => ( simpleTriggerInterface ? simpleTriggerInterface . aggregation : null ) ,
124135 [ simpleTriggerInterface ] ,
125136 ) ;
137+
126138 const triggerInterfacePathType = useMemo ( ( ) => {
127139 if ( ! simpleTriggerInterface || ! triggerMatchPath ) {
128140 return null ;
@@ -291,6 +303,9 @@ const SimpleTriggerForm = ({
291303 options = [
292304 'device_connected' ,
293305 'device_disconnected' ,
306+ 'device_registered' ,
307+ 'device_deletion_finished' ,
308+ 'device_deletion_started' ,
294309 'device_error' ,
295310 'device_empty_cache_received' ,
296311 ] ;
@@ -369,23 +384,68 @@ const SimpleTriggerForm = ({
369384 < Stack gap = { 3 } >
370385 < Row >
371386 < Col sm = { 12 } >
372- < Form . Group controlId = "triggerSimpleTriggerType" >
373- < Form . Label > Trigger type</ Form . Label >
387+ < Form . Group controlId = "triggerPath" >
388+ < Form . Label > Path</ Form . Label >
389+ < Form . Control
390+ type = { hasNumericKnownValue ? 'number' : 'text' }
391+ autoComplete = "off"
392+ required
393+ readOnly = { isReadOnly || isLoadingInterfaceMajors || isLoadingInterface }
394+ value = { _ . get ( simpleTrigger , 'matchPath' ) || '' }
395+ isInvalid = { _ . get ( validationErrors , 'matchPath' ) != null }
396+ onChange = { handleTriggerInterfacePathChange }
397+ list = "endpoints-list"
398+ />
399+ < Form . Control . Feedback type = "invalid" >
400+ { _ . get ( validationErrors , 'matchPath' ) }
401+ </ Form . Control . Feedback >
402+ < datalist id = "endpoints-list" >
403+ { endpointList . map ( ( endpoint , index ) => (
404+ < option key = { index } value = { endpoint } >
405+ { endpoint }
406+ </ option >
407+ ) ) }
408+ </ datalist >
409+ </ Form . Group >
410+ </ Col >
411+ </ Row >
412+ < Row >
413+ < Col sm = { 4 } >
414+ < Form . Group controlId = "triggerOperator" >
415+ < Form . Label > Operator</ Form . Label >
374416 < Form . Select
375- name = "triggerSimpleTriggerType "
376- disabled = { isReadOnly }
377- value = { _ . get ( simpleTrigger , 'type' ) }
378- onChange = { handleTriggerTypeChange }
379- isInvalid = { _ . get ( validationErrors , 'type ' ) != null }
417+ name = "triggerOperator "
418+ disabled = { isReadOnly || isLoadingInterfaceMajors || isLoadingInterface }
419+ value = { triggerValueMatchOperator || '*' }
420+ onChange = { handleTriggerInterfaceOperatorChange }
421+ isInvalid = { _ . get ( validationErrors , 'valueMatchOperator ' ) != null }
380422 >
381- < option value = "device_trigger" > Device Trigger</ option >
382- < option value = "data_trigger" > Data Trigger</ option >
423+ { renderTriggerOperatorOptions ( ) }
383424 </ Form . Select >
384425 < Form . Control . Feedback type = "invalid" >
385- { _ . get ( validationErrors , 'type ' ) }
426+ { _ . get ( validationErrors , 'valueMatchOperator ' ) }
386427 </ Form . Control . Feedback >
387428 </ Form . Group >
388429 </ Col >
430+ { hasSelectedOperator && (
431+ < Col sm = { 8 } >
432+ < Form . Group controlId = "triggerKnownValue" >
433+ < Form . Label > Value</ Form . Label >
434+ < Form . Control
435+ type = "text"
436+ autoComplete = "off"
437+ required
438+ readOnly = { isReadOnly || isLoadingInterfaceMajors || isLoadingInterface }
439+ value = { String ( _ . get ( simpleTrigger , 'knownValue' ) ?? '' ) }
440+ onChange = { handleTriggerInterfaceKnownValueChange }
441+ isInvalid = { _ . get ( validationErrors , 'knownValue' ) != null }
442+ />
443+ < Form . Control . Feedback type = "invalid" >
444+ { _ . get ( validationErrors , 'knownValue' ) }
445+ </ Form . Control . Feedback >
446+ </ Form . Group >
447+ </ Col >
448+ ) }
389449 </ Row >
390450 < Row >
391451 < Col sm = { hasTargetDevice || hasTargetGroup ? 4 : 12 } >
@@ -515,18 +575,10 @@ const SimpleTriggerForm = ({
515575 value = { _ . get ( simpleTrigger , 'matchPath' ) || '' }
516576 isInvalid = { _ . get ( validationErrors , 'matchPath' ) != null }
517577 onChange = { handleTriggerInterfacePathChange }
518- list = "endpoints-list"
519578 />
520579 < Form . Control . Feedback type = "invalid" >
521580 { _ . get ( validationErrors , 'matchPath' ) }
522581 </ Form . Control . Feedback >
523- < datalist id = "endpoints-list" >
524- { endpointList . map ( ( endpoint , index ) => (
525- < option key = { index } value = { endpoint } >
526- { endpoint }
527- </ option >
528- ) ) }
529- </ datalist >
530582 </ Form . Group >
531583 </ Col >
532584 </ Row >
0 commit comments