finished ap profiles

This commit is contained in:
Sean Macfarlane
2020-06-29 03:32:05 -04:00
parent 369e970814
commit 93b8575629
4 changed files with 33 additions and 20 deletions

View File

@@ -1,9 +1,11 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import { AddProfile as AddProfilePage } from '@tip-wlan/wlan-cloud-ui-library'; import { AddProfile as AddProfilePage } from '@tip-wlan/wlan-cloud-ui-library';
import gql from 'graphql-tag'; import gql from 'graphql-tag';
import { useMutation } from '@apollo/react-hooks'; import { useMutation, useQuery } from '@apollo/react-hooks';
import { notification } from 'antd'; import { notification } from 'antd';
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
import { GET_ALL_PROFILES } from 'graphql/queries';
const CREATE_PROFILE = gql` const CREATE_PROFILE = gql`
mutation CreateProfile( mutation CreateProfile(
@@ -31,6 +33,9 @@ const CREATE_PROFILE = gql`
const AddProfile = () => { const AddProfile = () => {
const { customerId } = useContext(UserContext); const { customerId } = useContext(UserContext);
const { data: ssidProfiles } = useQuery(GET_ALL_PROFILES, {
variables: { customerId, type: 'ssid' },
});
const [createProfile] = useMutation(CREATE_PROFILE); const [createProfile] = useMutation(CREATE_PROFILE);
const handleAddProfile = (profileType, name, details, childProfileIds = []) => { const handleAddProfile = (profileType, name, details, childProfileIds = []) => {
@@ -57,7 +62,14 @@ const AddProfile = () => {
); );
}; };
return <AddProfilePage onCreateProfile={handleAddProfile} />; return (
<AddProfilePage
onCreateProfile={handleAddProfile}
ssidProfiles={
(ssidProfiles && ssidProfiles.getAllProfiles && ssidProfiles.getAllProfiles.items) || []
}
/>
);
}; };
export default AddProfile; export default AddProfile;

View File

@@ -6,6 +6,7 @@ import { Alert, Spin, notification } from 'antd';
import { ProfileDetails as ProfileDetailsPage } from '@tip-wlan/wlan-cloud-ui-library'; import { ProfileDetails as ProfileDetailsPage } from '@tip-wlan/wlan-cloud-ui-library';
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
import { GET_ALL_PROFILES } from 'graphql/queries';
const GET_PROFILE = gql` const GET_PROFILE = gql`
query GetProfile($id: Int!) { query GetProfile($id: Int!) {
@@ -28,23 +29,6 @@ const GET_PROFILE = gql`
} }
`; `;
const GET_ALL_PROFILES = gql`
query GetAllProfiles($customerId: Int!, $cursor: String, $type: String) {
getAllProfiles(customerId: $customerId, cursor: $cursor, type: $type) {
items {
id
name
profileType
details
}
context {
cursor
lastPage
}
}
}
`;
const DELETE_PROFILE = gql` const DELETE_PROFILE = gql`
query DeleteProfile($id: Int!) { query DeleteProfile($id: Int!) {
deleteProfile(id: $id) { deleteProfile(id: $id) {

View File

@@ -157,3 +157,20 @@ export const FILTER_SERVICE_METRICS = gql`
} }
} }
`; `;
export const GET_ALL_PROFILES = gql`
query GetAllProfiles($customerId: Int!, $cursor: String, $type: String) {
getAllProfiles(customerId: $customerId, cursor: $cursor, type: $type) {
items {
id
name
profileType
details
}
context {
cursor
lastPage
}
}
}
`;

View File

@@ -20,7 +20,7 @@
"@ant-design/icons": "^4.2.1", "@ant-design/icons": "^4.2.1",
"@apollo/react-hoc": "^3.1.4", "@apollo/react-hoc": "^3.1.4",
"@apollo/react-hooks": "^3.1.3", "@apollo/react-hooks": "^3.1.3",
"@tip-wlan/wlan-cloud-ui-library": "^0.1.15", "@tip-wlan/wlan-cloud-ui-library": "^0.1.16",
"antd": "^4.3.1", "antd": "^4.3.1",
"apollo-boost": "^0.4.7", "apollo-boost": "^0.4.7",
"clean-webpack-plugin": "^3.0.0", "clean-webpack-plugin": "^3.0.0",