Skip to content

Commit

Permalink
uncomment real queries
Browse files Browse the repository at this point in the history
  • Loading branch information
alicenstar committed Oct 17, 2023
1 parent eb2dffe commit 1386e9b
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 79 deletions.
77 changes: 34 additions & 43 deletions web/src/components/apps/HelmVMClusterManagement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,45 +113,42 @@ const HelmVMClusterManagement = ({ fromLicenseFlow = false }) => {

const navigate = useNavigate();

const nodes = testData;
const nodesLoading = false;

// #region queries

// const { data: nodes, isLoading: nodesLoading } = useQuery({
// queryKey: "helmVmNodes",
// queryFn: async () => {
// return (
// await fetch(`${process.env.API_ENDPOINT}/helmvm/nodes`, {
// headers: {
// Accept: "application/json",
// },
// credentials: "include",
// method: "GET",
// })
// ).json();
// },
// onError: (err) => {
// if (err.status === 401) {
// Utilities.logoutUser();
// return;
// }
// console.log(
// "failed to get node status list, unexpected status code",
// err.status
// );
// },
// onSuccess: (data) => {
// setState({
// // if cluster doesn't support ha, then primary will be disabled. Force into secondary
// selectedNodeType: !data.ha ? "secondary" : state.selectedNodeType,
// });
// },
// config: {
// refetchInterval: 1000,
// retry: false,
// },
// });
const { data: nodes, isLoading: nodesLoading } = useQuery({
queryKey: "helmVmNodes",
queryFn: async () => {
return (
await fetch(`${process.env.API_ENDPOINT}/helmvm/nodes`, {
headers: {
Accept: "application/json",
},
credentials: "include",
method: "GET",
})
).json();
},
onError: (err) => {
if (err.status === 401) {
Utilities.logoutUser();
return;
}
console.log(
"failed to get node status list, unexpected status code",
err.status
);
},
onSuccess: (data) => {
setState({
// if cluster doesn't support ha, then primary will be disabled. Force into secondary
selectedNodeType: !data.ha ? "secondary" : state.selectedNodeType,
});
},
config: {
refetchInterval: 1000,
retry: false,
},
});

const {
data: generateSecondaryAddNodeCommand,
Expand Down Expand Up @@ -216,12 +213,6 @@ const HelmVMClusterManagement = ({ fromLicenseFlow = false }) => {
})
).json();
},
onSuccess: () => {
// if (fromLicenseFlow && data.isConfigurable) {
// navigate(`/${data.slug}/config`, { replace: true });
// return;
// }
},
});
// #endregion

Expand Down
72 changes: 36 additions & 36 deletions web/src/components/apps/HelmVMViewNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,43 +271,43 @@ const testData = {
};

const HelmVMViewNode = () => {
// const { nodeName } = useParams();
// const { data: node } = useQuery({
// queryKey: ["helmVmNode", nodeName],
// queryFn: async ({ queryKey }) => {
// const [, nodeName] = queryKey;
// return (
// await fetch(`${process.env.API_ENDPOINT}/helmvm/node/${nodeName}`, {
// headers: {
// Accept: "application/json",
// },
// credentials: "include",
// method: "GET",
// })
// ).json();
// },
// onError: (err) => {
// if (err.status === 401) {
// Utilities.logoutUser();
// return;
// }
// console.log(
// "failed to get node status list, unexpected status code",
// err.status
// );
// },
// onSuccess: (data) => {
// setState({
// // if cluster doesn't support ha, then primary will be disabled. Force into secondary
// selectedNodeType: !data.ha ? "secondary" : state.selectedNodeType,
// });
// },
// config: {
// retry: false,
// },
// });
const { nodeName } = useParams();
const { data: nodeData } = useQuery({
queryKey: ["helmVmNode", nodeName],
queryFn: async ({ queryKey }) => {
const [, nodeName] = queryKey;
return (
await fetch(`${process.env.API_ENDPOINT}/helmvm/node/${nodeName}`, {
headers: {
Accept: "application/json",
},
credentials: "include",
method: "GET",
})
).json();
},
onError: (err) => {
if (err.status === 401) {
Utilities.logoutUser();
return;
}
console.log(
"failed to get node status list, unexpected status code",
err.status
);
},
onSuccess: (data) => {
setState({
// if cluster doesn't support ha, then primary will be disabled. Force into secondary
selectedNodeType: !data.ha ? "secondary" : state.selectedNodeType,
});
},
config: {
retry: false,
},
});

const node = testData.nodes[0];
const node = nodeData || testData.nodes[0];

const columns = useMemo(
() => [
Expand Down

0 comments on commit 1386e9b

Please sign in to comment.