Skip to content

Commit c8df261

Browse files
Merge pull request #4444 from kris6673/Mailbox-Activity
Feat: Add Mailbox Activity report page
2 parents 8cffcfe + aa6aae8 commit c8df261

File tree

2 files changed

+160
-12
lines changed

2 files changed

+160
-12
lines changed

src/layouts/config.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,7 @@ export const nativeMenuItems = [
256256
{
257257
title: "Reports",
258258
path: "/tenant/reports",
259-
permissions: [
260-
"Tenant.Administration.*",
261-
"Scheduler.Billing.*",
262-
"Tenant.Application.*",
263-
],
259+
permissions: ["Tenant.Administration.*", "Scheduler.Billing.*", "Tenant.Application.*"],
264260
items: [
265261
{
266262
title: "Licence Report",
@@ -270,9 +266,7 @@ export const nativeMenuItems = [
270266
{
271267
title: "Sherweb Licence Report",
272268
path: "/tenant/reports/list-csp-licenses",
273-
permissions: [
274-
"Tenant.Directory.*"
275-
],
269+
permissions: ["Tenant.Directory.*"],
276270
},
277271
{
278272
title: "Consented Applications",
@@ -478,10 +472,7 @@ export const nativeMenuItems = [
478472
{
479473
title: "Reports",
480474
path: "/endpoint/reports",
481-
permissions: [
482-
"Endpoint.Device.*",
483-
"Endpoint.Autopilot.*",
484-
],
475+
permissions: ["Endpoint.Device.*", "Endpoint.Autopilot.*"],
485476
items: [
486477
{
487478
title: "Analytics Device Score",
@@ -711,6 +702,11 @@ export const nativeMenuItems = [
711702
path: "/email/reports/mailbox-statistics",
712703
permissions: ["Exchange.Mailbox.*"],
713704
},
705+
{
706+
title: "Mailbox Activity",
707+
path: "/email/reports/mailbox-activity",
708+
permissions: ["Exchange.Mailbox.*"],
709+
},
714710
{
715711
title: "Mailbox Client Access Settings",
716712
path: "/email/reports/mailbox-cas-settings",
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
import { useState } from "react";
2+
import { Layout as DashboardLayout } from "/src/layouts/index.js";
3+
import { CippTablePage } from "/src/components/CippComponents/CippTablePage.jsx";
4+
import {
5+
Button,
6+
Accordion,
7+
AccordionSummary,
8+
AccordionDetails,
9+
Typography,
10+
SvgIcon,
11+
Stack,
12+
} from "@mui/material";
13+
import { Grid } from "@mui/system";
14+
import { ExpandMore, Sort } from "@mui/icons-material";
15+
import { FunnelIcon, XMarkIcon } from "@heroicons/react/24/outline";
16+
import { useForm } from "react-hook-form";
17+
import CippFormComponent from "/src/components/CippComponents/CippFormComponent";
18+
19+
const Page = () => {
20+
const formControl = useForm({
21+
defaultValues: {
22+
period: { value: "D30", label: "30 days" },
23+
},
24+
});
25+
26+
const [expanded, setExpanded] = useState(false);
27+
const [selectedPeriod, setSelectedPeriod] = useState("D30");
28+
const [selectedPeriodLabel, setSelectedPeriodLabel] = useState("30 days");
29+
30+
const periodOptions = [
31+
{ value: "D7", label: "7 days" },
32+
{ value: "D30", label: "30 days" },
33+
{ value: "D90", label: "90 days" },
34+
{ value: "D180", label: "180 days" },
35+
];
36+
37+
const onSubmit = (data) => {
38+
const periodValue =
39+
typeof data.period === "object" && data.period?.value ? data.period.value : data.period;
40+
const periodLabel =
41+
typeof data.period === "object" && data.period?.label ? data.period.label : data.period;
42+
43+
setSelectedPeriod(periodValue);
44+
setSelectedPeriodLabel(periodLabel);
45+
setExpanded(false);
46+
};
47+
48+
const clearFilters = () => {
49+
formControl.reset({
50+
period: { value: "D30", label: "30 days" },
51+
});
52+
setSelectedPeriod("D30");
53+
setSelectedPeriodLabel("30 days");
54+
setExpanded(false);
55+
};
56+
57+
const tableFilter = (
58+
<Accordion expanded={expanded} onChange={() => setExpanded(!expanded)}>
59+
<AccordionSummary expandIcon={<ExpandMore />}>
60+
<Stack direction="row" spacing={1} alignItems="center">
61+
<SvgIcon>
62+
<FunnelIcon />
63+
</SvgIcon>
64+
<Typography variant="h6">
65+
Report Period
66+
<span style={{ fontSize: "0.8em", marginLeft: "10px", fontWeight: "normal" }}>
67+
(Period: {selectedPeriodLabel})
68+
</span>
69+
</Typography>
70+
</Stack>
71+
</AccordionSummary>
72+
<AccordionDetails>
73+
<form onSubmit={formControl.handleSubmit(onSubmit)}>
74+
<Grid container spacing={2}>
75+
<Grid size={{ xs: 12, md: 6 }}>
76+
<CippFormComponent
77+
type="autoComplete"
78+
name="period"
79+
multiple={false}
80+
label="Report Period"
81+
options={periodOptions}
82+
formControl={formControl}
83+
disableClearable={true}
84+
/>
85+
</Grid>
86+
87+
<Grid size={{ xs: 12 }}>
88+
<Stack direction="row" spacing={2}>
89+
<Button
90+
type="submit"
91+
variant="contained"
92+
color="primary"
93+
startIcon={
94+
<SvgIcon>
95+
<FunnelIcon />
96+
</SvgIcon>
97+
}
98+
>
99+
Apply
100+
</Button>
101+
<Button
102+
variant="outlined"
103+
color="primary"
104+
startIcon={
105+
<SvgIcon>
106+
<XMarkIcon />
107+
</SvgIcon>
108+
}
109+
onClick={clearFilters}
110+
>
111+
Reset
112+
</Button>
113+
</Stack>
114+
</Grid>
115+
</Grid>
116+
</form>
117+
</AccordionDetails>
118+
</Accordion>
119+
);
120+
121+
return (
122+
<CippTablePage
123+
tableFilter={tableFilter}
124+
title="Mailbox Activity"
125+
apiUrl="/api/ListGraphRequest"
126+
apiData={{
127+
Endpoint: `reports/getEmailActivityUserDetail(period='${selectedPeriod}')`,
128+
$format: "application/json",
129+
Sort: "userPrincipalName",
130+
}}
131+
apiDataKey="Results"
132+
queryKey={`MailboxActivity-${selectedPeriod}`}
133+
simpleColumns={[
134+
"userPrincipalName",
135+
"displayName",
136+
"sendCount",
137+
"receiveCount",
138+
"readCount",
139+
"meetingCreatedCount",
140+
"meetingInteractedCount",
141+
"lastActivityDate",
142+
"reportRefreshDate",
143+
"reportPeriod",
144+
]}
145+
offCanvas={null}
146+
/>
147+
);
148+
};
149+
150+
Page.getLayout = (page) => <DashboardLayout>{page}</DashboardLayout>;
151+
152+
export default Page;

0 commit comments

Comments
 (0)