1
0
mirror of https://github.com/tormachris/cf-workers-status-page.git synced 2026-04-02 23:15:36 +02:00
This commit is contained in:
Adam Janis
2020-11-08 13:56:02 +01:00
commit e85c5766a7
20 changed files with 1013 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
import config from '../../config.yaml'
export default function MonitorHistogram({ kvMonitorsDaysMap, monitor }) {
let date = new Date()
date.setDate(date.getDate() - config.settings.daysInHistory)
if (typeof window !== 'undefined') {
return (
<div
key={`${monitor.id}-histogram`}
className="horizontal flex histogram"
>
{Array.from(Array(config.settings.daysInHistory).keys()).map(key => {
date.setDate(date.getDate() + 1)
const dayInHistory = date.toISOString().split('T')[0]
const dayInHistoryKey = 'h_' + monitor.id + '_' + dayInHistory
let bg = ''
let dayInHistoryStatus = 'No data'
if (typeof kvMonitorsDaysMap[dayInHistoryKey] !== 'undefined') {
bg = kvMonitorsDaysMap[dayInHistoryKey] ? 'green' : 'orange'
dayInHistoryStatus = kvMonitorsDaysMap[dayInHistoryKey]
? 'No outages'
: 'Some outages'
}
return (
<div key={key} className="hitbox">
<div
className={`${bg} bar`}
data-tooltip={`${dayInHistory} - ${dayInHistoryStatus}`}
/>
</div>
)
})}
</div>
)
} else {
return (
<div
key={`${monitor.id}-histogram`}
className="horizontal flex histogram"
>
<div className="grey-text">Loading histogram ...</div>
</div>
)
}
}