25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

187 lines
5.4 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, GET_NOTIFICATION_QUEUE_STATUS } 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 [queueStatus, setQueueStatus] = React.useState(null);
  21. const [queueLoading, setQueueLoading] = React.useState(false);
  22. const [queueError, setQueueError] = React.useState(null);
  23. const fetchJvmInfo = () => {
  24. setLoading(true);
  25. setError(null);
  26. axios.get(`${GET_JVM_INFO}`)
  27. .then((response) => {
  28. if (response.status === 200) {
  29. console.log(response)
  30. setJvmInfo(response.data);
  31. }
  32. })
  33. .catch(error => {
  34. setError(error);
  35. setLoading(false);
  36. });
  37. };
  38. const fetchNotificationQueueStatus = () => {
  39. setQueueLoading(true);
  40. setQueueError(null);
  41. setQueueStatus(null);
  42. axios.get(`${GET_NOTIFICATION_QUEUE_STATUS}`)
  43. .then((response) => {
  44. if (response.status === 200) {
  45. setQueueStatus(response.data);
  46. }
  47. })
  48. .catch(err => {
  49. setQueueError(err);
  50. })
  51. .finally(() => {
  52. setQueueLoading(false);
  53. });
  54. };
  55. React.useEffect(() => {
  56. localStorage.setItem('searchCriteria', "");
  57. setLoading(false);
  58. }, []);
  59. React.useEffect(() => {
  60. if(jvmInfo != null) {
  61. if (Object.keys(jvmInfo).length > 0 && jvmInfo !== undefined) {
  62. setLoading(false);
  63. }
  64. }
  65. }, [jvmInfo]);
  66. const BackgroundHead = {
  67. backgroundImage: `url(${titleBackgroundImg})`,
  68. width: '100%',
  69. height: '100%',
  70. backgroundSize: 'contain',
  71. backgroundRepeat: 'no-repeat',
  72. backgroundColor: '#0C489E',
  73. backgroundPosition: 'right'
  74. };
  75. return (
  76. <Grid container sx={{ minHeight: '87vh', backgroundColor: "backgroundColor.default" }} direction="column">
  77. <Grid item xs={12}>
  78. <div style={BackgroundHead}>
  79. <Stack direction="row" height='70px' justifyContent="space-between" alignItems="center">
  80. <Typography ml={15} color='#FFF' variant="h4" sx={{ "textShadow": "0px 0px 25px #0c489e" }}>
  81. System Background Status
  82. </Typography>
  83. </Stack>
  84. </div>
  85. </Grid>
  86. <Grid item xs={12} ml={15} mb={2} mt={2}>
  87. <Stack direction="row" spacing={2}>
  88. <Button
  89. size="large"
  90. variant="contained"
  91. type="submit"
  92. sx={{
  93. textTransform: 'capitalize',
  94. alignItems: 'end'
  95. }}
  96. onClick={fetchJvmInfo}
  97. disabled={loading}
  98. >
  99. <Typography variant="h5">JVM Info</Typography>
  100. </Button>
  101. <Button
  102. size="large"
  103. variant="contained"
  104. type="button"
  105. sx={{
  106. textTransform: 'capitalize',
  107. alignItems: 'end'
  108. }}
  109. onClick={fetchNotificationQueueStatus}
  110. disabled={queueLoading}
  111. >
  112. <Typography variant="h5">Notification Queue Status</Typography>
  113. </Button>
  114. </Stack>
  115. </Grid>
  116. <Grid item xs={12} ml={15} mb={2} mt={2}>
  117. <Paper elevation={3} sx={{ p: 2, bgcolor: 'background.paper' }}>
  118. {loading ? (
  119. <Box display="flex" justifyContent="center" alignItems="center" minHeight={200}>
  120. <CircularProgress />
  121. </Box>
  122. ) : error ? (
  123. <Typography color="error">Error: {error.message}</Typography>
  124. ) : jvmInfo ? (
  125. <Box
  126. component="pre"
  127. sx={{
  128. p: 2,
  129. borderRadius: 1,
  130. bgcolor: 'grey.100',
  131. overflow: 'auto',
  132. maxHeight: 400,
  133. fontSize: '0.875rem',
  134. lineHeight: 1.6
  135. }}
  136. >
  137. {JSON.stringify(jvmInfo, null, 2)}
  138. </Box>
  139. ) : (
  140. <Typography>No data available</Typography>
  141. )}
  142. </Paper>
  143. </Grid>
  144. <Grid item xs={12} ml={15} mb={2} mt={2}>
  145. <Paper elevation={3} sx={{ p: 2, bgcolor: 'background.paper' }}>
  146. <Typography variant="h6" gutterBottom>Notification Queue Status</Typography>
  147. {queueLoading ? (
  148. <Box display="flex" justifyContent="center" alignItems="center" minHeight={120}>
  149. <CircularProgress />
  150. </Box>
  151. ) : queueError ? (
  152. <Typography color="error">Error: {queueError.message}</Typography>
  153. ) : queueStatus ? (
  154. <Box
  155. component="pre"
  156. sx={{
  157. p: 2,
  158. borderRadius: 1,
  159. bgcolor: 'grey.100',
  160. overflow: 'auto',
  161. maxHeight: 300,
  162. fontSize: '0.875rem',
  163. lineHeight: 1.6
  164. }}
  165. >
  166. {JSON.stringify(queueStatus, null, 2)}
  167. </Box>
  168. ) : (
  169. <Typography color="text.secondary">Click &quot;Notification Queue Status&quot; to load data.</Typography>
  170. )}
  171. </Paper>
  172. </Grid>
  173. </Grid>
  174. );
  175. };
  176. export default JVMDefault;