-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- make cluster selection by default in environmnet and integrated service creation - Resolve cluster offline status of all resource even cluster is online
- Loading branch information
1 parent
d7ccbf9
commit 49f55c8
Showing
11 changed files
with
232 additions
and
209 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { useCallback, useEffect, useState } from 'react'; | ||
import { useConsoleApi } from '../server/gql/api-provider'; | ||
import { parseNodes } from '../server/r-utils/common'; | ||
|
||
const findClusterStatus = (item?: { lastOnlineAt?: string }): boolean => { | ||
if (!item || !item.lastOnlineAt) { | ||
return false; | ||
} | ||
|
||
const lastTime = new Date(item.lastOnlineAt); | ||
const currentTime = new Date(); | ||
|
||
const timeDifference = | ||
(currentTime.getTime() - lastTime.getTime()) / (1000 * 60); | ||
|
||
console.log(timeDifference); | ||
|
||
switch (true) { | ||
case timeDifference <= 2: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
}; | ||
|
||
const useClusterStatus = () => { | ||
const api = useConsoleApi(); | ||
|
||
const [clusters, setClusters] = useState<any[]>([]); | ||
|
||
const listCluster = useCallback(async () => { | ||
try { | ||
const clusters = await api.listAllClusters(); | ||
setClusters(parseNodes(clusters.data) || []); | ||
return clusters; | ||
} catch (err) { | ||
console.error(err); | ||
return false; | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
listCluster(); | ||
}, []); | ||
|
||
return { findClusterStatus, clusters }; | ||
}; | ||
|
||
export default useClusterStatus; |
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
Oops, something went wrong.