diff --git a/packages/client/src/pages/PortalSettings/categories/security/sessions/index.js b/packages/client/src/pages/PortalSettings/categories/security/sessions/index.js index 17f8a0a42e..f51ff50e52 100644 --- a/packages/client/src/pages/PortalSettings/categories/security/sessions/index.js +++ b/packages/client/src/pages/PortalSettings/categories/security/sessions/index.js @@ -102,6 +102,8 @@ const Sessions = ({ onClickLogoutAllExceptThis, onClickRemoveSession, updateUserStatus, + getLoginHistoryReport, + isLoadingDownloadReport, isSessionsLoaded, }) => { useEffect(() => { @@ -174,8 +176,8 @@ const Sessions = ({ label={t("DownloadReportBtnText")} size="normal" minwidth="auto" - onClick={() => console.log("get report")} - isLoading={false} + onClick={() => getLoginHistoryReport()} + isLoading={isLoadingDownloadReport} /> {t("DownloadReportDescription")} @@ -250,6 +252,8 @@ export default inject(({ settingsStore, setup, peopleStore }) => { setDisableDialogVisible, setLogoutDialogVisible, setLogoutAllDialogVisible, + getLoginHistoryReport, + isLoadingDownloadReport, } = setup; return { @@ -279,6 +283,8 @@ export default inject(({ settingsStore, setup, peopleStore }) => { onClickLogoutAllExceptThis, onClickRemoveSession, updateUserStatus, + getLoginHistoryReport, + isLoadingDownloadReport, isSessionsLoaded: allSessions.length > 0, }; })( diff --git a/packages/client/src/store/SettingsSetupStore.js b/packages/client/src/store/SettingsSetupStore.js index 101f3e2ce9..6efed2c880 100644 --- a/packages/client/src/store/SettingsSetupStore.js +++ b/packages/client/src/store/SettingsSetupStore.js @@ -434,9 +434,16 @@ class SettingsSetupStore { }; getLoginHistoryReport = async () => { - const res = await api.settings.getLoginHistoryReport(); - setTimeout(() => window.open(res), 100); //hack for ios - return this.setAuditTrailReport(res); + try { + this.setIsLoadingDownloadReport(true); + const res = await api.settings.getLoginHistoryReport(); + setTimeout(() => window.open(res), 100); //hack for ios + return this.setAuditTrailReport(res); + } catch (error) { + console.log(error); + } finally { + this.setIsLoadingDownloadReport(false); + } }; getAuditTrailReport = async () => {