Skip to content

Commit

Permalink
Merge pull request #1243 from KelvinTegelaar/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
KelvinTegelaar authored Dec 2, 2022
2 parents 099a087 + ed922b4 commit 1218013
Show file tree
Hide file tree
Showing 28 changed files with 1,322 additions and 167 deletions.
2 changes: 1 addition & 1 deletion public/version_latest.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.17.0
2.18.0
87 changes: 56 additions & 31 deletions src/_nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
faBus,
faExclamationTriangle,
faUserShield,
faEnvelope,
} from '@fortawesome/free-solid-svg-icons'

const _nav = [
Expand Down Expand Up @@ -133,35 +134,6 @@ const _nav = [
},
],
},
{
component: CNavGroup,
name: 'Reports',
section: 'Reports',
to: '/tenant/reports',
icon: <FontAwesomeIcon icon={faChartBar} className="nav-icon" />,
items: [
{
component: CNavItem,
name: 'Graph Explorer',
to: '/tenant/administration/graph-explorer',
},
{
component: CNavItem,
name: 'Licence Report',
to: '/tenant/administration/list-licenses',
},
{
component: CNavItem,
name: 'Consented Applications',
to: '/tenant/administration/application-consent',
},
{
component: CNavItem,
name: 'Service Health',
to: '/tenant/administration/service-health',
},
],
},
{
component: CNavGroup,
name: 'Standards',
Expand Down Expand Up @@ -235,6 +207,35 @@ const _nav = [
},
],
},
{
component: CNavGroup,
name: 'Reports',
section: 'Reports',
to: '/tenant/reports',
icon: <FontAwesomeIcon icon={faChartBar} className="nav-icon" />,
items: [
{
component: CNavItem,
name: 'Graph Explorer',
to: '/tenant/administration/graph-explorer',
},
{
component: CNavItem,
name: 'Licence Report',
to: '/tenant/administration/list-licenses',
},
{
component: CNavItem,
name: 'Consented Applications',
to: '/tenant/administration/application-consent',
},
{
component: CNavItem,
name: 'Service Health',
to: '/tenant/administration/service-health',
},
],
},
{
component: CNavTitle,
name: 'Security & Compliance',
Expand Down Expand Up @@ -333,7 +334,7 @@ const _nav = [
},
{
component: CNavItem,
name: 'Add WinGet or Store App',
name: 'Add Store App',
to: '/endpoint/applications/add-winget-app',
},
{
Expand Down Expand Up @@ -517,7 +518,7 @@ const _nav = [
},
{
component: CNavGroup,
name: 'Transport Rules',
name: 'Transport',
section: 'Transport Rules',
to: '/tenant/administration',
icon: <FontAwesomeIcon icon={faBus} className="nav-icon" />,
Expand Down Expand Up @@ -554,6 +555,30 @@ const _nav = [
},
],
},
{
component: CNavGroup,
name: 'Spamfilter',
section: 'Spamfilter',
to: '/tenant/administration',
icon: <FontAwesomeIcon icon={faEnvelope} className="nav-icon" />,
items: [
{
component: CNavItem,
name: 'Spamfilter',
to: '/email/spamfilter/list-spamfilter',
},
{
component: CNavItem,
name: 'Apply Spamfilter Template',
to: '/email/spamfilter/deploy',
},
{
component: CNavItem,
name: 'Templates',
to: '/email/spamfilter/list-templates',
},
],
},
{
component: CNavGroup,
name: 'Reports',
Expand Down
14 changes: 7 additions & 7 deletions src/components/buttons/PdfButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import 'jspdf-autotable'
import PropTypes from 'prop-types'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faFilePdf } from '@fortawesome/free-solid-svg-icons'
import { useSelector } from 'react-redux'

function ExportPDFButton(props) {
const base64 = useSelector((state) => state.app.reportImage)
const exportPDF = (pdfData, pdfHeaders, pdfSize = 'A4', reportName = 'report') => {
const unit = 'pt'
const size = pdfSize // Use A1, A2, A3 or A4
const orientation = 'landscape' // portrait or landscape

const marginLeft = 40
const doc = new jsPDF(orientation, unit, size)

doc.setFontSize(10)
Expand All @@ -24,16 +24,16 @@ function ExportPDFButton(props) {
}
})

const title = reportName
let content = {
startY: 50,
startY: 100,
columns: headerObj,
body: pdfData,
theme: 'grid',
theme: 'striped',
headStyles: { fillColor: [247, 127, 0] },
}

doc.text(title, marginLeft, 40)
if (base64) {
doc.addImage(base64, 'png', 20, 20, 120, 100)
}
doc.autoTable(content)
doc.save(reportName + '.pdf')
}
Expand Down
5 changes: 4 additions & 1 deletion src/components/forms/RFFComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import {
CFormSelect,
CFormSwitch,
CFormTextarea,
CSpinner,
} from '@coreui/react'
import Select from 'react-select'
import AsyncSelect from 'react-select/async'
import { Field } from 'react-final-form'
import React from 'react'
import PropTypes from 'prop-types'
import { useRef } from 'react'

/*
wrapper classes for React Final Form with CoreUI
Expand Down Expand Up @@ -312,7 +315,7 @@ export const RFFSelectSearch = ({
className="react-select-container"
classNamePrefix="react-select"
{...input}
isClearable={true}
isClearable={false}
name={name}
id={name}
disabled={disabled}
Expand Down
82 changes: 82 additions & 0 deletions src/components/tables/CellGenericFormat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import {
faTimesCircle,
faCheckCircle,
faExclamationCircle,
} from '@fortawesome/free-solid-svg-icons'
import { CellBadge } from 'src/components/tables'
import { CBadge, CTooltip } from '@coreui/react'

const IconWarning = () => <FontAwesomeIcon icon={faExclamationCircle} className="text-warning" />
const IconError = () => <FontAwesomeIcon icon={faTimesCircle} className="text-danger" />
const IconSuccess = () => <FontAwesomeIcon icon={faCheckCircle} className="text-success" />

function nocolour(iscolourless, content) {
if (iscolourless) {
return <span className="no-colour">{content}</span>
}

return content
}

export default function CellBoolean({
cell,
warning = false,
reverse = false,
colourless = false,
noDataIsFalse = false,
}) {
let normalized = cell
if (typeof cell === 'boolean') {
normalized = cell
} else if (typeof cell === 'string') {
if (
cell.toLowerCase() === 'success' ||
cell.toLowerCase() === 'pass' ||
cell.toLowerCase() === 'true'
) {
normalized = true
} else if (cell.toLowerCase() === 'fail' || cell.toLowerCase() === 'false') {
normalized = false
}
}

if (cell === '' && !noDataIsFalse) {
return <CellBadge label="No Data" color="info" />
} else if (colourless && warning && reverse) {
return nocolour(colourless, normalized ? <IconWarning /> : <IconError />)
} else if (!reverse && !warning) {
return nocolour(colourless, normalized ? <IconSuccess /> : <IconError />)
} else if (!reverse && warning) {
return nocolour(colourless, normalized ? <IconSuccess /> : <IconWarning />)
} else if (reverse && !warning) {
return nocolour(colourless, normalized ? <IconError /> : <IconSuccess />)
} else if (reverse && warning) {
return nocolour(colourless, normalized ? <IconWarning /> : <IconSuccess />)
}
}

export function CellTip(cell, overflow = false) {
return (
<CTooltip content={String(cell)}>
<div className="celltip-content-nowrap">{String(cell)}</div>
</CTooltip>
)
}

export const cellGenericFormatter =
({ warning = false, reverse = false, colourless = true, noDataIsFalse } = {}) =>
(row, index, column, id) => {
const cell = column.selector(row)
if (cell === null || cell === undefined || cell.length === 0) {
return <CBadge color="info">No Data</CBadge>
}
if (typeof cell === 'boolean') {
return CellBoolean({ cell, warning, reverse, colourless, noDataIsFalse })
}
if (typeof cell === 'string') {
console.log(cell)
return CellTip(cell)
}
}
86 changes: 45 additions & 41 deletions src/components/tables/CippTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export default function CippTable({
error,
reportName,
columns = [],
dynamicColumns = true,
filterlist,
tableProps: {
keyField = 'id',
Expand Down Expand Up @@ -186,48 +187,51 @@ export default function CippTable({
}

if (!disablePDFExport) {
const addColumn = (columnname) => {
var index = columns.length - 1
let alreadyInArray = columns.find((o) => o.exportSelector === columnname)
if (!alreadyInArray) {
columns.splice(index, 0, {
name: columnname,
selector: (row) => row[columnname],
sortable: true,
exportSelector: columnname,
})
} else {
let indexOfExisting = columns.findIndex((o) => o.exportSelector === columnname)
columns = columns.splice(indexOfExisting, 1)
if (dynamicColumns === true) {
const addColumn = (columnname) => {
var index = columns.length - 1
let alreadyInArray = columns.find((o) => o.exportSelector === columnname)
if (!alreadyInArray) {
columns.splice(index, 0, {
name: columnname,
selector: (row) => row[columnname],
sortable: true,
exportSelector: columnname,
})
} else {
let indexOfExisting = columns.findIndex((o) => o.exportSelector === columnname)
columns = columns.splice(indexOfExisting, 1)
}
setUpdatedColumns(Date())
}
setUpdatedColumns(Date())

defaultActions.push([
<CDropdown className="me-2" variant="input-group">
<CDropdownToggle
className="btn btn-primary btn-sm m-1"
size="sm"
style={{
backgroundColor: '#f88c1a',
}}
>
<FontAwesomeIcon icon={faColumns} />
</CDropdownToggle>
<CDropdownMenu>
{dataKeys() &&
dataKeys().map((item, idx) => {
return (
<CDropdownItem key={idx} onClick={() => addColumn(item)}>
{columns.find((o) => o.exportSelector === item) && (
<FontAwesomeIcon icon={faCheck} />
)}{' '}
{item}
</CDropdownItem>
)
})}
</CDropdownMenu>
</CDropdown>,
])
}
defaultActions.push([
<CDropdown className="me-2" variant="input-group">
<CDropdownToggle
className="btn btn-primary btn-sm m-1"
size="sm"
style={{
backgroundColor: '#f88c1a',
}}
>
<FontAwesomeIcon icon={faColumns} />
</CDropdownToggle>
<CDropdownMenu>
{dataKeys() &&
dataKeys().map((item, idx) => {
return (
<CDropdownItem key={idx} onClick={() => addColumn(item)}>
{columns.find((o) => o.exportSelector === item) && (
<FontAwesomeIcon icon={faCheck} />
)}{' '}
{item}
</CDropdownItem>
)
})}
</CDropdownMenu>
</CDropdown>,
])
actions.forEach((action) => {
defaultActions.push(action)
})
Expand Down Expand Up @@ -288,7 +292,7 @@ export default function CippTable({
{!isFetching && error && <span>Error loading data</span>}
{!error && (
<div>
{columns.length === updatedColumns.length && (
{(columns.length === updatedColumns.length || !dynamicColumns) && (
<DataTable
customStyles={customStyles}
className="cipp-table"
Expand Down
Loading

0 comments on commit 1218013

Please sign in to comment.