Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recent Jobs and Tenant Onboarding #2356

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading