Skip to content

Commit ed53d22

Browse files
authored
Merge pull request #2215 from JohnDuprey/dev
UI tweaks
2 parents 890c800 + bef8ab3 commit ed53d22

File tree

2 files changed

+82
-4
lines changed

2 files changed

+82
-4
lines changed

src/components/layout/AppHeader.jsx

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,19 @@ import {
1313
CSidebarBrand,
1414
CButton,
1515
CFormSwitch,
16+
CLink,
1617
} from '@coreui/react'
1718
import { AppHeaderSearch } from 'src/components/header'
18-
import { TenantSelector } from '../utilities'
19+
import { CippActionsOffcanvas, TenantSelector } from '../utilities'
1920
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
2021
import { faBars } from '@fortawesome/free-solid-svg-icons'
2122
import { setCurrentTheme, setUserSettings, toggleSidebarShow } from 'src/store/features/app'
2223
import { useMediaPredicate } from 'react-media-hook'
23-
import { useGenericGetRequestQuery, useLoadAlertsDashQuery } from 'src/store/api/app'
24+
import {
25+
useGenericGetRequestQuery,
26+
useLazyGenericGetRequestQuery,
27+
useLoadAlertsDashQuery,
28+
} from 'src/store/api/app'
2429
import { useLocation } from 'react-router-dom'
2530

2631
const AppHeader = () => {
@@ -31,6 +36,11 @@ const AppHeader = () => {
3136
const sidebarShow = useSelector((state) => state.app.sidebarShow)
3237
const currentTheme = useSelector((state) => state.app.currentTheme)
3338
const preferredTheme = useMediaPredicate('(prefers-color-scheme: dark)') ? 'impact' : 'cyberdrain'
39+
const [cippQueueExtendedInfo, setCippQueueExtendedInfo] = useState([])
40+
const [cippQueueVisible, setCippQueueVisible] = useState(false)
41+
const [cippQueueRefresh, setCippQueueRefresh] = useState(
42+
(Math.random() + 1).toString(36).substring(7),
43+
)
3444
const { data: dashboard } = useLoadAlertsDashQuery()
3545
const {
3646
data: userSettings,
@@ -54,6 +64,49 @@ const AppHeader = () => {
5464
userSettings,
5565
])
5666

67+
const [getCippQueueList, cippQueueList] = useLazyGenericGetRequestQuery()
68+
69+
function loadCippQueue() {
70+
setCippQueueVisible(true)
71+
getCippQueueList({ path: 'api/ListCippQueue', params: { refresh: cippQueueRefresh } })
72+
}
73+
74+
function refreshCippQueue() {
75+
setCippQueueRefresh((Math.random() + 1).toString(36).substring(7))
76+
loadCippQueue()
77+
}
78+
79+
useEffect(() => {
80+
if (cippQueueList.isFetching || cippQueueList.isLoading) {
81+
setCippQueueExtendedInfo([
82+
{
83+
label: 'Fetching recent jobs',
84+
value: 'Please wait',
85+
timestamp: Date(),
86+
link: '#',
87+
},
88+
])
89+
}
90+
if (
91+
cippQueueList.isSuccess &&
92+
Array.isArray(cippQueueList.data) &&
93+
cippQueueList.data.length > 0
94+
) {
95+
setCippQueueExtendedInfo(
96+
cippQueueList.data?.map((job) => ({
97+
label: `${job.Name}`,
98+
value: job.Status,
99+
link: job.Link,
100+
timestamp: job.Timestamp,
101+
})),
102+
)
103+
} else {
104+
setCippQueueExtendedInfo([
105+
{ label: 'No jobs to display', value: '', timpestamp: Date(), link: '#' },
106+
])
107+
}
108+
}, [cippQueueList])
109+
57110
const SwitchTheme = () => {
58111
let targetTheme = preferredTheme
59112
if (isDark) {
@@ -97,6 +150,11 @@ const AppHeader = () => {
97150
<CNavItem>
98151
<AppHeaderSearch />
99152
</CNavItem>
153+
<CNavItem>
154+
<CButton variant="ghost" onClick={() => loadCippQueue()}>
155+
<FontAwesomeIcon icon={'history'} className="me-2" />
156+
</CButton>
157+
</CNavItem>
100158
<CNavItem>
101159
<div className="custom-switch-wrapper primary">
102160
<CFormSwitch
@@ -134,6 +192,26 @@ const AppHeader = () => {
134192
</div>
135193
))}
136194
</div>
195+
<CippActionsOffcanvas
196+
title="Recent Jobs"
197+
extendedInfo={[]}
198+
cards={cippQueueExtendedInfo}
199+
refreshFunction={refreshCippQueue}
200+
actions={[
201+
{
202+
label: 'Clear History',
203+
color: 'info',
204+
modal: true,
205+
modalUrl: `/api/RemoveCippQueue`,
206+
modalMessage: 'Are you sure you want clear the history?',
207+
icon: <FontAwesomeIcon icon="trash" className="me-2" />,
208+
},
209+
]}
210+
placement="end"
211+
visible={cippQueueVisible}
212+
id="cipp-queue"
213+
hideFunction={() => setCippQueueVisible(false)}
214+
/>
137215
</>
138216
)
139217
}

src/views/tenant/administration/AlertRules.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ const AlertRules = () => {
375375
}
376376

377377
return (
378-
<CippPage title={`Add Schedule`} tenantSelector={false}>
378+
<CippPage title={`Add Rule`} tenantSelector={false}>
379379
<>
380380
<CRow>
381381
<CCol md={4}>
@@ -480,7 +480,7 @@ const AlertRules = () => {
480480
<CRow className="mb-3">
481481
<CCol md={6}>
482482
<CButton type="submit" disabled={submitting}>
483-
Add Schedule
483+
Add Rule
484484
{postResults.isFetching && (
485485
<FontAwesomeIcon
486486
icon={faCircleNotch}

0 commit comments

Comments
 (0)