Skip to content

Commit

Permalink
console: Configure normalized uplink payload messages
Browse files Browse the repository at this point in the history
  • Loading branch information
johanstokking committed Aug 26, 2022
1 parent 11c38f9 commit 3f1e623
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/webui/console/components/events/utils/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export const dataTypeMap = {

export const applicationUpMessages = [
'uplink_message',
'uplink_normalized',
'join_accept',
'downlink_ack',
'downlink_nack',
Expand Down
4 changes: 4 additions & 0 deletions pkg/webui/console/components/events/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export const getPreviewComponentByApplicationUpMessage = message => {
case 'uplink_message':
messageType = 'ApplicationUplink'
break
case 'uplink_normalized':
messageType = 'ApplicationUplinkNormalized'
break
case 'join_accept':
messageType = 'ApplicationJoinAccept'
break
Expand All @@ -86,6 +89,7 @@ export const getPreviewComponentByApplicationUpMessage = message => {
break
case 'service_data':
messageType = 'ApplicationServiceData'
break
}

return messageType in dataTypeMap ? dataTypeMap[messageType] : DefaultPreview
Expand Down
8 changes: 8 additions & 0 deletions pkg/webui/console/components/pubsub-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,14 @@ export default class PubsubForm extends Component {
component={Input.Toggled}
description={sharedMessages.eventUplinkMessageDesc}
/>
<Form.Field
name="uplink_normalized"
type="toggled-input"
enabledMessage={sharedMessages.uplinkNormalized}
placeholder={pathPlaceholder}
component={Input.Toggled}
description={sharedMessages.eventUplinkNormalizedDesc}
/>
<Form.Field
name="join_accept"
type="toggled-input"
Expand Down
3 changes: 3 additions & 0 deletions pkg/webui/console/components/pubsub-form/mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const mapPubsubToFormValues = pubsub => {
location_solved: mapPubsubMessageTypeToFormValue(pubsub.location_solved),
service_data: mapPubsubMessageTypeToFormValue(pubsub.service_data),
uplink_message: mapPubsubMessageTypeToFormValue(pubsub.uplink_message),
uplink_normalized: mapPubsubMessageTypeToFormValue(pubsub.uplink_normalized),
}

return result
Expand Down Expand Up @@ -137,6 +138,7 @@ export const mapFormValuesToPubsub = (values, appId) => {
location_solved: mapMessageTypeFormValueToPubsubMessageType(values.location_solved),
service_data: mapMessageTypeFormValueToPubsubMessageType(values.service_data),
uplink_message: mapMessageTypeFormValueToPubsubMessageType(values.uplink_message),
uplink_normalized: mapMessageTypeFormValueToPubsubMessageType(values.uplink_normalized),
}

switch (values._provider) {
Expand Down Expand Up @@ -172,4 +174,5 @@ export const blankValues = {
location_solved: { enabled: false, value: '' },
service_data: { enabled: false, value: '' },
uplink_message: { enabled: false, value: '' },
uplink_normalized: { enabled: false, value: '' },
}
16 changes: 16 additions & 0 deletions pkg/webui/console/components/webhook-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ const validationSchema = Yup.object().shape({
})
.test('has path length at most 64 characters', m.messagePathValidateTooLong, messageCheck)
.nullable(),
uplink_normalized: Yup.object()
.shape({
path: Yup.string(),
})
.test('has path length at most 64 characters', m.messagePathValidateTooLong, messageCheck)
.nullable(),
join_accept: Yup.object()
.shape({
path: Yup.string(),
Expand Down Expand Up @@ -516,6 +522,16 @@ export default class WebhookForm extends Component {
component={Input.Toggled}
description={sharedMessages.eventUplinkMessageDesc}
/>
<Form.Field
name="uplink_normalized"
type="toggled-input"
enabledMessage={sharedMessages.uplinkNormalized}
placeholder={pathPlaceholder}
decode={decodeMessageType}
encode={encodeMessageType}
component={Input.Toggled}
description={sharedMessages.eventUplinkNormalizedDesc}
/>
<Form.Field
name="join_accept"
type="toggled-input"
Expand Down
1 change: 1 addition & 0 deletions pkg/webui/console/components/webhook-form/mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export const blankValues = {
},
downlink_api_key: '',
uplink_message: null,
uplink_normalized: null,
join_accept: null,
downlink_ack: null,
downlink_nack: null,
Expand Down
1 change: 1 addition & 0 deletions pkg/webui/console/containers/webhook-add/webhook-add.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const WebhookAdd = props => {
template_fields: fields,
base_url: urlTemplate.parse(template.base_url).expand(fields),
uplink_message: pathExpand(template.uplink_message, fields),
uplink_normalized: pathExpand(template.uplink_normalized, fields),
join_accept: pathExpand(template.join_accept, fields),
downlink_ack: pathExpand(template.downlink_ack, fields),
downlink_nack: pathExpand(template.downlink_nack, fields),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const pubsubEntitySelector = [
'location_solved',
'service_data',
'uplink_message',
'uplink_normalized',
]

const mapStateToProps = state => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const webhookEntitySelector = [
'headers',
'downlink_api_key',
'uplink_message',
'uplink_normalized',
'join_accept',
'downlink_ack',
'downlink_nack',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const selector = [
'name',
'service_data',
'uplink_message',
'uplink_normalized',
]

const mapStateToProps = state => ({
Expand Down
2 changes: 2 additions & 0 deletions pkg/webui/lib/shared-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export default defineMessages({
eventLocationSolvedDesc: 'An integration succeeded locating the end device',
eventServiceDataDesc: 'An integration emits an event',
eventUplinkMessageDesc: 'An uplink message is received by the application',
eventUplinkNormalizedDesc: 'A normalized uplink payload',
eventsCannotShow: 'Cannot show events',
expiry: 'Expiry',
exportJson: 'Export as JSON',
Expand Down Expand Up @@ -416,6 +417,7 @@ export default defineMessages({
uplink: 'Uplink',
uplinkFrameCount: 'Uplink frame count',
uplinkMessage: 'Uplink message',
uplinkNormalized: 'Normalized uplink',
uplinksReceived: 'Uplinks received',
unexposed: 'Unexposed',
used: '{currentValue}/{maxValue} used',
Expand Down

0 comments on commit 3f1e623

Please sign in to comment.