Use swagger api for Site Replication Status (#3208)
This commit is contained in:
@@ -33,13 +33,19 @@ import {
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { IAM_PAGES } from "../../../../common/SecureComponent/permissions";
|
||||
import { useAppDispatch } from "../../../../store";
|
||||
import { setHelpName } from "../../../../systemSlice";
|
||||
import useApi from "../../Common/Hooks/useApi";
|
||||
import { setErrorSnackMessage, setHelpName } from "../../../../systemSlice";
|
||||
import StatusCountCard from "../../Dashboard/BasicDashboard/StatusCountCard";
|
||||
import EntityReplicationLookup from "./EntityReplicationLookup";
|
||||
import TooltipWrapper from "../../Common/TooltipWrapper/TooltipWrapper";
|
||||
import PageHeaderWrapper from "../../Common/PageHeaderWrapper/PageHeaderWrapper";
|
||||
import HelpMenu from "../../HelpMenu";
|
||||
import { api } from "api";
|
||||
import { errorToHandler } from "api/errors";
|
||||
import {
|
||||
ApiError,
|
||||
HttpResponse,
|
||||
SiteReplicationStatusResponse,
|
||||
} from "api/consoleApi";
|
||||
|
||||
export type StatsResponseType = {
|
||||
maxBuckets?: number;
|
||||
@@ -91,15 +97,7 @@ const SiteReplicationStatus = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [stats, setStats] = useState<StatsResponseType>({});
|
||||
|
||||
const [isStatsLoading, invokeSiteStatsApi] = useApi(
|
||||
(res: any) => {
|
||||
setStats(res);
|
||||
},
|
||||
(err: any) => {
|
||||
setStats({});
|
||||
},
|
||||
);
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
|
||||
const {
|
||||
maxBuckets = 0,
|
||||
@@ -113,8 +111,22 @@ const SiteReplicationStatus = () => {
|
||||
} = stats || {};
|
||||
|
||||
const getStats = () => {
|
||||
let url = `api/v1/admin/site-replication/status?buckets=true&groups=true&policies=true&users=true`;
|
||||
invokeSiteStatsApi("GET", url);
|
||||
setLoading(true);
|
||||
api.admin
|
||||
.getSiteReplicationStatus({
|
||||
buckets: true,
|
||||
groups: true,
|
||||
policies: true,
|
||||
users: true,
|
||||
})
|
||||
.then((res: HttpResponse<SiteReplicationStatusResponse, ApiError>) => {
|
||||
setStats(res.data);
|
||||
})
|
||||
.catch((res: HttpResponse<SiteReplicationStatusResponse, ApiError>) => {
|
||||
setStats({});
|
||||
dispatch(setErrorSnackMessage(errorToHandler(res.error)));
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -163,7 +175,7 @@ const SiteReplicationStatus = () => {
|
||||
Replication status from all Sites
|
||||
</SectionTitle>
|
||||
|
||||
{!isStatsLoading ? (
|
||||
{!loading ? (
|
||||
<Box
|
||||
sx={{
|
||||
display: "grid",
|
||||
|
||||
@@ -114,7 +114,7 @@ const AddIDPConfiguration = ({
|
||||
navigate(backLink);
|
||||
dispatch(setServerNeedsRestart(res.data.restart === true));
|
||||
})
|
||||
.catch(async (res: HttpResponse<SetIDPResponse, ApiError>) => {
|
||||
.catch((res: HttpResponse<SetIDPResponse, ApiError>) => {
|
||||
dispatch(setErrorSnackMessage(errorToHandler(res.error)));
|
||||
})
|
||||
.finally(() => setLoadingCreate(false));
|
||||
|
||||
@@ -72,7 +72,7 @@ const GetApiKeyModal = ({ open, closeModal, onSet }: IGetApiKeyModalProps) => {
|
||||
getApiKey(res.data.access_token);
|
||||
}
|
||||
})
|
||||
.catch(async (res: HttpResponse<SubnetLoginResponse, ApiError>) => {
|
||||
.catch((res: HttpResponse<SubnetLoginResponse, ApiError>) => {
|
||||
onError(res.error);
|
||||
})
|
||||
.finally(() => setLoadingSave(false));
|
||||
@@ -90,7 +90,7 @@ const GetApiKeyModal = ({ open, closeModal, onSet }: IGetApiKeyModalProps) => {
|
||||
closeModal();
|
||||
}
|
||||
})
|
||||
.catch(async (res: HttpResponse<SubnetLoginResponse, ApiError>) => {
|
||||
.catch((res: HttpResponse<SubnetLoginResponse, ApiError>) => {
|
||||
onError(res.error);
|
||||
})
|
||||
.finally(() => setLoadingSave(false));
|
||||
@@ -105,7 +105,7 @@ const GetApiKeyModal = ({ open, closeModal, onSet }: IGetApiKeyModalProps) => {
|
||||
setMfaToken(res.data.mfa_token);
|
||||
}
|
||||
})
|
||||
.catch(async (res: HttpResponse<SubnetLoginResponse, ApiError>) => {
|
||||
.catch((res: HttpResponse<SubnetLoginResponse, ApiError>) => {
|
||||
onError(res.error);
|
||||
})
|
||||
.finally(() => setLoadingSave(false));
|
||||
|
||||
@@ -66,7 +66,7 @@ const OfflineRegistration = () => {
|
||||
dispatch(fetchLicenseInfo());
|
||||
dispatch(setServerNeedsRestart(true));
|
||||
})
|
||||
.catch(async (res: HttpResponse<SetConfigResponse, ApiError>) => {
|
||||
.catch((res: HttpResponse<SetConfigResponse, ApiError>) => {
|
||||
dispatch(setErrorSnackMessage(errorToHandler(res.error)));
|
||||
})
|
||||
.finally(() => setLoadingSave(false));
|
||||
|
||||
Reference in New Issue
Block a user