Skip to content
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

Allow to only set frequency plans within the same band #6747

Merged
merged 5 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ For details about compatibility between different releases, see the **Commitment

- Rate limiting classes for individual HTTP paths.
- Rate limiting keys for HTTP endpoints now contain the caller API key ID when available. The caller IP is still available as a fallback.
- Allow users to set multiple frequency plans only in the same band in the Console.

### Changed

Expand Down
14 changes: 12 additions & 2 deletions pkg/webui/components/key-value-map/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const Entry = ({
removeMessage,
distinctOptions,
atLeastOneEntry,
filterByTag,
}) => {
const [currentValue, setCurrentValue] = useState(value)
const [newOptions, setNewOptions] = useState(undefined)
Expand Down Expand Up @@ -98,8 +99,15 @@ const Entry = ({
} else {
newOptions = options.filter(v => !fieldValue.includes(v.value))
}
setNewOptions(newOptions)
}, [currentValue, options, fieldValue])

let taggedOptions = newOptions
if (fieldValue.length >= 2 && filterByTag) {
const selectedOption = options.find(v => v.value === fieldValue[0])
taggedOptions = newOptions.filter(v => selectedOption.tag === v.tag)
}

setNewOptions(taggedOptions)
}, [currentValue, options, fieldValue, filterByTag])

const showRemoveButton = atLeastOneEntry ? index !== 0 : true

Expand Down Expand Up @@ -157,6 +165,7 @@ Entry.propTypes = {
atLeastOneEntry: PropTypes.bool,
distinctOptions: PropTypes.bool,
fieldValue: PropTypes.any,
filterByTag: PropTypes.bool,
index: PropTypes.number.isRequired,
indexAsKey: PropTypes.bool.isRequired,
inputElement: PropTypes.elementType.isRequired,
Expand Down Expand Up @@ -184,6 +193,7 @@ Entry.defaultProps = {
distinctOptions: false,
fieldValue: undefined,
atLeastOneEntry: false,
filterByTag: false,
}

export default Entry
4 changes: 4 additions & 0 deletions pkg/webui/components/key-value-map/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const KeyValueMap = ({
valuePlaceholder,
distinctOptions,
atLeastOneEntry,
filterByTag,
}) => {
const handleEntryChange = useCallback(
(index, newValues) => {
Expand Down Expand Up @@ -98,6 +99,7 @@ const KeyValueMap = ({
removeMessage={removeMessage}
distinctOptions={distinctOptions}
atLeastOneEntry={atLeastOneEntry}
filterByTag={filterByTag}
/>
))}
</div>
Expand All @@ -122,6 +124,7 @@ KeyValueMap.propTypes = {
className: PropTypes.string,
disabled: PropTypes.bool,
distinctOptions: PropTypes.bool,
filterByTag: PropTypes.bool,
indexAsKey: PropTypes.bool,
inputElement: PropTypes.elementType,
isReadOnly: PropTypes.func,
Expand Down Expand Up @@ -157,6 +160,7 @@ KeyValueMap.defaultProps = {
removeMessage: undefined,
distinctOptions: false,
atLeastOneEntry: false,
filterByTag: false,
}

export default KeyValueMap
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const GatewayFrequencyPlansSelect = () => {
additionalInputProps={{ options: freqPlanOptions }}
distinctOptions
atLeastOneEntry
filterByTag
required
/>
)
Expand Down
5 changes: 3 additions & 2 deletions pkg/webui/console/containers/freq-plans-select/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@

import { defineMessages } from 'react-intl'

export const formatOptions = plans => plans.map(plan => ({ value: plan.id, label: plan.name }))
export const formatOptions = plans =>
plans.map(plan => ({ value: plan.id, label: plan.name, tag: plan.band_id }))
export const m = defineMessages({
warning: 'Frequency plans unavailable',
none: 'Do not set a frequency plan',
selectFrequencyPlan: 'Select a frequency plan...',
addFrequencyPlan: 'Add frequency plan',
frequencyPlanDescription:
'Note: most gateways use a single frequency plan. Some 16 and 64 channel gateways however allow setting multiple.',
'Note: most gateways use a single frequency plan. Some 16 and 64 channel gateways however allow setting multiple. Furthermore, setting frequency plans from different brands is not supported.',
ryaplots marked this conversation as resolved.
Show resolved Hide resolved
})
2 changes: 1 addition & 1 deletion pkg/webui/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@
"console.containers.freq-plans-select.utils.none": "Do not set a frequency plan",
"console.containers.freq-plans-select.utils.selectFrequencyPlan": "Select a frequency plan...",
"console.containers.freq-plans-select.utils.addFrequencyPlan": "Add frequency plan",
"console.containers.freq-plans-select.utils.frequencyPlanDescription": "Note: most gateways use a single frequency plan. Some 16 and 64 channel gateways however allow setting multiple.",
"console.containers.freq-plans-select.utils.frequencyPlanDescription": "Note: most gateways use a single frequency plan. Some 16 and 64 channel gateways however allow setting multiple. Furthermore, setting frequency plans from different brands is not supported.",
"console.containers.gateway-connection.index.lastSeenAvailableTooltip": "The elapsed time since the network registered the last activity of this gateway. This is determined from received uplinks, or sent status messages of this gateway.",
"console.containers.gateway-connection.index.disconnectedTooltip": "The gateway has currently no TCP connection established with the Gateway Server. For (rare) UDP based gateways, this can also mean that the gateway initiated no pull/push data request within the last 30 seconds.",
"console.containers.gateway-connection.index.connectedTooltip": "This gateway is connected to the Gateway Server but the network has not registered any activity (sent uplinks or status messages) from it yet.",
Expand Down
Loading