You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

121 lines
3.2 KiB

  1. // import { useState } from 'react';
  2. // material-ui
  3. import {
  4. Grid,
  5. Typography,
  6. Stack,
  7. Paper,
  8. Box,
  9. CircularProgress,
  10. Button
  11. } from '@mui/material';
  12. import * as React from "react";
  13. import { GET_JVM_INFO } from "utils/ApiPathConst";
  14. import axios from "axios";
  15. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  16. const JVMDefault = () => {
  17. const [jvmInfo, setJvmInfo] = React.useState(null);
  18. const [loading, setLoading] = React.useState(true);
  19. const [error, setError] = React.useState(null);
  20. const fetchJvmInfo = () => {
  21. setLoading(true);
  22. setError(null);
  23. axios.get(`${GET_JVM_INFO}`)
  24. .then((response) => {
  25. if (response.status === 200) {
  26. console.log(response)
  27. setJvmInfo(response.data);
  28. }
  29. })
  30. .catch(error => {
  31. setError(error);
  32. setLoading(false);
  33. });
  34. };
  35. React.useEffect(() => {
  36. localStorage.setItem('searchCriteria', "");
  37. setLoading(false);
  38. }, []);
  39. React.useEffect(() => {
  40. if(jvmInfo != null) {
  41. if (Object.keys(jvmInfo).length > 0 && jvmInfo !== undefined) {
  42. setLoading(false);
  43. }
  44. }
  45. }, [jvmInfo]);
  46. const BackgroundHead = {
  47. backgroundImage: `url(${titleBackgroundImg})`,
  48. width: '100%',
  49. height: '100%',
  50. backgroundSize: 'contain',
  51. backgroundRepeat: 'no-repeat',
  52. backgroundColor: '#0C489E',
  53. backgroundPosition: 'right'
  54. };
  55. return (
  56. <Grid container sx={{ minHeight: '87vh', backgroundColor: "backgroundColor.default" }} direction="column">
  57. <Grid item xs={12}>
  58. <div style={BackgroundHead}>
  59. <Stack direction="row" height='70px' justifyContent="space-between" alignItems="center">
  60. <Typography ml={15} color='#FFF' variant="h4" sx={{ "textShadow": "0px 0px 25px #0C489E" }}>
  61. JVM Information
  62. </Typography>
  63. </Stack>
  64. </div>
  65. </Grid>
  66. <Grid item xs={12} ml={15} mb={2} mt={2}>
  67. <Button
  68. size="large"
  69. variant="contained"
  70. type="submit"
  71. sx={{
  72. textTransform: 'capitalize',
  73. alignItems: 'end'
  74. }}
  75. onClick={fetchJvmInfo}
  76. disabled={loading}
  77. >
  78. <Typography variant="h5">JVM Info</Typography>
  79. </Button>
  80. </Grid>
  81. <Grid item xs={12} ml={15} mb={2} mt={2}>
  82. <Paper elevation={3} sx={{ p: 2, bgcolor: 'background.paper' }}>
  83. {loading ? (
  84. <Box display="flex" justifyContent="center" alignItems="center" minHeight={200}>
  85. <CircularProgress />
  86. </Box>
  87. ) : error ? (
  88. <Typography color="error">Error: {error.message}</Typography>
  89. ) : jvmInfo ? (
  90. <Box
  91. component="pre"
  92. sx={{
  93. p: 2,
  94. borderRadius: 1,
  95. bgcolor: 'grey.100',
  96. overflow: 'auto',
  97. maxHeight: 400,
  98. fontSize: '0.875rem',
  99. lineHeight: 1.6
  100. }}
  101. >
  102. {JSON.stringify(jvmInfo, null, 2)}
  103. </Box>
  104. ) : (
  105. <Typography>No data available</Typography>
  106. )}
  107. </Paper>
  108. </Grid>
  109. </Grid>
  110. );
  111. };
  112. export default JVMDefault;