|
- // import { useState } from 'react';
-
- // material-ui
- import {
- Grid,
- Typography,
- Stack,
- Paper,
- Box,
- CircularProgress,
- Button
- } from '@mui/material';
- import * as React from "react";
- import { GET_JVM_INFO } from "utils/ApiPathConst";
- import axios from "axios";
-
- import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
-
- const JVMDefault = () => {
- const [jvmInfo, setJvmInfo] = React.useState(null);
- const [loading, setLoading] = React.useState(true);
- const [error, setError] = React.useState(null);
-
- const fetchJvmInfo = () => {
- setLoading(true);
- setError(null);
- axios.get(`${GET_JVM_INFO}`)
- .then((response) => {
- if (response.status === 200) {
- console.log(response)
- setJvmInfo(response.data);
- }
- })
- .catch(error => {
- setError(error);
- setLoading(false);
- });
- };
-
- React.useEffect(() => {
- localStorage.setItem('searchCriteria', "");
- setLoading(false);
- }, []);
-
- React.useEffect(() => {
- if(jvmInfo != null) {
- if (Object.keys(jvmInfo).length > 0 && jvmInfo !== undefined) {
- setLoading(false);
- }
- }
- }, [jvmInfo]);
-
- const BackgroundHead = {
- backgroundImage: `url(${titleBackgroundImg})`,
- width: '100%',
- height: '100%',
- backgroundSize: 'contain',
- backgroundRepeat: 'no-repeat',
- backgroundColor: '#0C489E',
- backgroundPosition: 'right'
- };
-
- return (
- <Grid container sx={{ minHeight: '87vh', backgroundColor: "backgroundColor.default" }} direction="column">
- <Grid item xs={12}>
- <div style={BackgroundHead}>
- <Stack direction="row" height='70px' justifyContent="space-between" alignItems="center">
- <Typography ml={15} color='#FFF' variant="h4" sx={{ "textShadow": "0px 0px 25px #0C489E" }}>
- JVM Information
- </Typography>
- </Stack>
- </div>
- </Grid>
- <Grid item xs={12} ml={15} mb={2} mt={2}>
- <Button
- size="large"
- variant="contained"
- type="submit"
- sx={{
- textTransform: 'capitalize',
- alignItems: 'end'
- }}
- onClick={fetchJvmInfo}
- disabled={loading}
- >
- <Typography variant="h5">JVM Info</Typography>
- </Button>
- </Grid>
- <Grid item xs={12} ml={15} mb={2} mt={2}>
- <Paper elevation={3} sx={{ p: 2, bgcolor: 'background.paper' }}>
- {loading ? (
- <Box display="flex" justifyContent="center" alignItems="center" minHeight={200}>
- <CircularProgress />
- </Box>
- ) : error ? (
- <Typography color="error">Error: {error.message}</Typography>
- ) : jvmInfo ? (
- <Box
- component="pre"
- sx={{
- p: 2,
- borderRadius: 1,
- bgcolor: 'grey.100',
- overflow: 'auto',
- maxHeight: 400,
- fontSize: '0.875rem',
- lineHeight: 1.6
- }}
- >
- {JSON.stringify(jvmInfo, null, 2)}
- </Box>
- ) : (
- <Typography>No data available</Typography>
- )}
- </Paper>
- </Grid>
- </Grid>
- );
- };
-
- export default JVMDefault;
|