mirror of
https://github.com/Telecominfraproject/wlan-cloud-ui.git
synced 2025-11-01 11:17:59 +00:00
added delete equipment
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
|||||||
} from 'graphql/mutations';
|
} from 'graphql/mutations';
|
||||||
import { updateQueryGetAllProfiles } from 'graphql/functions';
|
import { updateQueryGetAllProfiles } from 'graphql/functions';
|
||||||
import UserContext from 'contexts/UserContext';
|
import UserContext from 'contexts/UserContext';
|
||||||
|
import history from 'utils/history';
|
||||||
|
|
||||||
const GET_EQUIPMENT = gql`
|
const GET_EQUIPMENT = gql`
|
||||||
query GetEquipment($id: ID!) {
|
query GetEquipment($id: ID!) {
|
||||||
@@ -123,6 +124,14 @@ const UPDATE_EQUIPMENT = gql`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const DELETE_EQUIPMENT = gql`
|
||||||
|
mutation DeleteEquipment($id: ID!) {
|
||||||
|
deleteEquipment(id: $id) {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
const toTime = moment();
|
const toTime = moment();
|
||||||
const fromTime = moment().subtract(1, 'hour');
|
const fromTime = moment().subtract(1, 'hour');
|
||||||
|
|
||||||
@@ -181,6 +190,7 @@ const AccessPointDetails = ({ locations }) => {
|
|||||||
const [updateEquipmentFirmware] = useMutation(UPDATE_EQUIPMENT_FIRMWARE);
|
const [updateEquipmentFirmware] = useMutation(UPDATE_EQUIPMENT_FIRMWARE);
|
||||||
const [requestEquipmentSwitchBank] = useMutation(REQUEST_EQUIPMENT_SWITCH_BANK);
|
const [requestEquipmentSwitchBank] = useMutation(REQUEST_EQUIPMENT_SWITCH_BANK);
|
||||||
const [requestEquipmentReboot] = useMutation(REQUEST_EQUIPMENT_REBOOT);
|
const [requestEquipmentReboot] = useMutation(REQUEST_EQUIPMENT_REBOOT);
|
||||||
|
const [deleteEquipment] = useMutation(DELETE_EQUIPMENT);
|
||||||
|
|
||||||
const refetchData = () => {
|
const refetchData = () => {
|
||||||
refetch();
|
refetch();
|
||||||
@@ -232,6 +242,24 @@ const AccessPointDetails = ({ locations }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleDeleteEquipment = () => {
|
||||||
|
deleteEquipment({ variables: { id } })
|
||||||
|
.then(() => {
|
||||||
|
refetch();
|
||||||
|
history.replace('/network/access-points');
|
||||||
|
notification.success({
|
||||||
|
message: 'Success',
|
||||||
|
description: 'Equipment successfully deleted',
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() =>
|
||||||
|
notification.error({
|
||||||
|
message: 'Error',
|
||||||
|
description: 'Equipment could not be deleted.',
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const handleUpdateEquipmentFirmware = (equipmentId, firmwareVersionId) =>
|
const handleUpdateEquipmentFirmware = (equipmentId, firmwareVersionId) =>
|
||||||
updateEquipmentFirmware({ variables: { equipmentId, firmwareVersionId } })
|
updateEquipmentFirmware({ variables: { equipmentId, firmwareVersionId } })
|
||||||
.then(firmwareResp => {
|
.then(firmwareResp => {
|
||||||
@@ -335,6 +363,7 @@ const AccessPointDetails = ({ locations }) => {
|
|||||||
<AccessPointDetailsPage
|
<AccessPointDetailsPage
|
||||||
handleRefresh={refetchData}
|
handleRefresh={refetchData}
|
||||||
onUpdateEquipment={handleUpdateEquipment}
|
onUpdateEquipment={handleUpdateEquipment}
|
||||||
|
onDeleteEquipment={handleDeleteEquipment}
|
||||||
data={data?.getEquipment}
|
data={data?.getEquipment}
|
||||||
profiles={dataProfiles?.getAllProfiles?.items}
|
profiles={dataProfiles?.getAllProfiles?.items}
|
||||||
osData={{
|
osData={{
|
||||||
|
|||||||
Reference in New Issue
Block a user