Skip to content

Commit 30a5344

Browse files
Merge pull request #2153 from KelvinTegelaar/dev
Dev to release
2 parents 9d1698e + 129d3a7 commit 30a5344

File tree

24 files changed

+719
-114
lines changed

24 files changed

+719
-114
lines changed

public/version_latest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.1.1
1+
5.2.0

src/_nav.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ const _nav = [
5050
name: 'Groups',
5151
to: '/identity/administration/groups',
5252
},
53+
{
54+
component: CNavItem,
55+
name: 'Devices',
56+
to: '/identity/administration/devices',
57+
},
5358
{
5459
component: CNavItem,
5560
name: 'Deploy Group Template',
@@ -737,6 +742,11 @@ const _nav = [
737742
name: 'Logbook',
738743
to: '/cipp/logs',
739744
},
745+
{
746+
component: CNavItem,
747+
name: 'Statistics',
748+
to: '/cipp/statistics',
749+
},
740750
{
741751
component: CNavItem,
742752
name: 'SAM Setup Wizard',

src/components/tables/CippTable.jsx

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,14 +389,43 @@ export default function CippTable({
389389
}
390390
const newModalBody = {}
391391
for (let [objName, objValue] of Object.entries(modalBody)) {
392-
if (objValue.toString().startsWith('!')) {
392+
if (typeof objValue === 'object' && objValue !== null) {
393+
newModalBody[objName] = {}
394+
for (let [nestedObjName, nestedObjValue] of Object.entries(objValue)) {
395+
if (typeof nestedObjValue === 'string' && nestedObjValue.startsWith('!')) {
396+
newModalBody[objName][nestedObjName] = row[nestedObjValue.replace('!', '')]
397+
} else {
398+
newModalBody[objName][nestedObjName] = nestedObjValue
399+
}
400+
}
401+
} else if (typeof objValue === 'string' && objValue.startsWith('!')) {
393402
newModalBody[objName] = row[objValue.replace('!', '')]
403+
} else {
404+
newModalBody[objName] = objValue
394405
}
395406
}
396407
const NewModalUrl = `${modalUrl.split('?')[0]}?${urlParams.toString()}`
408+
const selectedValue = inputRef.current.value
409+
let additionalFields = {}
410+
if (inputRef.current.nodeName === 'SELECT') {
411+
const selectedItem = dropDownInfo.data.find(
412+
(item) => item[modalDropdown.valueField] === selectedValue,
413+
)
414+
if (selectedItem && modalDropdown.addedField) {
415+
Object.keys(modalDropdown.addedField).forEach((key) => {
416+
additionalFields[key] = selectedItem[modalDropdown.addedField[key]]
417+
})
418+
}
419+
}
420+
397421
const results = await genericPostRequest({
398422
path: NewModalUrl,
399-
values: { ...modalBody, ...newModalBody, ...{ input: inputRef.current.value } },
423+
values: {
424+
...modalBody,
425+
...newModalBody,
426+
...additionalFields,
427+
...{ input: inputRef.current.value },
428+
},
400429
})
401430
resultsarr.push(results)
402431
setMassResults(resultsarr)
@@ -466,6 +495,7 @@ export default function CippTable({
466495
}
467496

468497
const executeselectedAction = (item) => {
498+
console.log(item)
469499
setModalContent({
470500
item,
471501
})
@@ -556,6 +586,9 @@ export default function CippTable({
556586
let output = {}
557587
for (let k in obj) {
558588
let val = obj[k]
589+
if (val === null) {
590+
val = ''
591+
}
559592
const newKey = prefix ? prefix + '.' + k : k
560593
if (typeof val === 'object') {
561594
if (Array.isArray(val)) {

src/components/utilities/CippCodeOffcanvas.jsx

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import React, { useState } from 'react'
1+
import React, { useState, useEffect } from 'react'
22
import { CButton, CCallout, CCol, CRow, CSpinner } from '@coreui/react'
33
import { CippOffcanvas } from 'src/components/utilities'
44
import { useLazyGenericGetRequestQuery, useLazyGenericPostRequestQuery } from 'src/store/api/app'
55

66
import { Editor } from '@monaco-editor/react'
77
import { useSelector } from 'react-redux'
88
import PropTypes from 'prop-types'
9+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
10+
import CopyToClipboard from 'react-copy-to-clipboard'
911

1012
function CippCodeOffCanvas({
1113
row,
@@ -14,11 +16,13 @@ function CippCodeOffCanvas({
1416
type,
1517
title = 'Template JSON',
1618
hideButton = false,
19+
path = `/api/ExecEditTemplate?type=${type}`,
1720
}) {
1821
const [SaveTemplate, templateDetails] = useLazyGenericPostRequestQuery()
1922
const currentTheme = useSelector((state) => state.app.currentTheme)
2023
const [templateData, setFormData] = useState(row)
2124
const [invalidJSON, setInvalid] = useState(false)
25+
const [copied, setCopied] = useState(false)
2226

2327
function handleEditorChange(value, event) {
2428
try {
@@ -29,6 +33,10 @@ function CippCodeOffCanvas({
2933
}
3034
}
3135

36+
useEffect(() => {
37+
setCopied(false)
38+
}, [setCopied, templateData])
39+
3240
return (
3341
<>
3442
<CippOffcanvas
@@ -53,18 +61,32 @@ function CippCodeOffCanvas({
5361
<CRow className="mb-3">
5462
<CCol>
5563
{!hideButton && (
56-
<CButton
57-
disabled={invalidJSON}
58-
onClick={() =>
59-
SaveTemplate({
60-
path: `/api/ExecEditTemplate?type=${type}`,
61-
method: 'POST',
62-
values: templateData,
63-
})
64-
}
65-
>
66-
Save changes {templateDetails.isFetching && <CSpinner size="sm" />}
67-
</CButton>
64+
<>
65+
<CButton
66+
disabled={invalidJSON}
67+
onClick={() =>
68+
SaveTemplate({
69+
path: path,
70+
method: 'POST',
71+
values: templateData,
72+
})
73+
}
74+
className="me-2"
75+
>
76+
{templateDetails.isFetching ? (
77+
<CSpinner size="sm" className="me-2" />
78+
) : (
79+
<FontAwesomeIcon icon="save" className="me-2" />
80+
)}
81+
Save changes
82+
</CButton>
83+
<CopyToClipboard text={JSON.stringify(row, null, 2)} onCopy={() => setCopied(true)}>
84+
<CButton disabled={invalidJSON}>
85+
<FontAwesomeIcon icon={copied ? 'check' : 'clipboard'} className="me-2" /> Copy
86+
to Clipboard
87+
</CButton>
88+
</CopyToClipboard>
89+
</>
6890
)}
6991
</CCol>
7092
</CRow>
@@ -83,6 +105,7 @@ CippCodeOffCanvas.propTypes = {
83105
type: PropTypes.string,
84106
title: PropTypes.string,
85107
hideButton: PropTypes.bool,
108+
path: PropTypes.string,
86109
}
87110

88111
export default CippCodeOffCanvas

src/components/utilities/SharedModal.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function mapBodyComponent({ componentType, data, componentProps }) {
2929
}
3030

3131
const sharedProps = {
32-
componentType: PropTypes.oneOf(['table', 'list', 'text', 'confirm']),
32+
componentType: PropTypes.oneOf(['table', 'list', 'text', 'confirm', 'codeblock']),
3333
componentProps: PropTypes.object,
3434
body: PropTypes.oneOfType([PropTypes.node, PropTypes.element]),
3535
data: PropTypes.any,

0 commit comments

Comments
 (0)