Skip to content

Commit

Permalink
Merge pull request #56 from KelvinTegelaar/dev
Browse files Browse the repository at this point in the history
[pull] dev from KelvinTegelaar:dev
  • Loading branch information
kris6673 authored Jul 12, 2024
2 parents 66a298d + 0db3e2e commit 81ca69e
Show file tree
Hide file tree
Showing 15 changed files with 197 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cipp",
"version": "5.9.3",
"version": "6.0.2",
"description": "The CyberDrain Improved Partner Portal is a portal to help manage administration for Microsoft Partners.",
"homepage": "https://cipp.app/",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion public/version_latest.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.9.3
6.0.2
5 changes: 5 additions & 0 deletions src/_nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,11 @@ const _nav = [
name: 'Extensions Settings',
to: '/cipp/extensions',
},
{
component: CNavItem,
name: 'Extension Sync',
to: '/cipp/extension-sync',
},
{
component: CNavItem,
name: 'User Settings',
Expand Down
24 changes: 24 additions & 0 deletions src/components/tables/CellBytes.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import PropTypes from 'prop-types'

export function CellBytes({ cell }) {
return (cell / 1024 ** 3).toFixed(2)
}

CellBytes.propTypes = {
propName: PropTypes.string,
cell: PropTypes.object,
}

export function CellBytesToPercentage({ row, value, dividedBy }) {
return Math.round((row[value] / row[dividedBy]) * 100 * 10) / 10
}

CellBytesToPercentage.propTypes = {
propName: PropTypes.string,
cell: PropTypes.object,
}

export const cellBytesFormatter = () => (row, index, column, id) => {
const cell = column.selector(row)
return CellBytes({ cell })
}
2 changes: 0 additions & 2 deletions src/components/tables/CellCopyButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import PropTypes from 'prop-types'
import CippCopyToClipboard from '../utilities/CippCopyToClipboard'

export function CellCopyButton({ cell }) {
console.log('hi! cell:', cell)
return <CippCopyToClipboard text={cell} />
}

Expand All @@ -13,6 +12,5 @@ CellCopyButton.propTypes = {

export const cellCopyButtonFormatter = () => (row, index, column, id) => {
const cell = column.selector(row)
console.log('cell:', cell)
return CellCopyButton({ cell })
}
12 changes: 7 additions & 5 deletions src/components/tables/CippTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -629,12 +629,14 @@ export default function CippTable({
if (!disablePDFExport || !disableCSVExport) {
const keys = []
const exportFormatter = {}
const exportFormatterArgs = {}
columns.map((col) => {
if (col.exportSelector) keys.push(col.exportSelector)
if (col.exportFormatter) exportFormatter[col.exportSelector] = col.exportFormatter
if (col.exportFormatterArgs)
exportFormatterArgs[col.exportSelector] = col.exportFormatterArgs
return null
})

// Define the flatten function
const flatten = (obj, prefix = '') => {
if (obj === null) return {}
Expand Down Expand Up @@ -664,18 +666,18 @@ export default function CippTable({
// Define the applyFormatter function
const applyFormatter = (obj) => {
return Object.keys(obj).reduce((acc, key) => {
const formatterArgs = exportFormatterArgs[key]
const formatter = exportFormatter[key]
// Since the keys after flattening will be dot-separated, we need to adjust this to support nested keys if necessary.
const keyParts = key.split('.')
const finalKeyPart = keyParts[keyParts.length - 1]
const formattedValue =
typeof formatter === 'function' ? formatter({ cell: obj[key] }) : obj[key]
typeof formatter === 'function'
? formatter({ row: obj, cell: obj[key], ...formatterArgs })
: obj[key]
acc[key] = formattedValue
return acc
}, {})
}

// Process exportData function
const processExportData = (exportData, selectedColumns) => {
//filter out the columns that are not selected via selectedColumns
exportData = exportData.map((item) => {
Expand Down
1 change: 1 addition & 0 deletions src/importsMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ import React from 'react'
"/license": React.lazy(() => import('./views/pages/license/License')),
"/cipp/settings": React.lazy(() => import('./views/cipp/app-settings/CIPPSettings')),
"/cipp/extensions": React.lazy(() => import('./views/cipp/Extensions')),
"/cipp/extension-sync": React.lazy(() => import('./views/cipp/ExtensionSync')),
"/cipp/setup": React.lazy(() => import('./views/cipp/Setup')),
"/tenant/administration/securescore": React.lazy(() => import('./views/tenant/administration/SecureScore')),
"/tenant/administration/gdap": React.lazy(() => import('./views/tenant/administration/GDAPWizard')),
Expand Down
6 changes: 6 additions & 0 deletions src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,12 @@
"component": "views/cipp/Extensions",
"allowedRoles": ["admin"]
},
{
"path": "/cipp/extension-sync",
"name": "Extension Sync",
"component": "views/cipp/ExtensionSync",
"allowedRoles": ["admin"]
},
{
"path": "/cipp/setup",
"name": "Setup",
Expand Down
16 changes: 4 additions & 12 deletions src/views/cipp/ExtensionMappings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,7 @@ export default function ExtensionMappings({ type, fieldMappings = false, autoMap
name: tenant.displayName,
value: tenant.customerId,
}))}
onChange={(e) => {
setMappingArray(e.value)
}}
onChange={(e) => setTenantMappingsArray(e.value)}
isLoading={listMappingBackendResult.isFetching}
/>
</CCol>
Expand All @@ -238,16 +236,10 @@ export default function ExtensionMappings({ type, fieldMappings = false, autoMap
<CCol xs="5">
<RFFSelectSearch
name="companyId"
values={listMappingBackendResult.data?.Companies.filter((client) => {
return !Object.values(listMappingBackendResult.data?.Mappings)
.map((value) => {
return value.value
})
.includes(client.value.toString())
}).map((client) => ({
values={listMappingBackendResult.data?.Companies.map((client) => ({
name: client.name,
value: client.value,
}))}
})).sort((a, b) => a.name.localeCompare(b.name))}
onChange={(e) => setMappingValue(e)}
placeholder={`Select a ${type} Organization`}
isLoading={listMappingBackendResult.isFetching}
Expand All @@ -267,7 +259,7 @@ export default function ExtensionMappings({ type, fieldMappings = false, autoMap
...mappingArray,
{
Tenant: listMappingBackendResult.data?.Tenants.find(
(tenant) => tenant.customerId === mappingArray,
(tenant) => tenant.customerId === tenantMappingArray,
),
companyName: mappingValue.label,
companyId: mappingValue.value,
Expand Down
97 changes: 97 additions & 0 deletions src/views/cipp/ExtensionSync.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import React, { useState } from 'react'
import { CCol, CRow } from '@coreui/react'
import { useSelector } from 'react-redux'

import { useLazyGenericGetRequestQuery, useLazyGenericPostRequestQuery } from 'src/store/api/app'

import { CippPage, CippPageList } from 'src/components/layout'
import { CellTip, cellGenericFormatter } from 'src/components/tables/CellGenericFormat'
import 'react-datepicker/dist/react-datepicker.css'
import { CellBadge, cellBadgeFormatter, cellDateFormatter } from 'src/components/tables'
import { TitleButton } from 'src/components/buttons'

const ExtensionSync = () => {
const [ExecuteGetRequest, getResults] = useLazyGenericGetRequestQuery()
const tenantDomain = useSelector((state) => state.app.currentTenant.defaultDomainName)
const [refreshState, setRefreshState] = useState(false)
const [genericPostRequest, postResults] = useLazyGenericPostRequestQuery()

const columns = [
{
name: 'Tenant',
selector: (row) => row['Tenant'],
sortable: true,
cell: cellGenericFormatter(),
exportSelector: 'Tenants',
},
{
name: 'Sync Type',
selector: (row) => row['SyncType'],
sortable: true,
cell: cellBadgeFormatter({ color: 'info' }),
exportSelector: 'SyncType',
},
{
name: 'Task',
selector: (row) => row['Name'],
sortable: true,
cell: cellGenericFormatter(),
exportSelector: 'Name',
},
{
name: 'Scheduled Time',
selector: (row) => row['ScheduledTime'],
sortable: true,
cell: cellDateFormatter({ format: 'short' }),
exportSelector: 'ScheduledTime',
},
{
name: 'Last Run',
selector: (row) => row['ExecutedTime'],
sortable: true,
cell: cellDateFormatter({ format: 'short' }),
exportSelector: 'ExecutedTime',
},
{
name: 'Repeats every',
selector: (row) => row['RepeatsEvery'],
sortable: true,
cell: (row) => CellTip(row['RepeatsEvery']),
exportSelector: 'RepeatsEvery',
},
{
name: 'Results',
selector: (row) => row['Results'],
sortable: true,
cell: cellGenericFormatter(),
exportSelector: 'Results',
},
]

return (
<CippPage title={`Extension Sync`} tenantSelector={false}>
<>
<CRow>
<CCol>
<CippPageList
key={refreshState}
capabilities={{
allTenants: true,
helpContext: 'https://google.com',
}}
title="Extension Sync"
tenantSelector={false}
datatable={{
columns,
reportName: `Extension Sync Report`,
path: `/api/ListExtensionSync`,
}}
/>
</CCol>
</CRow>
</>
</CippPage>
)
}

export default ExtensionSync
6 changes: 6 additions & 0 deletions src/views/cipp/Extensions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default function CIPPExtensions() {
path: 'api/ExecExtensionSync?Extension=' + integrationType,
})
}
disabled={disabled}
className="me-2"
>
<FontAwesomeIcon
Expand Down Expand Up @@ -198,6 +199,11 @@ export default function CIPPExtensions() {
)}
</CippCallout>
)}
{listSyncExtensionResult?.data?.Results && (
<CippCallout color={listSyncExtensionResult.isSuccess ? 'success' : 'danger'}>
{listSyncExtensionResult?.data?.Results}
</CippCallout>
)}
</CippButtonCard>
</CCol>
{integration.mappingRequired && (
Expand Down
22 changes: 18 additions & 4 deletions src/views/email-exchange/reports/MailboxStatisticsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import React, { useEffect, useState } from 'react'
import { useSelector } from 'react-redux'
import { CellTip, cellBooleanFormatter } from 'src/components/tables'
import { CippPageList } from 'src/components/layout'
import {
CellBytes,
CellBytesToPercentage,
cellBytesFormatter,
} from 'src/components/tables/CellBytes'

const MailboxStatsList = () => {
const [tenantColumnSet, setTenantColumn] = useState(true)
Expand Down Expand Up @@ -64,23 +69,32 @@ const MailboxStatsList = () => {
exportSelector: 'lastActivityDate',
},
{
selector: (row) => (row['storageUsedInBytes'] / 1024 ** 3).toFixed(2),
selector: (row) => row['storageUsedInBytes'],
cell: cellBytesFormatter(),
name: 'Used Space (GB)',
sortable: true,
exportSelector: 'storageUsedInBytes',
exportFormatter: CellBytes,
},
{
selector: (row) => (row['prohibitSendReceiveQuotaInBytes'] / 1024 ** 3).toFixed(2),
selector: (row) => row['prohibitSendReceiveQuotaInBytes'],
cell: cellBytesFormatter(),
name: 'Quota (GB)',
sortable: true,
exportSelector: 'QuotaGB',
exportSelector: 'prohibitSendReceiveQuotaInBytes',
exportFormatter: CellBytes,
},
{
selector: (row) =>
Math.round((row.storageUsedInBytes / row.prohibitSendReceiveQuotaInBytes) * 100 * 10) / 10,
name: 'Quota Used(%)',
sortable: true,
exportSelector: 'QuotaUsed',
exportSelector: 'CippStatus',
exportFormatter: CellBytesToPercentage,
exportFormatterArgs: {
value: 'storageUsedInBytes',
dividedBy: 'prohibitSendReceiveQuotaInBytes',
},
},
{
selector: (row) => row['itemCount'],
Expand Down
2 changes: 1 addition & 1 deletion src/views/home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ const TenantDashboard = () => {
{organization.verifiedDomains?.slice(0, 3).map((item, idx) => (
<li key={idx}>{item.name}</li>
))}
{organization.verifiedDomains?.length > 5 && (
{organization.verifiedDomains?.length > 3 && (
<>
<CCollapse visible={domainVisible}>
{organization.verifiedDomains?.slice(3).map((item, idx) => (
Expand Down
Loading

0 comments on commit 81ca69e

Please sign in to comment.