-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show live CPU and memory usage of user session backend (#414)
- Loading branch information
1 parent
3af6571
commit d643050
Showing
3 changed files
with
36 additions
and
23 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
23 changes: 23 additions & 0 deletions
23
frontend/src/framework/internal/components/NavBar/private-components/UserSessionState.tsx
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,23 @@ | ||
import { Memory } from "@mui/icons-material"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
|
||
import { apiService } from "@framework/ApiService"; | ||
|
||
const useUserSessionState = () => useQuery({ | ||
queryKey: ["default.userSessionContainer"], | ||
queryFn: () => apiService.default.userSessionContainer(), | ||
refetchInterval: 2000 | ||
}); | ||
|
||
export const UserSessionState = ({expanded}: {expanded: boolean}) => { | ||
|
||
const sessionState = useUserSessionState(); | ||
|
||
const memoryPercent = Math.round(sessionState.data?.memorySystem?.percent) || "-" | ||
const cpuPercent = Math.round(sessionState.data?.cpuPercent) || "-" | ||
|
||
return <div className="text-xs whitespace-nowrap text-gray-400"> | ||
<div><Memory fontSize="small" /> {expanded ? "Memory:" : "M"} {memoryPercent} %</div> | ||
<div><Memory fontSize="small" /> {expanded ? "CPU:" : "C"} {cpuPercent} %</div> | ||
</div> | ||
} |