mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov-ui.git
synced 2025-10-29 09:42:23 +00:00
2.6.57: prettierrrc now has printWidth of 120 instead of 100
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"printWidth": 100,
|
"printWidth": 120,
|
||||||
"trailingComma": "all",
|
"trailingComma": "all",
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"semi": true,
|
"semi": true,
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "wlan-cloud-owprov-ui",
|
"name": "wlan-cloud-owprov-ui",
|
||||||
"version": "2.6.56",
|
"version": "2.6.57",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "wlan-cloud-owprov-ui",
|
"name": "wlan-cloud-owprov-ui",
|
||||||
"version": "2.6.56",
|
"version": "2.6.57",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@chakra-ui/icons": "^1.1.1",
|
"@chakra-ui/icons": "^1.1.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wlan-cloud-owprov-ui",
|
"name": "wlan-cloud-owprov-ui",
|
||||||
"version": "2.6.56",
|
"version": "2.6.57",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ const queryClient = new QueryClient({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const storageToken =
|
const storageToken = localStorage.getItem('access_token') ?? sessionStorage.getItem('access_token');
|
||||||
localStorage.getItem('access_token') ?? sessionStorage.getItem('access_token');
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
|
|||||||
@@ -18,15 +18,7 @@ const defaultProps = {
|
|||||||
isStringFile: false,
|
isStringFile: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const FileInputButton = ({
|
const FileInputButton = ({ value, setValue, setFileName, refreshId, accept, isHidden, isStringFile }) => {
|
||||||
value,
|
|
||||||
setValue,
|
|
||||||
setFileName,
|
|
||||||
refreshId,
|
|
||||||
accept,
|
|
||||||
isHidden,
|
|
||||||
isStringFile,
|
|
||||||
}) => {
|
|
||||||
const [fileKey, setFileKey] = useState(uuid());
|
const [fileKey, setFileKey] = useState(uuid());
|
||||||
let fileReader;
|
let fileReader;
|
||||||
|
|
||||||
|
|||||||
@@ -22,15 +22,7 @@ const defaultProps = {
|
|||||||
dirtyCheck: false,
|
dirtyCheck: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const SaveButton = ({
|
const SaveButton = ({ onClick, isDisabled, isLoading, isCompact, isDirty, dirtyCheck, ...props }) => {
|
||||||
onClick,
|
|
||||||
isDisabled,
|
|
||||||
isLoading,
|
|
||||||
isCompact,
|
|
||||||
isDirty,
|
|
||||||
dirtyCheck,
|
|
||||||
...props
|
|
||||||
}) => {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const breakpoint = useBreakpoint();
|
const breakpoint = useBreakpoint();
|
||||||
|
|
||||||
|
|||||||
@@ -21,15 +21,7 @@ const defaultProps = {
|
|||||||
isDirty: false,
|
isDirty: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ToggleEditButton = ({
|
const ToggleEditButton = ({ toggleEdit, isEditing, isDirty, isDisabled, isLoading, isCompact, ...props }) => {
|
||||||
toggleEdit,
|
|
||||||
isEditing,
|
|
||||||
isDirty,
|
|
||||||
isDisabled,
|
|
||||||
isLoading,
|
|
||||||
isCompact,
|
|
||||||
...props
|
|
||||||
}) => {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const breakpoint = useBreakpoint();
|
const breakpoint = useBreakpoint();
|
||||||
const { isOpen: showConfirm, onOpen: openConfirm, onClose: closeConfirm } = useDisclosure();
|
const { isOpen: showConfirm, onOpen: openConfirm, onClose: closeConfirm } = useDisclosure();
|
||||||
@@ -61,11 +53,7 @@ const ToggleEditButton = ({
|
|||||||
>
|
>
|
||||||
{isEditing ? t('common.stop_editing') : t('common.edit')}
|
{isEditing ? t('common.stop_editing') : t('common.edit')}
|
||||||
</Button>
|
</Button>
|
||||||
<ConfirmCloseAlert
|
<ConfirmCloseAlert isOpen={showConfirm} confirm={closeCancelAndForm} cancel={closeConfirm} />
|
||||||
isOpen={showConfirm}
|
|
||||||
confirm={closeCancelAndForm}
|
|
||||||
cancel={closeConfirm}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,7 @@ import React, { useEffect } from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import {
|
import { Button, Checkbox, IconButton, Menu, MenuButton, MenuItem, MenuList, useBreakpoint } from '@chakra-ui/react';
|
||||||
Button,
|
|
||||||
Checkbox,
|
|
||||||
IconButton,
|
|
||||||
Menu,
|
|
||||||
MenuButton,
|
|
||||||
MenuItem,
|
|
||||||
MenuList,
|
|
||||||
useBreakpoint,
|
|
||||||
} from '@chakra-ui/react';
|
|
||||||
import { useAuth } from 'contexts/AuthProvider';
|
import { useAuth } from 'contexts/AuthProvider';
|
||||||
import { FunnelSimple } from 'phosphor-react';
|
import { FunnelSimple } from 'phosphor-react';
|
||||||
|
|
||||||
@@ -34,8 +25,7 @@ const ColumnPicker = ({ preference, columns, hiddenColumns, setHiddenColumns })
|
|||||||
|
|
||||||
const handleColumnClick = (id) => {
|
const handleColumnClick = (id) => {
|
||||||
let newHidden = [];
|
let newHidden = [];
|
||||||
if (hiddenColumns.find((hidden) => hidden === id))
|
if (hiddenColumns.find((hidden) => hidden === id)) newHidden = [...hiddenColumns.filter((hidden) => hidden !== id)];
|
||||||
newHidden = [...hiddenColumns.filter((hidden) => hidden !== id)];
|
|
||||||
else newHidden = [...hiddenColumns, id];
|
else newHidden = [...hiddenColumns, id];
|
||||||
setPref({ preference, value: newHidden.join(',') });
|
setPref({ preference, value: newHidden.join(',') });
|
||||||
setHiddenColumns(newHidden);
|
setHiddenColumns(newHidden);
|
||||||
@@ -52,11 +42,7 @@ const ColumnPicker = ({ preference, columns, hiddenColumns, setHiddenColumns })
|
|||||||
<MenuButton as={IconButton} icon={<FunnelSimple />} />
|
<MenuButton as={IconButton} icon={<FunnelSimple />} />
|
||||||
<MenuList>
|
<MenuList>
|
||||||
{columns.map((column) => (
|
{columns.map((column) => (
|
||||||
<MenuItem
|
<MenuItem key={uuid()} isDisabled={column.alwaysShow} onClick={() => handleColumnClick(column.id)}>
|
||||||
key={uuid()}
|
|
||||||
isDisabled={column.alwaysShow}
|
|
||||||
onClick={() => handleColumnClick(column.id)}
|
|
||||||
>
|
|
||||||
<Checkbox
|
<Checkbox
|
||||||
defaultChecked={!hiddenColumns.find((hidden) => hidden === column.id)}
|
defaultChecked={!hiddenColumns.find((hidden) => hidden === column.id)}
|
||||||
isDisabled={column.alwaysShow}
|
isDisabled={column.alwaysShow}
|
||||||
@@ -77,11 +63,7 @@ const ColumnPicker = ({ preference, columns, hiddenColumns, setHiddenColumns })
|
|||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuList>
|
<MenuList>
|
||||||
{columns.map((column) => (
|
{columns.map((column) => (
|
||||||
<MenuItem
|
<MenuItem key={uuid()} isDisabled={column.alwaysShow} onClick={() => handleColumnClick(column.id)}>
|
||||||
key={uuid()}
|
|
||||||
isDisabled={column.alwaysShow}
|
|
||||||
onClick={() => handleColumnClick(column.id)}
|
|
||||||
>
|
|
||||||
<Checkbox
|
<Checkbox
|
||||||
defaultChecked={!hiddenColumns.find((hidden) => hidden === column.id)}
|
defaultChecked={!hiddenColumns.find((hidden) => hidden === column.id)}
|
||||||
isDisabled={column.alwaysShow}
|
isDisabled={column.alwaysShow}
|
||||||
|
|||||||
@@ -33,39 +33,18 @@ const Form = ({ name }) => {
|
|||||||
{ label: 'CORPORATE', value: 'CORPORATE' },
|
{ label: 'CORPORATE', value: 'CORPORATE' },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<CreatableSelectField
|
<CreatableSelectField name={`${name}.phones`} label={t('contacts.phones')} placeholder="+1(202)555-0103" />
|
||||||
name={`${name}.phones`}
|
<CreatableSelectField name={`${name}.mobiles`} label={t('contacts.mobiles')} placeholder="+1(202)555-0103" />
|
||||||
label={t('contacts.phones')}
|
|
||||||
placeholder="+1(202)555-0103"
|
|
||||||
/>
|
|
||||||
<CreatableSelectField
|
|
||||||
name={`${name}.mobiles`}
|
|
||||||
label={t('contacts.mobiles')}
|
|
||||||
placeholder="+1(202)555-0103"
|
|
||||||
/>
|
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
|
|
||||||
<AddressSearchField
|
<AddressSearchField placeholder={t('common.address_search_autofill')} namePrefix={name} maxWidth="600px" mb={2} />
|
||||||
placeholder={t('common.address_search_autofill')}
|
|
||||||
namePrefix={name}
|
|
||||||
maxWidth="600px"
|
|
||||||
mb={2}
|
|
||||||
/>
|
|
||||||
<SimpleGrid minChildWidth="300px" spacing="20px" mb={8}>
|
<SimpleGrid minChildWidth="300px" spacing="20px" mb={8}>
|
||||||
<StringField
|
<StringField name={`${name}.addressLineOne`} label={t('locations.address_line_one')} isRequired />
|
||||||
name={`${name}.addressLineOne`}
|
|
||||||
label={t('locations.address_line_one')}
|
|
||||||
isRequired
|
|
||||||
/>
|
|
||||||
<StringField name={`${name}.addressLineTwo`} label={t('locations.address_line_two')} />
|
<StringField name={`${name}.addressLineTwo`} label={t('locations.address_line_two')} />
|
||||||
<StringField name={`${name}.city`} label={t('locations.city')} isRequired />
|
<StringField name={`${name}.city`} label={t('locations.city')} isRequired />
|
||||||
<StringField name={`${name}.state`} label={t('locations.state')} isRequired />
|
<StringField name={`${name}.state`} label={t('locations.state')} isRequired />
|
||||||
<StringField name={`${name}.postal`} label={t('locations.postal')} isRequired />
|
<StringField name={`${name}.postal`} label={t('locations.postal')} isRequired />
|
||||||
<SelectField
|
<SelectField name={`${name}.country`} label={t('locations.country')} options={COUNTRY_LIST} />
|
||||||
name={`${name}.country`}
|
|
||||||
label={t('locations.country')}
|
|
||||||
options={COUNTRY_LIST}
|
|
||||||
/>
|
|
||||||
<StringField name={`${name}.buildingName`} label={t('locations.building_name')} />
|
<StringField name={`${name}.buildingName`} label={t('locations.building_name')} />
|
||||||
<StringField name={`${name}.geoCode`} label={t('locations.geocode')} />
|
<StringField name={`${name}.geoCode`} label={t('locations.geocode')} />
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
import React, { useCallback, useEffect, useState } from 'react';
|
import React, { useCallback, useEffect, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import {
|
import { CloseButton, Modal, ModalBody, ModalContent, ModalOverlay, SimpleGrid, useDisclosure } from '@chakra-ui/react';
|
||||||
CloseButton,
|
|
||||||
Modal,
|
|
||||||
ModalBody,
|
|
||||||
ModalContent,
|
|
||||||
ModalOverlay,
|
|
||||||
SimpleGrid,
|
|
||||||
useDisclosure,
|
|
||||||
} from '@chakra-ui/react';
|
|
||||||
import ModalHeader from 'components/ModalHeader';
|
import ModalHeader from 'components/ModalHeader';
|
||||||
import SaveButton from 'components/Buttons/SaveButton';
|
import SaveButton from 'components/Buttons/SaveButton';
|
||||||
import ConfirmCloseAlert from 'components/ConfirmCloseAlert';
|
import ConfirmCloseAlert from 'components/ConfirmCloseAlert';
|
||||||
@@ -154,29 +146,13 @@ const LocationPickerCreatorModal = ({ setLocation, reset }) => {
|
|||||||
{ label: 'CORPORATE', value: 'CORPORATE' },
|
{ label: 'CORPORATE', value: 'CORPORATE' },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<CreatableSelectField
|
<CreatableSelectField name="phones" label={t('contacts.phones')} placeholder="+1(202)555-0103" />
|
||||||
name="phones"
|
<CreatableSelectField name="mobiles" label={t('contacts.mobiles')} placeholder="+1(202)555-0103" />
|
||||||
label={t('contacts.phones')}
|
|
||||||
placeholder="+1(202)555-0103"
|
|
||||||
/>
|
|
||||||
<CreatableSelectField
|
|
||||||
name="mobiles"
|
|
||||||
label={t('contacts.mobiles')}
|
|
||||||
placeholder="+1(202)555-0103"
|
|
||||||
/>
|
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
|
|
||||||
<AddressSearchField
|
<AddressSearchField placeholder={t('common.address_search_autofill')} maxWidth="600px" mb={2} />
|
||||||
placeholder={t('common.address_search_autofill')}
|
|
||||||
maxWidth="600px"
|
|
||||||
mb={2}
|
|
||||||
/>
|
|
||||||
<SimpleGrid minChildWidth="300px" spacing="20px" mb={8}>
|
<SimpleGrid minChildWidth="300px" spacing="20px" mb={8}>
|
||||||
<StringField
|
<StringField name="addressLineOne" label={t('locations.address_line_one')} isRequired />
|
||||||
name="addressLineOne"
|
|
||||||
label={t('locations.address_line_one')}
|
|
||||||
isRequired
|
|
||||||
/>
|
|
||||||
<StringField name="addressLineTwo" label={t('locations.address_line_two')} />
|
<StringField name="addressLineTwo" label={t('locations.address_line_two')} />
|
||||||
<StringField name="city" label={t('locations.city')} isRequired />
|
<StringField name="city" label={t('locations.city')} isRequired />
|
||||||
<StringField name="state" label={t('locations.state')} isRequired />
|
<StringField name="state" label={t('locations.state')} isRequired />
|
||||||
|
|||||||
@@ -24,14 +24,7 @@ const defaultProps = {
|
|||||||
venueId: null,
|
venueId: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const LocationPickerCreator = ({
|
const LocationPickerCreator = ({ locationName, createLocationName, editing, isModal, entityId, venueId }) => {
|
||||||
locationName,
|
|
||||||
createLocationName,
|
|
||||||
editing,
|
|
||||||
isModal,
|
|
||||||
entityId,
|
|
||||||
venueId,
|
|
||||||
}) => {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const [{ value: location }, , { setValue: setLocation }] = useField(locationName);
|
const [{ value: location }, , { setValue: setLocation }] = useField(locationName);
|
||||||
|
|||||||
@@ -33,17 +33,7 @@ const defaultProps = {
|
|||||||
isDisabled: false,
|
isDisabled: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const FastNumberInput = ({
|
const FastNumberInput = ({ label, value, unit, onChange, onBlur, error, touched, isRequired, isDisabled }) => (
|
||||||
label,
|
|
||||||
value,
|
|
||||||
unit,
|
|
||||||
onChange,
|
|
||||||
onBlur,
|
|
||||||
error,
|
|
||||||
touched,
|
|
||||||
isRequired,
|
|
||||||
isDisabled,
|
|
||||||
}) => (
|
|
||||||
<FormControl isInvalid={error && touched} isRequired={isRequired} isDisabled={isDisabled}>
|
<FormControl isInvalid={error && touched} isRequired={isRequired} isDisabled={isDisabled}>
|
||||||
<FormLabel ms="4px" fontSize="md" fontWeight="normal">
|
<FormLabel ms="4px" fontSize="md" fontWeight="normal">
|
||||||
{label}
|
{label}
|
||||||
|
|||||||
@@ -39,15 +39,7 @@ const defaultProps = {
|
|||||||
isDisabled: false,
|
isDisabled: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const DeviceConfigurationsModal = ({
|
const DeviceConfigurationsModal = ({ name, initialValue, setValue, errors, isDisabled, isRequired, label }) => {
|
||||||
name,
|
|
||||||
initialValue,
|
|
||||||
setValue,
|
|
||||||
errors,
|
|
||||||
isDisabled,
|
|
||||||
isRequired,
|
|
||||||
label,
|
|
||||||
}) => {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const [localValue, setLocalValue] = useState([]);
|
const [localValue, setLocalValue] = useState([]);
|
||||||
@@ -86,10 +78,7 @@ const DeviceConfigurationsModal = ({
|
|||||||
const { length } = initialValue;
|
const { length } = initialValue;
|
||||||
if (length === 0) return t('entities.add_configurations');
|
if (length === 0) return t('entities.add_configurations');
|
||||||
if (length === 1 && configurations)
|
if (length === 1 && configurations)
|
||||||
return (
|
return configurations.find((conf) => conf.id === initialValue[0])?.name ?? `1 ${t('configurations.one')}`;
|
||||||
configurations.find((conf) => conf.id === initialValue[0])?.name ??
|
|
||||||
`1 ${t('configurations.one')}`
|
|
||||||
);
|
|
||||||
return `${length} ${t('configurations.title')}`;
|
return `${length} ${t('configurations.title')}`;
|
||||||
}, [initialValue, configurations]);
|
}, [initialValue, configurations]);
|
||||||
|
|
||||||
@@ -221,22 +210,14 @@ const DeviceConfigurationsModal = ({
|
|||||||
<ModalBody overflowX="auto">
|
<ModalBody overflowX="auto">
|
||||||
<DataTable
|
<DataTable
|
||||||
columns={columns(true)}
|
columns={columns(true)}
|
||||||
data={
|
data={configurations ? localValue.map((id) => configurations.find((config) => config.id === id)) : []}
|
||||||
configurations
|
|
||||||
? localValue.map((id) => configurations.find((config) => config.id === id))
|
|
||||||
: []
|
|
||||||
}
|
|
||||||
isLoading={isFetching}
|
isLoading={isFetching}
|
||||||
obj={t('configurations.title')}
|
obj={t('configurations.title')}
|
||||||
/>
|
/>
|
||||||
<Box h="100px" />
|
<Box h="100px" />
|
||||||
<DataTable
|
<DataTable
|
||||||
columns={columns(false)}
|
columns={columns(false)}
|
||||||
data={
|
data={configurations?.filter((config) => !localValue.find((local) => local === config.id)) ?? []}
|
||||||
configurations?.filter(
|
|
||||||
(config) => !localValue.find((local) => local === config.id),
|
|
||||||
) ?? []
|
|
||||||
}
|
|
||||||
isLoading={isFetching}
|
isLoading={isFetching}
|
||||||
obj={t('configurations.title')}
|
obj={t('configurations.title')}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -17,14 +17,7 @@ const defaultProps = {
|
|||||||
isDisabled: false,
|
isDisabled: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const DeviceConfigurationsModalField = ({
|
const DeviceConfigurationsModalField = ({ name, label, setFieldValue, errors, isDisabled, isRequired }) => {
|
||||||
name,
|
|
||||||
label,
|
|
||||||
setFieldValue,
|
|
||||||
errors,
|
|
||||||
isDisabled,
|
|
||||||
isRequired,
|
|
||||||
}) => {
|
|
||||||
const setValue = (value) => setFieldValue(name, value);
|
const setValue = (value) => setFieldValue(name, value);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -55,10 +55,7 @@ const MultiPhoneNumberFieldInput = ({
|
|||||||
definitionKey,
|
definitionKey,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const NoOptionsMessage = useCallback(
|
const NoOptionsMessage = useCallback(() => <h6 className="text-center pt-2">{t('common.type_for_options')}</h6>, []);
|
||||||
() => <h6 className="text-center pt-2">{t('common.type_for_options')}</h6>,
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormControl isInvalid={error && touched} isRequired={isRequired} hidden={isHidden}>
|
<FormControl isInvalid={error && touched} isRequired={isRequired} hidden={isHidden}>
|
||||||
|
|||||||
@@ -16,11 +16,7 @@ const defaultProps = {
|
|||||||
const SortIcon = ({ isSorted, isSortedDesc, canSort }) => {
|
const SortIcon = ({ isSorted, isSortedDesc, canSort }) => {
|
||||||
if (canSort) {
|
if (canSort) {
|
||||||
if (isSorted) {
|
if (isSorted) {
|
||||||
return isSortedDesc ? (
|
return isSortedDesc ? <Icon pt={2} h={5} w={5} as={ArrowDown} /> : <Icon pt={2} h={5} w={5} as={ArrowUp} />;
|
||||||
<Icon pt={2} h={5} w={5} as={ArrowDown} />
|
|
||||||
) : (
|
|
||||||
<Icon pt={2} h={5} w={5} as={ArrowUp} />
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return <Icon pt={2} h={5} w={5} as={Circle} />;
|
return <Icon pt={2} h={5} w={5} as={Circle} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,8 +119,7 @@ const DataTable = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (setPageInfo && pageIndex !== undefined)
|
if (setPageInfo && pageIndex !== undefined) setPageInfo({ index: pageIndex, limit: queryPageSize });
|
||||||
setPageInfo({ index: pageIndex, limit: queryPageSize });
|
|
||||||
}, [queryPageSize, pageIndex]);
|
}, [queryPageSize, pageIndex]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -133,13 +132,7 @@ const DataTable = ({
|
|||||||
|
|
||||||
// If this is a manual DataTable, with a page index that is higher than 0 and higher than the max possible page, we send to index 0
|
// If this is a manual DataTable, with a page index that is higher than 0 and higher than the max possible page, we send to index 0
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (isManual && data && isManual && pageIndex > 0 && Math.ceil(count / queryPageSize) - 1 < pageIndex) {
|
||||||
isManual &&
|
|
||||||
data &&
|
|
||||||
isManual &&
|
|
||||||
pageIndex > 0 &&
|
|
||||||
Math.ceil(count / queryPageSize) - 1 < pageIndex
|
|
||||||
) {
|
|
||||||
gotoPage(0);
|
gotoPage(0);
|
||||||
setPageInfo({ index: 0, limit: queryPageSize });
|
setPageInfo({ index: 0, limit: queryPageSize });
|
||||||
}
|
}
|
||||||
@@ -239,11 +232,7 @@ const DataTable = ({
|
|||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip label={t('table.previous_page')}>
|
<Tooltip label={t('table.previous_page')}>
|
||||||
<IconButton
|
<IconButton onClick={previousPage} isDisabled={!canPreviousPage} icon={<ChevronLeftIcon h={6} w={6} />} />
|
||||||
onClick={previousPage}
|
|
||||||
isDisabled={!canPreviousPage}
|
|
||||||
icon={<ChevronLeftIcon h={6} w={6} />}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
@@ -298,11 +287,7 @@ const DataTable = ({
|
|||||||
|
|
||||||
<Flex>
|
<Flex>
|
||||||
<Tooltip label={t('table.next_page')}>
|
<Tooltip label={t('table.next_page')}>
|
||||||
<IconButton
|
<IconButton onClick={nextPage} isDisabled={!canNextPage} icon={<ChevronRightIcon h={6} w={6} />} />
|
||||||
onClick={nextPage}
|
|
||||||
isDisabled={!canNextPage}
|
|
||||||
icon={<ChevronRightIcon h={6} w={6} />}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip label={t('table.last_page')}>
|
<Tooltip label={t('table.last_page')}>
|
||||||
<IconButton
|
<IconButton
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import {
|
import { Button, FormControl, FormLabel, Input, InputGroup, InputRightElement, useBoolean } from '@chakra-ui/react';
|
||||||
Button,
|
|
||||||
FormControl,
|
|
||||||
FormLabel,
|
|
||||||
Input,
|
|
||||||
InputGroup,
|
|
||||||
InputRightElement,
|
|
||||||
useBoolean,
|
|
||||||
} from '@chakra-ui/react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
@@ -44,12 +36,7 @@ const DisplayStringField = ({ label, value, isRequired, hideButton }) => {
|
|||||||
/>
|
/>
|
||||||
{hideButton && (
|
{hideButton && (
|
||||||
<InputRightElement width="4.5rem">
|
<InputRightElement width="4.5rem">
|
||||||
<Button
|
<Button h="1.75rem" size="sm" onClick={setShow.toggle} _disabled={{ opacity: 0.8, cursor: 'not-allowed' }}>
|
||||||
h="1.75rem"
|
|
||||||
size="sm"
|
|
||||||
onClick={setShow.toggle}
|
|
||||||
_disabled={{ opacity: 0.8, cursor: 'not-allowed' }}
|
|
||||||
>
|
|
||||||
{show ? t('common.hide') : t('common.show')}
|
{show ? t('common.hide') : t('common.show')}
|
||||||
</Button>
|
</Button>
|
||||||
</InputRightElement>
|
</InputRightElement>
|
||||||
|
|||||||
@@ -9,17 +9,11 @@ import { Plus, Trash } from 'phosphor-react';
|
|||||||
|
|
||||||
const getEntitiesApi = async (pageInfo) => {
|
const getEntitiesApi = async (pageInfo) => {
|
||||||
if (Array.isArray(pageInfo)) {
|
if (Array.isArray(pageInfo)) {
|
||||||
return axiosProv
|
return axiosProv.get(`entity?withExtendedInfo=true&select=${pageInfo}`).then(({ data }) => data);
|
||||||
.get(`entity?withExtendedInfo=true&select=${pageInfo}`)
|
|
||||||
.then(({ data }) => data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return axiosProv
|
return axiosProv
|
||||||
.get(
|
.get(`entity?withExtendedInfo=true&limit=${pageInfo.limit}&offset=${pageInfo.limit * pageInfo.index}`)
|
||||||
`entity?withExtendedInfo=true&limit=${pageInfo.limit}&offset=${
|
|
||||||
pageInfo.limit * pageInfo.index
|
|
||||||
}`,
|
|
||||||
)
|
|
||||||
.then(({ data }) => data);
|
.then(({ data }) => data);
|
||||||
};
|
};
|
||||||
const getCountApi = async () => axiosProv.get(`entity?countOnly=true`).then(({ data }) => data);
|
const getCountApi = async () => axiosProv.get(`entity?countOnly=true`).then(({ data }) => data);
|
||||||
|
|||||||
@@ -150,15 +150,7 @@ const FileInput = ({ setValue, refreshId, errors }) => {
|
|||||||
{t('certificates.device_macs')}
|
{t('certificates.device_macs')}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<Input
|
<Input borderRadius="15px" pt={1} fontSize="sm" type="file" onChange={changeFile} key={fileKey} accept=".csv" />
|
||||||
borderRadius="15px"
|
|
||||||
pt={1}
|
|
||||||
fontSize="sm"
|
|
||||||
type="file"
|
|
||||||
onChange={changeFile}
|
|
||||||
key={fileKey}
|
|
||||||
accept=".csv"
|
|
||||||
/>
|
|
||||||
<InputRightElement hidden={!result}>
|
<InputRightElement hidden={!result}>
|
||||||
{' '}
|
{' '}
|
||||||
<IconButton icon={<CloseIcon />} onClick={resetFile} />
|
<IconButton icon={<CloseIcon />} onClick={resetFile} />
|
||||||
|
|||||||
@@ -22,19 +22,14 @@ const AddressSearchField = ({ namePrefix, isDisabled, placeholder, isHidden, ...
|
|||||||
|
|
||||||
const onSelect = (v) => {
|
const onSelect = (v) => {
|
||||||
const city =
|
const city =
|
||||||
v.locality.long_name ??
|
v.locality.long_name ?? v.administrative_area_level_3.long_name ?? v.administrative_area_level_2.long_name;
|
||||||
v.administrative_area_level_3.long_name ??
|
|
||||||
v.administrative_area_level_2.long_name;
|
|
||||||
|
|
||||||
setFieldValue(
|
setFieldValue(
|
||||||
`${namePrefix ? `${namePrefix}.` : ''}addressLineOne`,
|
`${namePrefix ? `${namePrefix}.` : ''}addressLineOne`,
|
||||||
`${v.street_number.long_name} ${v.route.long_name}`,
|
`${v.street_number.long_name} ${v.route.long_name}`,
|
||||||
);
|
);
|
||||||
setFieldValue(`${namePrefix ? `${namePrefix}.` : ''}city`, city);
|
setFieldValue(`${namePrefix ? `${namePrefix}.` : ''}city`, city);
|
||||||
setFieldValue(
|
setFieldValue(`${namePrefix ? `${namePrefix}.` : ''}state`, v.administrative_area_level_1.long_name);
|
||||||
`${namePrefix ? `${namePrefix}.` : ''}state`,
|
|
||||||
v.administrative_area_level_1.long_name,
|
|
||||||
);
|
|
||||||
setFieldValue(`${namePrefix ? `${namePrefix}.` : ''}postal`, v.postal_code.long_name);
|
setFieldValue(`${namePrefix ? `${namePrefix}.` : ''}postal`, v.postal_code.long_name);
|
||||||
setFieldValue(`${namePrefix ? `${namePrefix}.` : ''}country`, v.country.short_name);
|
setFieldValue(`${namePrefix ? `${namePrefix}.` : ''}country`, v.country.short_name);
|
||||||
setFieldValue(`${namePrefix ? `${namePrefix}.` : ''}geoCode`, JSON.stringify(v.geoCode));
|
setFieldValue(`${namePrefix ? `${namePrefix}.` : ''}geoCode`, JSON.stringify(v.geoCode));
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ const findDefinition = (definitionKey, CONFIGURATION_DESCRIPTIONS) => {
|
|||||||
if (length < 2) return null;
|
if (length < 2) return null;
|
||||||
const start = split.slice(0, length - 1);
|
const start = split.slice(0, length - 1);
|
||||||
const end = split[length - 1];
|
const end = split[length - 1];
|
||||||
return (
|
return CONFIGURATION_DESCRIPTIONS[start.slice(0, length - 1).join('.')]?.properties[end]?.description ?? null;
|
||||||
CONFIGURATION_DESCRIPTIONS[start.slice(0, length - 1).join('.')]?.properties[end]
|
|
||||||
?.description ?? null
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
|
|||||||
@@ -44,10 +44,7 @@ const FastCreatableSelectInput = ({
|
|||||||
placeholder,
|
placeholder,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const NoOptionsMessage = useCallback(
|
const NoOptionsMessage = useCallback(() => <h6 className="text-center pt-2">{t('common.type_for_options')}</h6>, []);
|
||||||
() => <h6 className="text-center pt-2">{t('common.type_for_options')}</h6>,
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormControl isInvalid={error && touched} isRequired={isRequired} hidden={isHidden}>
|
<FormControl isInvalid={error && touched} isRequired={isRequired} hidden={isHidden}>
|
||||||
|
|||||||
@@ -95,12 +95,7 @@ const FileInputModal = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<FormControl
|
<FormControl isInvalid={error && touched} isRequired={isRequired} isDisabled={isDisabled} hidden={isHidden}>
|
||||||
isInvalid={error && touched}
|
|
||||||
isRequired={isRequired}
|
|
||||||
isDisabled={isDisabled}
|
|
||||||
hidden={isHidden}
|
|
||||||
>
|
|
||||||
<FormLabel ms="4px" fontSize="md" fontWeight="normal">
|
<FormLabel ms="4px" fontSize="md" fontWeight="normal">
|
||||||
{label}
|
{label}
|
||||||
<ConfigurationFieldExplanation definitionKey={definitionKey} />
|
<ConfigurationFieldExplanation definitionKey={definitionKey} />
|
||||||
@@ -126,10 +121,7 @@ const FileInputModal = ({
|
|||||||
title={label}
|
title={label}
|
||||||
right={
|
right={
|
||||||
<>
|
<>
|
||||||
<SaveButton
|
<SaveButton onClick={saveValue} isDisabled={tempValue.length === 0 || !test(tempValue)} />
|
||||||
onClick={saveValue}
|
|
||||||
isDisabled={tempValue.length === 0 || !test(tempValue)}
|
|
||||||
/>
|
|
||||||
<CloseButton ml={2} onClick={onClose} />
|
<CloseButton ml={2} onClick={onClose} />
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,11 +130,7 @@ const ListInputModalField = ({
|
|||||||
h="1.75rem"
|
h="1.75rem"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={addEntry}
|
onClick={addEntry}
|
||||||
isDisabled={
|
isDisabled={entry.length === 0 || !validation(entry) || localValue.find((val) => val === entry)}
|
||||||
entry.length === 0 ||
|
|
||||||
!validation(entry) ||
|
|
||||||
localValue.find((val) => val === entry)
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{t('crud.add')}
|
{t('crud.add')}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -43,17 +43,7 @@ const defaultProps = {
|
|||||||
isHidden: false,
|
isHidden: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ObjectArrayFieldModal = ({
|
const ObjectArrayFieldModal = ({ name, label, fields, schema, columns, editing, isDisabled, isRequired, isHidden }) => {
|
||||||
name,
|
|
||||||
label,
|
|
||||||
fields,
|
|
||||||
schema,
|
|
||||||
columns,
|
|
||||||
editing,
|
|
||||||
isDisabled,
|
|
||||||
isRequired,
|
|
||||||
isHidden,
|
|
||||||
}) => {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [tempValue, setTempValue] = useState([]);
|
const [tempValue, setTempValue] = useState([]);
|
||||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||||
@@ -96,12 +86,7 @@ const ObjectArrayFieldModal = ({
|
|||||||
<Field name={name}>
|
<Field name={name}>
|
||||||
{({ field, meta: { touched, error } }) => (
|
{({ field, meta: { touched, error } }) => (
|
||||||
<>
|
<>
|
||||||
<FormControl
|
<FormControl isInvalid={error && touched} isRequired={isRequired} isDisabled={isDisabled} hidden={isHidden}>
|
||||||
isInvalid={error && touched}
|
|
||||||
isRequired={isRequired}
|
|
||||||
isDisabled={isDisabled}
|
|
||||||
hidden={isHidden}
|
|
||||||
>
|
|
||||||
<FormLabel ms="4px" fontSize="md" fontWeight="normal">
|
<FormLabel ms="4px" fontSize="md" fontWeight="normal">
|
||||||
{label}
|
{label}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
@@ -119,11 +104,7 @@ const ObjectArrayFieldModal = ({
|
|||||||
title={name}
|
title={name}
|
||||||
right={
|
right={
|
||||||
<>
|
<>
|
||||||
<SaveButton
|
<SaveButton onClick={onChange} hidden={!editing} isDisabled={tempValue.length === 0} />
|
||||||
onClick={onChange}
|
|
||||||
hidden={!editing}
|
|
||||||
isDisabled={tempValue.length === 0}
|
|
||||||
/>
|
|
||||||
<CloseButton ml={2} onClick={onClose} />
|
<CloseButton ml={2} onClick={onClose} />
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
@@ -150,12 +131,7 @@ const ObjectArrayFieldModal = ({
|
|||||||
<Button colorScheme="blue" isDisabled={!isValid} onClick={submitForm}>
|
<Button colorScheme="blue" isDisabled={!isValid} onClick={submitForm}>
|
||||||
{t('crud.add')}
|
{t('crud.add')}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button colorScheme="gray" isDisabled={!isDirty} ml={2} onClick={resetForm}>
|
||||||
colorScheme="gray"
|
|
||||||
isDisabled={!isDirty}
|
|
||||||
ml={2}
|
|
||||||
onClick={resetForm}
|
|
||||||
>
|
|
||||||
{t('common.reset')}
|
{t('common.reset')}
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -50,12 +50,7 @@ const FastSelectInput = ({
|
|||||||
w,
|
w,
|
||||||
definitionKey,
|
definitionKey,
|
||||||
}) => (
|
}) => (
|
||||||
<FormControl
|
<FormControl isInvalid={error && touched} isRequired={isRequired} isDisabled={isDisabled} hidden={isHidden}>
|
||||||
isInvalid={error && touched}
|
|
||||||
isRequired={isRequired}
|
|
||||||
isDisabled={isDisabled}
|
|
||||||
hidden={isHidden}
|
|
||||||
>
|
|
||||||
<FormLabel ms="4px" fontSize="md" fontWeight="normal" _disabled={{ opacity: 0.8 }}>
|
<FormLabel ms="4px" fontSize="md" fontWeight="normal" _disabled={{ opacity: 0.8 }}>
|
||||||
{label} <ConfigurationFieldExplanation definitionKey={definitionKey} />
|
{label} <ConfigurationFieldExplanation definitionKey={definitionKey} />
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
|
|||||||
@@ -23,15 +23,7 @@ const defaultProps = {
|
|||||||
isHidden: false,
|
isHidden: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const SelectWithSearchField = ({
|
const SelectWithSearchField = ({ options, name, isDisabled, label, isRequired, isHidden, isPortal }) => {
|
||||||
options,
|
|
||||||
name,
|
|
||||||
isDisabled,
|
|
||||||
label,
|
|
||||||
isRequired,
|
|
||||||
isHidden,
|
|
||||||
isPortal,
|
|
||||||
}) => {
|
|
||||||
const { errors, touched, setFieldValue } = useFormikContext();
|
const { errors, touched, setFieldValue } = useFormikContext();
|
||||||
const onChange = (ent) => {
|
const onChange = (ent) => {
|
||||||
setFieldValue(name, ent.value);
|
setFieldValue(name, ent.value);
|
||||||
|
|||||||
@@ -21,15 +21,7 @@ const defaultProps = {
|
|||||||
definitionKey: null,
|
definitionKey: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ToggleField = ({
|
const ToggleField = ({ name, isDisabled, label, isRequired, element, falseIsUndefined, definitionKey }) => {
|
||||||
name,
|
|
||||||
isDisabled,
|
|
||||||
label,
|
|
||||||
isRequired,
|
|
||||||
element,
|
|
||||||
falseIsUndefined,
|
|
||||||
definitionKey,
|
|
||||||
}) => {
|
|
||||||
const [{ value }, { touched, error }, { setValue, setTouched }] = useField(name);
|
const [{ value }, { touched, error }, { setValue, setTouched }] = useField(name);
|
||||||
|
|
||||||
const onChange = useCallback((e) => {
|
const onChange = useCallback((e) => {
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ const LoadingOverlay = ({ isLoading, children }) => {
|
|||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '100%',
|
height: '100%',
|
||||||
backgroundColor:
|
backgroundColor: colorMode === 'light' ? 'var(--chakra-colors-gray-200)' : 'var(--chakra-colors-gray-900)',
|
||||||
colorMode === 'light' ? 'var(--chakra-colors-gray-200)' : 'var(--chakra-colors-gray-900)',
|
|
||||||
zIndex: '1100',
|
zIndex: '1100',
|
||||||
opacity: '0.4',
|
opacity: '0.4',
|
||||||
filter: 'alpha(opacity=40)',
|
filter: 'alpha(opacity=40)',
|
||||||
|
|||||||
@@ -38,10 +38,7 @@ const NotesTable = ({ notes, setNotes, isDisabled }) => {
|
|||||||
setNewNote('');
|
setNewNote('');
|
||||||
};
|
};
|
||||||
|
|
||||||
const memoizedDate = useCallback(
|
const memoizedDate = useCallback((cell) => <FormattedDate date={cell.row.values.created} key={uuid()} />, []);
|
||||||
(cell) => <FormattedDate date={cell.row.values.created} key={uuid()} />,
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
const columns = useMemo(
|
const columns = useMemo(
|
||||||
() => [
|
() => [
|
||||||
|
|||||||
@@ -7,9 +7,7 @@ const propTypes = {
|
|||||||
field: PropTypes.instanceOf(Object).isRequired,
|
field: PropTypes.instanceOf(Object).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
const PhoneInput = ({ editing, field }) => (
|
const PhoneInput = ({ editing, field }) => <Input borderRadius="15px" type="string" isDisabled={!editing} {...field} />;
|
||||||
<Input borderRadius="15px" type="string" isDisabled={!editing} {...field} />
|
|
||||||
);
|
|
||||||
|
|
||||||
PhoneInput.propTypes = propTypes;
|
PhoneInput.propTypes = propTypes;
|
||||||
|
|
||||||
|
|||||||
@@ -50,15 +50,7 @@ const CreateConfigurationForm = ({
|
|||||||
return `ven:${splitEntity[1]}`;
|
return `ven:${splitEntity[1]}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const createParameters = ({
|
const createParameters = ({ name, description, note, deviceTypes, entity, rrm, __CREATE_CONFIG }) => ({
|
||||||
name,
|
|
||||||
description,
|
|
||||||
note,
|
|
||||||
deviceTypes,
|
|
||||||
entity,
|
|
||||||
rrm,
|
|
||||||
__CREATE_CONFIG,
|
|
||||||
}) => ({
|
|
||||||
name,
|
name,
|
||||||
rrm,
|
rrm,
|
||||||
deviceTypes,
|
deviceTypes,
|
||||||
@@ -127,13 +119,7 @@ const CreateConfigurationForm = ({
|
|||||||
{({ errors, touched, setFieldValue }) => (
|
{({ errors, touched, setFieldValue }) => (
|
||||||
<>
|
<>
|
||||||
<SimpleGrid minChildWidth="300px" spacing="20px" mb={6}>
|
<SimpleGrid minChildWidth="300px" spacing="20px" mb={6}>
|
||||||
<StringField
|
<StringField name="name" label={t('common.name')} errors={errors} touched={touched} isRequired />
|
||||||
name="name"
|
|
||||||
label={t('common.name')}
|
|
||||||
errors={errors}
|
|
||||||
touched={touched}
|
|
||||||
isRequired
|
|
||||||
/>
|
|
||||||
<MultiSelectField
|
<MultiSelectField
|
||||||
name="deviceTypes"
|
name="deviceTypes"
|
||||||
label={t('configurations.device_types')}
|
label={t('configurations.device_types')}
|
||||||
@@ -189,20 +175,10 @@ const CreateConfigurationForm = ({
|
|||||||
isRequired
|
isRequired
|
||||||
w={28}
|
w={28}
|
||||||
/>
|
/>
|
||||||
<StringField
|
<StringField name="description" label={t('common.description')} errors={errors} touched={touched} />
|
||||||
name="description"
|
|
||||||
label={t('common.description')}
|
|
||||||
errors={errors}
|
|
||||||
touched={touched}
|
|
||||||
/>
|
|
||||||
<StringField name="note" label={t('common.note')} errors={errors} touched={touched} />
|
<StringField name="note" label={t('common.note')} errors={errors} touched={touched} />
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
<SpecialConfigurationManager
|
<SpecialConfigurationManager editing isEnabledByDefault isOnlySections onChange={onConfigurationChange} />
|
||||||
editing
|
|
||||||
isEnabledByDefault
|
|
||||||
isOnlySections
|
|
||||||
onChange={onConfigurationChange}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Formik>
|
</Formik>
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
import React, { useCallback, useState } from 'react';
|
import React, { useCallback, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import {
|
import { Button, useDisclosure, Modal, ModalOverlay, ModalContent, ModalBody, toast } from '@chakra-ui/react';
|
||||||
Button,
|
|
||||||
useDisclosure,
|
|
||||||
Modal,
|
|
||||||
ModalOverlay,
|
|
||||||
ModalContent,
|
|
||||||
ModalBody,
|
|
||||||
toast,
|
|
||||||
} from '@chakra-ui/react';
|
|
||||||
import { AddIcon } from '@chakra-ui/icons';
|
import { AddIcon } from '@chakra-ui/icons';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useMutation } from 'react-query';
|
import { useMutation } from 'react-query';
|
||||||
@@ -64,8 +56,7 @@ const CreateConfigurationModal = ({ refresh, entityId }) => {
|
|||||||
setConfiguration(null);
|
setConfiguration(null);
|
||||||
onOpen();
|
onOpen();
|
||||||
};
|
};
|
||||||
const closeModal = () =>
|
const closeModal = () => (form.dirty || configuration?.__form?.isDirty ? openConfirm() : onClose());
|
||||||
form.dirty || configuration?.__form?.isDirty ? openConfirm() : onClose();
|
|
||||||
const closeCancelAndForm = () => {
|
const closeCancelAndForm = () => {
|
||||||
closeConfirm();
|
closeConfirm();
|
||||||
onClose();
|
onClose();
|
||||||
@@ -73,13 +64,7 @@ const CreateConfigurationModal = ({ refresh, entityId }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button alignItems="center" colorScheme="blue" rightIcon={<AddIcon />} onClick={openModal} ml={2}>
|
||||||
alignItems="center"
|
|
||||||
colorScheme="blue"
|
|
||||||
rightIcon={<AddIcon />}
|
|
||||||
onClick={openModal}
|
|
||||||
ml={2}
|
|
||||||
>
|
|
||||||
{t('crud.create')}
|
{t('crud.create')}
|
||||||
</Button>
|
</Button>
|
||||||
<Modal onClose={closeModal} isOpen={isOpen} size="xl" scrollBehavior="inside">
|
<Modal onClose={closeModal} isOpen={isOpen} size="xl" scrollBehavior="inside">
|
||||||
@@ -92,11 +77,7 @@ const CreateConfigurationModal = ({ refresh, entityId }) => {
|
|||||||
<SaveButton
|
<SaveButton
|
||||||
onClick={form.submitForm}
|
onClick={form.submitForm}
|
||||||
isLoading={form.isSubmitting}
|
isLoading={form.isSubmitting}
|
||||||
isDisabled={
|
isDisabled={!form.isValid || !form.dirty || (configuration !== null && !configuration.__form.isValid)}
|
||||||
!form.isValid ||
|
|
||||||
!form.dirty ||
|
|
||||||
(configuration !== null && !configuration.__form.isValid)
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<CloseButton ml={2} onClick={closeModal} />
|
<CloseButton ml={2} onClick={closeModal} />
|
||||||
</>
|
</>
|
||||||
@@ -115,11 +96,7 @@ const CreateConfigurationModal = ({ refresh, entityId }) => {
|
|||||||
/>
|
/>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
<ConfirmCloseAlert
|
<ConfirmCloseAlert isOpen={showConfirm} confirm={closeCancelAndForm} cancel={closeConfirm} />
|
||||||
isOpen={showConfirm}
|
|
||||||
confirm={closeCancelAndForm}
|
|
||||||
cancel={closeConfirm}
|
|
||||||
/>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,10 +17,7 @@ const ConfigurationsTable = ({ select, actions }) => {
|
|||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const { data: configurations, isFetching } = useGetSelectConfigurations({ t, toast, select });
|
const { data: configurations, isFetching } = useGetSelectConfigurations({ t, toast, select });
|
||||||
|
|
||||||
const dateCell = useCallback(
|
const dateCell = useCallback((cell, key) => <FormattedDate date={cell.row.values[key]} key={uuid()} />, []);
|
||||||
(cell, key) => <FormattedDate date={cell.row.values[key]} key={uuid()} />,
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
const typesCell = useCallback((cell) => cell.row.values.deviceTypes.join(', '), []);
|
const typesCell = useCallback((cell) => cell.row.values.deviceTypes.join(', '), []);
|
||||||
|
|
||||||
// Columns array. This array contains your table headings and accessors which maps keys from data array
|
// Columns array. This array contains your table headings and accessors which maps keys from data array
|
||||||
|
|||||||
@@ -210,11 +210,7 @@ const AssignContactModal = ({ entityId, venueId, alreadyClaimed }) => {
|
|||||||
</Box>
|
</Box>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
<ConfirmCloseAlert
|
<ConfirmCloseAlert isOpen={showConfirm} confirm={closeCancelAndForm} cancel={closeConfirm} />
|
||||||
isOpen={showConfirm}
|
|
||||||
confirm={closeCancelAndForm}
|
|
||||||
cancel={closeConfirm}
|
|
||||||
/>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -94,10 +94,8 @@ const CreateContactForm = ({ isOpen, onClose, refresh, formRef, parent }) => {
|
|||||||
phones,
|
phones,
|
||||||
description,
|
description,
|
||||||
accessPIN,
|
accessPIN,
|
||||||
entity:
|
entity: entity === '' || entity.split(':')[0] !== 'ent' ? undefined : entity.split(':')[1],
|
||||||
entity === '' || entity.split(':')[0] !== 'ent' ? undefined : entity.split(':')[1],
|
venue: entity === '' || entity.split(':')[0] !== 'ven' ? undefined : entity.split(':')[1],
|
||||||
venue:
|
|
||||||
entity === '' || entity.split(':')[0] !== 'ven' ? undefined : entity.split(':')[1],
|
|
||||||
notes: note.length > 0 ? [{ note }] : undefined,
|
notes: note.length > 0 ? [{ note }] : undefined,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -142,13 +140,7 @@ const CreateContactForm = ({ isOpen, onClose, refresh, formRef, parent }) => {
|
|||||||
{({ errors, touched, setFieldValue }) => (
|
{({ errors, touched, setFieldValue }) => (
|
||||||
<Form>
|
<Form>
|
||||||
<SimpleGrid minChildWidth="300px" spacing="20px" mb={8}>
|
<SimpleGrid minChildWidth="300px" spacing="20px" mb={8}>
|
||||||
<StringField
|
<StringField name="name" label={t('contacts.visual')} errors={errors} touched={touched} isRequired />
|
||||||
name="name"
|
|
||||||
label={t('contacts.visual')}
|
|
||||||
errors={errors}
|
|
||||||
touched={touched}
|
|
||||||
isRequired
|
|
||||||
/>
|
|
||||||
<SelectField
|
<SelectField
|
||||||
name="type"
|
name="type"
|
||||||
label={t('common.type')}
|
label={t('common.type')}
|
||||||
@@ -207,12 +199,7 @@ const CreateContactForm = ({ isOpen, onClose, refresh, formRef, parent }) => {
|
|||||||
{ value: 'Dr.', label: 'Dr.' },
|
{ value: 'Dr.', label: 'Dr.' },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<StringField
|
<StringField name="title" label={t('contacts.title')} errors={errors} touched={touched} />
|
||||||
name="title"
|
|
||||||
label={t('contacts.title')}
|
|
||||||
errors={errors}
|
|
||||||
touched={touched}
|
|
||||||
/>
|
|
||||||
<StringField
|
<StringField
|
||||||
name="firstname"
|
name="firstname"
|
||||||
label={t('contacts.first_name')}
|
label={t('contacts.first_name')}
|
||||||
@@ -220,24 +207,9 @@ const CreateContactForm = ({ isOpen, onClose, refresh, formRef, parent }) => {
|
|||||||
touched={touched}
|
touched={touched}
|
||||||
isRequired
|
isRequired
|
||||||
/>
|
/>
|
||||||
<StringField
|
<StringField name="lastname" label={t('contacts.last_name')} errors={errors} touched={touched} />
|
||||||
name="lastname"
|
<StringField name="initials" label={t('contacts.initials')} errors={errors} touched={touched} />
|
||||||
label={t('contacts.last_name')}
|
<StringField name="description" label={t('common.description')} errors={errors} touched={touched} />
|
||||||
errors={errors}
|
|
||||||
touched={touched}
|
|
||||||
/>
|
|
||||||
<StringField
|
|
||||||
name="initials"
|
|
||||||
label={t('contacts.initials')}
|
|
||||||
errors={errors}
|
|
||||||
touched={touched}
|
|
||||||
/>
|
|
||||||
<StringField
|
|
||||||
name="description"
|
|
||||||
label={t('common.description')}
|
|
||||||
errors={errors}
|
|
||||||
touched={touched}
|
|
||||||
/>
|
|
||||||
<StringField
|
<StringField
|
||||||
name="primaryEmail"
|
name="primaryEmail"
|
||||||
label={t('contacts.primary_email')}
|
label={t('contacts.primary_email')}
|
||||||
@@ -267,12 +239,7 @@ const CreateContactForm = ({ isOpen, onClose, refresh, formRef, parent }) => {
|
|||||||
placeholder="+1(202)555-0103"
|
placeholder="+1(202)555-0103"
|
||||||
setFieldValue={setFieldValue}
|
setFieldValue={setFieldValue}
|
||||||
/>
|
/>
|
||||||
<StringField
|
<StringField name="accessPIN" label={t('contacts.access_pin')} errors={errors} touched={touched} />
|
||||||
name="accessPIN"
|
|
||||||
label={t('contacts.access_pin')}
|
|
||||||
errors={errors}
|
|
||||||
touched={touched}
|
|
||||||
/>
|
|
||||||
<StringField name="note" label={t('common.note')} errors={errors} touched={touched} />
|
<StringField name="note" label={t('common.note')} errors={errors} touched={touched} />
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
import React, { useCallback, useState } from 'react';
|
import React, { useCallback, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import {
|
import { Button, useDisclosure, Modal, ModalOverlay, ModalContent, ModalBody } from '@chakra-ui/react';
|
||||||
Button,
|
|
||||||
useDisclosure,
|
|
||||||
Modal,
|
|
||||||
ModalOverlay,
|
|
||||||
ModalContent,
|
|
||||||
ModalBody,
|
|
||||||
} from '@chakra-ui/react';
|
|
||||||
import { AddIcon } from '@chakra-ui/icons';
|
import { AddIcon } from '@chakra-ui/icons';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import ConfirmCloseAlert from 'components/ConfirmCloseAlert';
|
import ConfirmCloseAlert from 'components/ConfirmCloseAlert';
|
||||||
@@ -101,11 +94,7 @@ const CreateContactModal = ({ refresh, entityId, isVenue }) => {
|
|||||||
/>
|
/>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
<ConfirmCloseAlert
|
<ConfirmCloseAlert isOpen={showConfirm} confirm={closeCancelAndForm} cancel={closeConfirm} />
|
||||||
isOpen={showConfirm}
|
|
||||||
confirm={closeCancelAndForm}
|
|
||||||
cancel={closeConfirm}
|
|
||||||
/>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -269,9 +269,7 @@ const EditContactForm = ({ editing, isOpen, onClose, refresh, contact, formRef }
|
|||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel>
|
<TabPanel>
|
||||||
<Field name="notes">
|
<Field name="notes">
|
||||||
{({ field }) => (
|
{({ field }) => <NotesTable notes={field.value} setNotes={setFieldValue} isDisabled={!editing} />}
|
||||||
<NotesTable notes={field.value} setNotes={setFieldValue} isDisabled={!editing} />
|
|
||||||
)}
|
|
||||||
</Field>
|
</Field>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
</TabPanels>
|
</TabPanels>
|
||||||
|
|||||||
@@ -26,10 +26,7 @@ const ContactTable = ({ actions, select, ignoredColumns, refreshId, disabledIds
|
|||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const { data: venues, isFetching, refetch } = useGetSelectContacts({ t, toast, select });
|
const { data: venues, isFetching, refetch } = useGetSelectContacts({ t, toast, select });
|
||||||
|
|
||||||
const memoizedDate = useCallback(
|
const memoizedDate = useCallback((cell, key) => <FormattedDate date={cell.row.values[key]} key={uuid()} />, []);
|
||||||
(cell, key) => <FormattedDate date={cell.row.values[key]} key={uuid()} />,
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
// Columns array. This array contains your table headings and accessors which maps keys from data array
|
// Columns array. This array contains your table headings and accessors which maps keys from data array
|
||||||
const columns = React.useMemo(() => {
|
const columns = React.useMemo(() => {
|
||||||
|
|||||||
@@ -17,10 +17,7 @@ const EntityTable = ({ actions, select }) => {
|
|||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const { data: entities, isFetching } = useGetSelectEntities({ t, toast, select });
|
const { data: entities, isFetching } = useGetSelectEntities({ t, toast, select });
|
||||||
|
|
||||||
const dateCell = useCallback(
|
const dateCell = useCallback((cell, key) => <FormattedDate date={cell.row.values[key]} key={uuid()} />, []);
|
||||||
(cell, key) => <FormattedDate date={cell.row.values[key]} key={uuid()} />,
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
// Columns array. This array contains your table headings and accessors which maps keys from data array
|
// Columns array. This array contains your table headings and accessors which maps keys from data array
|
||||||
const columns = useMemo(() => {
|
const columns = useMemo(() => {
|
||||||
|
|||||||
@@ -136,13 +136,7 @@ const AssignTagModal = ({ entityId, alreadyClaimedDevices }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button alignItems="center" colorScheme="blue" rightIcon={<Lock size={20} />} onClick={openModal} ml={2}>
|
||||||
alignItems="center"
|
|
||||||
colorScheme="blue"
|
|
||||||
rightIcon={<Lock size={20} />}
|
|
||||||
onClick={openModal}
|
|
||||||
ml={2}
|
|
||||||
>
|
|
||||||
{t('common.claim')}
|
{t('common.claim')}
|
||||||
</Button>
|
</Button>
|
||||||
<Modal onClose={closeModal} isOpen={isOpen} size="xl">
|
<Modal onClose={closeModal} isOpen={isOpen} size="xl">
|
||||||
@@ -184,11 +178,7 @@ const AssignTagModal = ({ entityId, alreadyClaimedDevices }) => {
|
|||||||
</Box>
|
</Box>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
<ConfirmCloseAlert
|
<ConfirmCloseAlert isOpen={showConfirm} confirm={closeCancelAndForm} cancel={closeConfirm} />
|
||||||
isOpen={showConfirm}
|
|
||||||
confirm={closeCancelAndForm}
|
|
||||||
cancel={closeConfirm}
|
|
||||||
/>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,15 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import {
|
import { Modal, ModalOverlay, ModalContent, ModalBody, Alert, AlertIcon, Heading, Box } from '@chakra-ui/react';
|
||||||
Modal,
|
|
||||||
ModalOverlay,
|
|
||||||
ModalContent,
|
|
||||||
ModalBody,
|
|
||||||
Alert,
|
|
||||||
AlertIcon,
|
|
||||||
Heading,
|
|
||||||
Box,
|
|
||||||
} from '@chakra-ui/react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import CloseButton from 'components/Buttons/CloseButton';
|
import CloseButton from 'components/Buttons/CloseButton';
|
||||||
import ModalHeader from 'components/ModalHeader';
|
import ModalHeader from 'components/ModalHeader';
|
||||||
|
|||||||
@@ -54,16 +54,7 @@ const CreateTagForm = ({
|
|||||||
return `ven:${splitEntity[1]}`;
|
return `ven:${splitEntity[1]}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const createParameters = ({
|
const createParameters = ({ serialNumber, name, description, note, deviceType, devClass, rrm, entity }) => ({
|
||||||
serialNumber,
|
|
||||||
name,
|
|
||||||
description,
|
|
||||||
note,
|
|
||||||
deviceType,
|
|
||||||
devClass,
|
|
||||||
rrm,
|
|
||||||
entity,
|
|
||||||
}) => ({
|
|
||||||
serialNumber,
|
serialNumber,
|
||||||
name,
|
name,
|
||||||
rrm,
|
rrm,
|
||||||
@@ -152,13 +143,7 @@ const CreateTagForm = ({
|
|||||||
touched={touched}
|
touched={touched}
|
||||||
isRequired
|
isRequired
|
||||||
/>
|
/>
|
||||||
<StringField
|
<StringField name="name" label={t('common.name')} errors={errors} touched={touched} isRequired />
|
||||||
name="name"
|
|
||||||
label={t('common.name')}
|
|
||||||
errors={errors}
|
|
||||||
touched={touched}
|
|
||||||
isRequired
|
|
||||||
/>
|
|
||||||
<SelectField
|
<SelectField
|
||||||
name="deviceType"
|
name="deviceType"
|
||||||
label={t('inventory.device_type')}
|
label={t('inventory.device_type')}
|
||||||
@@ -223,12 +208,7 @@ const CreateTagForm = ({
|
|||||||
]}
|
]}
|
||||||
isRequired
|
isRequired
|
||||||
/>
|
/>
|
||||||
<StringField
|
<StringField name="description" label={t('common.description')} errors={errors} touched={touched} />
|
||||||
name="description"
|
|
||||||
label={t('common.description')}
|
|
||||||
errors={errors}
|
|
||||||
touched={touched}
|
|
||||||
/>
|
|
||||||
<StringField name="note" label={t('common.note')} errors={errors} touched={touched} />
|
<StringField name="note" label={t('common.note')} errors={errors} touched={touched} />
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
<SpecialConfigurationManager editing onChange={onConfigurationChange} />
|
<SpecialConfigurationManager editing onChange={onConfigurationChange} />
|
||||||
|
|||||||
@@ -64,8 +64,7 @@ const CreateTagModal = ({ refresh, entityId, subId }) => {
|
|||||||
setConfiguration(null);
|
setConfiguration(null);
|
||||||
onOpen();
|
onOpen();
|
||||||
};
|
};
|
||||||
const closeModal = () =>
|
const closeModal = () => (form.dirty || configuration?.__form?.isDirty ? openConfirm() : onClose());
|
||||||
form.dirty || configuration?.__form?.isDirty ? openConfirm() : onClose();
|
|
||||||
const closeCancelAndForm = () => {
|
const closeCancelAndForm = () => {
|
||||||
closeConfirm();
|
closeConfirm();
|
||||||
onClose();
|
onClose();
|
||||||
@@ -84,11 +83,7 @@ const CreateTagModal = ({ refresh, entityId, subId }) => {
|
|||||||
<SaveButton
|
<SaveButton
|
||||||
onClick={form.submitForm}
|
onClick={form.submitForm}
|
||||||
isLoading={form.isSubmitting}
|
isLoading={form.isSubmitting}
|
||||||
isDisabled={
|
isDisabled={!form.isValid || !form.dirty || (configuration !== null && !configuration.__form.isValid)}
|
||||||
!form.isValid ||
|
|
||||||
!form.dirty ||
|
|
||||||
(configuration !== null && !configuration.__form.isValid)
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<CloseButton ml={2} onClick={closeModal} />
|
<CloseButton ml={2} onClick={closeModal} />
|
||||||
</>
|
</>
|
||||||
@@ -109,11 +104,7 @@ const CreateTagModal = ({ refresh, entityId, subId }) => {
|
|||||||
/>
|
/>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
<ConfirmCloseAlert
|
<ConfirmCloseAlert isOpen={showConfirm} confirm={closeCancelAndForm} cancel={closeConfirm} />
|
||||||
isOpen={showConfirm}
|
|
||||||
confirm={closeCancelAndForm}
|
|
||||||
cancel={closeConfirm}
|
|
||||||
/>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -50,16 +50,9 @@ const ComputedConfigurationDisplay = ({ computedConfig }) => {
|
|||||||
{computedConfig.explanation?.map((exp) => (
|
{computedConfig.explanation?.map((exp) => (
|
||||||
<AccordionItem key={uuid()}>
|
<AccordionItem key={uuid()}>
|
||||||
<AccordionButton
|
<AccordionButton
|
||||||
bg={
|
bg={exp.action === 'added' ? 'var(--chakra-colors-green-500)' : 'var(--chakra-colors-red-500)'}
|
||||||
exp.action === 'added'
|
|
||||||
? 'var(--chakra-colors-green-500)'
|
|
||||||
: 'var(--chakra-colors-red-500)'
|
|
||||||
}
|
|
||||||
_hover={{
|
_hover={{
|
||||||
bg:
|
bg: exp.action === 'added' ? 'var(--chakra-colors-green-700)' : 'var(--chakra-colors-red-700)',
|
||||||
exp.action === 'added'
|
|
||||||
? 'var(--chakra-colors-green-700)'
|
|
||||||
: 'var(--chakra-colors-red-700)',
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Center>
|
<Center>
|
||||||
|
|||||||
@@ -45,9 +45,7 @@ const ConfigurationPicker = ({ tagId, name, isDisabled }) => {
|
|||||||
classNamePrefix="chakra-react-select"
|
classNamePrefix="chakra-react-select"
|
||||||
menuPortalTarget={document.body}
|
menuPortalTarget={document.body}
|
||||||
options={[{ value: '', label: t('common.none') }, ...options]}
|
options={[{ value: '', label: t('common.none') }, ...options]}
|
||||||
value={[{ value: '', label: t('common.none') }, ...options].find(
|
value={[{ value: '', label: t('common.none') }, ...options].find((opt) => opt.value === value)}
|
||||||
(opt) => opt.value === value,
|
|
||||||
)}
|
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -2,16 +2,7 @@ import React, { useEffect, useState } from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import {
|
import { useToast, Tabs, TabList, TabPanels, TabPanel, Tab, SimpleGrid, Textarea } from '@chakra-ui/react';
|
||||||
useToast,
|
|
||||||
Tabs,
|
|
||||||
TabList,
|
|
||||||
TabPanels,
|
|
||||||
TabPanel,
|
|
||||||
Tab,
|
|
||||||
SimpleGrid,
|
|
||||||
Textarea,
|
|
||||||
} from '@chakra-ui/react';
|
|
||||||
import { Formik, Field, Form } from 'formik';
|
import { Formik, Field, Form } from 'formik';
|
||||||
import NotesTable from 'components/NotesTable';
|
import NotesTable from 'components/NotesTable';
|
||||||
import StringField from 'components/FormFields/StringField';
|
import StringField from 'components/FormFields/StringField';
|
||||||
@@ -199,23 +190,9 @@ const EditTagForm = ({
|
|||||||
<TabPanel>
|
<TabPanel>
|
||||||
<Form>
|
<Form>
|
||||||
<SimpleGrid minChildWidth="300px" spacing="20px">
|
<SimpleGrid minChildWidth="300px" spacing="20px">
|
||||||
<StringField
|
<StringField name="serialNumber" label={t('inventory.serial_number')} isDisabled isRequired />
|
||||||
name="serialNumber"
|
<StringField name="name" label={t('common.name')} isDisabled={!editing} isRequired />
|
||||||
label={t('inventory.serial_number')}
|
<StringField name="description" label={t('common.description')} isDisabled={!editing} />
|
||||||
isDisabled
|
|
||||||
isRequired
|
|
||||||
/>
|
|
||||||
<StringField
|
|
||||||
name="name"
|
|
||||||
label={t('common.name')}
|
|
||||||
isDisabled={!editing}
|
|
||||||
isRequired
|
|
||||||
/>
|
|
||||||
<StringField
|
|
||||||
name="description"
|
|
||||||
label={t('common.description')}
|
|
||||||
isDisabled={!editing}
|
|
||||||
/>
|
|
||||||
<SelectField
|
<SelectField
|
||||||
name="deviceType"
|
name="deviceType"
|
||||||
label={t('inventory.device_type')}
|
label={t('inventory.device_type')}
|
||||||
@@ -289,15 +266,11 @@ const EditTagForm = ({
|
|||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel>
|
<TabPanel>
|
||||||
<Field name="notes">
|
<Field name="notes">
|
||||||
{({ field }) => (
|
{({ field }) => <NotesTable notes={field.value} setNotes={setFieldValue} isDisabled={!editing} />}
|
||||||
<NotesTable notes={field.value} setNotes={setFieldValue} isDisabled={!editing} />
|
|
||||||
)}
|
|
||||||
</Field>
|
</Field>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel>
|
<TabPanel>
|
||||||
<Field name="state">
|
<Field name="state">{({ field }) => <Textarea {...field} isDisabled={!editing} />}</Field>
|
||||||
{({ field }) => <Textarea {...field} isDisabled={!editing} />}
|
|
||||||
</Field>
|
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
</TabPanels>
|
</TabPanels>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|||||||
@@ -71,11 +71,7 @@ const SpecialConfigurationForm = ({ editing, configuration, formRef }) => {
|
|||||||
isDisabled={!editing}
|
isDisabled={!editing}
|
||||||
w={36}
|
w={36}
|
||||||
/>
|
/>
|
||||||
<ToggleField
|
<ToggleField name="firmwareRCOnly" label={t('configurations.rc_only')} isDisabled={!editing} />
|
||||||
name="firmwareRCOnly"
|
|
||||||
label={t('configurations.rc_only')}
|
|
||||||
isDisabled={!editing}
|
|
||||||
/>
|
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
</Formik>
|
</Formik>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -45,13 +45,7 @@ const defaultProps = {
|
|||||||
isOnlySections: false,
|
isOnlySections: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const SpecialConfigurationManager = ({
|
const SpecialConfigurationManager = ({ editing, configId, onChange, isEnabledByDefault, isOnlySections }) => {
|
||||||
editing,
|
|
||||||
configId,
|
|
||||||
onChange,
|
|
||||||
isEnabledByDefault,
|
|
||||||
isOnlySections,
|
|
||||||
}) => {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const [sections, setSections] = useState(isEnabledByDefault ? BASE_SECTIONS : null);
|
const [sections, setSections] = useState(isEnabledByDefault ? BASE_SECTIONS : null);
|
||||||
@@ -120,11 +114,7 @@ const SpecialConfigurationManager = ({
|
|||||||
<Spacer />
|
<Spacer />
|
||||||
<DeleteButton onClick={handleDeleteClick} isDisabled={!editing} />
|
<DeleteButton onClick={handleDeleteClick} isDisabled={!editing} />
|
||||||
</Heading>
|
</Heading>
|
||||||
<SpecialConfigurationForm
|
<SpecialConfigurationForm editing={editing} formRef={formRef} configuration={configuration} />
|
||||||
editing={editing}
|
|
||||||
formRef={formRef}
|
|
||||||
configuration={configuration}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<ConfigurationSectionsCard
|
<ConfigurationSectionsCard
|
||||||
|
|||||||
@@ -88,8 +88,7 @@ const EditTagModal = ({ isOpen, onClose, tag, refresh, pushConfig }) => {
|
|||||||
|
|
||||||
const onConfigurationChange = useCallback((conf) => setConfiguration(conf), []);
|
const onConfigurationChange = useCallback((conf) => setConfiguration(conf), []);
|
||||||
|
|
||||||
const closeModal = () =>
|
const closeModal = () => (form.dirty || configuration?.__form?.isDirty ? openConfirm() : onClose());
|
||||||
form.dirty || configuration?.__form?.isDirty ? openConfirm() : onClose();
|
|
||||||
const closeCancelAndForm = () => {
|
const closeCancelAndForm = () => {
|
||||||
closeConfirm();
|
closeConfirm();
|
||||||
onClose();
|
onClose();
|
||||||
@@ -115,11 +114,7 @@ const EditTagModal = ({ isOpen, onClose, tag, refresh, pushConfig }) => {
|
|||||||
<SaveButton
|
<SaveButton
|
||||||
onClick={form.submitForm}
|
onClick={form.submitForm}
|
||||||
isLoading={form.isSubmitting}
|
isLoading={form.isSubmitting}
|
||||||
isDisabled={
|
isDisabled={!editing || !form.isValid || (configuration !== null && !configuration.__form.isValid)}
|
||||||
!editing ||
|
|
||||||
!form.isValid ||
|
|
||||||
(configuration !== null && !configuration.__form.isValid)
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Tooltip hasArrow label={t('configurations.push_configuration')} placement="top">
|
<Tooltip hasArrow label={t('configurations.push_configuration')} placement="top">
|
||||||
<IconButton
|
<IconButton
|
||||||
|
|||||||
@@ -52,11 +52,7 @@ const ImportDeviceTests = ({ devicesToTest, setPhase, setDevicesToImport }) => {
|
|||||||
return axios
|
return axios
|
||||||
.get(`${axiosProv.defaults.baseURL}/inventory/${device.SerialNumber}`, options)
|
.get(`${axiosProv.defaults.baseURL}/inventory/${device.SerialNumber}`, options)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (
|
if (response.data.venue !== '' || response.data.entity !== '' || response.data.subscriber !== '')
|
||||||
response.data.venue !== '' ||
|
|
||||||
response.data.entity !== '' ||
|
|
||||||
response.data.subscriber !== ''
|
|
||||||
)
|
|
||||||
deviceResult.alreadyAssigned = true;
|
deviceResult.alreadyAssigned = true;
|
||||||
else deviceResult.foundUnassigned = true;
|
else deviceResult.foundUnassigned = true;
|
||||||
return deviceResult;
|
return deviceResult;
|
||||||
@@ -68,14 +64,9 @@ const ImportDeviceTests = ({ devicesToTest, setPhase, setDevicesToImport }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const testDevice = (device, alreadyTested) => {
|
const testDevice = (device, alreadyTested) => {
|
||||||
if (
|
if (device.SerialNumber === '' || device.SerialNumber.length !== 12 || !device.SerialNumber.match('^[a-fA-F0-9]+$'))
|
||||||
device.SerialNumber === '' ||
|
|
||||||
device.SerialNumber.length !== 12 ||
|
|
||||||
!device.SerialNumber.match('^[a-fA-F0-9]+$')
|
|
||||||
)
|
|
||||||
return t('devices.invalid_serial_number');
|
return t('devices.invalid_serial_number');
|
||||||
if (!deviceTypes.find((devType) => devType === device.DeviceType))
|
if (!deviceTypes.find((devType) => devType === device.DeviceType)) return t('devices.device_type_not_found');
|
||||||
return t('devices.device_type_not_found');
|
|
||||||
if (alreadyTested.find((testedDevice) => device.SerialNumber === testedDevice))
|
if (alreadyTested.find((testedDevice) => device.SerialNumber === testedDevice))
|
||||||
return t('devices.duplicate_serial');
|
return t('devices.duplicate_serial');
|
||||||
return null;
|
return null;
|
||||||
@@ -127,11 +118,7 @@ const ImportDeviceTests = ({ devicesToTest, setPhase, setDevicesToImport }) => {
|
|||||||
const newLength = testResult?.newDevices?.length ?? -1;
|
const newLength = testResult?.newDevices?.length ?? -1;
|
||||||
const unassignedLength = testResult?.foundNotAssigned?.length ?? -1;
|
const unassignedLength = testResult?.foundNotAssigned?.length ?? -1;
|
||||||
const assignedLength = testResult?.foundAssigned?.length ?? -1;
|
const assignedLength = testResult?.foundAssigned?.length ?? -1;
|
||||||
return (
|
return newLength > 0 || (unassignedLength > 0 && assignUnassigned) || (assignedLength > 0 && reassign);
|
||||||
newLength > 0 ||
|
|
||||||
(unassignedLength > 0 && assignUnassigned) ||
|
|
||||||
(assignedLength > 0 && reassign)
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const startImport = () => {
|
const startImport = () => {
|
||||||
|
|||||||
@@ -94,12 +94,7 @@ const ImportDeviceCsvModal = ({ refresh, deviceClass, parent }) => {
|
|||||||
const getButton = () => {
|
const getButton = () => {
|
||||||
if (breakpoint !== 'base' && breakpoint !== 'sm') {
|
if (breakpoint !== 'base' && breakpoint !== 'sm') {
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button ml={2} colorScheme="blue" onClick={openModal} rightIcon={<UploadSimple size={20} />}>
|
||||||
ml={2}
|
|
||||||
colorScheme="blue"
|
|
||||||
onClick={openModal}
|
|
||||||
rightIcon={<UploadSimple size={20} />}
|
|
||||||
>
|
|
||||||
{t('devices.import_batch_tags')}
|
{t('devices.import_batch_tags')}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
@@ -107,12 +102,7 @@ const ImportDeviceCsvModal = ({ refresh, deviceClass, parent }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip label={t('devices.import_batch_tags')}>
|
<Tooltip label={t('devices.import_batch_tags')}>
|
||||||
<IconButton
|
<IconButton ml={2} colorScheme="blue" onClick={openModal} icon={<UploadSimple size={20} />} />
|
||||||
ml={2}
|
|
||||||
colorScheme="blue"
|
|
||||||
onClick={openModal}
|
|
||||||
icon={<UploadSimple size={20} />}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -130,17 +120,10 @@ const ImportDeviceCsvModal = ({ refresh, deviceClass, parent }) => {
|
|||||||
<Modal onClose={closeModal} isOpen={isOpen} size="xl">
|
<Modal onClose={closeModal} isOpen={isOpen} size="xl">
|
||||||
<ModalOverlay />
|
<ModalOverlay />
|
||||||
<ModalContent maxWidth={{ sm: '600px', md: '700px', lg: '800px', xl: '50%' }}>
|
<ModalContent maxWidth={{ sm: '600px', md: '700px', lg: '800px', xl: '50%' }}>
|
||||||
<ModalHeader
|
<ModalHeader title={t('devices.import_batch_tags')} right={<CloseButton ml={2} onClick={closeModal} />} />
|
||||||
title={t('devices.import_batch_tags')}
|
|
||||||
right={<CloseButton ml={2} onClick={closeModal} />}
|
|
||||||
/>
|
|
||||||
<ModalBody>{getPhase()}</ModalBody>
|
<ModalBody>{getPhase()}</ModalBody>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
<ConfirmCloseAlert
|
<ConfirmCloseAlert isOpen={showConfirm} confirm={closeCancelAndForm} cancel={closeConfirm} />
|
||||||
isOpen={showConfirm}
|
|
||||||
confirm={closeCancelAndForm}
|
|
||||||
cancel={closeConfirm}
|
|
||||||
/>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -57,10 +57,7 @@ const InventoryTable = ({
|
|||||||
pageInfo,
|
pageInfo,
|
||||||
tagSelect,
|
tagSelect,
|
||||||
owner,
|
owner,
|
||||||
enabled:
|
enabled: (!isManual && pageInfo !== null) || (isManual && tagSelect?.length > 0) || (isManual && owner !== null),
|
||||||
(!isManual && pageInfo !== null) ||
|
|
||||||
(isManual && tagSelect?.length > 0) ||
|
|
||||||
(isManual && owner !== null),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const deviceActions = useCallback(
|
const deviceActions = useCallback(
|
||||||
@@ -77,8 +74,7 @@ const InventoryTable = ({
|
|||||||
icon={<Plus size={20} />}
|
icon={<Plus size={20} />}
|
||||||
size="sm"
|
size="sm"
|
||||||
isDisabled={serialsToDisable.find(
|
isDisabled={serialsToDisable.find(
|
||||||
(serial) =>
|
(serial) => serial === cell.row.values.serialNumber || serial === cell.row.original.id,
|
||||||
serial === cell.row.values.serialNumber || serial === cell.row.original.id,
|
|
||||||
)}
|
)}
|
||||||
onClick={() => addAction(cell.row.values.serialNumber)}
|
onClick={() => addAction(cell.row.values.serialNumber)}
|
||||||
/>
|
/>
|
||||||
@@ -91,9 +87,7 @@ const InventoryTable = ({
|
|||||||
colorScheme="blue"
|
colorScheme="blue"
|
||||||
icon={<Trash size={20} />}
|
icon={<Trash size={20} />}
|
||||||
size="sm"
|
size="sm"
|
||||||
isDisabled={serialsToDisable.find(
|
isDisabled={serialsToDisable.find((serial) => serial === cell.row.values.serialNumber)}
|
||||||
(serial) => serial === cell.row.values.serialNumber,
|
|
||||||
)}
|
|
||||||
onClick={() => removeAction(cell.row.values.serialNumber)}
|
onClick={() => removeAction(cell.row.values.serialNumber)}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
@@ -208,11 +208,7 @@ const AssignLocationModal = ({ entityId, alreadyClaimed }) => {
|
|||||||
</Box>
|
</Box>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
<ConfirmCloseAlert
|
<ConfirmCloseAlert isOpen={showConfirm} confirm={closeCancelAndForm} cancel={closeConfirm} />
|
||||||
isOpen={showConfirm}
|
|
||||||
confirm={closeCancelAndForm}
|
|
||||||
cancel={closeConfirm}
|
|
||||||
/>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -143,19 +143,8 @@ const CreateLocationForm = ({ isOpen, onClose, refresh, formRef, entityId }) =>
|
|||||||
{({ errors, touched, setFieldValue }) => (
|
{({ errors, touched, setFieldValue }) => (
|
||||||
<Form>
|
<Form>
|
||||||
<SimpleGrid minChildWidth="300px" spacing="20px" mb={8}>
|
<SimpleGrid minChildWidth="300px" spacing="20px" mb={8}>
|
||||||
<StringField
|
<StringField name="name" label={t('common.name')} errors={errors} touched={touched} isRequired />
|
||||||
name="name"
|
<StringField name="description" label={t('common.description')} errors={errors} touched={touched} />
|
||||||
label={t('common.name')}
|
|
||||||
errors={errors}
|
|
||||||
touched={touched}
|
|
||||||
isRequired
|
|
||||||
/>
|
|
||||||
<StringField
|
|
||||||
name="description"
|
|
||||||
label={t('common.description')}
|
|
||||||
errors={errors}
|
|
||||||
touched={touched}
|
|
||||||
/>
|
|
||||||
<SelectWithSearchField
|
<SelectWithSearchField
|
||||||
name="entity"
|
name="entity"
|
||||||
label={t('inventory.parent')}
|
label={t('inventory.parent')}
|
||||||
@@ -204,11 +193,7 @@ const CreateLocationForm = ({ isOpen, onClose, refresh, formRef, entityId }) =>
|
|||||||
/>
|
/>
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
|
|
||||||
<AddressSearchField
|
<AddressSearchField placeholder={t('common.address_search_autofill')} maxWidth="600px" mb={2} />
|
||||||
placeholder={t('common.address_search_autofill')}
|
|
||||||
maxWidth="600px"
|
|
||||||
mb={2}
|
|
||||||
/>
|
|
||||||
<SimpleGrid minChildWidth="300px" spacing="20px" mb={8}>
|
<SimpleGrid minChildWidth="300px" spacing="20px" mb={8}>
|
||||||
<StringField
|
<StringField
|
||||||
name="addressLineOne"
|
name="addressLineOne"
|
||||||
@@ -223,27 +208,9 @@ const CreateLocationForm = ({ isOpen, onClose, refresh, formRef, entityId }) =>
|
|||||||
errors={errors}
|
errors={errors}
|
||||||
touched={touched}
|
touched={touched}
|
||||||
/>
|
/>
|
||||||
<StringField
|
<StringField name="city" label={t('locations.city')} errors={errors} touched={touched} isRequired />
|
||||||
name="city"
|
<StringField name="state" label={t('locations.state')} errors={errors} touched={touched} isRequired />
|
||||||
label={t('locations.city')}
|
<StringField name="postal" label={t('locations.postal')} errors={errors} touched={touched} isRequired />
|
||||||
errors={errors}
|
|
||||||
touched={touched}
|
|
||||||
isRequired
|
|
||||||
/>
|
|
||||||
<StringField
|
|
||||||
name="state"
|
|
||||||
label={t('locations.state')}
|
|
||||||
errors={errors}
|
|
||||||
touched={touched}
|
|
||||||
isRequired
|
|
||||||
/>
|
|
||||||
<StringField
|
|
||||||
name="postal"
|
|
||||||
label={t('locations.postal')}
|
|
||||||
errors={errors}
|
|
||||||
touched={touched}
|
|
||||||
isRequired
|
|
||||||
/>
|
|
||||||
<SelectField
|
<SelectField
|
||||||
name="country"
|
name="country"
|
||||||
label={t('locations.country')}
|
label={t('locations.country')}
|
||||||
@@ -251,18 +218,8 @@ const CreateLocationForm = ({ isOpen, onClose, refresh, formRef, entityId }) =>
|
|||||||
touched={touched}
|
touched={touched}
|
||||||
options={COUNTRY_LIST}
|
options={COUNTRY_LIST}
|
||||||
/>
|
/>
|
||||||
<StringField
|
<StringField name="buildingName" label={t('locations.building_name')} errors={errors} touched={touched} />
|
||||||
name="buildingName"
|
<StringField name="geoCode" label={t('locations.geocode')} errors={errors} touched={touched} />
|
||||||
label={t('locations.building_name')}
|
|
||||||
errors={errors}
|
|
||||||
touched={touched}
|
|
||||||
/>
|
|
||||||
<StringField
|
|
||||||
name="geoCode"
|
|
||||||
label={t('locations.geocode')}
|
|
||||||
errors={errors}
|
|
||||||
touched={touched}
|
|
||||||
/>
|
|
||||||
<StringField name="note" label={t('common.note')} errors={errors} touched={touched} />
|
<StringField name="note" label={t('common.note')} errors={errors} touched={touched} />
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
import React, { useCallback, useState } from 'react';
|
import React, { useCallback, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import {
|
import { Button, useDisclosure, Modal, ModalOverlay, ModalContent, ModalBody } from '@chakra-ui/react';
|
||||||
Button,
|
|
||||||
useDisclosure,
|
|
||||||
Modal,
|
|
||||||
ModalOverlay,
|
|
||||||
ModalContent,
|
|
||||||
ModalBody,
|
|
||||||
} from '@chakra-ui/react';
|
|
||||||
import { AddIcon } from '@chakra-ui/icons';
|
import { AddIcon } from '@chakra-ui/icons';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import ConfirmCloseAlert from 'components/ConfirmCloseAlert';
|
import ConfirmCloseAlert from 'components/ConfirmCloseAlert';
|
||||||
@@ -92,11 +85,7 @@ const CreateLocationModal = ({ refresh, entityId }) => {
|
|||||||
/>
|
/>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
<ConfirmCloseAlert
|
<ConfirmCloseAlert isOpen={showConfirm} confirm={closeCancelAndForm} cancel={closeConfirm} />
|
||||||
isOpen={showConfirm}
|
|
||||||
confirm={closeCancelAndForm}
|
|
||||||
cancel={closeConfirm}
|
|
||||||
/>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -132,17 +132,8 @@ const EditLocationForm = ({ editing, isOpen, onClose, refresh, location, formRef
|
|||||||
<TabPanel>
|
<TabPanel>
|
||||||
<Form>
|
<Form>
|
||||||
<SimpleGrid minChildWidth="300px" spacing="20px" mb={8}>
|
<SimpleGrid minChildWidth="300px" spacing="20px" mb={8}>
|
||||||
<StringField
|
<StringField name="name" label={t('common.name')} isRequired isDisabled={!editing} />
|
||||||
name="name"
|
<StringField name="description" label={t('common.description')} isDisabled={!editing} />
|
||||||
label={t('common.name')}
|
|
||||||
isRequired
|
|
||||||
isDisabled={!editing}
|
|
||||||
/>
|
|
||||||
<StringField
|
|
||||||
name="description"
|
|
||||||
label={t('common.description')}
|
|
||||||
isDisabled={!editing}
|
|
||||||
/>
|
|
||||||
<SelectWithSearchField
|
<SelectWithSearchField
|
||||||
name="entity"
|
name="entity"
|
||||||
label={t('inventory.parent')}
|
label={t('inventory.parent')}
|
||||||
@@ -196,53 +187,24 @@ const EditLocationForm = ({ editing, isOpen, onClose, refresh, location, formRef
|
|||||||
isRequired
|
isRequired
|
||||||
isDisabled={!editing}
|
isDisabled={!editing}
|
||||||
/>
|
/>
|
||||||
<StringField
|
<StringField name="addressLineTwo" label={t('locations.address_line_two')} isDisabled={!editing} />
|
||||||
name="addressLineTwo"
|
<StringField name="city" label={t('locations.city')} isRequired isDisabled={!editing} />
|
||||||
label={t('locations.address_line_two')}
|
<StringField name="state" label={t('locations.state')} isRequired isDisabled={!editing} />
|
||||||
isDisabled={!editing}
|
<StringField name="postal" label={t('locations.postal')} isRequired isDisabled={!editing} />
|
||||||
/>
|
|
||||||
<StringField
|
|
||||||
name="city"
|
|
||||||
label={t('locations.city')}
|
|
||||||
isRequired
|
|
||||||
isDisabled={!editing}
|
|
||||||
/>
|
|
||||||
<StringField
|
|
||||||
name="state"
|
|
||||||
label={t('locations.state')}
|
|
||||||
isRequired
|
|
||||||
isDisabled={!editing}
|
|
||||||
/>
|
|
||||||
<StringField
|
|
||||||
name="postal"
|
|
||||||
label={t('locations.postal')}
|
|
||||||
isRequired
|
|
||||||
isDisabled={!editing}
|
|
||||||
/>
|
|
||||||
<SelectField
|
<SelectField
|
||||||
name="country"
|
name="country"
|
||||||
label={t('locations.country')}
|
label={t('locations.country')}
|
||||||
options={COUNTRY_LIST}
|
options={COUNTRY_LIST}
|
||||||
isDisabled={!editing}
|
isDisabled={!editing}
|
||||||
/>
|
/>
|
||||||
<StringField
|
<StringField name="buildingName" label={t('locations.building_name')} isDisabled={!editing} />
|
||||||
name="buildingName"
|
<StringField name="geoCode" label={t('locations.geocode')} isDisabled={!editing} />
|
||||||
label={t('locations.building_name')}
|
|
||||||
isDisabled={!editing}
|
|
||||||
/>
|
|
||||||
<StringField
|
|
||||||
name="geoCode"
|
|
||||||
label={t('locations.geocode')}
|
|
||||||
isDisabled={!editing}
|
|
||||||
/>
|
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
</Form>
|
</Form>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel>
|
<TabPanel>
|
||||||
<Field name="notes">
|
<Field name="notes">
|
||||||
{({ field }) => (
|
{({ field }) => <NotesTable notes={field.value} setNotes={setFieldValue} isDisabled={!editing} />}
|
||||||
<NotesTable notes={field.value} setNotes={setFieldValue} isDisabled={!editing} />
|
|
||||||
)}
|
|
||||||
</Field>
|
</Field>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
</TabPanels>
|
</TabPanels>
|
||||||
|
|||||||
@@ -25,10 +25,7 @@ const LocationTable = ({ actions, select, refreshId, ignoredColumns, disabledIds
|
|||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const { data: venues, isFetching, refetch } = useGetSelectLocations({ t, toast, select });
|
const { data: venues, isFetching, refetch } = useGetSelectLocations({ t, toast, select });
|
||||||
|
|
||||||
const memoizedDate = useCallback(
|
const memoizedDate = useCallback((cell, key) => <FormattedDate date={cell.row.values[key]} key={uuid()} />, []);
|
||||||
(cell, key) => <FormattedDate date={cell.row.values[key]} key={uuid()} />,
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
// Columns array. This array contains your table headings and accessors which maps keys from data array
|
// Columns array. This array contains your table headings and accessors which maps keys from data array
|
||||||
const columns = React.useMemo(() => {
|
const columns = React.useMemo(() => {
|
||||||
|
|||||||
@@ -77,11 +77,7 @@ const CreateVenueModal = ({ parentId, entityId, isDisabled }) => {
|
|||||||
/>
|
/>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
<ConfirmCloseAlert
|
<ConfirmCloseAlert isOpen={showConfirm} confirm={closeCancelAndForm} cancel={closeConfirm} />
|
||||||
isOpen={showConfirm}
|
|
||||||
confirm={closeCancelAndForm}
|
|
||||||
cancel={closeConfirm}
|
|
||||||
/>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,10 +17,7 @@ const VenueTable = ({ actions, select }) => {
|
|||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const { data: venues, isFetching } = useGetSelectVenues({ t, toast, select });
|
const { data: venues, isFetching } = useGetSelectVenues({ t, toast, select });
|
||||||
|
|
||||||
const memoizedDate = useCallback(
|
const memoizedDate = useCallback((cell, key) => <FormattedDate date={cell.row.values[key]} key={uuid()} />, []);
|
||||||
(cell, key) => <FormattedDate date={cell.row.values[key]} key={uuid()} />,
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
// Columns array. This array contains your table headings and accessors which maps keys from data array
|
// Columns array. This array contains your table headings and accessors which maps keys from data array
|
||||||
const columns = React.useMemo(() => {
|
const columns = React.useMemo(() => {
|
||||||
|
|||||||
@@ -121,11 +121,7 @@ const VerifyNumberModal = ({ isOpen, cancel, phoneNumber }) => {
|
|||||||
<Button ref={cancelRef} onClick={cancel} mr={4}>
|
<Button ref={cancelRef} onClick={cancel} mr={4}>
|
||||||
{t('common.cancel')}
|
{t('common.cancel')}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button colorScheme="blue" isLoading={sendPhoneTest.isLoading} onClick={handleSendClick}>
|
||||||
colorScheme="blue"
|
|
||||||
isLoading={sendPhoneTest.isLoading}
|
|
||||||
onClick={handleSendClick}
|
|
||||||
>
|
|
||||||
{t('account.resend')}
|
{t('account.resend')}
|
||||||
</Button>
|
</Button>
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
|
|||||||
@@ -95,8 +95,7 @@ export const CreateCertificateSchema = (t) =>
|
|||||||
|
|
||||||
const splitPort = v.split(':');
|
const splitPort = v.split(':');
|
||||||
|
|
||||||
if ((splitPort.length === 2 && splitPort[1] < 1) || splitPort[1] > 65535)
|
if ((splitPort.length === 2 && splitPort[1] < 1) || splitPort[1] > 65535) return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}),
|
}),
|
||||||
@@ -175,10 +174,7 @@ export const BatchSchema = (t) =>
|
|||||||
redirector: Yup.string().required(t('form.required')),
|
redirector: Yup.string().required(t('form.required')),
|
||||||
manufacturer: Yup.string().required(t('form.required')),
|
manufacturer: Yup.string().required(t('form.required')),
|
||||||
model: Yup.string().required(t('form.required')),
|
model: Yup.string().required(t('form.required')),
|
||||||
commonNames: Yup.array()
|
commonNames: Yup.array().of(Yup.string()).required(t('form.required')).min(1, t('batch.need_devices')),
|
||||||
.of(Yup.string())
|
|
||||||
.required(t('form.required'))
|
|
||||||
.min(1, t('batch.need_devices')),
|
|
||||||
note: Yup.string(),
|
note: Yup.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -204,10 +200,7 @@ export const CreateConfigurationSchema = (t) =>
|
|||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
name: Yup.string().required(t('form.required')),
|
name: Yup.string().required(t('form.required')),
|
||||||
rrm: Yup.string().required(t('form.required')),
|
rrm: Yup.string().required(t('form.required')),
|
||||||
deviceTypes: Yup.array()
|
deviceTypes: Yup.array().of(Yup.string()).required(t('form.required')).min(1, t('form.required')),
|
||||||
.of(Yup.string())
|
|
||||||
.required(t('form.required'))
|
|
||||||
.min(1, t('form.required')),
|
|
||||||
description: Yup.string(),
|
description: Yup.string(),
|
||||||
entity: Yup.string().required(t('form.required')),
|
entity: Yup.string().required(t('form.required')),
|
||||||
note: Yup.string(),
|
note: Yup.string(),
|
||||||
|
|||||||
@@ -1,15 +1,7 @@
|
|||||||
import React, { useState, useMemo, useEffect } from 'react';
|
import React, { useState, useMemo, useEffect } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
||||||
import {
|
import { axiosAnalytics, axiosFms, axiosGw, axiosOwls, axiosProv, axiosSec, axiosSub } from 'utils/axiosInstances';
|
||||||
axiosAnalytics,
|
|
||||||
axiosFms,
|
|
||||||
axiosGw,
|
|
||||||
axiosOwls,
|
|
||||||
axiosProv,
|
|
||||||
axiosSec,
|
|
||||||
axiosSub,
|
|
||||||
} from 'utils/axiosInstances';
|
|
||||||
import { useToast } from '@chakra-ui/react';
|
import { useToast } from '@chakra-ui/react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useGetEndpoints } from 'hooks/Network/Endpoints';
|
import { useGetEndpoints } from 'hooks/Network/Endpoints';
|
||||||
@@ -23,13 +15,10 @@ const deleteToken = async (currentToken) =>
|
|||||||
.then(() => true)
|
.then(() => true)
|
||||||
.catch(() => false);
|
.catch(() => false);
|
||||||
|
|
||||||
const getAvatar = async (id, cache) =>
|
const getAvatar = async (id, cache) => axiosSec.get(`avatar/${id}?cache=${cache}`, { responseType: 'arraybuffer' });
|
||||||
axiosSec.get(`avatar/${id}?cache=${cache}`, { responseType: 'arraybuffer' });
|
|
||||||
|
|
||||||
const getConfigDescriptions = async (baseUrl) =>
|
const getConfigDescriptions = async (baseUrl) =>
|
||||||
axios
|
axios.get(`${baseUrl.split('/api')[0]}/wwwassets/ucentral.schema.pretty.json`).then(({ data }) => data.$defs);
|
||||||
.get(`${baseUrl.split('/api')[0]}/wwwassets/ucentral.schema.pretty.json`)
|
|
||||||
.then(({ data }) => data.$defs);
|
|
||||||
const getUser = async () => axiosSec.get('oauth2?me=true').then(({ data }) => data);
|
const getUser = async () => axiosSec.get('oauth2?me=true').then(({ data }) => data);
|
||||||
|
|
||||||
const getPreferences = async () => axiosSec.get('preferences').then(({ data }) => data);
|
const getPreferences = async () => axiosSec.get('preferences').then(({ data }) => data);
|
||||||
@@ -105,13 +94,9 @@ export const AuthProvider = ({ token, children }) => {
|
|||||||
enabled: !!userId,
|
enabled: !!userId,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const { data: avatar } = useQuery(
|
const { data: avatar } = useQuery(['get-user-avatar', userId, userAvatar], () => getAvatar(userId, userAvatar), {
|
||||||
['get-user-avatar', userId, userAvatar],
|
enabled: userAvatar !== '' && userAvatar !== '0',
|
||||||
() => getAvatar(userId, userAvatar),
|
});
|
||||||
{
|
|
||||||
enabled: userAvatar !== '' && userAvatar !== '0',
|
|
||||||
},
|
|
||||||
);
|
|
||||||
const updatePreferences = useMutation((newPrefs) => putPreferences(newPrefs), {
|
const updatePreferences = useMutation((newPrefs) => putPreferences(newPrefs), {
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
queryClient.setQueryData(['get-preferences', userId], data.data);
|
queryClient.setQueryData(['get-preferences', userId], data.data);
|
||||||
@@ -181,10 +166,7 @@ export const AuthProvider = ({ token, children }) => {
|
|||||||
() => ({
|
() => ({
|
||||||
avatar: avatar?.data
|
avatar: avatar?.data
|
||||||
? `data:;base64,${btoa(
|
? `data:;base64,${btoa(
|
||||||
new Uint8Array(avatar.data).reduce(
|
new Uint8Array(avatar.data).reduce((data, byte) => data + String.fromCharCode(byte), ''),
|
||||||
(data, byte) => data + String.fromCharCode(byte),
|
|
||||||
'',
|
|
||||||
),
|
|
||||||
)}`
|
)}`
|
||||||
: '',
|
: '',
|
||||||
refetchUser,
|
refetchUser,
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ export const useGetConfigurations = ({ t, toast }) =>
|
|||||||
useQuery(
|
useQuery(
|
||||||
['get-configurations'],
|
['get-configurations'],
|
||||||
() =>
|
() =>
|
||||||
axiosProv
|
axiosProv.get('configurations?withExtendedInfo=true&offset=0, limit=500').then(({ data }) => data.configurations),
|
||||||
.get('configurations?withExtendedInfo=true&offset=0, limit=500')
|
|
||||||
.then(({ data }) => data.configurations),
|
|
||||||
{
|
{
|
||||||
staleTime: 200 * 1000,
|
staleTime: 200 * 1000,
|
||||||
onError: (e) => {
|
onError: (e) => {
|
||||||
@@ -131,10 +129,7 @@ export const useGetConfigurationInUse = ({ t, toast, id, enabled }) =>
|
|||||||
export const useGetConfigurationAffected = ({ t, toast, id, enabled }) =>
|
export const useGetConfigurationAffected = ({ t, toast, id, enabled }) =>
|
||||||
useQuery(
|
useQuery(
|
||||||
['get-config-affected', id],
|
['get-config-affected', id],
|
||||||
() =>
|
() => axiosProv.get(`/configurations/${id}?computedAffected=true`).then(({ data }) => data.affectedDevices),
|
||||||
axiosProv
|
|
||||||
.get(`/configurations/${id}?computedAffected=true`)
|
|
||||||
.then(({ data }) => data.affectedDevices),
|
|
||||||
{
|
{
|
||||||
enabled,
|
enabled,
|
||||||
onError: (e) => {
|
onError: (e) => {
|
||||||
@@ -154,8 +149,7 @@ export const useGetConfigurationAffected = ({ t, toast, id, enabled }) =>
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
export const useDeleteConfiguration = () =>
|
export const useDeleteConfiguration = () => useMutation((id) => axiosProv.delete(`configurations/${id}`));
|
||||||
useMutation((id) => axiosProv.delete(`configurations/${id}`));
|
|
||||||
|
|
||||||
export const useUpdateConfiguration = ({ id }) =>
|
export const useUpdateConfiguration = ({ id }) =>
|
||||||
useMutation((newConf) => axiosProv.put(`configurations/${id}`, newConf));
|
useMutation((newConf) => axiosProv.put(`configurations/${id}`, newConf));
|
||||||
|
|||||||
@@ -2,40 +2,32 @@ import { useMutation, useQuery } from 'react-query';
|
|||||||
import { axiosProv } from 'utils/axiosInstances';
|
import { axiosProv } from 'utils/axiosInstances';
|
||||||
|
|
||||||
export const useGetContactCount = ({ t, toast, enabled }) =>
|
export const useGetContactCount = ({ t, toast, enabled }) =>
|
||||||
useQuery(
|
useQuery(['get-contact-count'], () => axiosProv.get('contact?countOnly=true').then(({ data }) => data.count), {
|
||||||
['get-contact-count'],
|
enabled,
|
||||||
() => axiosProv.get('contact?countOnly=true').then(({ data }) => data.count),
|
staleTime: 30000,
|
||||||
{
|
onError: (e) => {
|
||||||
enabled,
|
if (!toast.isActive('contact-count-fetching-error'))
|
||||||
staleTime: 30000,
|
toast({
|
||||||
onError: (e) => {
|
id: 'contact-count-fetching-error',
|
||||||
if (!toast.isActive('contact-count-fetching-error'))
|
title: t('common.error'),
|
||||||
toast({
|
description: t('crud.error_fetching_obj', {
|
||||||
id: 'contact-count-fetching-error',
|
obj: t('contacts.other'),
|
||||||
title: t('common.error'),
|
e: e?.response?.data?.ErrorDescription,
|
||||||
description: t('crud.error_fetching_obj', {
|
}),
|
||||||
obj: t('contacts.other'),
|
status: 'error',
|
||||||
e: e?.response?.data?.ErrorDescription,
|
duration: 5000,
|
||||||
}),
|
isClosable: true,
|
||||||
status: 'error',
|
position: 'top-right',
|
||||||
duration: 5000,
|
});
|
||||||
isClosable: true,
|
|
||||||
position: 'top-right',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
|
|
||||||
export const useGetContacts = ({ t, toast, pageInfo, enabled, count }) =>
|
export const useGetContacts = ({ t, toast, pageInfo, enabled, count }) =>
|
||||||
useQuery(
|
useQuery(
|
||||||
['get-contacts-with-pagination', pageInfo, count],
|
['get-contacts-with-pagination', pageInfo, count],
|
||||||
() =>
|
() =>
|
||||||
axiosProv
|
axiosProv
|
||||||
.get(
|
.get(`contact?withExtendedInfo=true&limit=${pageInfo.limit}&offset=${pageInfo.limit * pageInfo.index}`)
|
||||||
`contact?withExtendedInfo=true&limit=${pageInfo.limit}&offset=${
|
|
||||||
pageInfo.limit * pageInfo.index
|
|
||||||
}`,
|
|
||||||
)
|
|
||||||
.then(({ data }) => data.contacts),
|
.then(({ data }) => data.contacts),
|
||||||
{
|
{
|
||||||
keepPreviousData: true,
|
keepPreviousData: true,
|
||||||
@@ -65,9 +57,7 @@ export const useGetSelectContacts = ({ t, toast, select }) =>
|
|||||||
() =>
|
() =>
|
||||||
select.length === 0
|
select.length === 0
|
||||||
? []
|
? []
|
||||||
: axiosProv
|
: axiosProv.get(`contact?withExtendedInfo=true&select=${select}`).then(({ data }) => data.contacts),
|
||||||
.get(`contact?withExtendedInfo=true&select=${select}`)
|
|
||||||
.then(({ data }) => data.contacts),
|
|
||||||
{
|
{
|
||||||
staleTime: 100 * 1000,
|
staleTime: 100 * 1000,
|
||||||
onError: (e) => {
|
onError: (e) => {
|
||||||
@@ -91,10 +81,7 @@ export const useGetSelectContacts = ({ t, toast, select }) =>
|
|||||||
export const useGetAllContacts = ({ t, toast }) =>
|
export const useGetAllContacts = ({ t, toast }) =>
|
||||||
useQuery(
|
useQuery(
|
||||||
['get-all-contacts'],
|
['get-all-contacts'],
|
||||||
() =>
|
() => axiosProv.get(`contact?withExtendedInfo=true&limit=500&offset=0`).then(({ data }) => data.contacts),
|
||||||
axiosProv
|
|
||||||
.get(`contact?withExtendedInfo=true&limit=500&offset=0`)
|
|
||||||
.then(({ data }) => data.contacts),
|
|
||||||
{
|
{
|
||||||
staleTime: 1000 * 1000,
|
staleTime: 1000 * 1000,
|
||||||
onError: (e) => {
|
onError: (e) => {
|
||||||
@@ -135,11 +122,9 @@ export const useGetContact = ({ t, toast, enabled, id }) =>
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const useCreateContact = () =>
|
export const useCreateContact = () => useMutation((newContact) => axiosProv.post('contact/0', newContact));
|
||||||
useMutation((newContact) => axiosProv.post('contact/0', newContact));
|
|
||||||
|
|
||||||
export const useUpdateContact = ({ id }) =>
|
export const useUpdateContact = ({ id }) => useMutation((newContact) => axiosProv.put(`contact/${id}`, newContact));
|
||||||
useMutation((newContact) => axiosProv.put(`contact/${id}`, newContact));
|
|
||||||
|
|
||||||
const claimContacts = async (contactIds, entity, venue) => {
|
const claimContacts = async (contactIds, entity, venue) => {
|
||||||
const addPromises = contactIds.map(async (id) =>
|
const addPromises = contactIds.map(async (id) =>
|
||||||
|
|||||||
@@ -2,12 +2,8 @@ import { useQuery } from 'react-query';
|
|||||||
import { axiosFms } from 'utils/axiosInstances';
|
import { axiosFms } from 'utils/axiosInstances';
|
||||||
|
|
||||||
const useGetDeviceTypes = () =>
|
const useGetDeviceTypes = () =>
|
||||||
useQuery(
|
useQuery(['get-device-types'], () => axiosFms.get('/firmwares?deviceSet=true').then(({ data }) => data.deviceTypes), {
|
||||||
['get-device-types'],
|
staleTime: Infinity,
|
||||||
() => axiosFms.get('/firmwares?deviceSet=true').then(({ data }) => data.deviceTypes),
|
});
|
||||||
{
|
|
||||||
staleTime: Infinity,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
export default useGetDeviceTypes;
|
export default useGetDeviceTypes;
|
||||||
|
|||||||
@@ -2,27 +2,23 @@ import { useQuery } from 'react-query';
|
|||||||
import { axiosGw, axiosSec } from 'utils/axiosInstances';
|
import { axiosGw, axiosSec } from 'utils/axiosInstances';
|
||||||
|
|
||||||
export const useGetEndpoints = ({ t, toast, onSuccess }) =>
|
export const useGetEndpoints = ({ t, toast, onSuccess }) =>
|
||||||
useQuery(
|
useQuery(['get-endpoints'], () => axiosSec.get('systemEndpoints').then(({ data }) => data.endpoints), {
|
||||||
['get-endpoints'],
|
enabled: false,
|
||||||
() => axiosSec.get('systemEndpoints').then(({ data }) => data.endpoints),
|
staleTime: Infinity,
|
||||||
{
|
onSuccess,
|
||||||
enabled: false,
|
onError: (e) => {
|
||||||
staleTime: Infinity,
|
if (!toast.isActive('endpoints-fetching-error'))
|
||||||
onSuccess,
|
toast({
|
||||||
onError: (e) => {
|
id: 'user-fetching-error',
|
||||||
if (!toast.isActive('endpoints-fetching-error'))
|
title: t('common.error'),
|
||||||
toast({
|
description: t('user.error_fetching', { e: e?.response?.data?.ErrorDescription }),
|
||||||
id: 'user-fetching-error',
|
status: 'error',
|
||||||
title: t('common.error'),
|
duration: 5000,
|
||||||
description: t('user.error_fetching', { e: e?.response?.data?.ErrorDescription }),
|
isClosable: true,
|
||||||
status: 'error',
|
position: 'top-right',
|
||||||
duration: 5000,
|
});
|
||||||
isClosable: true,
|
|
||||||
position: 'top-right',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
|
|
||||||
export const useGetGatewayUi = () =>
|
export const useGetGatewayUi = () =>
|
||||||
useQuery(['get-gw-ui'], () => axiosGw.get('system?command=info').then(({ data }) => data.UI), {
|
useQuery(['get-gw-ui'], () => axiosGw.get('system?command=info').then(({ data }) => data.UI), {
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ import { axiosProv } from 'utils/axiosInstances';
|
|||||||
export const useGetEntities = ({ t, toast }) =>
|
export const useGetEntities = ({ t, toast }) =>
|
||||||
useQuery(
|
useQuery(
|
||||||
['get-entities'],
|
['get-entities'],
|
||||||
() =>
|
() => axiosProv.get('entity?withExtendedInfo=true&offset=0&limit=500').then(({ data }) => data.entities),
|
||||||
axiosProv
|
|
||||||
.get('entity?withExtendedInfo=true&offset=0&limit=500')
|
|
||||||
.then(({ data }) => data.entities),
|
|
||||||
{
|
{
|
||||||
staleTime: 30000,
|
staleTime: 30000,
|
||||||
onError: (e) => {
|
onError: (e) => {
|
||||||
@@ -34,9 +31,7 @@ export const useGetSelectEntities = ({ t, toast, select }) =>
|
|||||||
() =>
|
() =>
|
||||||
select.length === 0
|
select.length === 0
|
||||||
? []
|
? []
|
||||||
: axiosProv
|
: axiosProv.get(`entity?withExtendedInfo=true&select=${select}`).then(({ data }) => data.entities),
|
||||||
.get(`entity?withExtendedInfo=true&select=${select}`)
|
|
||||||
.then(({ data }) => data.entities),
|
|
||||||
{
|
{
|
||||||
staleTime: 100 * 1000,
|
staleTime: 100 * 1000,
|
||||||
onError: (e) => {
|
onError: (e) => {
|
||||||
@@ -58,32 +53,27 @@ export const useGetSelectEntities = ({ t, toast, select }) =>
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const useGetEntity = ({ t, toast, id = null }) =>
|
export const useGetEntity = ({ t, toast, id = null }) =>
|
||||||
useQuery(
|
useQuery(['get-entity', id], () => axiosProv.get(`entity/${id}?withExtendedInfo=true`).then(({ data }) => data), {
|
||||||
['get-entity', id],
|
enabled: id !== null,
|
||||||
() => axiosProv.get(`entity/${id}?withExtendedInfo=true`).then(({ data }) => data),
|
onError: (e) => {
|
||||||
{
|
if (!toast.isActive('entity-fetching-error'))
|
||||||
enabled: id !== null,
|
toast({
|
||||||
onError: (e) => {
|
id: 'subscribers-fetching-error',
|
||||||
if (!toast.isActive('entity-fetching-error'))
|
title: t('common.error'),
|
||||||
toast({
|
description: t('crud.error_fetching_obj', {
|
||||||
id: 'subscribers-fetching-error',
|
obj: t('entities.one'),
|
||||||
title: t('common.error'),
|
e: e?.response?.data?.ErrorDescription,
|
||||||
description: t('crud.error_fetching_obj', {
|
}),
|
||||||
obj: t('entities.one'),
|
status: 'error',
|
||||||
e: e?.response?.data?.ErrorDescription,
|
duration: 5000,
|
||||||
}),
|
isClosable: true,
|
||||||
status: 'error',
|
position: 'top-right',
|
||||||
duration: 5000,
|
});
|
||||||
isClosable: true,
|
|
||||||
position: 'top-right',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
|
|
||||||
export const useCreateEntity = () => useMutation((newEnt) => axiosProv.post('entity/0', newEnt));
|
export const useCreateEntity = () => useMutation((newEnt) => axiosProv.post('entity/0', newEnt));
|
||||||
|
|
||||||
export const useUpdateEntity = ({ id }) =>
|
export const useUpdateEntity = ({ id }) => useMutation((newEnt) => axiosProv.put(`entity/${id}`, newEnt));
|
||||||
useMutation((newEnt) => axiosProv.put(`entity/${id}`, newEnt));
|
|
||||||
|
|
||||||
export const useDeleteEntity = () => useMutation((id) => axiosProv.delete(`entity/${id}`));
|
export const useDeleteEntity = () => useMutation((id) => axiosProv.delete(`entity/${id}`));
|
||||||
|
|||||||
@@ -2,26 +2,22 @@ import { useQuery } from 'react-query';
|
|||||||
import { axiosProv, axiosSec } from 'utils/axiosInstances';
|
import { axiosProv, axiosSec } from 'utils/axiosInstances';
|
||||||
|
|
||||||
export default ({ t, toast }) =>
|
export default ({ t, toast }) =>
|
||||||
useQuery(
|
useQuery(['get-entity-tree'], () => axiosProv.get('entity?getTree=true').then(({ data }) => data), {
|
||||||
['get-entity-tree'],
|
enabled: axiosProv.defaults.baseURL !== axiosSec.defaults.baseURL,
|
||||||
() => axiosProv.get('entity?getTree=true').then(({ data }) => data),
|
staleTime: 3600 * 1000,
|
||||||
{
|
onError: (e) => {
|
||||||
enabled: axiosProv.defaults.baseURL !== axiosSec.defaults.baseURL,
|
if (!toast.isActive('entity-tree-fetching-error'))
|
||||||
staleTime: 3600 * 1000,
|
toast({
|
||||||
onError: (e) => {
|
id: 'subscribers-fetching-error',
|
||||||
if (!toast.isActive('entity-tree-fetching-error'))
|
title: t('common.error'),
|
||||||
toast({
|
description: t('crud.error_fetching_obj', {
|
||||||
id: 'subscribers-fetching-error',
|
obj: t('entities.tree'),
|
||||||
title: t('common.error'),
|
e: e?.response?.data?.ErrorDescription,
|
||||||
description: t('crud.error_fetching_obj', {
|
}),
|
||||||
obj: t('entities.tree'),
|
status: 'error',
|
||||||
e: e?.response?.data?.ErrorDescription,
|
duration: 5000,
|
||||||
}),
|
isClosable: true,
|
||||||
status: 'error',
|
position: 'top-right',
|
||||||
duration: 5000,
|
});
|
||||||
isClosable: true,
|
|
||||||
position: 'top-right',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
|
|||||||
@@ -44,9 +44,7 @@ export const useGetInventoryTags = ({
|
|||||||
['get-inventory-with-select', tagSelect],
|
['get-inventory-with-select', tagSelect],
|
||||||
() =>
|
() =>
|
||||||
tagSelect.length > 0
|
tagSelect.length > 0
|
||||||
? axiosProv
|
? axiosProv.get(`inventory?withExtendedInfo=true&select=${tagSelect}`).then(({ data }) => data.taglist)
|
||||||
.get(`inventory?withExtendedInfo=true&select=${tagSelect}`)
|
|
||||||
.then(({ data }) => data.taglist)
|
|
||||||
: [],
|
: [],
|
||||||
{
|
{
|
||||||
enabled,
|
enabled,
|
||||||
@@ -73,10 +71,7 @@ export const useGetInventoryTags = ({
|
|||||||
if (owner !== undefined && owner !== null) {
|
if (owner !== undefined && owner !== null) {
|
||||||
return useQuery(
|
return useQuery(
|
||||||
['get-inventory-with-owner', owner],
|
['get-inventory-with-owner', owner],
|
||||||
() =>
|
() => axiosProv.get(`inventory?serialOnly=true&subscriber=${owner}`).then(({ data }) => data.serialNumbers),
|
||||||
axiosProv
|
|
||||||
.get(`inventory?serialOnly=true&subscriber=${owner}`)
|
|
||||||
.then(({ data }) => data.serialNumbers),
|
|
||||||
{
|
{
|
||||||
enabled,
|
enabled,
|
||||||
onError: (e) => {
|
onError: (e) => {
|
||||||
@@ -158,8 +153,7 @@ export const useGetTag = ({ t, toast, enabled, serialNumber }) =>
|
|||||||
export const useGetComputedConfiguration = ({ t, toast, enabled, serialNumber }) =>
|
export const useGetComputedConfiguration = ({ t, toast, enabled, serialNumber }) =>
|
||||||
useQuery(
|
useQuery(
|
||||||
['get-tag-computed-configuration', serialNumber],
|
['get-tag-computed-configuration', serialNumber],
|
||||||
() =>
|
() => axiosProv.get(`inventory/${serialNumber}?config=true&explain=true`).then(({ data }) => data),
|
||||||
axiosProv.get(`inventory/${serialNumber}?config=true&explain=true`).then(({ data }) => data),
|
|
||||||
{
|
{
|
||||||
enabled,
|
enabled,
|
||||||
onError: (e) => {
|
onError: (e) => {
|
||||||
@@ -183,8 +177,7 @@ export const useGetComputedConfiguration = ({ t, toast, enabled, serialNumber })
|
|||||||
export const usePushConfig = ({ t, toast, onSuccess }) =>
|
export const usePushConfig = ({ t, toast, onSuccess }) =>
|
||||||
useMutation(
|
useMutation(
|
||||||
['apply-tag-configuration'],
|
['apply-tag-configuration'],
|
||||||
(serialNumber) =>
|
(serialNumber) => axiosProv.get(`inventory/${serialNumber}?applyConfiguration=true`).then(({ data }) => data),
|
||||||
axiosProv.get(`inventory/${serialNumber}?applyConfiguration=true`).then(({ data }) => data),
|
|
||||||
{
|
{
|
||||||
onSuccess,
|
onSuccess,
|
||||||
onError: (e) => {
|
onError: (e) => {
|
||||||
@@ -227,9 +220,7 @@ const claimDevices = async (serialNumbers, entity, isVenue) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const unassignResults = await Promise.all(unassignPromises);
|
const unassignResults = await Promise.all(unassignPromises);
|
||||||
const unassignErrors = await unassignResults
|
const unassignErrors = await unassignResults.filter((res) => res.error).map((res) => res.serialNumber);
|
||||||
.filter((res) => res.error)
|
|
||||||
.map((res) => res.serialNumber);
|
|
||||||
|
|
||||||
const claimResults = await Promise.all(addPromises);
|
const claimResults = await Promise.all(addPromises);
|
||||||
const claimErrors = claimResults.filter((res) => res.error).map((res) => res.serialNumber);
|
const claimErrors = claimResults.filter((res) => res.error).map((res) => res.serialNumber);
|
||||||
|
|||||||
@@ -2,40 +2,32 @@ import { useMutation, useQuery } from 'react-query';
|
|||||||
import { axiosProv } from 'utils/axiosInstances';
|
import { axiosProv } from 'utils/axiosInstances';
|
||||||
|
|
||||||
export const useGetLocationCount = ({ t, toast, enabled }) =>
|
export const useGetLocationCount = ({ t, toast, enabled }) =>
|
||||||
useQuery(
|
useQuery(['get-location-count'], () => axiosProv.get('location?countOnly=true').then(({ data }) => data.count), {
|
||||||
['get-location-count'],
|
enabled,
|
||||||
() => axiosProv.get('location?countOnly=true').then(({ data }) => data.count),
|
staleTime: 30000,
|
||||||
{
|
onError: (e) => {
|
||||||
enabled,
|
if (!toast.isActive('location-count-fetching-error'))
|
||||||
staleTime: 30000,
|
toast({
|
||||||
onError: (e) => {
|
id: 'location-count-fetching-error',
|
||||||
if (!toast.isActive('location-count-fetching-error'))
|
title: t('common.error'),
|
||||||
toast({
|
description: t('crud.error_fetching_obj', {
|
||||||
id: 'location-count-fetching-error',
|
obj: t('locations.other'),
|
||||||
title: t('common.error'),
|
e: e?.response?.data?.ErrorDescription,
|
||||||
description: t('crud.error_fetching_obj', {
|
}),
|
||||||
obj: t('locations.other'),
|
status: 'error',
|
||||||
e: e?.response?.data?.ErrorDescription,
|
duration: 5000,
|
||||||
}),
|
isClosable: true,
|
||||||
status: 'error',
|
position: 'top-right',
|
||||||
duration: 5000,
|
});
|
||||||
isClosable: true,
|
|
||||||
position: 'top-right',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
|
|
||||||
export const useGetLocations = ({ t, toast, pageInfo, enabled, count }) =>
|
export const useGetLocations = ({ t, toast, pageInfo, enabled, count }) =>
|
||||||
useQuery(
|
useQuery(
|
||||||
['get-locations-with-pagination', pageInfo, count],
|
['get-locations-with-pagination', pageInfo, count],
|
||||||
() =>
|
() =>
|
||||||
axiosProv
|
axiosProv
|
||||||
.get(
|
.get(`location?withExtendedInfo=true&limit=${pageInfo.limit}&offset=${pageInfo.limit * pageInfo.index}`)
|
||||||
`location?withExtendedInfo=true&limit=${pageInfo.limit}&offset=${
|
|
||||||
pageInfo.limit * pageInfo.index
|
|
||||||
}`,
|
|
||||||
)
|
|
||||||
.then(({ data }) => data.locations),
|
.then(({ data }) => data.locations),
|
||||||
{
|
{
|
||||||
keepPreviousData: true,
|
keepPreviousData: true,
|
||||||
@@ -65,9 +57,7 @@ export const useGetSelectLocations = ({ t, toast, select, enabled = true }) =>
|
|||||||
() =>
|
() =>
|
||||||
select.length === 0
|
select.length === 0
|
||||||
? []
|
? []
|
||||||
: axiosProv
|
: axiosProv.get(`location?withExtendedInfo=true&select=${select}`).then(({ data }) => data.locations),
|
||||||
.get(`location?withExtendedInfo=true&select=${select}`)
|
|
||||||
.then(({ data }) => data.locations),
|
|
||||||
{
|
{
|
||||||
enabled,
|
enabled,
|
||||||
staleTime: 100 * 1000,
|
staleTime: 100 * 1000,
|
||||||
@@ -94,13 +84,7 @@ export const useGetAllLocations = ({ t, toast, venueId }) =>
|
|||||||
['get-all-locations', venueId],
|
['get-all-locations', venueId],
|
||||||
() =>
|
() =>
|
||||||
axiosProv
|
axiosProv
|
||||||
.get(
|
.get(`${venueId ? `venue?locationsForVenue=${venueId}` : 'location?withExtendedInfo=true&limit=500&offset=0'}`)
|
||||||
`${
|
|
||||||
venueId
|
|
||||||
? `venue?locationsForVenue=${venueId}`
|
|
||||||
: 'location?withExtendedInfo=true&limit=500&offset=0'
|
|
||||||
}`,
|
|
||||||
)
|
|
||||||
.then(({ data }) => data.locations),
|
.then(({ data }) => data.locations),
|
||||||
{
|
{
|
||||||
staleTime: 1000 * 1000,
|
staleTime: 1000 * 1000,
|
||||||
@@ -142,11 +126,9 @@ export const useGetLocation = ({ t, toast, enabled, id }) =>
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const useCreateLocation = () =>
|
export const useCreateLocation = () => useMutation((newLocation) => axiosProv.post('location/0', newLocation));
|
||||||
useMutation((newLocation) => axiosProv.post('location/0', newLocation));
|
|
||||||
|
|
||||||
export const useUpdateLocation = ({ id }) =>
|
export const useUpdateLocation = ({ id }) => useMutation((newLocation) => axiosProv.put(`location/${id}`, newLocation));
|
||||||
useMutation((newLocation) => axiosProv.put(`location/${id}`, newLocation));
|
|
||||||
|
|
||||||
const claimLocations = async (locationIds, entity) => {
|
const claimLocations = async (locationIds, entity) => {
|
||||||
const addPromises = locationIds.map(async (id) =>
|
const addPromises = locationIds.map(async (id) =>
|
||||||
@@ -166,5 +148,4 @@ const claimLocations = async (locationIds, entity) => {
|
|||||||
return { claimErrors };
|
return { claimErrors };
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useClaimLocations = ({ entityId }) =>
|
export const useClaimLocations = ({ entityId }) => useMutation((locationIds) => claimLocations(locationIds, entityId));
|
||||||
useMutation((locationIds) => claimLocations(locationIds, entityId));
|
|
||||||
|
|||||||
@@ -2,12 +2,8 @@ import { useQuery } from 'react-query';
|
|||||||
import { axiosSec } from 'utils/axiosInstances';
|
import { axiosSec } from 'utils/axiosInstances';
|
||||||
|
|
||||||
const useGetRequirements = () =>
|
const useGetRequirements = () =>
|
||||||
useQuery(
|
useQuery(['get-requirements'], () => axiosSec.post('oauth2?requirements=true', {}).then(({ data }) => data), {
|
||||||
['get-requirements'],
|
staleTime: Infinity,
|
||||||
() => axiosSec.post('oauth2?requirements=true', {}).then(({ data }) => data),
|
});
|
||||||
{
|
|
||||||
staleTime: Infinity,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
export default useGetRequirements;
|
export default useGetRequirements;
|
||||||
|
|||||||
@@ -2,52 +2,44 @@ import { useMutation, useQuery } from 'react-query';
|
|||||||
import { axiosProv } from 'utils/axiosInstances';
|
import { axiosProv } from 'utils/axiosInstances';
|
||||||
|
|
||||||
export const useGetResourcesCount = ({ t, toast }) =>
|
export const useGetResourcesCount = ({ t, toast }) =>
|
||||||
useQuery(
|
useQuery(['get-resources-count'], () => axiosProv.get(`variables?countOnly=true`).then(({ data }) => data.count), {
|
||||||
['get-resources-count'],
|
staleTime: 30000,
|
||||||
() => axiosProv.get(`variables?countOnly=true`).then(({ data }) => data.count),
|
onError: (e) => {
|
||||||
{
|
if (!toast.isActive('variables-fetching-error'))
|
||||||
staleTime: 30000,
|
toast({
|
||||||
onError: (e) => {
|
id: 'variables-fetching-error',
|
||||||
if (!toast.isActive('variables-fetching-error'))
|
title: t('common.error'),
|
||||||
toast({
|
description: t('crud.error_fetching_obj', {
|
||||||
id: 'variables-fetching-error',
|
obj: t('resources.title'),
|
||||||
title: t('common.error'),
|
e: e?.response?.data?.ErrorDescription,
|
||||||
description: t('crud.error_fetching_obj', {
|
}),
|
||||||
obj: t('resources.title'),
|
status: 'error',
|
||||||
e: e?.response?.data?.ErrorDescription,
|
duration: 5000,
|
||||||
}),
|
isClosable: true,
|
||||||
status: 'error',
|
position: 'top-right',
|
||||||
duration: 5000,
|
});
|
||||||
isClosable: true,
|
|
||||||
position: 'top-right',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
|
|
||||||
export const useGetAllResources = ({ t, toast }) =>
|
export const useGetAllResources = ({ t, toast }) =>
|
||||||
useQuery(
|
useQuery(['get-all-resources'], () => axiosProv.get(`variables?limit=500`).then(({ data }) => data.variableBlocks), {
|
||||||
['get-all-resources'],
|
staleTime: 1000 * 1000,
|
||||||
() => axiosProv.get(`variables?limit=500`).then(({ data }) => data.variableBlocks),
|
onError: (e) => {
|
||||||
{
|
if (!toast.isActive('resource-fetching-error'))
|
||||||
staleTime: 1000 * 1000,
|
toast({
|
||||||
onError: (e) => {
|
id: 'resource-fetching-error',
|
||||||
if (!toast.isActive('resource-fetching-error'))
|
title: t('common.error'),
|
||||||
toast({
|
description: t('crud.error_fetching_obj', {
|
||||||
id: 'resource-fetching-error',
|
obj: t('resources.configuration_resource'),
|
||||||
title: t('common.error'),
|
e: e?.response?.data?.ErrorDescription,
|
||||||
description: t('crud.error_fetching_obj', {
|
}),
|
||||||
obj: t('resources.configuration_resource'),
|
status: 'error',
|
||||||
e: e?.response?.data?.ErrorDescription,
|
duration: 5000,
|
||||||
}),
|
isClosable: true,
|
||||||
status: 'error',
|
position: 'top-right',
|
||||||
duration: 5000,
|
});
|
||||||
isClosable: true,
|
|
||||||
position: 'top-right',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
|
|
||||||
export const useGetResources = ({ t, toast, pageInfo, select, count }) => {
|
export const useGetResources = ({ t, toast, pageInfo, select, count }) => {
|
||||||
if (select !== undefined && select !== null) {
|
if (select !== undefined && select !== null) {
|
||||||
@@ -55,9 +47,7 @@ export const useGetResources = ({ t, toast, pageInfo, select, count }) => {
|
|||||||
['get-resources-with-select', select],
|
['get-resources-with-select', select],
|
||||||
() =>
|
() =>
|
||||||
select.length > 0
|
select.length > 0
|
||||||
? axiosProv
|
? axiosProv.get(`variables?withExtendedInfo=true&select=${select}`).then(({ data }) => data.variableBlocks)
|
||||||
.get(`variables?withExtendedInfo=true&select=${select}`)
|
|
||||||
.then(({ data }) => data.variableBlocks)
|
|
||||||
: [],
|
: [],
|
||||||
{
|
{
|
||||||
keepPreviousData: true,
|
keepPreviousData: true,
|
||||||
@@ -136,8 +126,6 @@ export const useGetResource = ({ t, toast, id, enabled }) =>
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
export const useCreateResource = () =>
|
export const useCreateResource = () => useMutation((newResource) => axiosProv.post('variables/0', newResource));
|
||||||
useMutation((newResource) => axiosProv.post('variables/0', newResource));
|
export const useUpdateResource = (id) => useMutation((resource) => axiosProv.put(`variables/${id}`, resource));
|
||||||
export const useUpdateResource = (id) =>
|
|
||||||
useMutation((resource) => axiosProv.put(`variables/${id}`, resource));
|
|
||||||
export const useDeleteResource = () => useMutation((id) => axiosProv.delete(`variables/${id}`, {}));
|
export const useDeleteResource = () => useMutation((id) => axiosProv.delete(`variables/${id}`, {}));
|
||||||
|
|||||||
@@ -22,25 +22,21 @@ export const useGetSubscribers = ({ t, toast }) =>
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const useGetSubscriber = ({ t, toast, id, enabled }) =>
|
export const useGetSubscriber = ({ t, toast, id, enabled }) =>
|
||||||
useQuery(
|
useQuery(['get-subscriber', id], () => axiosSec.get(`subuser/${id}?withExtendedInfo=true`).then(({ data }) => data), {
|
||||||
['get-subscriber', id],
|
enabled,
|
||||||
() => axiosSec.get(`subuser/${id}?withExtendedInfo=true`).then(({ data }) => data),
|
onError: (e) => {
|
||||||
{
|
if (!toast.isActive('subscriber-fetching-error'))
|
||||||
enabled,
|
toast({
|
||||||
onError: (e) => {
|
id: 'subscriber-fetching-error',
|
||||||
if (!toast.isActive('subscriber-fetching-error'))
|
title: t('common.error'),
|
||||||
toast({
|
description: t('crud.error_fetching_obj', {
|
||||||
id: 'subscriber-fetching-error',
|
obj: t('subscribers.one'),
|
||||||
title: t('common.error'),
|
e: e?.response?.data?.ErrorDescription,
|
||||||
description: t('crud.error_fetching_obj', {
|
}),
|
||||||
obj: t('subscribers.one'),
|
status: 'error',
|
||||||
e: e?.response?.data?.ErrorDescription,
|
duration: 5000,
|
||||||
}),
|
isClosable: true,
|
||||||
status: 'error',
|
position: 'top-right',
|
||||||
duration: 5000,
|
});
|
||||||
isClosable: true,
|
|
||||||
position: 'top-right',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
|
|||||||
@@ -1,28 +1,24 @@
|
|||||||
import { useQuery } from 'react-query';
|
import { useQuery } from 'react-query';
|
||||||
|
|
||||||
export const useGetSystemInfo = ({ t, toast, axiosInstance, name }) =>
|
export const useGetSystemInfo = ({ t, toast, axiosInstance, name }) =>
|
||||||
useQuery(
|
useQuery(['get-system-info', name], () => axiosInstance.get('/system?command=info').then(({ data }) => data), {
|
||||||
['get-system-info', name],
|
staleTime: 60000,
|
||||||
() => axiosInstance.get('/system?command=info').then(({ data }) => data),
|
onError: (e) => {
|
||||||
{
|
if (!toast.isActive('system-fetching-error'))
|
||||||
staleTime: 60000,
|
toast({
|
||||||
onError: (e) => {
|
id: 'system-fetching-error',
|
||||||
if (!toast.isActive('system-fetching-error'))
|
title: t('common.error'),
|
||||||
toast({
|
description: t('crud.error_fetching_obj', {
|
||||||
id: 'system-fetching-error',
|
obj: t('system.title'),
|
||||||
title: t('common.error'),
|
e: e?.response?.data?.ErrorDescription,
|
||||||
description: t('crud.error_fetching_obj', {
|
}),
|
||||||
obj: t('system.title'),
|
status: 'error',
|
||||||
e: e?.response?.data?.ErrorDescription,
|
duration: 5000,
|
||||||
}),
|
isClosable: true,
|
||||||
status: 'error',
|
position: 'top-right',
|
||||||
duration: 5000,
|
});
|
||||||
isClosable: true,
|
|
||||||
position: 'top-right',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
|
|
||||||
export const useGetSubsystems = ({ t, toast, enabled, axiosInstance, name }) =>
|
export const useGetSubsystems = ({ t, toast, enabled, axiosInstance, name }) =>
|
||||||
useQuery(
|
useQuery(
|
||||||
|
|||||||
@@ -21,10 +21,7 @@ export const useGetUsers = ({ t, toast, setUsersWithAvatars }) =>
|
|||||||
results.map((response) => {
|
results.map((response) => {
|
||||||
if (response.status === 'fulfilled' && response?.value !== '') {
|
if (response.status === 'fulfilled' && response?.value !== '') {
|
||||||
const base64 = btoa(
|
const base64 = btoa(
|
||||||
new Uint8Array(response.value.data).reduce(
|
new Uint8Array(response.value.data).reduce((respData, byte) => respData + String.fromCharCode(byte), ''),
|
||||||
(respData, byte) => respData + String.fromCharCode(byte),
|
|
||||||
'',
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
return `data:;base64,${base64}`;
|
return `data:;base64,${base64}`;
|
||||||
}
|
}
|
||||||
@@ -53,25 +50,21 @@ export const useGetUsers = ({ t, toast, setUsersWithAvatars }) =>
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const useGetUser = ({ t, toast, id, enabled }) =>
|
export const useGetUser = ({ t, toast, id, enabled }) =>
|
||||||
useQuery(
|
useQuery(['get-user', id], () => axiosSec.get(`user/${id}?withExtendedInfo=true`).then(({ data }) => data), {
|
||||||
['get-user', id],
|
enabled,
|
||||||
() => axiosSec.get(`user/${id}?withExtendedInfo=true`).then(({ data }) => data),
|
onError: (e) => {
|
||||||
{
|
if (!toast.isActive('user-fetching-error'))
|
||||||
enabled,
|
toast({
|
||||||
onError: (e) => {
|
id: 'user-fetching-error',
|
||||||
if (!toast.isActive('user-fetching-error'))
|
title: t('common.error'),
|
||||||
toast({
|
description: t('crud.error_fetching_obj', {
|
||||||
id: 'user-fetching-error',
|
obj: t('users.one'),
|
||||||
title: t('common.error'),
|
e: e?.response?.data?.ErrorDescription,
|
||||||
description: t('crud.error_fetching_obj', {
|
}),
|
||||||
obj: t('users.one'),
|
status: 'error',
|
||||||
e: e?.response?.data?.ErrorDescription,
|
duration: 5000,
|
||||||
}),
|
isClosable: true,
|
||||||
status: 'error',
|
position: 'top-right',
|
||||||
duration: 5000,
|
});
|
||||||
isClosable: true,
|
|
||||||
position: 'top-right',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ import { axiosProv } from 'utils/axiosInstances';
|
|||||||
export const useGetVenues = ({ t, toast }) =>
|
export const useGetVenues = ({ t, toast }) =>
|
||||||
useQuery(
|
useQuery(
|
||||||
['get-venues'],
|
['get-venues'],
|
||||||
() =>
|
() => axiosProv.get('venue?withExtendedInfo=true&offset=0&limit=500').then(({ data }) => data.venues),
|
||||||
axiosProv
|
|
||||||
.get('venue?withExtendedInfo=true&offset=0&limit=500')
|
|
||||||
.then(({ data }) => data.venues),
|
|
||||||
{
|
{
|
||||||
staleTime: 30000,
|
staleTime: 30000,
|
||||||
onError: (e) => {
|
onError: (e) => {
|
||||||
@@ -34,9 +31,7 @@ export const useGetSelectVenues = ({ t, toast, select }) =>
|
|||||||
() =>
|
() =>
|
||||||
select.length === 0
|
select.length === 0
|
||||||
? []
|
? []
|
||||||
: axiosProv
|
: axiosProv.get(`venue?withExtendedInfo=true&select=${select}`).then(({ data }) => data.venues),
|
||||||
.get(`venue?withExtendedInfo=true&select=${select}`)
|
|
||||||
.then(({ data }) => data.venues),
|
|
||||||
{
|
{
|
||||||
staleTime: 100 * 1000,
|
staleTime: 100 * 1000,
|
||||||
onError: (e) => {
|
onError: (e) => {
|
||||||
@@ -58,42 +53,32 @@ export const useGetSelectVenues = ({ t, toast, select }) =>
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const useGetVenue = ({ t, toast, id }) =>
|
export const useGetVenue = ({ t, toast, id }) =>
|
||||||
useQuery(
|
useQuery(['get-venue', id], () => axiosProv.get(`venue/${id}?withExtendedInfo=true`).then(({ data }) => data), {
|
||||||
['get-venue', id],
|
onError: (e) => {
|
||||||
() => axiosProv.get(`venue/${id}?withExtendedInfo=true`).then(({ data }) => data),
|
if (!toast.isActive('venue-fetching-error'))
|
||||||
{
|
toast({
|
||||||
onError: (e) => {
|
id: 'subscribers-fetching-error',
|
||||||
if (!toast.isActive('venue-fetching-error'))
|
title: t('common.error'),
|
||||||
toast({
|
description: t('crud.error_fetching_obj', {
|
||||||
id: 'subscribers-fetching-error',
|
obj: t('venues.one'),
|
||||||
title: t('common.error'),
|
e: e?.response?.data?.ErrorDescription,
|
||||||
description: t('crud.error_fetching_obj', {
|
}),
|
||||||
obj: t('venues.one'),
|
status: 'error',
|
||||||
e: e?.response?.data?.ErrorDescription,
|
duration: 5000,
|
||||||
}),
|
isClosable: true,
|
||||||
status: 'error',
|
position: 'top-right',
|
||||||
duration: 5000,
|
});
|
||||||
isClosable: true,
|
|
||||||
position: 'top-right',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
|
|
||||||
export const useCreateVenue = () =>
|
export const useCreateVenue = () =>
|
||||||
useMutation(({ params, createObjects }) =>
|
useMutation(({ params, createObjects }) =>
|
||||||
axiosProv.post(
|
axiosProv.post(`venue/0${createObjects ? `?createObjects=${JSON.stringify(createObjects)}` : ''}`, params),
|
||||||
`venue/0${createObjects ? `?createObjects=${JSON.stringify(createObjects)}` : ''}`,
|
|
||||||
params,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
export const useUpdateVenue = ({ id }) =>
|
export const useUpdateVenue = ({ id }) =>
|
||||||
useMutation(({ params, createObjects }) =>
|
useMutation(({ params, createObjects }) =>
|
||||||
axiosProv.put(
|
axiosProv.put(`venue/${id}${createObjects ? `?createObjects=${JSON.stringify(createObjects)}` : ''}`, params),
|
||||||
`venue/${id}${createObjects ? `?createObjects=${JSON.stringify(createObjects)}` : ''}`,
|
|
||||||
params,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
export const useDeleteVenue = () => useMutation((id) => axiosProv.delete(`venue/${id}`));
|
export const useDeleteVenue = () => useMutation((id) => axiosProv.delete(`venue/${id}`));
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ const Navbar = ({ secondary, toggleSidebar, isSidebarOpen }) => {
|
|||||||
const { logout, user, avatar } = useAuth();
|
const { logout, user, avatar } = useAuth();
|
||||||
const getActiveRoute = () => {
|
const getActiveRoute = () => {
|
||||||
const route = routes.find(
|
const route = routes.find(
|
||||||
(r) =>
|
(r) => r.path === location.pathname || location.pathname.split('/')[1] === r.path.split('/')[1],
|
||||||
r.path === location.pathname || location.pathname.split('/')[1] === r.path.split('/')[1],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (route) return route.navName ?? route.name;
|
if (route) return route.navName ?? route.name;
|
||||||
@@ -64,10 +63,7 @@ const Navbar = ({ secondary, toggleSidebar, isSidebarOpen }) => {
|
|||||||
'linear-gradient(112.83deg, rgba(255, 255, 255, 0.21) 0%, rgba(255, 255, 255, 0) 110.84%)',
|
'linear-gradient(112.83deg, rgba(255, 255, 255, 0.21) 0%, rgba(255, 255, 255, 0) 110.84%)',
|
||||||
);
|
);
|
||||||
const scrolledNavbarBorder = useColorModeValue('#FFFFFF', 'rgba(255, 255, 255, 0.31)');
|
const scrolledNavbarBorder = useColorModeValue('#FFFFFF', 'rgba(255, 255, 255, 0.31)');
|
||||||
const scrolledNavbarFilter = useColorModeValue(
|
const scrolledNavbarFilter = useColorModeValue('none', 'drop-shadow(0px 7px 23px rgba(0, 0, 0, 0.05))');
|
||||||
'none',
|
|
||||||
'drop-shadow(0px 7px 23px rgba(0, 0, 0, 0.05))',
|
|
||||||
);
|
|
||||||
|
|
||||||
if (scrolled === true) {
|
if (scrolled === true) {
|
||||||
navbarPosition = 'fixed';
|
navbarPosition = 'fixed';
|
||||||
@@ -148,12 +144,7 @@ const Navbar = ({ secondary, toggleSidebar, isSidebarOpen }) => {
|
|||||||
<Menu>
|
<Menu>
|
||||||
<MenuButton py={2} transition="all 0.3s" _focus={{ boxShadow: 'none' }}>
|
<MenuButton py={2} transition="all 0.3s" _focus={{ boxShadow: 'none' }}>
|
||||||
<HStack>
|
<HStack>
|
||||||
<VStack
|
<VStack display={{ base: 'none', md: 'flex' }} alignItems="flex-start" spacing={0} height={12}>
|
||||||
display={{ base: 'none', md: 'flex' }}
|
|
||||||
alignItems="flex-start"
|
|
||||||
spacing={0}
|
|
||||||
height={12}
|
|
||||||
>
|
|
||||||
<Text fontWeight="bold">{user?.name}</Text>
|
<Text fontWeight="bold">{user?.name}</Text>
|
||||||
<Text fontSize="sm">{`${uppercaseFirstLetter(user?.userRole)}`}</Text>
|
<Text fontSize="sm">{`${uppercaseFirstLetter(user?.userRole)}`}</Text>
|
||||||
</VStack>
|
</VStack>
|
||||||
|
|||||||
@@ -6,13 +6,7 @@ import NavLinkButton from './NavLinkButton';
|
|||||||
const createLinks = (routes, activeRoute, role, toggleSidebar = () => {}) =>
|
const createLinks = (routes, activeRoute, role, toggleSidebar = () => {}) =>
|
||||||
routes.map((route) =>
|
routes.map((route) =>
|
||||||
route.isEntity ? (
|
route.isEntity ? (
|
||||||
<EntityNavButton
|
<EntityNavButton key={uuid()} activeRoute={activeRoute} role={role} route={route} toggleSidebar={toggleSidebar} />
|
||||||
key={uuid()}
|
|
||||||
activeRoute={activeRoute}
|
|
||||||
role={role}
|
|
||||||
route={route}
|
|
||||||
toggleSidebar={toggleSidebar}
|
|
||||||
/>
|
|
||||||
) : (
|
) : (
|
||||||
<NavLinkButton key={uuid()} activeRoute={activeRoute} role={role} route={route} />
|
<NavLinkButton key={uuid()} activeRoute={activeRoute} role={role} route={route} />
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -26,10 +26,7 @@ const EntityNavButton = ({ activeRoute, route, role, toggleSidebar }) => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||||
const activeArrowColor = useColorModeValue('var(--chakra-colors-gray-700)', 'white');
|
const activeArrowColor = useColorModeValue('var(--chakra-colors-gray-700)', 'white');
|
||||||
const inactiveArrowColor = useColorModeValue(
|
const inactiveArrowColor = useColorModeValue('var(--chakra-colors-gray-600)', 'var(--chakra-colors-gray-200)');
|
||||||
'var(--chakra-colors-gray-600)',
|
|
||||||
'var(--chakra-colors-gray-200)',
|
|
||||||
);
|
|
||||||
const activeTextColor = useColorModeValue('gray.700', 'white');
|
const activeTextColor = useColorModeValue('gray.700', 'white');
|
||||||
const inactiveTextColor = useColorModeValue('gray.600', 'gray.200');
|
const inactiveTextColor = useColorModeValue('gray.600', 'gray.200');
|
||||||
const inactiveIconColor = useColorModeValue('gray.100', 'gray.600');
|
const inactiveIconColor = useColorModeValue('gray.100', 'gray.600');
|
||||||
@@ -63,14 +60,7 @@ const EntityNavButton = ({ activeRoute, route, role, toggleSidebar }) => {
|
|||||||
rightIcon={<ArrowCircleRight size={24} color={activeArrowColor} />}
|
rightIcon={<ArrowCircleRight size={24} color={activeArrowColor} />}
|
||||||
>
|
>
|
||||||
<Flex>
|
<Flex>
|
||||||
<IconBox
|
<IconBox bg="blue.300" color="white" h="42px" w="42px" me="12px" transition={variantChange}>
|
||||||
bg="blue.300"
|
|
||||||
color="white"
|
|
||||||
h="42px"
|
|
||||||
w="42px"
|
|
||||||
me="12px"
|
|
||||||
transition={variantChange}
|
|
||||||
>
|
|
||||||
{route.icon(true)}
|
{route.icon(true)}
|
||||||
</IconBox>
|
</IconBox>
|
||||||
<Text color={activeTextColor} my="auto" fontSize="lg">
|
<Text color={activeTextColor} my="auto" fontSize="lg">
|
||||||
@@ -103,14 +93,7 @@ const EntityNavButton = ({ activeRoute, route, role, toggleSidebar }) => {
|
|||||||
rightIcon={<ArrowCircleRight size={20} color={inactiveArrowColor} />}
|
rightIcon={<ArrowCircleRight size={20} color={inactiveArrowColor} />}
|
||||||
>
|
>
|
||||||
<Flex>
|
<Flex>
|
||||||
<IconBox
|
<IconBox bg={inactiveIconColor} color="blue.300" h="34px" w="34px" me="12px" transition={variantChange}>
|
||||||
bg={inactiveIconColor}
|
|
||||||
color="blue.300"
|
|
||||||
h="34px"
|
|
||||||
w="34px"
|
|
||||||
me="12px"
|
|
||||||
transition={variantChange}
|
|
||||||
>
|
|
||||||
{route.icon(false)}
|
{route.icon(false)}
|
||||||
</IconBox>
|
</IconBox>
|
||||||
<Text color={inactiveTextColor} my="auto" fontSize="sm">
|
<Text color={inactiveTextColor} my="auto" fontSize="sm">
|
||||||
|
|||||||
@@ -42,15 +42,11 @@ const renderList = (tree, depth, goTo) => {
|
|||||||
colorScheme="blue"
|
colorScheme="blue"
|
||||||
variant="link"
|
variant="link"
|
||||||
onClick={() => goTo(tree.uuid, tree.type)}
|
onClick={() => goTo(tree.uuid, tree.type)}
|
||||||
leftIcon={
|
leftIcon={tree.type === 'entity' ? <TreeStructure size={16} /> : <Buildings size={16} />}
|
||||||
tree.type === 'entity' ? <TreeStructure size={16} /> : <Buildings size={16} />
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{tree.name}
|
{tree.name}
|
||||||
</Button>
|
</Button>
|
||||||
<UnorderedList styleType="none">
|
<UnorderedList styleType="none">{renderList(tree.children, depth + 2, goTo)}</UnorderedList>
|
||||||
{renderList(tree.children, depth + 2, goTo)}
|
|
||||||
</UnorderedList>
|
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</UnorderedList>
|
</UnorderedList>
|
||||||
);
|
);
|
||||||
@@ -73,9 +69,7 @@ const renderList = (tree, depth, goTo) => {
|
|||||||
colorScheme="blue"
|
colorScheme="blue"
|
||||||
variant="link"
|
variant="link"
|
||||||
onClick={() => goTo(obj.uuid, obj.type)}
|
onClick={() => goTo(obj.uuid, obj.type)}
|
||||||
leftIcon={
|
leftIcon={obj.type === 'entity' ? <TreeStructure size={16} /> : <Buildings size={16} />}
|
||||||
obj.type === 'entity' ? <TreeStructure size={16} /> : <Buildings size={16} />
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{obj.name}
|
{obj.name}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -181,13 +175,7 @@ const EntityPopover = ({ isOpen, onClose, children, toggleSidebar }) => {
|
|||||||
<PopoverHeader fontWeight="semibold" display="flex" alignItems="center">
|
<PopoverHeader fontWeight="semibold" display="flex" alignItems="center">
|
||||||
<Heading size="md">{t('entities.title')}</Heading>
|
<Heading size="md">{t('entities.title')}</Heading>
|
||||||
<Spacer />
|
<Spacer />
|
||||||
<IconButton
|
<IconButton ref={initRef} colorScheme="gray" onClick={onClose} icon={<X size={20} />} ms="auto" />
|
||||||
ref={initRef}
|
|
||||||
colorScheme="gray"
|
|
||||||
onClick={onClose}
|
|
||||||
icon={<X size={20} />}
|
|
||||||
ms="auto"
|
|
||||||
/>
|
|
||||||
</PopoverHeader>
|
</PopoverHeader>
|
||||||
<PopoverArrow />
|
<PopoverArrow />
|
||||||
<PopoverBody overflowX="auto" overflowY="auto" maxH="80vh">
|
<PopoverBody overflowX="auto" overflowY="auto" maxH="80vh">
|
||||||
@@ -206,13 +194,7 @@ const EntityPopover = ({ isOpen, onClose, children, toggleSidebar }) => {
|
|||||||
<PopoverHeader fontWeight="semibold" display="flex" alignItems="center">
|
<PopoverHeader fontWeight="semibold" display="flex" alignItems="center">
|
||||||
<Heading size="md">{t('entities.title')}</Heading>
|
<Heading size="md">{t('entities.title')}</Heading>
|
||||||
<Spacer />
|
<Spacer />
|
||||||
<IconButton
|
<IconButton ref={initRef} colorScheme="gray" onClick={onClose} icon={<X size={20} />} ms="auto" />
|
||||||
ref={initRef}
|
|
||||||
colorScheme="gray"
|
|
||||||
onClick={onClose}
|
|
||||||
icon={<X size={20} />}
|
|
||||||
ms="auto"
|
|
||||||
/>
|
|
||||||
</PopoverHeader>
|
</PopoverHeader>
|
||||||
<PopoverArrow />
|
<PopoverArrow />
|
||||||
<PopoverBody overflowY="auto" maxH="80vh">
|
<PopoverBody overflowY="auto" maxH="80vh">
|
||||||
|
|||||||
@@ -54,14 +54,7 @@ const NavLinkButton = ({ activeRoute, route, role }) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Flex>
|
<Flex>
|
||||||
<IconBox
|
<IconBox bg="blue.300" color="white" h="42px" w="42px" me="12px" transition={variantChange}>
|
||||||
bg="blue.300"
|
|
||||||
color="white"
|
|
||||||
h="42px"
|
|
||||||
w="42px"
|
|
||||||
me="12px"
|
|
||||||
transition={variantChange}
|
|
||||||
>
|
|
||||||
{route.icon(true)}
|
{route.icon(true)}
|
||||||
</IconBox>
|
</IconBox>
|
||||||
<Text color={activeTextColor} my="auto" fontSize="lg">
|
<Text color={activeTextColor} my="auto" fontSize="lg">
|
||||||
@@ -92,14 +85,7 @@ const NavLinkButton = ({ activeRoute, route, role }) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Flex>
|
<Flex>
|
||||||
<IconBox
|
<IconBox bg={inactiveIconColor} color="blue.300" h="34px" w="34px" me="12px" transition={variantChange}>
|
||||||
bg={inactiveIconColor}
|
|
||||||
color="blue.300"
|
|
||||||
h="34px"
|
|
||||||
w="34px"
|
|
||||||
me="12px"
|
|
||||||
transition={variantChange}
|
|
||||||
>
|
|
||||||
{route.icon(false)}
|
{route.icon(false)}
|
||||||
</IconBox>
|
</IconBox>
|
||||||
<Text color={inactiveTextColor} my="auto" fontSize="sm">
|
<Text color={inactiveTextColor} my="auto" fontSize="sm">
|
||||||
|
|||||||
@@ -62,12 +62,7 @@ const Sidebar = ({ routes, isOpen, toggle }) => {
|
|||||||
alignItems="center"
|
alignItems="center"
|
||||||
fontSize="11px"
|
fontSize="11px"
|
||||||
>
|
>
|
||||||
<img
|
<img src={colorMode === 'light' ? lightLogo : darkLogo} alt="OpenWifi" width="180px" height="100px" />
|
||||||
src={colorMode === 'light' ? lightLogo : darkLogo}
|
|
||||||
alt="OpenWifi"
|
|
||||||
width="180px"
|
|
||||||
height="100px"
|
|
||||||
/>
|
|
||||||
</Link>
|
</Link>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
@@ -92,9 +87,7 @@ const Sidebar = ({ routes, isOpen, toggle }) => {
|
|||||||
<Box maxW="100%" h="90vh">
|
<Box maxW="100%" h="90vh">
|
||||||
<Box>{brand}</Box>
|
<Box>{brand}</Box>
|
||||||
<Flex direction="column" mb="40px" h="calc(100vh - 200px)" alignItems="center">
|
<Flex direction="column" mb="40px" h="calc(100vh - 200px)" alignItems="center">
|
||||||
<Box overflowY="auto">
|
<Box overflowY="auto">{createLinks(routes, activeRoute, user?.userRole ?? '', toggle)}</Box>
|
||||||
{createLinks(routes, activeRoute, user?.userRole ?? '', toggle)}
|
|
||||||
</Box>
|
|
||||||
<Spacer />
|
<Spacer />
|
||||||
<Box>
|
<Box>
|
||||||
<Text color="gray.400">
|
<Text color="gray.400">
|
||||||
@@ -132,9 +125,7 @@ const Sidebar = ({ routes, isOpen, toggle }) => {
|
|||||||
>
|
>
|
||||||
<Box>{brand}</Box>
|
<Box>{brand}</Box>
|
||||||
<Flex direction="column" mb="40px" h="calc(100vh - 200px)" alignItems="center">
|
<Flex direction="column" mb="40px" h="calc(100vh - 200px)" alignItems="center">
|
||||||
<Box overflowY="auto">
|
<Box overflowY="auto">{createLinks(routes, activeRoute, user?.userRole ?? '', toggle)}</Box>
|
||||||
{createLinks(routes, activeRoute, user?.userRole ?? '', toggle)}
|
|
||||||
</Box>
|
|
||||||
<Spacer />
|
<Spacer />
|
||||||
<Box>
|
<Box>
|
||||||
<Text color="gray.400">
|
<Text color="gray.400">
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ import Sidebar from './Sidebar';
|
|||||||
|
|
||||||
const Layout = () => {
|
const Layout = () => {
|
||||||
const breakpoint = useBreakpoint();
|
const breakpoint = useBreakpoint();
|
||||||
const [isSidebarOpen, { toggle: toggleSidebar }] = useBoolean(
|
const [isSidebarOpen, { toggle: toggleSidebar }] = useBoolean(breakpoint !== 'base' && breakpoint !== 'sm');
|
||||||
breakpoint !== 'base' && breakpoint !== 'sm',
|
|
||||||
);
|
|
||||||
document.documentElement.dir = 'ltr';
|
document.documentElement.dir = 'ltr';
|
||||||
|
|
||||||
const getActiveRoute = (r) => {
|
const getActiveRoute = (r) => {
|
||||||
@@ -52,8 +50,7 @@ const Layout = () => {
|
|||||||
}
|
}
|
||||||
return activeNavbar;
|
return activeNavbar;
|
||||||
};
|
};
|
||||||
const getRoutes = (r) =>
|
const getRoutes = (r) => r.map((route) => <Route path={route.path} element={<route.component />} key={uuid()} />);
|
||||||
r.map((route) => <Route path={route.path} element={<route.component />} key={uuid()} />);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -43,14 +43,7 @@ const propTypes = {
|
|||||||
deleteAvatar: PropTypes.instanceOf(Object).isRequired,
|
deleteAvatar: PropTypes.instanceOf(Object).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
const UpdateAccountForm = ({
|
const UpdateAccountForm = ({ updateUser, deleteAvatar, updateAvatar, finishUpdate, editing, formRef }) => {
|
||||||
updateUser,
|
|
||||||
deleteAvatar,
|
|
||||||
updateAvatar,
|
|
||||||
finishUpdate,
|
|
||||||
editing,
|
|
||||||
formRef,
|
|
||||||
}) => {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [verifNumber, setVerifNumber] = useState('');
|
const [verifNumber, setVerifNumber] = useState('');
|
||||||
const { avatar: savedAvatar } = useAuth();
|
const { avatar: savedAvatar } = useAuth();
|
||||||
@@ -90,19 +83,14 @@ const UpdateAccountForm = ({
|
|||||||
key={formKey}
|
key={formKey}
|
||||||
initialValues={{
|
initialValues={{
|
||||||
...user,
|
...user,
|
||||||
mfa: user.userTypeProprietaryInfo.mfa.enabled
|
mfa: user.userTypeProprietaryInfo.mfa.enabled ? user.userTypeProprietaryInfo.mfa.method : '',
|
||||||
? user.userTypeProprietaryInfo.mfa.method
|
|
||||||
: '',
|
|
||||||
phoneNumber:
|
phoneNumber:
|
||||||
user.userTypeProprietaryInfo.mobiles.length > 0
|
user.userTypeProprietaryInfo.mobiles.length > 0
|
||||||
? user.userTypeProprietaryInfo.mobiles[0].number.replace('+', '')
|
? user.userTypeProprietaryInfo.mobiles[0].number.replace('+', '')
|
||||||
: '',
|
: '',
|
||||||
}}
|
}}
|
||||||
validationSchema={UpdateUserSchema(t)}
|
validationSchema={UpdateUserSchema(t)}
|
||||||
onSubmit={(
|
onSubmit={({ description, name, currentPassword, phoneNumber, mfa, notes }, { setSubmitting }) => {
|
||||||
{ description, name, currentPassword, phoneNumber, mfa, notes },
|
|
||||||
{ setSubmitting },
|
|
||||||
) => {
|
|
||||||
const onSuccess = () => {
|
const onSuccess = () => {
|
||||||
finishUpdate();
|
finishUpdate();
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
@@ -147,10 +135,7 @@ const UpdateAccountForm = ({
|
|||||||
updateUser.mutateAsync(params, {
|
updateUser.mutateAsync(params, {
|
||||||
onSuccess,
|
onSuccess,
|
||||||
onError: (e) => {
|
onError: (e) => {
|
||||||
if (
|
if (e?.response?.data?.ErrorDescription === 'You must provide at least one validated phone number.') {
|
||||||
e?.response?.data?.ErrorDescription ===
|
|
||||||
'You must provide at least one validated phone number.'
|
|
||||||
) {
|
|
||||||
toggleVerifyNumber(params, onSuccess);
|
toggleVerifyNumber(params, onSuccess);
|
||||||
} else {
|
} else {
|
||||||
toast({
|
toast({
|
||||||
@@ -216,11 +201,7 @@ const UpdateAccountForm = ({
|
|||||||
</Field>
|
</Field>
|
||||||
<Field name="userRole">
|
<Field name="userRole">
|
||||||
{({ field }) => (
|
{({ field }) => (
|
||||||
<FormControl
|
<FormControl isInvalid={errors.userRole && touched.userRole} isRequired isDisabled>
|
||||||
isInvalid={errors.userRole && touched.userRole}
|
|
||||||
isRequired
|
|
||||||
isDisabled
|
|
||||||
>
|
|
||||||
<FormLabel ms="4px" fontSize="md" fontWeight="normal">
|
<FormLabel ms="4px" fontSize="md" fontWeight="normal">
|
||||||
{t('user.role')}
|
{t('user.role')}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
@@ -309,13 +290,7 @@ const UpdateAccountForm = ({
|
|||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel>
|
<TabPanel>
|
||||||
<Field name="notes">
|
<Field name="notes">
|
||||||
{({ field }) => (
|
{({ field }) => <NotesTable notes={field.value} setNotes={setFieldValue} isDisabled={!editing} />}
|
||||||
<NotesTable
|
|
||||||
notes={field.value}
|
|
||||||
setNotes={setFieldValue}
|
|
||||||
isDisabled={!editing}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Field>
|
</Field>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
</TabPanels>
|
</TabPanels>
|
||||||
|
|||||||
@@ -1,17 +1,7 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import {
|
import { Alert, Button, Center, Heading, HStack, PinInput, PinInputField, Spinner, Text } from '@chakra-ui/react';
|
||||||
Alert,
|
|
||||||
Button,
|
|
||||||
Center,
|
|
||||||
Heading,
|
|
||||||
HStack,
|
|
||||||
PinInput,
|
|
||||||
PinInputField,
|
|
||||||
Spinner,
|
|
||||||
Text,
|
|
||||||
} from '@chakra-ui/react';
|
|
||||||
import { useVerifyAuthenticator } from 'hooks/Network/GoogleAuthenticator';
|
import { useVerifyAuthenticator } from 'hooks/Network/GoogleAuthenticator';
|
||||||
import { ArrowRightIcon } from '@chakra-ui/icons';
|
import { ArrowRightIcon } from '@chakra-ui/icons';
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,7 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import {
|
import { CloseButton, Modal, ModalBody, ModalContent, ModalOverlay, useDisclosure } from '@chakra-ui/react';
|
||||||
CloseButton,
|
|
||||||
Modal,
|
|
||||||
ModalBody,
|
|
||||||
ModalContent,
|
|
||||||
ModalOverlay,
|
|
||||||
useDisclosure,
|
|
||||||
} from '@chakra-ui/react';
|
|
||||||
import SaveButton from 'components/Buttons/SaveButton';
|
import SaveButton from 'components/Buttons/SaveButton';
|
||||||
import ConfirmCloseAlert from 'components/ConfirmCloseAlert';
|
import ConfirmCloseAlert from 'components/ConfirmCloseAlert';
|
||||||
import ModalHeader from 'components/ModalHeader';
|
import ModalHeader from 'components/ModalHeader';
|
||||||
@@ -54,13 +47,9 @@ const GoogleAuthenticatorModal = ({ isOpen, onClose, onSuccess }) => {
|
|||||||
/>
|
/>
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
{currentStep === 'intro' && <GoogleAuthenticatorIntro setCurrentStep={setCurrentStep} />}
|
{currentStep === 'intro' && <GoogleAuthenticatorIntro setCurrentStep={setCurrentStep} />}
|
||||||
{currentStep === 'qr-code' && (
|
{currentStep === 'qr-code' && <GoogleAuthenticatorQrDisplay setCurrentStep={setCurrentStep} />}
|
||||||
<GoogleAuthenticatorQrDisplay setCurrentStep={setCurrentStep} />
|
|
||||||
)}
|
|
||||||
{currentStep === 'tests' && <GoogleAuthenticatorTests setCurrentStep={setCurrentStep} />}
|
{currentStep === 'tests' && <GoogleAuthenticatorTests setCurrentStep={setCurrentStep} />}
|
||||||
{currentStep === 'activated' && (
|
{currentStep === 'activated' && <GoogleAuthenticatorActivationSuccess onSuccess={onActivated} />}
|
||||||
<GoogleAuthenticatorActivationSuccess onSuccess={onActivated} />
|
|
||||||
)}
|
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
<ConfirmCloseAlert isOpen={showConfirm} confirm={closeCancelAndForm} cancel={closeConfirm} />
|
<ConfirmCloseAlert isOpen={showConfirm} confirm={closeCancelAndForm} cancel={closeConfirm} />
|
||||||
|
|||||||
@@ -23,16 +23,7 @@ const defaultProps = {
|
|||||||
isHidden: false,
|
isHidden: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const MfaSelectField = ({
|
const MfaSelectField = ({ name, errors, touched, isDisabled, label, isRequired, isHidden, setFieldValue }) => {
|
||||||
name,
|
|
||||||
errors,
|
|
||||||
touched,
|
|
||||||
isDisabled,
|
|
||||||
label,
|
|
||||||
isRequired,
|
|
||||||
isHidden,
|
|
||||||
setFieldValue,
|
|
||||||
}) => {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||||
|
|
||||||
|
|||||||
@@ -32,19 +32,11 @@ const AddSubsectionModal = ({ editing, activeSubs, addSub }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CreateButton
|
<CreateButton label={t('configurations.add_subsection')} onClick={onOpen} isDisabled={!editing} ml={2} />
|
||||||
label={t('configurations.add_subsection')}
|
|
||||||
onClick={onOpen}
|
|
||||||
isDisabled={!editing}
|
|
||||||
ml={2}
|
|
||||||
/>
|
|
||||||
<Modal onClose={onClose} isOpen={isOpen} size="sm" scrollBehavior="inside">
|
<Modal onClose={onClose} isOpen={isOpen} size="sm" scrollBehavior="inside">
|
||||||
<ModalOverlay />
|
<ModalOverlay />
|
||||||
<ModalContent>
|
<ModalContent>
|
||||||
<ModalHeader
|
<ModalHeader title={t('configurations.add_subsection')} right={<CloseButton ml={2} onClick={onClose} />} />
|
||||||
title={t('configurations.add_subsection')}
|
|
||||||
right={<CloseButton ml={2} onClick={onClose} />}
|
|
||||||
/>
|
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
<SimpleGrid minChildWidth="200px" spacing={4}>
|
<SimpleGrid minChildWidth="200px" spacing={4}>
|
||||||
<Center>
|
<Center>
|
||||||
@@ -57,11 +49,7 @@ const AddSubsectionModal = ({ editing, activeSubs, addSub }) => {
|
|||||||
</Button>
|
</Button>
|
||||||
</Center>
|
</Center>
|
||||||
<Center>
|
<Center>
|
||||||
<Button
|
<Button colorScheme="blue" isDisabled={activeSubs.includes('unit')} onClick={() => addNewSub('unit')}>
|
||||||
colorScheme="blue"
|
|
||||||
isDisabled={activeSubs.includes('unit')}
|
|
||||||
onClick={() => addNewSub('unit')}
|
|
||||||
>
|
|
||||||
{t('configurations.unit')}
|
{t('configurations.unit')}
|
||||||
</Button>
|
</Button>
|
||||||
</Center>
|
</Center>
|
||||||
|
|||||||
@@ -1,15 +1,7 @@
|
|||||||
import React, { useCallback, useState } from 'react';
|
import React, { useCallback, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import isEqual from 'react-fast-compare';
|
import isEqual from 'react-fast-compare';
|
||||||
import {
|
import { Button, useDisclosure, Modal, ModalBody, ModalContent, ModalOverlay, Box } from '@chakra-ui/react';
|
||||||
Button,
|
|
||||||
useDisclosure,
|
|
||||||
Modal,
|
|
||||||
ModalBody,
|
|
||||||
ModalContent,
|
|
||||||
ModalOverlay,
|
|
||||||
Box,
|
|
||||||
} from '@chakra-ui/react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Plus } from 'phosphor-react';
|
import { Plus } from 'phosphor-react';
|
||||||
import ModalHeader from 'components/ModalHeader';
|
import ModalHeader from 'components/ModalHeader';
|
||||||
@@ -53,14 +45,7 @@ const CreateInterfaceButton = ({ editing, arrayHelpers: { push: pushInterface }
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button colorScheme="blue" type="submit" onClick={onOpen} rightIcon={<Plus size={20} />} hidden={!editing} ml={2}>
|
||||||
colorScheme="blue"
|
|
||||||
type="submit"
|
|
||||||
onClick={onOpen}
|
|
||||||
rightIcon={<Plus size={20} />}
|
|
||||||
hidden={!editing}
|
|
||||||
ml={2}
|
|
||||||
>
|
|
||||||
{t('configurations.add_interface')}
|
{t('configurations.add_interface')}
|
||||||
</Button>
|
</Button>
|
||||||
<Modal onClose={onClose} isOpen={isOpen} size="sm" scrollBehavior="inside">
|
<Modal onClose={onClose} isOpen={isOpen} size="sm" scrollBehavior="inside">
|
||||||
|
|||||||
@@ -22,14 +22,7 @@ const InterfaceExpertModal = ({ editing }) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<EditButton mt={2} label={t('configurations.expert_name')} onClick={onOpen} />
|
<EditButton mt={2} label={t('configurations.expert_name')} onClick={onOpen} />
|
||||||
{isOpen && (
|
{isOpen && <InterfaceExpertForm config={value} onClose={onClose} setConfig={setConfig} editing={editing} />}
|
||||||
<InterfaceExpertForm
|
|
||||||
config={value}
|
|
||||||
onClose={onClose}
|
|
||||||
setConfig={setConfig}
|
|
||||||
editing={editing}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,12 +14,7 @@ const IpV4 = ({ editing, index, isEnabled }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<NumberField
|
<NumberField name={`configuration[${index}].bridge.mtu`} label="bridge.mtu" isDisabled={!editing} isRequired />
|
||||||
name={`configuration[${index}].bridge.mtu`}
|
|
||||||
label="bridge.mtu"
|
|
||||||
isDisabled={!editing}
|
|
||||||
isRequired
|
|
||||||
/>
|
|
||||||
<NumberField
|
<NumberField
|
||||||
name={`configuration[${index}].bridge.tx-queue-len`}
|
name={`configuration[${index}].bridge.tx-queue-len`}
|
||||||
label="bridge.tx-queue-len"
|
label="bridge.tx-queue-len"
|
||||||
|
|||||||
@@ -20,10 +20,7 @@ const DhcpIpV4 = ({ editing, index }) => {
|
|||||||
|
|
||||||
const onEnabledChange = (e) => {
|
const onEnabledChange = (e) => {
|
||||||
if (e.target.checked) {
|
if (e.target.checked) {
|
||||||
setFieldValue(
|
setFieldValue(`configuration[${index}].ipv4.dhcp`, INTERFACE_IPV4_DHCP_SCHEMA(t, true).cast());
|
||||||
`configuration[${index}].ipv4.dhcp`,
|
|
||||||
INTERFACE_IPV4_DHCP_SCHEMA(t, true).cast(),
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
setFieldValue(`configuration[${index}].ipv4.dhcp`, undefined);
|
setFieldValue(`configuration[${index}].ipv4.dhcp`, undefined);
|
||||||
setFieldValue(`configuration[${index}].ipv4.dhcp-lease`, undefined);
|
setFieldValue(`configuration[${index}].ipv4.dhcp-lease`, undefined);
|
||||||
@@ -41,13 +38,7 @@ const DhcpIpV4 = ({ editing, index }) => {
|
|||||||
<FormLabel ms="4px" fontSize="md" fontWeight="normal">
|
<FormLabel ms="4px" fontSize="md" fontWeight="normal">
|
||||||
Enable DHCP
|
Enable DHCP
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<Switch
|
<Switch onChange={onEnabledChange} isChecked={isEnabled} borderRadius="15px" size="lg" isDisabled={!editing} />
|
||||||
onChange={onEnabledChange}
|
|
||||||
isChecked={isEnabled}
|
|
||||||
borderRadius="15px"
|
|
||||||
size="lg"
|
|
||||||
isDisabled={!editing}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
{isEnabled && (
|
{isEnabled && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -20,10 +20,7 @@ const DhcpLeaseIpV4 = ({ editing, index }) => {
|
|||||||
|
|
||||||
const onEnabledChange = (e) => {
|
const onEnabledChange = (e) => {
|
||||||
if (e.target.checked) {
|
if (e.target.checked) {
|
||||||
setFieldValue(
|
setFieldValue(`configuration[${index}].ipv4.dhcp-lease`, INTERFACE_IPV4_DHCP_LEASE_SCHEMA(t, true).cast());
|
||||||
`configuration[${index}].ipv4.dhcp-lease`,
|
|
||||||
INTERFACE_IPV4_DHCP_LEASE_SCHEMA(t, true).cast(),
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
setFieldValue(`configuration[${index}].ipv4.dhcp-lease`, undefined);
|
setFieldValue(`configuration[${index}].ipv4.dhcp-lease`, undefined);
|
||||||
}
|
}
|
||||||
@@ -40,13 +37,7 @@ const DhcpLeaseIpV4 = ({ editing, index }) => {
|
|||||||
<FormLabel ms="4px" fontSize="md" fontWeight="normal">
|
<FormLabel ms="4px" fontSize="md" fontWeight="normal">
|
||||||
Enable DHCP-LEASE
|
Enable DHCP-LEASE
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<Switch
|
<Switch onChange={onEnabledChange} isChecked={isEnabled} borderRadius="15px" size="lg" isDisabled={!editing} />
|
||||||
onChange={onEnabledChange}
|
|
||||||
isChecked={isEnabled}
|
|
||||||
borderRadius="15px"
|
|
||||||
size="lg"
|
|
||||||
isDisabled={!editing}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
{isEnabled && (
|
{isEnabled && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ const IpV4 = ({ editing, index }) => {
|
|||||||
const onIpv4Change = (e) => {
|
const onIpv4Change = (e) => {
|
||||||
if (e.target.value === '') {
|
if (e.target.value === '') {
|
||||||
setFieldValue(`configuration[${index}].ipv4`, undefined);
|
setFieldValue(`configuration[${index}].ipv4`, undefined);
|
||||||
} else if (e.target.value === 'dynamic')
|
} else if (e.target.value === 'dynamic') setFieldValue(`configuration[${index}].ipv4`, { addressing: 'dynamic' });
|
||||||
setFieldValue(`configuration[${index}].ipv4`, { addressing: 'dynamic' });
|
|
||||||
else {
|
else {
|
||||||
setFieldValue(`configuration[${index}].ipv4`, {
|
setFieldValue(`configuration[${index}].ipv4`, {
|
||||||
...INTERFACE_IPV4_SCHEMA(t, true).cast(),
|
...INTERFACE_IPV4_SCHEMA(t, true).cast(),
|
||||||
@@ -56,25 +55,13 @@ const IpV4 = ({ editing, index }) => {
|
|||||||
mx={2}
|
mx={2}
|
||||||
/>
|
/>
|
||||||
<FormControl isDisabled={!editing} hidden={getIpv4Value() === ''}>
|
<FormControl isDisabled={!editing} hidden={getIpv4Value() === ''}>
|
||||||
<Select
|
<Select value={getIpv4Value()} onChange={onIpv4Change} borderRadius="15px" fontSize="sm" w="120px">
|
||||||
value={getIpv4Value()}
|
|
||||||
onChange={onIpv4Change}
|
|
||||||
borderRadius="15px"
|
|
||||||
fontSize="sm"
|
|
||||||
w="120px"
|
|
||||||
>
|
|
||||||
<option value="dynamic">dynamic</option>
|
<option value="dynamic">dynamic</option>
|
||||||
<option value="static">static</option>
|
<option value="static">static</option>
|
||||||
</Select>
|
</Select>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Heading>
|
</Heading>
|
||||||
<SimpleGrid
|
<SimpleGrid minChildWidth="300px" spacing="20px" mb={getIpv4Value() === 'static' ? 8 : undefined} mt={2} w="100%">
|
||||||
minChildWidth="300px"
|
|
||||||
spacing="20px"
|
|
||||||
mb={getIpv4Value() === 'static' ? 8 : undefined}
|
|
||||||
mt={2}
|
|
||||||
w="100%"
|
|
||||||
>
|
|
||||||
<StaticIpV4 index={index} isEnabled={getIpv4Value() === 'static'} editing={editing} />
|
<StaticIpV4 index={index} isEnabled={getIpv4Value() === 'static'} editing={editing} />
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -43,13 +43,7 @@ const IpV6 = ({ editing, index }) => {
|
|||||||
mx={2}
|
mx={2}
|
||||||
/>
|
/>
|
||||||
<FormControl isDisabled hidden={getIpv6Value() === ''}>
|
<FormControl isDisabled hidden={getIpv6Value() === ''}>
|
||||||
<Select
|
<Select value={getIpv6Value()} onChange={onIpv6Change} borderRadius="15px" fontSize="sm" w="120px">
|
||||||
value={getIpv6Value()}
|
|
||||||
onChange={onIpv6Change}
|
|
||||||
borderRadius="15px"
|
|
||||||
fontSize="sm"
|
|
||||||
w="120px"
|
|
||||||
>
|
|
||||||
<option value="dynamic">dynamic</option>
|
<option value="dynamic">dynamic</option>
|
||||||
</Select>
|
</Select>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|||||||
@@ -26,15 +26,10 @@ const Encryption = ({ editing, namePrefix }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const isEnabled = useMemo(
|
const isEnabled = useMemo(() => getIn(values, `${namePrefix}`) !== undefined, [getIn(values, `${namePrefix}`)]);
|
||||||
() => getIn(values, `${namePrefix}`) !== undefined,
|
|
||||||
[getIn(values, `${namePrefix}`)],
|
|
||||||
);
|
|
||||||
|
|
||||||
const isKeyNeeded = useMemo(
|
const isKeyNeeded = useMemo(
|
||||||
() =>
|
() => getIn(values, `${namePrefix}`) !== undefined && keyProtos.includes(getIn(values, `${namePrefix}`).proto),
|
||||||
getIn(values, `${namePrefix}`) !== undefined &&
|
|
||||||
keyProtos.includes(getIn(values, `${namePrefix}`).proto),
|
|
||||||
[getIn(values, `${namePrefix}`)],
|
[getIn(values, `${namePrefix}`)],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,7 @@ import StringField from 'components/FormFields/StringField';
|
|||||||
import { FormControl, FormLabel, SimpleGrid, Switch } from '@chakra-ui/react';
|
import { FormControl, FormLabel, SimpleGrid, Switch } from '@chakra-ui/react';
|
||||||
import ObjectArrayFieldModal from 'components/FormFields/ObjectArrayFieldModal';
|
import ObjectArrayFieldModal from 'components/FormFields/ObjectArrayFieldModal';
|
||||||
import NumberField from 'components/FormFields/NumberField';
|
import NumberField from 'components/FormFields/NumberField';
|
||||||
import {
|
import { INTERFACE_SSID_RADIUS_LOCAL_SCHEMA, INTERFACE_SSID_RADIUS_LOCAL_USER_SCHEMA } from '../../interfacesConstants';
|
||||||
INTERFACE_SSID_RADIUS_LOCAL_SCHEMA,
|
|
||||||
INTERFACE_SSID_RADIUS_LOCAL_USER_SCHEMA,
|
|
||||||
} from '../../interfacesConstants';
|
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
editing: PropTypes.bool.isRequired,
|
editing: PropTypes.bool.isRequired,
|
||||||
@@ -28,10 +25,7 @@ const Local = ({ editing, namePrefix }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const isEnabled = useMemo(
|
const isEnabled = useMemo(() => getIn(values, `${namePrefix}`) !== undefined, [getIn(values, `${namePrefix}`)]);
|
||||||
() => getIn(values, `${namePrefix}`) !== undefined,
|
|
||||||
[getIn(values, `${namePrefix}`)],
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -67,13 +61,7 @@ const Local = ({ editing, namePrefix }) => {
|
|||||||
<StringField name="mac" label="mac" isRequired />
|
<StringField name="mac" label="mac" isRequired />
|
||||||
<StringField name="user-name" label="user-name" isRequired />
|
<StringField name="user-name" label="user-name" isRequired />
|
||||||
<StringField name="password" label="password" isRequired hideButton />
|
<StringField name="password" label="password" isRequired hideButton />
|
||||||
<NumberField
|
<NumberField name="vlan-id" label="vlan-id" isDisabled={!editing} isRequired w={24} />
|
||||||
name="vlan-id"
|
|
||||||
label="vlan-id"
|
|
||||||
isDisabled={!editing}
|
|
||||||
isRequired
|
|
||||||
w={24}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
columns={[
|
columns={[
|
||||||
|
|||||||
@@ -34,22 +34,9 @@ const LockedRadius = ({ variableBlockId }) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SimpleGrid minChildWidth="300px" spacing="20px">
|
<SimpleGrid minChildWidth="300px" spacing="20px">
|
||||||
<DisplayStringField
|
<DisplayStringField label="authentication.host" value={data.authentication.host} isRequired />
|
||||||
label="authentication.host"
|
<DisplayNumberField label="authentication.port" value={data.authentication.port} isRequired />
|
||||||
value={data.authentication.host}
|
<DisplayStringField label="authentication.secret" value={data.authentication.secret} isRequired hideButton />
|
||||||
isRequired
|
|
||||||
/>
|
|
||||||
<DisplayNumberField
|
|
||||||
label="authentication.port"
|
|
||||||
value={data.authentication.port}
|
|
||||||
isRequired
|
|
||||||
/>
|
|
||||||
<DisplayStringField
|
|
||||||
label="authentication.secret"
|
|
||||||
value={data.authentication.secret}
|
|
||||||
isRequired
|
|
||||||
hideButton
|
|
||||||
/>
|
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
<FormControl isDisabled>
|
<FormControl isDisabled>
|
||||||
<FormLabel ms="4px" fontSize="md" fontWeight="normal">
|
<FormLabel ms="4px" fontSize="md" fontWeight="normal">
|
||||||
@@ -67,12 +54,7 @@ const LockedRadius = ({ variableBlockId }) => {
|
|||||||
<SimpleGrid minChildWidth="300px" spacing="20px">
|
<SimpleGrid minChildWidth="300px" spacing="20px">
|
||||||
<DisplayStringField label="accounting.host" value={data.accounting?.host} isRequired />
|
<DisplayStringField label="accounting.host" value={data.accounting?.host} isRequired />
|
||||||
<DisplayNumberField label="accounting.port" value={data.accounting?.port} isRequired />
|
<DisplayNumberField label="accounting.port" value={data.accounting?.port} isRequired />
|
||||||
<DisplayStringField
|
<DisplayStringField label="accounting.secret" value={data.accounting?.secret} isRequired hideButton />
|
||||||
label="accounting.secret"
|
|
||||||
value={data.accounting?.secret}
|
|
||||||
isRequired
|
|
||||||
hideButton
|
|
||||||
/>
|
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
)}
|
)}
|
||||||
<FormControl isDisabled>
|
<FormControl isDisabled>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user