Skip to content

Commit 99a0f16

Browse files
Merge branch 'dev' of https://github.com/KelvinTegelaar/CIPP into dev
2 parents f9f2857 + 8d4ad67 commit 99a0f16

File tree

4 files changed

+163
-2
lines changed

4 files changed

+163
-2
lines changed

src/pages/cipp/logs/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
1717
import { useForm } from "react-hook-form";
1818
import CippFormComponent from "../../../components/CippComponents/CippFormComponent";
1919
import { FunnelIcon, XMarkIcon } from "@heroicons/react/24/outline";
20+
import { EyeIcon } from "@heroicons/react/24/outline";
2021

2122
const simpleColumns = [
2223
"DateTime",
@@ -34,6 +35,15 @@ const simpleColumns = [
3435
const apiUrl = "/api/Listlogs";
3536
const pageTitle = "Logbook Results";
3637

38+
const actions = [
39+
{
40+
label: "View Log Entry",
41+
link: "/cipp/logs/logentry?logentry=[RowKey]",
42+
icon: <EyeIcon />,
43+
color: "primary",
44+
},
45+
];
46+
3747
const Page = () => {
3848
const formControl = useForm({
3949
defaultValues: {
@@ -303,6 +313,7 @@ const Page = () => {
303313
Severity: severity, // Pass severity filter from state
304314
Filter: filterEnabled, // Pass filter toggle state
305315
}}
316+
actions={actions}
306317
/>
307318
);
308319
};

src/pages/cipp/logs/logentry.js

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
import { useRouter } from "next/router";
2+
import { Layout as DashboardLayout } from "/src/layouts/index.js";
3+
import { ApiGetCall } from "/src/api/ApiCall";
4+
import {
5+
Button,
6+
SvgIcon,
7+
Box,
8+
Container,
9+
Chip,
10+
} from "@mui/material";
11+
import { Stack } from "@mui/system";
12+
import ArrowLeftIcon from "@mui/icons-material/ArrowLeft";
13+
import { CippPropertyListCard } from "/src/components/CippCards/CippPropertyListCard";
14+
import { CippInfoBar } from "/src/components/CippCards/CippInfoBar";
15+
import CippFormSkeleton from "/src/components/CippFormPages/CippFormSkeleton";
16+
17+
const Page = () => {
18+
const router = useRouter();
19+
const { logentry } = router.query;
20+
21+
const logRequest = ApiGetCall({
22+
url: `/api/Listlogs`,
23+
data: {
24+
logentryid: logentry,
25+
},
26+
queryKey: `GetLogEntry-${logentry}`,
27+
waiting: !!logentry,
28+
});
29+
30+
const handleBackClick = () => {
31+
router.push("/cipp/logs");
32+
};
33+
34+
// Get the log data from array
35+
const logData = logRequest.data?.[0];
36+
37+
// Top info bar data like dashboard
38+
const logInfo = logData ? [
39+
{ name: "Log ID", data: logData.RowKey },
40+
{ name: "Date & Time", data: new Date(logData.DateTime).toLocaleString() },
41+
{ name: "API", data: logData.API },
42+
{
43+
name: "Severity",
44+
data: (
45+
<Chip
46+
label={logData.Severity}
47+
color={
48+
logData.Severity === "CRITICAL" ? "error" :
49+
logData.Severity === "Error" ? "error" :
50+
logData.Severity === "Warn" ? "warning" :
51+
logData.Severity === "Info" ? "info" : "default"
52+
}
53+
variant="filled"
54+
/>
55+
)
56+
},
57+
] : [];
58+
59+
// Main log properties
60+
const propertyItems = logData ? [
61+
{ label: "Tenant", value: logData.Tenant },
62+
{ label: "User", value: logData.User },
63+
{ label: "Message", value: logData.Message },
64+
{ label: "Tenant ID", value: logData.TenantID },
65+
{ label: "App ID", value: logData.AppId || "None" },
66+
{ label: "IP Address", value: logData.IP || "None" },
67+
] : [];
68+
69+
// LogData properties
70+
const logDataItems = logData?.LogData && typeof logData.LogData === 'object'
71+
? Object.entries(logData.LogData).map(([key, value]) => ({
72+
label: key,
73+
value: typeof value === 'object' ? JSON.stringify(value, null, 2) : String(value),
74+
}))
75+
: [];
76+
77+
return (
78+
<Box sx={{ flexGrow: 1, py: 4 }}>
79+
<Container maxWidth={false}>
80+
<Stack spacing={2}>
81+
{/* Back button */}
82+
<Button
83+
color="inherit"
84+
onClick={handleBackClick}
85+
startIcon={
86+
<SvgIcon fontSize="small">
87+
<ArrowLeftIcon />
88+
</SvgIcon>
89+
}
90+
sx={{ alignSelf: "flex-start" }}
91+
>
92+
Back to Logs
93+
</Button>
94+
95+
{logRequest.isLoading && <CippFormSkeleton layout={[1, 1, 1]} />}
96+
97+
{logRequest.isError && (
98+
<CippPropertyListCard
99+
title="Error"
100+
propertyItems={[
101+
{ label: "Error", value: "Failed to load log entry" }
102+
]}
103+
/>
104+
)}
105+
106+
{logRequest.isSuccess && logData && (
107+
<>
108+
{/* Top info bar like dashboard */}
109+
<CippInfoBar data={logInfo} isFetching={logRequest.isLoading} />
110+
111+
{/* Main log information */}
112+
<CippPropertyListCard
113+
title="Log Details"
114+
propertyItems={propertyItems}
115+
isFetching={logRequest.isLoading}
116+
/>
117+
118+
{/* LogData in separate card */}
119+
{logDataItems.length > 0 && (
120+
<CippPropertyListCard
121+
title="Additional Log Data"
122+
propertyItems={logDataItems}
123+
isFetching={logRequest.isLoading}
124+
showDivider={false}
125+
/>
126+
)}
127+
</>
128+
)}
129+
</Stack>
130+
</Container>
131+
</Box>
132+
);
133+
};
134+
135+
Page.getLayout = (page) => <DashboardLayout>{page}</DashboardLayout>;
136+
137+
export default Page;

src/pages/tenant/administration/alert-configuration/alert.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,13 @@ const AlertWizard = () => {
253253
recommendedOption.label += " (Recommended)";
254254
}
255255
setRecurrenceOptions(updatedRecurrenceOptions);
256-
formControl.setValue("recurrence", recommendedOption);
256+
257+
// Only set the recommended recurrence if we're NOT editing an existing alert
258+
if (!editAlert) {
259+
formControl.setValue("recurrence", recommendedOption);
260+
}
257261
}
258-
}, [commandValue]);
262+
}, [commandValue, editAlert]);
259263

260264
useEffect(() => {
261265
// Logic to handle template-based form updates when a preset is selected

src/utils/get-cipp-formatting.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,15 @@ export const getCippFormatting = (data, cellName, type, canReceive, flatten = tr
196196
return isText ? data : data;
197197
}
198198

199+
// Handle log message field
200+
const messageFields = ["Message"];
201+
if (messageFields.includes(cellName)) {
202+
if (typeof data === "string" && data.length > 15) {
203+
return isText ? data : `${data.substring(0, 120)}...`;
204+
}
205+
return isText ? data : data;
206+
}
207+
199208
if (cellName === "alignmentScore" || cellName === "combinedAlignmentScore") {
200209
// Handle alignment score, return a percentage with a label
201210
return isText ? (

0 commit comments

Comments
 (0)