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, onClickLogoutAllExceptThis,
onClickRemoveSession, onClickRemoveSession,
updateUserStatus, updateUserStatus,
getLoginHistoryReport,
isLoadingDownloadReport,
isSessionsLoaded, isSessionsLoaded,
}) => { }) => {
useEffect(() => { useEffect(() => {
@ -174,8 +176,8 @@ const Sessions = ({
label={t("DownloadReportBtnText")} label={t("DownloadReportBtnText")}
size="normal" size="normal"
minwidth="auto" minwidth="auto"
onClick={() => console.log("get report")} onClick={() => getLoginHistoryReport()}
isLoading={false} isLoading={isLoadingDownloadReport}
/> />
<span className="download-report_description"> <span className="download-report_description">
{t("DownloadReportDescription")} {t("DownloadReportDescription")}
@ -250,6 +252,8 @@ export default inject(({ settingsStore, setup, peopleStore }) => {
setDisableDialogVisible, setDisableDialogVisible,
setLogoutDialogVisible, setLogoutDialogVisible,
setLogoutAllDialogVisible, setLogoutAllDialogVisible,
getLoginHistoryReport,
isLoadingDownloadReport,
} = setup; } = setup;
return { return {
@ -279,6 +283,8 @@ export default inject(({ settingsStore, setup, peopleStore }) => {
onClickLogoutAllExceptThis, onClickLogoutAllExceptThis,
onClickRemoveSession, onClickRemoveSession,
updateUserStatus, updateUserStatus,
getLoginHistoryReport,
isLoadingDownloadReport,
isSessionsLoaded: allSessions.length > 0, isSessionsLoaded: allSessions.length > 0,
}; };
})( })(

View File

@ -434,9 +434,16 @@ class SettingsSetupStore {
}; };
getLoginHistoryReport = async () => { getLoginHistoryReport = async () => {
try {
this.setIsLoadingDownloadReport(true);
const res = await api.settings.getLoginHistoryReport(); const res = await api.settings.getLoginHistoryReport();
setTimeout(() => window.open(res), 100); //hack for ios setTimeout(() => window.open(res), 100); //hack for ios
return this.setAuditTrailReport(res); return this.setAuditTrailReport(res);
} catch (error) {
console.log(error);
} finally {
this.setIsLoadingDownloadReport(false);
}
}; };
getAuditTrailReport = async () => { getAuditTrailReport = async () => {