-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: klusterlet and dashboard fixes
Signed-off-by: Ilan Pinto <[email protected]>
- Loading branch information
1 parent
4ef114e
commit daac146
Showing
9 changed files
with
167 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { useState, useEffect, useRef} from 'react'; | ||
import { OcmResource } from '../../../src/data/loader' | ||
import { kubeImage } from '../common/common'; | ||
|
||
|
||
|
||
import { Spinner } from '@patternfly/react-core'; | ||
import ShowSubscriptionStatuses from '../comp/SubscriptionStatuses'; | ||
import ShowAppliedManifestWorks from '../comp/AppliedManifestWorks'; | ||
import ShowKlusterlets from '../comp/Klusterlets'; | ||
|
||
export default function ManagedClusterPage(){ | ||
let [kubeImages, setKubeImages] = useState<kubeImage[]>([]); | ||
|
||
|
||
let dataRequests = useRef(0); | ||
let klusterletRef = useRef<OcmResource[]>([]); | ||
|
||
let appliedManifestWorkRef = useRef<OcmResource[]>([]); | ||
let managedClusterSetsRef = useRef<OcmResource[]>([]); | ||
let kubeImagesRef = useRef<kubeImage[]>([]); | ||
|
||
useEffect(() => { | ||
dataRequests.current += 1 | ||
|
||
window.addEventListener("message", event => { | ||
if ('crsDistribution' in event.data.msg) { | ||
dataRequests.current += 1 | ||
let crsData = JSON.parse(event.data.msg.crsDistribution.crs) | ||
switch (event.data.msg.crsDistribution.kind) { | ||
case 'Klusterlet' : | ||
klusterletRef.current = crsData; | ||
break; | ||
case 'AppliedManifestWork': | ||
if (appliedManifestWorkRef.current.length !== crsData.length) { | ||
appliedManifestWorkRef.current = crsData; | ||
} | ||
break; | ||
case 'ManagedClusterSet': | ||
if (managedClusterSetsRef.current.length !== crsData.length) { | ||
managedClusterSetsRef.current = crsData ; | ||
} | ||
break; | ||
|
||
} | ||
|
||
if (event.data.images) { | ||
if (event.data.images) { | ||
//TODO move this logic to Graph | ||
kubeImagesRef.current = event.data.images | ||
//setting the image state re-renders the component | ||
setKubeImages(kubeImagesRef.current) | ||
} | ||
} | ||
} | ||
}); | ||
|
||
|
||
},[kubeImages]); | ||
|
||
if(dataRequests.current > 1 ){ | ||
return (<> | ||
<ShowKlusterlets klusterlets={klusterletRef.current} /> | ||
<ShowAppliedManifestWorks appliedManifestWorks={appliedManifestWorkRef.current} kubeImages={kubeImagesRef.current} /> | ||
{/* <ShowSubscriptionStatuses/> */} | ||
|
||
</> | ||
) | ||
} | ||
|
||
|
||
else { | ||
return ( <Spinner isSVG size='xl'/> | ||
) | ||
} | ||
|
||
} |