Skip to content

Commit

Permalink
[WIFI-13031] Add support for radius endpoints
Browse files Browse the repository at this point in the history
Signed-off-by: Charles <[email protected]>
  • Loading branch information
BourqueCharles committed Oct 16, 2023
1 parent 204e6e0 commit cede218
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 76 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wlan-cloud-owprov-ui",
"version": "2.11.0(56)",
"version": "2.11.0(57)",
"description": "",
"main": "index.tsx",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import React from 'react';
import { Flex, FormControl, FormLabel, Heading, SimpleGrid, Switch } from '@chakra-ui/react';
import NumberField from 'components/FormFields/NumberField';
import { Flex, Heading, SimpleGrid } from '@chakra-ui/react';
import StringField from 'components/FormFields/StringField';
import ToggleField from 'components/FormFields/ToggleField';

type Props = {
editing: boolean;
namePrefix: string;
onAccountingChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
isAccountingEnabled: boolean;
// eslint-disable-next-line react/no-unused-prop-types
isPasspoint?: boolean;
};
const OpenRoamingRadiusForm = ({ editing, namePrefix, onAccountingChange, isAccountingEnabled }: Props) => (
const OpenRoamingRadiusForm = ({ editing, namePrefix }: Props) => (
<>
<Flex mt={6}>
<div>
Expand All @@ -21,39 +18,6 @@ const OpenRoamingRadiusForm = ({ editing, namePrefix, onAccountingChange, isAcco
</Heading>
</div>
</Flex>
<FormControl isDisabled={!editing}>
<FormLabel ms="4px" fontSize="md" fontWeight="normal">
Enable Accounting
</FormLabel>
<Switch
onChange={onAccountingChange}
isChecked={isAccountingEnabled}
borderRadius="15px"
size="lg"
isDisabled={!editing}
_disabled={{ opacity: 0.8, cursor: 'not-allowed' }}
/>
</FormControl>
{isAccountingEnabled && (
<SimpleGrid minChildWidth="300px" spacing="20px">
<StringField name={`${namePrefix}.accounting.host`} label="accounting.host" isDisabled={!editing} isRequired />
<NumberField
name={`${namePrefix}.accounting.port`}
label="accounting.port"
isDisabled={!editing}
isRequired
hideArrows
w={24}
/>
<StringField
name={`${namePrefix}.accounting.secret`}
label="accounting.secret"
isDisabled={!editing}
isRequired
hideButton
/>
</SimpleGrid>
)}
<SimpleGrid minChildWidth="300px" spacing="20px">
<StringField
name={`${namePrefix}.nas-identifier`}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,10 @@
import React, { useMemo } from 'react';
import React from 'react';
import RadiusForm from './Radius';
import useFastField from 'hooks/useFastField';

type Props = { editing: boolean; namePrefix: string; isPasspoint?: boolean };

const OpenRoamingRadius = ({ editing, namePrefix, isPasspoint }: Props) => {
const { value: accounting, onChange: setAccounting } = useFastField({ name: `${namePrefix}.accounting` });

const onEnabledAccountingChange = (e: React.ChangeEvent<HTMLInputElement>) => {
if (e.target.checked) {
setAccounting({
host: '192.168.178.192',
port: 1813,
secret: 'YOUR_SECRET',
});
} else {
setAccounting(undefined);
}
};

const isAccountingEnabled = useMemo(() => accounting !== undefined, [accounting !== undefined]);

return (
<RadiusForm
editing={editing}
onAccountingChange={onEnabledAccountingChange}
isAccountingEnabled={isAccountingEnabled}
namePrefix={namePrefix}
isPasspoint={isPasspoint}
/>
);
};
const OpenRoamingRadius = ({ editing, namePrefix, isPasspoint }: Props) => (
<RadiusForm editing={editing} namePrefix={namePrefix} isPasspoint={isPasspoint} />
);

export default React.memo(OpenRoamingRadius);
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const CONSORTIUMS = {
generic: [],
radsec: [],
} as const;

const DEFAULT_VALUE = (defaultEndpoint?: RadiusEndpoint) => ({
'bss-mode': 'ap',
'dtim-period': 2,
Expand All @@ -32,11 +31,6 @@ const DEFAULT_VALUE = (defaultEndpoint?: RadiusEndpoint) => ({
radius: {
__radiusEndpoint: defaultEndpoint?.id ?? '',
'chargeable-user-id': true,
accounting: {
host: 'example.com',
port: '1813',
secret: 'Secret',
},
},
'pass-point': {
'venue-group': 1,
Expand Down

0 comments on commit cede218

Please sign in to comment.