Merge branch 'master' into release/v1.0.0

This commit is contained in:
Sean Macfarlane
2021-03-18 18:02:59 -04:00
8 changed files with 118 additions and 50 deletions

View File

@@ -92,7 +92,9 @@ const App = () => {
<ProtectedRouteWithLayout exact path={ROUTES.addprofile} component={AddProfile} />
<ProtectedRouteWithLayout exact path={ROUTES.alarms} component={Alarms} />
<ProtectedRouteWithLayout exact path={ROUTES.account} component={EditAccount} />
{user?.id !== 0 && (
<ProtectedRouteWithLayout exact path={ROUTES.account} component={EditAccount} />
)}
{user?.roles?.[0] === 'SuperUser' && (
<ProtectedRouteWithLayout exact path={ROUTES.users} component={Accounts} />
)}

View File

@@ -13,7 +13,7 @@ import { removeItem } from 'utils/localStorage';
import UserContext from 'contexts/UserContext';
const MasterLayout = ({ children }) => {
const { roles, customerId } = useContext(UserContext);
const { roles, customerId, id: currentUserId } = useContext(UserContext);
const client = useApolloClient();
const location = useLocation();
@@ -56,11 +56,15 @@ const MasterLayout = ({ children }) => {
key: 'settings',
text: 'Settings',
children: [
{
key: 'editAccount',
path: ROUTES.account,
text: 'Edit Account',
},
...(currentUserId !== 0
? [
{
key: 'editAccount',
path: ROUTES.account,
text: 'Edit Account',
},
]
: []),
{
key: 'logout',
path: ROUTES.root,
@@ -90,6 +94,7 @@ const MasterLayout = ({ children }) => {
menuItems={menuItems}
mobileMenuItems={mobileMenuItems}
totalAlarms={data && data.getAlarmCount}
currentUserId={currentUserId}
>
{children}
</Layout>

View File

@@ -89,8 +89,8 @@ const accessPointsTableColumns = [
},
{
title: 'CHANNEL',
dataIndex: 'channel',
render: renderTableCell,
dataIndex: ['status', 'channel', 'detailsJSON', 'channelNumberStatusDataMap'],
render: text => renderTableCell(Object.values(text ?? [])),
},
{
title: 'OCCUPANCY',

View File

@@ -237,23 +237,20 @@ const BulkEditAPs = ({ locations, checkedLocations }) => {
return minLoadValue;
};
const setAccessPointsBulkEditTableData = (dataSource = []) => {
const tableData = dataSource.items.map(({ id: key, name, details }) => {
return {
key,
id: key,
name,
manualChannelNumber: getRadioDetails(details, 'manualChannelNumber'),
manualBackupChannelNumber: getRadioDetails(details, 'manualBackupChannelNumber'),
cellSize: getRadioDetails(details, 'cellSize'),
probeResponseThreshold: getRadioDetails(details, 'probeResponseThreshold'),
clientDisconnectThreshold: getRadioDetails(details, 'clientDisconnectThreshold'),
snrDrop: getRadioDetails(details, 'snrDrop'),
minLoad: getRadioDetails(details, 'minLoad'),
};
});
return tableData;
};
const setAccessPointsBulkEditTableData = (dataSource = []) =>
dataSource.items.map(({ id: key, name, details }) => ({
key,
id: key,
name,
manualChannelNumber: getRadioDetails(details, 'manualChannelNumber'),
manualBackupChannelNumber: getRadioDetails(details, 'manualBackupChannelNumber'),
cellSize: getRadioDetails(details, 'cellSize'),
probeResponseThreshold: getRadioDetails(details, 'probeResponseThreshold'),
clientDisconnectThreshold: getRadioDetails(details, 'clientDisconnectThreshold'),
snrDrop: getRadioDetails(details, 'snrDrop'),
minLoad: getRadioDetails(details, 'minLoad'),
radioMap: Object.keys(details?.radioMap || {}),
}));
const setUpdatedBulkEditTableData = (
equipmentId,
@@ -393,7 +390,7 @@ const BulkEditAPs = ({ locations, checkedLocations }) => {
return (
<BulkEditAccessPoints
tableColumns={accessPointsChannelTableColumns}
tableData={setAccessPointsBulkEditTableData(equipData && equipData?.filterEquipment)}
tableData={setAccessPointsBulkEditTableData(equipData?.filterEquipment)}
onLoadMore={handleLoadMore}
isLastPage={equipData?.filterEquipment?.context?.lastPage}
onSaveChanges={handleSaveChanges}

View File

@@ -4,11 +4,11 @@ import { useQuery, useMutation, gql } from '@apollo/client';
import { Alert, notification } from 'antd';
import { ProfileDetails as ProfileDetailsPage, Loading } from '@tip-wlan/wlan-cloud-ui-library';
import { ROUTES } from 'constants/index';
import { ROUTES, AUTH_TOKEN } from 'constants/index';
import UserContext from 'contexts/UserContext';
import { GET_ALL_PROFILES } from 'graphql/queries';
import { FILE_UPLOAD } from 'graphql/mutations';
import { GET_ALL_PROFILES, GET_API_URL } from 'graphql/queries';
import { fetchMoreProfiles } from 'graphql/functions';
import { getItem } from 'utils/localStorage';
const GET_PROFILE = gql`
query GetProfile($id: ID!) {
@@ -75,6 +75,8 @@ const ProfileDetails = () => {
const [redirect, setRedirect] = useState(false);
const { data: apiUrl } = useQuery(GET_API_URL);
const { loading, error, data } = useQuery(GET_PROFILE, {
variables: { id },
fetchPolicy: 'network-only',
@@ -130,8 +132,6 @@ const ProfileDetails = () => {
const [updateProfile] = useMutation(UPDATE_PROFILE);
const [deleteProfile] = useMutation(DELETE_PROFILE);
const [fileUpload] = useMutation(FILE_UPLOAD);
const handleDeleteProfile = () => {
deleteProfile({ variables: { id } })
.then(() => {
@@ -177,20 +177,77 @@ const ProfileDetails = () => {
);
};
const handleFileUpload = (fileName, file) =>
fileUpload({ variables: { fileName, file } })
.then(() => {
notification.success({
message: 'Success',
description: 'File successfully uploaded.',
});
const handleFileUpload = async (fileName, file) => {
const token = getItem(AUTH_TOKEN);
if (apiUrl?.getApiUrl) {
fetch(`${apiUrl?.getApiUrl}filestore/${fileName}`, {
method: 'POST',
headers: {
Authorization: token ? `Bearer ${token.access_token}` : '',
'Content-Type': 'application/octet-stream',
},
body: file,
})
.catch(() =>
notification.error({
message: 'Error',
description: 'File could not be uploaded.',
.then(response => response.json())
.then(resp => {
if (resp?.success) {
notification.success({
message: 'Success',
description: 'File successfully uploaded.',
});
} else {
notification.error({
message: 'Error',
description: 'File could not be uploaded.',
});
}
})
);
.catch(() => {
notification.error({
message: 'Error',
description: 'File could not be uploaded.',
});
});
} else {
notification.error({
message: 'Error',
description: 'File could not be uploaded.',
});
}
};
const handleDownloadFile = async name => {
const token = getItem(AUTH_TOKEN);
if (apiUrl?.getApiUrl) {
return fetch(`${apiUrl?.getApiUrl}filestore/${encodeURIComponent(name)}`, {
method: 'GET',
headers: {
'Content-Type': 'application/octet-stream',
Authorization: token ? `Bearer ${token.access_token}` : '',
},
})
.then(response => response.blob())
.then(blob => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result);
reader.onerror = reject;
reader.readAsDataURL(blob);
});
})
.catch(() => {
notification.error({
message: 'Error',
description: 'File could not be retrieved.',
});
});
}
return notification.error({
message: 'Error',
description: 'File could not be retrieved.',
});
};
const handleFetchMoreProfiles = (e, key) => {
if (key === 'radius') fetchMoreProfiles(e, radiusProfiles, fetchMoreRadiusProfiles);
@@ -237,6 +294,7 @@ const ProfileDetails = () => {
idProviderProfiles={idProviderProfiles?.getAllProfiles?.items}
fileUpload={handleFileUpload}
onFetchMoreProfiles={handleFetchMoreProfiles}
onDownloadFile={handleDownloadFile}
/>
);
};

View File

@@ -70,6 +70,9 @@ export const FILTER_EQUIPMENT = gql`
firmware {
detailsJSON
}
channel {
detailsJSON
}
}
}
context
@@ -122,6 +125,9 @@ export const GET_EQUIPMENT = gql`
osPerformance {
detailsJSON
}
channel {
detailsJSON
}
}
model
alarmsCount

8
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "wlan-cloud-ui",
"version": "1.0.0",
"version": "1.0.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -1845,9 +1845,9 @@
}
},
"@tip-wlan/wlan-cloud-ui-library": {
"version": "1.0.0",
"resolved": "https://tip.jfrog.io/artifactory/api/npm/tip-wlan-cloud-npm-repo/@tip-wlan/wlan-cloud-ui-library/-/@tip-wlan/wlan-cloud-ui-library-1.0.0.tgz",
"integrity": "sha1-rIoDd5zpwhIepEg07pCy8JQRsEg="
"version": "1.0.7",
"resolved": "https://tip.jfrog.io/artifactory/api/npm/tip-wlan-cloud-npm-repo/@tip-wlan/wlan-cloud-ui-library/-/@tip-wlan/wlan-cloud-ui-library-1.0.7.tgz",
"integrity": "sha1-DY0x0dDNYEevjnO4RYKVQXO4uMk="
},
"@types/anymatch": {
"version": "1.3.1",

View File

@@ -1,6 +1,6 @@
{
"name": "wlan-cloud-ui",
"version": "1.0.0",
"version": "1.0.5",
"author": "ConnectUs",
"description": "React Portal",
"engines": {
@@ -21,7 +21,7 @@
"dependencies": {
"@ant-design/icons": "^4.2.1",
"@apollo/client": "^3.1.3",
"@tip-wlan/wlan-cloud-ui-library": "^1.0.0",
"@tip-wlan/wlan-cloud-ui-library": "^1.0.7",
"antd": "^4.5.2",
"apollo-upload-client": "^13.0.0",
"clean-webpack-plugin": "^3.0.0",