Skip to content

Commit

Permalink
Merge pull request #2356 from JohnDuprey/dev
Browse files Browse the repository at this point in the history
Recent Jobs and Tenant Onboarding
  • Loading branch information
JohnDuprey authored Apr 23, 2024
2 parents b8fd9bf + abbddb8 commit f359a3c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 28 deletions.
77 changes: 55 additions & 22 deletions src/components/layout/AppHeader.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react'
import React, { useState, useEffect, useRef } from 'react'
import { useSelector, useDispatch } from 'react-redux'
import {
CAlert,
Expand Down Expand Up @@ -72,8 +72,29 @@ const AppHeader = () => {
loadCippQueue()
}

function useInterval(callback, delay, state) {
const savedCallback = useRef()

// Remember the latest callback.
useEffect(() => {
savedCallback.current = callback
})

// Set up the interval.
useEffect(() => {
function tick() {
savedCallback.current()
}

if (delay !== null) {
let id = setInterval(tick, delay)
return () => clearInterval(id)
}
}, [delay, state])
}

useEffect(() => {
if (cippQueueList.isFetching || cippQueueList.isLoading) {
if (cippQueueList.isUninitialized && (cippQueueList.isFetching || cippQueueList.isLoading)) {
setCippQueueExtendedInfo([
{
label: 'Fetching recent jobs',
Expand All @@ -82,28 +103,40 @@ const AppHeader = () => {
link: '#',
},
])
}
if (
cippQueueList.isSuccess &&
Array.isArray(cippQueueList.data) &&
cippQueueList.data.length > 0
) {
setCippQueueExtendedInfo(
cippQueueList.data?.map((job) => ({
label: `${job.Name}`,
value: job.Status,
link: job.Link,
timestamp: job.Timestamp,
percent: job.PercentComplete,
progressText: `${job.PercentComplete}%`,
})),
)
} else {
setCippQueueExtendedInfo([
{ label: 'No jobs to display', value: '', timestamp: Date(), link: '#' },
])
if (
cippQueueList.isSuccess &&
Array.isArray(cippQueueList.data) &&
cippQueueList.data.length > 0
) {
setCippQueueExtendedInfo(
cippQueueList.data?.map((job) => ({
label: `${job.Name}`,
value: job.Status,
link: job.Link,
timestamp: job.Timestamp,
percent: job.PercentComplete,
progressText: `${job.PercentComplete}%`,
})),
)
} else {
setCippQueueExtendedInfo([
{ label: 'No jobs to display', value: '', timestamp: Date(), link: '#' },
])
}
}
}, [cippQueueList])
}, [cippQueueList, setCippQueueExtendedInfo])

useInterval(
async () => {
if (cippQueueVisible) {
setCippQueueRefresh((Math.random() + 1).toString(36).substring(7))
getCippQueueList({ path: 'api/ListCippQueue', params: { refresh: cippQueueRefresh } })
}
},
5000,
cippQueueVisible,
)

const SwitchTheme = () => {
let targetTheme = preferredTheme
Expand Down
2 changes: 1 addition & 1 deletion src/components/utilities/CippActionsOffcanvas.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export default function CippActionsOffcanvas(props) {
</CCardBody>
<CCardFooter className="text-end">
<CRow>
{action.percent && (
{action?.percent > 0 && (
<CCol xs="8">
<div className="mt-1">
<CProgress>
Expand Down
10 changes: 5 additions & 5 deletions src/views/tenant/administration/TenantOnboardingWizard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,14 @@ const TenantOnboardingWizard = () => {
reportName="Add-GDAP-Relationship"
keyField="id"
path="/api/ListGraphRequest"
params={{ Endpoint: 'tenantRelationships/delegatedAdminRelationships' }}
params={{
Endpoint: 'tenantRelationships/delegatedAdminRelationships',
$filter:
"(status eq 'active' or status eq 'approvalPending') and not startsWith(displayName,'MLT_')",
}}
columns={columns}
filterlist={[
{ filterName: 'Active Relationships', filter: 'Complex: status eq active' },
{
filterName: 'Terminated Relationships',
filter: 'Complex: status eq terminated',
},
{
filterName: 'Pending Relationships',
filter: 'Complex: status eq approvalPending',
Expand Down

0 comments on commit f359a3c

Please sign in to comment.