Skip to content

Commit

Permalink
Added Connection Filter
Browse files Browse the repository at this point in the history
added Connection Filter functionality to the front end.
  • Loading branch information
BNWEIN committed Jan 2, 2025
1 parent aa9494b commit bf83efa
Show file tree
Hide file tree
Showing 6 changed files with 229 additions and 1 deletion.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 3 additions & 1 deletion src/layouts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,9 @@ export const nativeMenuItems = [
path: "/email/spamfilter",
items: [
{ title: "Spamfilter", path: "/email/spamfilter/list-spamfilter" },
{ title: "Templates", path: "/email/spamfilter/list-templates" },
{ title: "Spamfilter templates", path: "/email/spamfilter/list-templates" },
{ title: "Connection filter", path: "/email/connectionfilter/list-connectionfilter" },
{ title: "Connection filter templates", path: "/email/connectionfilter/list-templates" },
],
},
{
Expand Down
17 changes: 17 additions & 0 deletions src/pages/email/connectionfilter/deploy/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

import { Layout as DashboardLayout } from "/src/layouts/index.js";

const Page = () => {
const pageTitle = "Apply Spamfilter Template";

return (
<div>
<h1>{pageTitle}</h1>
<p>This is a placeholder page for the apply spamfilter template section.</p>
</div>
);
};

Page.getLayout = (page) => <DashboardLayout>{page}</DashboardLayout>;

export default Page;
87 changes: 87 additions & 0 deletions src/pages/email/connectionfilter/list-connectionfilter/add.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import React, { useEffect } from "react";
import { Grid, Divider } from "@mui/material";
import { useForm, useWatch } from "react-hook-form";
import { Layout as DashboardLayout } from "/src/layouts/index.js";
import CippFormPage from "/src/components/CippFormPages/CippFormPage";
import CippFormComponent from "/src/components/CippComponents/CippFormComponent";
import { CippFormTenantSelector } from "/src/components/CippComponents/CippFormTenantSelector";

const AddPolicy = () => {
const formControl = useForm({
mode: "onChange",
defaultValues: {
selectedTenants: [],
TemplateList: null,
PowerShellCommand: "",
},
});

const templateListVal = useWatch({ control: formControl.control, name: "TemplateList" });

useEffect(() => {
if (templateListVal?.value) {
formControl.setValue("PowerShellCommand", JSON.stringify(templateListVal?.value));
}
}, [templateListVal, formControl]);

return (
<CippFormPage
formControl={formControl}
queryKey="AddConnectionFilter"
title="Add Connection Filter"
backButtonTitle="Connection Filter Overview"
postUrl="/api/AddConnectionFilter"
>
<Grid container spacing={2}>
<Grid item xs={12}>
<CippFormTenantSelector
label="Select Tenants"
formControl={formControl}
name="selectedTenants"
type="multiple"
allTenants={true}
validators={{ required: "At least one tenant must be selected" }}
/>
</Grid>

<Divider sx={{ my: 2, width: "100%" }} />

{/* TemplateList */}
<Grid item xs={12} md={12}>
<CippFormComponent
type="autoComplete"
label="Select a template (optional)"
name="TemplateList"
formControl={formControl}
multiple={false}
api={{
queryKey: `TemplateListConnectionFilter`,
labelField: "name",
valueField: (option) => option,
url: "/api/ListConnectionFilterTemplates",
}}
placeholder="Select a template or enter PowerShell JSON manually"
/>
</Grid>

<Divider sx={{ my: 2, width: "100%" }} />

<Grid item xs={12}>
<CippFormComponent
type="textField"
label="Parameters (JSON)"
name="PowerShellCommand"
formControl={formControl}
multiline
rows={6}
validators={{ required: "Please enter the PowerShell parameters as JSON." }}
/>
</Grid>
</Grid>
</CippFormPage>
);
};

AddPolicy.getLayout = (page) => <DashboardLayout>{page}</DashboardLayout>;

export default AddPolicy;
62 changes: 62 additions & 0 deletions src/pages/email/connectionfilter/list-connectionfilter/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Layout as DashboardLayout } from "/src/layouts/index.js";
import { CippTablePage } from "/src/components/CippComponents/CippTablePage.jsx";
import { Button } from "@mui/material";
import Link from "next/link";

const Page = () => {
const pageTitle = "Connection Filters";

const actions = [
{
label: "Create template based on rule",
type: "POST",
url: "/api/AddConnectionfilterTemplate",
dataFunction: (data) => {
return { ...data };
},
confirmText: "Are you sure you want to create a template based on this rule?",
},
];

const offCanvas = {
extendedInfoFields: [
"DistinguishedName",
"DirectoryBasedEdgeBlockMode",
"ExchangeVersion",
"ExchangeObjectId",
"OrganizationalUnitRoot",
"WhenCreated",
"WhenChanged",
"Guid",
],
actions: actions,
};

const simpleColumns = [
"Name",
"IsDefault",
"IPAllowList",
"IPBlockList",
"EnableSafeList",
];

return (
<CippTablePage
title={pageTitle}
apiUrl="/api/ListConnectionFilter"
actions={actions}
offCanvas={offCanvas}
simpleColumns={simpleColumns}
cardButton={
<>
<Button component={Link} href="/email/connectionfilter/list-connectionfilter/add">
Deploy ConnectionFilter
</Button>
</>
}
/>
);
};

Page.getLayout = (page) => <DashboardLayout>{page}</DashboardLayout>;
export default Page;
59 changes: 59 additions & 0 deletions src/pages/email/connectionfilter/list-templates/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Layout as DashboardLayout } from "/src/layouts/index.js";
import { CippTablePage } from "/src/components/CippComponents/CippTablePage.jsx";
import { EyeIcon, TrashIcon } from "@heroicons/react/24/outline";

const Page = () => {
const pageTitle = "Connection filter Templates";

const actions = [
{
label: "View Template",
icon: <EyeIcon />, // Placeholder for the view icon
color: "success",
offCanvas: true,
},
{
label: "Delete Template",
type: "POST",
url: "/api/RemoveConnectionfilterTemplate",
data: { ID: "GUID" },
confirmText: "Do you want to delete the template?",
icon: <TrashIcon />, // Placeholder for the delete icon
color: "danger",
},
];

const offCanvas = {
extendedInfoFields: [
"name",
"IsDefault",
"IPAllowList",
"IPBlockList",
"EnableSafeList",
"GUID",
],
actions: actions,
};

const simpleColumns = [
"name",
"IsDefault",
"IPAllowList",
"IPBlockList",
"EnableSafeList",
"GUID",
];

return (
<CippTablePage
title={pageTitle}
apiUrl="/api/ListConnectionfilterTemplates"
actions={actions}
offCanvas={offCanvas}
simpleColumns={simpleColumns}
/>
);
};

Page.getLayout = (page) => <DashboardLayout>{page}</DashboardLayout>;
export default Page;

0 comments on commit bf83efa

Please sign in to comment.