@@ -3,11 +3,12 @@ import {
3
3
Container ,
4
4
CardBody ,
5
5
Card ,
6
+ Badge ,
6
7
CardHeader ,
7
8
FormGroup ,
8
9
} from '../../../../app/components'
9
10
import { useTranslation } from 'react-i18next'
10
-
11
+ import applicationStyle from '../../../../app/routes/Apps/Gluu/styles/applicationstyle'
11
12
import { buildPayload } from '../../../../app/utils/PermChecker'
12
13
import { connect } from 'react-redux'
13
14
import { getHealthStatus } from '../../redux/actions/HealthAction'
@@ -19,9 +20,27 @@ function HealthPage({ serverStatus, dbStatus, dispatch }) {
19
20
const options = { }
20
21
21
22
useEffect ( ( ) => {
23
+ fetchHealthInfo ( userAction , options , dispatch )
24
+ } , [ ] )
25
+
26
+ function fetchHealthInfo ( ) {
22
27
buildPayload ( userAction , 'GET Health Status' , options )
23
28
dispatch ( getHealthStatus ( userAction ) )
24
- } , [ ] )
29
+ }
30
+
31
+ function getColor ( status ) {
32
+ return isUp ( status ) ? 'primary' : 'danger'
33
+ }
34
+
35
+ function isUp ( status ) {
36
+ if ( status ) {
37
+ return (
38
+ status . toUpperCase ( ) === 'ONLINE' . toUpperCase ( ) ||
39
+ status . toUpperCase ( ) === 'RUNNING' . toUpperCase ( )
40
+ )
41
+ }
42
+ return false
43
+ }
25
44
26
45
return (
27
46
< Container >
@@ -31,17 +50,35 @@ function HealthPage({ serverStatus, dbStatus, dispatch }) {
31
50
< FormGroup row />
32
51
< FormGroup row />
33
52
< CardBody >
34
- < Card className = "mb-3" >
35
- < CardHeader tag = "h6" className = "bg-success text-white" >
53
+ < Card className = "mb-3" style = { applicationStyle . buttonStyle } >
54
+ < CardHeader tag = "h6" className = "text-white" >
36
55
{ t ( 'titles.oauth_server_status_title' ) }
37
56
</ CardHeader >
38
- < CardBody > { serverStatus } </ CardBody >
57
+ < CardBody
58
+ style = {
59
+ isUp ( serverStatus )
60
+ ? applicationStyle . healthUp
61
+ : applicationStyle . healthDown
62
+ }
63
+ >
64
+ { serverStatus && (
65
+ < Badge color = { getColor ( serverStatus ) } > { serverStatus } </ Badge >
66
+ ) }
67
+ </ CardBody >
39
68
</ Card >
40
- < Card className = "mb-3" >
41
- < CardHeader tag = "h6" className = "bg-success text-white" >
69
+ < Card className = "mb-3" style = { applicationStyle . buttonStyle } >
70
+ < CardHeader tag = "h6" className = "text-white" >
42
71
{ t ( 'titles.database_status_title' ) }
43
72
</ CardHeader >
44
- < CardBody > { dbStatus } </ CardBody >
73
+ < CardBody
74
+ style = {
75
+ isUp ( dbStatus )
76
+ ? applicationStyle . healthUp
77
+ : applicationStyle . healthDown
78
+ }
79
+ >
80
+ { dbStatus && < Badge color = { getColor ( dbStatus ) } > { dbStatus } </ Badge > }
81
+ </ CardBody >
45
82
</ Card >
46
83
</ CardBody >
47
84
</ Card >
0 commit comments