2018-07-16 04:04:43 +00:00
|
|
|
import React from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
2018-06-12 21:56:50 +00:00
|
|
|
|
2018-07-16 04:04:43 +00:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
2018-07-14 01:57:02 +00:00
|
|
|
|
2018-07-16 04:04:43 +00:00
|
|
|
import './Service.css'
|
|
|
|
import Graph from './Graph.js'
|
2018-06-12 21:56:50 +00:00
|
|
|
|
2018-07-13 19:07:53 +00:00
|
|
|
const Service = ({ graph, name, status, latency, description }) => (
|
2018-06-12 21:56:50 +00:00
|
|
|
<div className="service">
|
2018-07-14 01:49:45 +00:00
|
|
|
<header>
|
|
|
|
<div className="emoji">
|
2018-07-14 01:57:02 +00:00
|
|
|
<FontAwesomeIcon
|
|
|
|
icon={`${status ? 'check' : 'exclamation'}-circle`}
|
|
|
|
style={{ color: status ? '#2ECC40' : '#FF4136' }}
|
|
|
|
/>
|
2018-07-13 19:07:53 +00:00
|
|
|
</div>
|
2018-07-14 01:49:45 +00:00
|
|
|
<h2 className="title">
|
2018-07-13 19:32:33 +00:00
|
|
|
{name} {latency ? (
|
2018-07-14 01:49:45 +00:00
|
|
|
<span className="latency">
|
2018-07-14 02:39:44 +00:00
|
|
|
{Math.round(latency)}ms
|
2018-07-13 19:07:53 +00:00
|
|
|
</span>
|
|
|
|
) : null}
|
2018-06-12 21:56:50 +00:00
|
|
|
</h2>
|
|
|
|
</header>
|
2018-07-14 01:49:45 +00:00
|
|
|
<p className="description">
|
2018-06-12 21:56:50 +00:00
|
|
|
{description}
|
|
|
|
</p>
|
2018-07-14 02:40:45 +00:00
|
|
|
{graph ? <Graph data={graph} /> : null}
|
2018-06-12 21:56:50 +00:00
|
|
|
</div>
|
2018-07-16 04:04:43 +00:00
|
|
|
)
|
2018-06-12 21:56:50 +00:00
|
|
|
|
2018-07-14 02:01:13 +00:00
|
|
|
Service.defaultProps = {
|
|
|
|
graph: null,
|
|
|
|
latency: null,
|
2018-07-16 04:04:43 +00:00
|
|
|
}
|
2018-07-14 02:01:13 +00:00
|
|
|
|
|
|
|
Service.propTypes = {
|
|
|
|
graph: PropTypes.arrayOf(
|
|
|
|
PropTypes.arrayOf(PropTypes.number),
|
|
|
|
),
|
|
|
|
name: PropTypes.string.isRequired,
|
|
|
|
status: PropTypes.bool.isRequired,
|
|
|
|
latency: PropTypes.number,
|
|
|
|
description: PropTypes.string.isRequired,
|
2018-07-16 04:04:43 +00:00
|
|
|
}
|
2018-07-14 02:01:13 +00:00
|
|
|
|
2018-07-16 04:04:43 +00:00
|
|
|
export default Service
|