added method for download report

This commit is contained in:
Elyor Djalilov 2024-06-20 12:51:09 +05:00
parent f713c56f50
commit 790d289781
2 changed files with 18 additions and 5 deletions

View File

@ -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}
/>
<span className="download-report_description">
{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,
};
})(

View File

@ -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 () => {