Skip to content

Commit 4008058

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into dev
2 parents 84c4154 + b989aa8 commit 4008058

File tree

4 files changed

+123
-21
lines changed

4 files changed

+123
-21
lines changed

public/version_latest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.8.0
1+
4.0.0

src/scss/_themes.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@
408408
--cui-color-orange: #f77f00;
409409
--cui-color-table-border: rgba(146, 154, 158, 0.8);
410410
--cui-color-card-shadow: rgba(207, 192, 192, 0.2);
411-
411+
--text-medium-emphasis: rgba(255, 255, 255, 0.6);
412412
// Core UI Impact theme variables.
413413
--cui-header-hover-color: var(--cyberdrain-light);
414414
--cui-header-active-color: var(--cyberdrain-accent-blue);
@@ -519,7 +519,9 @@
519519
overflow: hidden;
520520
z-index: 1; /* Necessary for overflow: hidden to work correctly in Safari */
521521
}
522-
522+
.text-medium-emphasis {
523+
color: var(--text-medium-emphasis) !important;
524+
}
523525
.react-loading-skeleton::after {
524526
content: ' ';
525527
display: var(--pseudo-element-display);

src/views/tenant/standards/BestPracticeAnalyser.js

Lines changed: 117 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import React, { useEffect, useState } from 'react'
22
import {
3+
CBadge,
34
CButton,
45
CCard,
56
CCardBody,
67
CCardHeader,
8+
CCardText,
79
CCardTitle,
810
CCol,
911
CCollapse,
@@ -21,6 +23,9 @@ import {
2123
faSearch,
2224
faExclamationTriangle,
2325
faCheck,
26+
faCross,
27+
faTimes,
28+
faExclamation,
2429
} from '@fortawesome/free-solid-svg-icons'
2530
import { CippTable, cellBooleanFormatter } from 'src/components/tables'
2631
import { useSelector } from 'react-redux'
@@ -58,6 +63,37 @@ const RefreshAction = () => {
5863
</CButton>
5964
)
6065
}
66+
67+
const getsubcolumns = (data) => {
68+
const flatObj = data && data.length > 0 ? data : [{ data: 'No Data Found' }]
69+
const QueryColumns = []
70+
if (flatObj[0]) {
71+
Object.keys(flatObj[0]).map((key) => {
72+
QueryColumns.push({
73+
name: key,
74+
selector: (row) => row[key], // Accessing the property using the key
75+
sortable: true,
76+
exportSelector: key,
77+
cell: cellGenericFormatter(),
78+
})
79+
})
80+
}
81+
return QueryColumns
82+
}
83+
const getNestedValue = (obj, path) => {
84+
if (!path) return undefined
85+
return path.split('.').reduce((acc, part) => {
86+
// Check for an array marker
87+
const match = part.match(/(.*?)\[(\d+)\]/)
88+
if (match) {
89+
const propName = match[1]
90+
const index = parseInt(match[2], 10)
91+
return acc[propName] ? acc[propName][index] : undefined
92+
}
93+
// If no array marker, simply return the property value
94+
return acc ? acc[part] : undefined
95+
}, obj)
96+
}
6197
const BestPracticeAnalyser = () => {
6298
const { data: templates = [], isLoading: templatesfetch } = useGenericGetRequestQuery({
6399
path: 'api/listBPATemplates',
@@ -73,6 +109,7 @@ const BestPracticeAnalyser = () => {
73109
const shippedValues = {
74110
SearchNow: true,
75111
Report: values.reportTemplate,
112+
tenantFilter: tenant.customerId,
76113
random: (Math.random() + 1).toString(36).substring(7),
77114
}
78115
var queryString = Object.keys(shippedValues)
@@ -99,21 +136,6 @@ const BestPracticeAnalyser = () => {
99136
if (graphrequest.data.length === 0) {
100137
graphrequest.data = [{ data: 'No Data Found' }]
101138
}
102-
103-
const getNestedValue = (obj, path) => {
104-
if (!path) return undefined
105-
return path.split('.').reduce((acc, part) => {
106-
// Check for an array marker
107-
const match = part.match(/(.*?)\[(\d+)\]/)
108-
if (match) {
109-
const propName = match[1]
110-
const index = parseInt(match[2], 10)
111-
return acc[propName] ? acc[propName][index] : undefined
112-
}
113-
// If no array marker, simply return the property value
114-
return acc ? acc[part] : undefined
115-
}, obj)
116-
}
117139
const flatObj = graphrequest.data.Columns ? graphrequest.data.Columns : []
118140

119141
flatObj.map((col) => {
@@ -157,7 +179,7 @@ const BestPracticeAnalyser = () => {
157179
execGraphRequest({
158180
path: 'api/listBPA',
159181
params: {
160-
tenantFilter: tenant.defaultDomainName,
182+
tenantFilter: tenant.customerId,
161183
Report: Report,
162184
SearchNow: SearchNow,
163185
},
@@ -226,13 +248,14 @@ const BestPracticeAnalyser = () => {
226248
<CippPage title="Report Results" tenantSelector={false}>
227249
{graphrequest.isUninitialized && <span>Choose a BPA Report to get started.</span>}
228250
{graphrequest.isFetching && <CSpinner />}
229-
{graphrequest.isSuccess && QueryColumns.set && (
251+
{graphrequest.isSuccess && QueryColumns.set && graphrequest.data.Style == 'Table' && (
230252
<CCard className="content-card">
231253
<CCardHeader className="d-flex justify-content-between align-items-center">
232254
<CCardTitle>Best Practice Report</CCardTitle>
233255
</CCardHeader>
234256
<CCardBody>
235257
<CippTable
258+
key={QueryColumns.data}
236259
reportName="BestPracticeAnalyser"
237260
dynamicColumns={false}
238261
columns={QueryColumns.data}
@@ -245,6 +268,83 @@ const BestPracticeAnalyser = () => {
245268
</CCardBody>
246269
</CCard>
247270
)}
271+
{graphrequest.isSuccess && QueryColumns.set && graphrequest.data.Style == 'Tenant' && (
272+
<>
273+
<CRow>
274+
{graphrequest.data.Columns.map((info, idx) => (
275+
<CCol sm={10} md={4} className="mb-3">
276+
<CCard className="h-100">
277+
<CCardHeader>
278+
<CCardTitle>{info.name}</CCardTitle>
279+
</CCardHeader>
280+
<CCardBody>
281+
<CCardText>
282+
{info.formatter === 'bool' && (
283+
<CBadge
284+
color={graphrequest.data.Data[info.value] ? 'info' : 'danger'}
285+
>
286+
<FontAwesomeIcon
287+
icon={graphrequest.data.Data[info.value] ? faCheck : faTimes}
288+
size="lg"
289+
className="me-1"
290+
/>
291+
{graphrequest.data.Data[info.value] ? 'Yes' : 'No'}
292+
</CBadge>
293+
)}
294+
{info.formatter === 'reverseBool' && (
295+
<CBadge
296+
color={graphrequest.data.Data[info.value] ? 'danger' : 'info'}
297+
>
298+
<FontAwesomeIcon
299+
icon={graphrequest.data.Data[info.value] ? faTimes : faCheck}
300+
size="lg"
301+
className="me-1"
302+
/>
303+
{graphrequest.data.Data[info.value] ? 'No' : 'Yes'}
304+
</CBadge>
305+
)}
306+
{info.formatter === 'warnBool' && (
307+
<CBadge
308+
color={graphrequest.data.Data[info.value] ? 'info' : 'warning'}
309+
>
310+
<FontAwesomeIcon
311+
icon={
312+
graphrequest.data.Data[info.value] ? faCheck : faExclamation
313+
}
314+
size="lg"
315+
className="me-1"
316+
/>
317+
{graphrequest.data.Data[info.value] ? 'Yes' : 'No'}
318+
</CBadge>
319+
)}
320+
321+
{info.formatter === 'table' && (
322+
<CippTable
323+
key={QueryColumns.data}
324+
reportName="BestPracticeAnalyser"
325+
dynamicColumns={false}
326+
columns={getsubcolumns(graphrequest.data.Data[info.value])}
327+
data={graphrequest.data.Data[info.value]}
328+
isFetching={graphrequest.isFetching}
329+
/>
330+
)}
331+
332+
{info.formatter === 'number' && (
333+
<p class="fs-1 text-center">
334+
{getNestedValue(graphrequest.data.Data, info.value)}
335+
</p>
336+
)}
337+
</CCardText>
338+
<CCardText>
339+
<small className="text-medium-emphasis">{info.desc}</small>
340+
</CCardText>
341+
</CCardBody>
342+
</CCard>
343+
</CCol>
344+
))}
345+
</CRow>
346+
</>
347+
)}
248348
</CippPage>
249349
</CCol>
250350
</CRow>

version_latest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.8.0
1+
4.0.0

0 commit comments

Comments
 (0)