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

Managed gateway #7178

Draft
wants to merge 15 commits into
base: v3.31
Choose a base branch
from
Draft

Managed gateway #7178

wants to merge 15 commits into from

Conversation

PavelJankoski
Copy link
Contributor

Summary

Implementation of managed gateway functionality.

Changes

  • Change gateway registration form to be able to claim gateway.
  • New menu item for managed gateway in the gateway details.
  • Connection settings and wifi profiles screens.

Testing

Steps
  1. Login to console.
  2. Go to gateways screen.
  3. Click on register gateway.
  4. Enter managed gateway EUI.
  5. Claim gateway.
  6. In the gateway details screen go to connection settings and wifi profiles screens.
  7. Try all CRUD operations in those screens.
Results

image

image

image

image

image

image

image

image

image

image

Notes for Reviewers

This is still WIP and needs backend integration. Just to have perception of how the UI turned out so far. Also some of the icons will be changed in the UI(i couldn't find related icon on the google material icons library from the wireframes).

Checklist

  • Scope: The referenced issue is addressed, there are no unrelated changes.
  • Compatibility: The changes are backwards compatible with existing API, storage, configuration and CLI, according to the compatibility commitments in README.md for the chosen target branch.
  • Documentation: Relevant documentation is added or updated.
  • Testing: The steps/process to test this feature are clearly explained including testing for regressions.
  • Infrastructure: If infrastructural changes (e.g., new RPC, configuration) are needed, a separate issue is created in the infrastructural repositories.
  • Changelog: Significant features, behavior changes, deprecations and fixes are added to CHANGELOG.md.
  • Commits: Commit messages follow guidelines in CONTRIBUTING.md, there are no fixup commits left.

@PavelJankoski PavelJankoski added this to the 2024 Q3 milestone Jul 6, 2024
@PavelJankoski PavelJankoski self-assigned this Jul 6, 2024
@github-actions github-actions bot added the ui/web This is related to a web interface label Jul 6, 2024
@johanstokking johanstokking mentioned this pull request Jul 9, 2024
13 tasks
Copy link
Contributor

@ryaplots ryaplots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!
After a first look, see my comments:

Comment on lines +16 to +17
width: 100%
display: flex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use utility classes for this?

Comment on lines +131 to +143
{accessPoints.map(a => (
<AccessPointListItem
key={a.ssid}
accessPoint={{ ...a, _type: 'all' }}
onClick={handleSelectAccessPoint}
isActive={value.ssid === a.ssid}
/>
))}
<AccessPointListItem
accessPoint={{ ssid: '', password: '', _type: 'other' }}
onClick={handleSelectAccessPoint}
isActive={value._type === 'other'}
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a FetchSelect component, can we use that one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that at first but seems like we cannot have custom styling of the options in a select component. (Cannot add additional divs, paragraphs, icons etc.)

{managedGateway.result.system_metrics.temperature} &deg;C
</div>
<Link.Anchor primary href="/gateways/adding-gateways">
{m.officialDocumentation.defaultMessage}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should then be a <Message />

Suggested change
{m.officialDocumentation.defaultMessage}
<Message content={m.officialDocumentation} />

)}
</div>
<div>
<Message content={m.macAddress} />: {managedGateway.result.entity.ethernet_mac_address}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ethernet_mac_adress can be a value of the message

Comment on lines +46 to +51
const valuesNormalized = useMemo(() => {
if (!namePrefix) return values
const nameSplitted = namePrefix.split('.')

return values[nameSplitted[0]][parseInt(nameSplitted[1])]
}, [namePrefix, values])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the encoders/decoders or the valueSetter() for these values manipulations?

Comment on lines +78 to +83
// Register hidden fields so they don't get cleaned.
useEffect(() => {
const hiddenFields = ['target_gateway_server_address', 'cups_redirection']
addToFieldRegistry(...hiddenFields)
return () => removeFromFieldRegistry(...hiddenFields)
}, [addToFieldRegistry, removeFromFieldRegistry])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the submit function you have access to the cleaned values:

const handleSubmit = useCallback(
    async (values, { }, cleanedValues) => { },
    []
)

So, I think this useEffect() shoudn't be necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copy pasted most of the registration/claiming code from ENT repo and looks like this code is that these fields are added to the fieldRegistry so that they will be present in the cleanedValues in the handleSubmit function. Once I remove the useEffect, target_gateway_server_address and cups_redirection are not present in the clean values. This is the submit function that his form is using:

const handleSubmit = useCallback(
    ({ _inputMethod, ...values }, _, cleanValues) => {
      if (_inputMethod !== 'register') {
        return handleClaimSubmit(values, cleanValues)
      }
      return handleRegistrationSubmit(values, cleanValues)
    },
    [handleClaimSubmit, handleRegistrationSubmit],
  )

  const downloadLns = useCallback(() => {
    if (lnsKey) {
      const content = composeDataUri(`Authorization: Bearer ${lnsKey}\r\n`)
      downloadDataUriAsFile(content, 'tc.key')
    }
  }, [lnsKey])

Comment on lines +78 to +83
// Register hidden fields so they don't get cleaned.
useEffect(() => {
const hiddenField = ['gateway_server_address', 'enforce_duty_cycle', 'schedule_anytime_delay']
addToFieldRegistry(...hiddenField)
return () => removeFromFieldRegistry(...hiddenField)
}, [addToFieldRegistry, removeFromFieldRegistry])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as the other comment.

@PavelJankoski
Copy link
Contributor Author

Great suggestions @ryaplots, I will address these comments in the integration branch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ui/web This is related to a web interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants