Skip to content

Commit 096d041

Browse files
committed
cipp timer table
1 parent 4ed17a7 commit 096d041

File tree

4 files changed

+103
-1
lines changed

4 files changed

+103
-1
lines changed

src/components/CippComponents/CippApiDialog.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useSettings } from "../../hooks/use-settings";
99
import CippFormComponent from "./CippFormComponent";
1010

1111
export const CippApiDialog = (props) => {
12-
const { createDialog, title, fields, api, row, relatedQueryKeys, ...other } = props;
12+
const { createDialog, title, fields, api, row = {}, relatedQueryKeys, ...other } = props;
1313
const router = useRouter();
1414
const [addedFieldData, setAddedFieldData] = useState({});
1515
const [partialResults, setPartialResults] = useState([]);

src/layouts/config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@ export const nativeMenuItems = [
464464
path: "/cipp/advanced/exchange-cmdlets",
465465
roles: ["superadmin"],
466466
},
467+
{
468+
title: "Timers",
469+
path: "/cipp/advanced/timers",
470+
roles: ["superadmin"],
471+
}
467472
],
468473
},
469474
],

src/pages/cipp/advanced/timers.js

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { Layout as DashboardLayout } from "/src/layouts/index.js";
2+
import { SvgIcon, Button } from "@mui/material";
3+
import { Refresh } from "@mui/icons-material";
4+
import { ApiPostCall } from "../../../api/ApiCall";
5+
import { useEffect, useState } from "react";
6+
import { CippTablePage } from "/src/components/CippComponents/CippTablePage";
7+
import { useDialog } from "../../../hooks/use-dialog";
8+
import { CippApiDialog } from "../../../components/CippComponents/CippApiDialog";
9+
10+
const Page = () => {
11+
const pageTitle = "Timers";
12+
const apiUrl = "/api/ExecCippFunction";
13+
const apiData = { FunctionName: "Get-CIPPTimerFunctions", Parameters: { ListAllTasks: true } };
14+
const [data, setData] = useState([]);
15+
const createDialog = useDialog();
16+
const simpleColumns = [
17+
"Priority",
18+
"Command",
19+
"Parameters",
20+
"Cron",
21+
"NextOccurrence",
22+
"LastOccurrence",
23+
"Status",
24+
"PreferredProcessor",
25+
];
26+
27+
const offCanvas = {
28+
extendedInfoFields: simpleColumns,
29+
actions: [],
30+
};
31+
32+
const fetchData = ApiPostCall({
33+
relatedQueryKeys: ["CippTimers"],
34+
onResult: (result) => setData(result),
35+
});
36+
37+
const handleRefresh = () => {
38+
fetchData.mutate({ url: apiUrl, data: apiData });
39+
};
40+
41+
useEffect(() => {
42+
if (!fetchData.isSuccess) {
43+
handleRefresh();
44+
}
45+
}, [fetchData.isSuccess]);
46+
47+
const ResetToDefaultButton = () => {
48+
return (
49+
<Button
50+
variant="contained"
51+
size="small"
52+
onClick={createDialog.handleOpen}
53+
startIcon={
54+
<SvgIcon fontSize="small">
55+
<Refresh />
56+
</SvgIcon>
57+
}
58+
>
59+
Reset to Default
60+
</Button>
61+
);
62+
};
63+
64+
return (
65+
<>
66+
<CippTablePage
67+
title={pageTitle}
68+
data={data}
69+
simpleColumns={simpleColumns}
70+
tenantInTitle={false}
71+
refreshFunction={handleRefresh}
72+
isFetching={fetchData.isPending}
73+
cardButton={<ResetToDefaultButton />}
74+
offCanvas={offCanvas}
75+
actions={[]}
76+
/>
77+
<CippApiDialog
78+
title="Reset to Default"
79+
createDialog={createDialog}
80+
fields={[]}
81+
api={{
82+
url: apiUrl,
83+
confirmText: "Do you want to reset all timers to default?",
84+
type: "POST",
85+
data: { FunctionName: "!Get-CIPPTimerFunctions", Parameters: { ResetToDefault: true } },
86+
relatedQueryKeys: ["CippTimers"],
87+
}}
88+
/>
89+
</>
90+
);
91+
};
92+
93+
Page.getLayout = (page) => <DashboardLayout>{page}</DashboardLayout>;
94+
95+
export default Page;

src/utils/get-cipp-formatting.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ export const getCippFormatting = (data, cellName, type, canReceive) => {
9292
"renewalDate",
9393
"commitmentTerm.renewalConfiguration.renewalDate",
9494
"purchaseDate",
95+
"NextOccurrence",
96+
"LastOccurrence",
9597
];
9698

9799
const matchDateTime = /[dD]ate[tT]ime/;

0 commit comments

Comments
 (0)