mirror of
https://github.com/KevinMidboe/ISPDowntimeMonitor.git
synced 2025-12-08 20:29:07 +00:00
Use endpoint for uptime for bar graph.
This commit is contained in:
@@ -1,28 +1,39 @@
|
|||||||
|
|
||||||
const createEvent = () => {
|
const clickEventPopupIncident = (event) => {
|
||||||
const event = document.createElement('div')
|
const element = event.toElement;
|
||||||
event.className = 'event';
|
const indicentId = element.getAttribute('incident-id');
|
||||||
|
popover(indicentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
const createEvent = (event) => {
|
||||||
|
const element = document.createElement('div')
|
||||||
|
element.className = 'event';
|
||||||
const tooltip = document.createElement('span');
|
const tooltip = document.createElement('span');
|
||||||
tooltip.className = 'tooltip';
|
tooltip.className = 'tooltip';
|
||||||
const tooltipContent = new Date().toLocaleString()
|
const tooltipContent = new Date(event.date).toLocaleString()
|
||||||
tooltip.innerText = tooltipContent;
|
tooltip.innerText = tooltipContent;
|
||||||
|
|
||||||
event.appendChild(tooltip);
|
element.setAttribute('incident-id', event._id)
|
||||||
return event;
|
element.onclick = clickEventPopupIncident;
|
||||||
|
|
||||||
|
element.appendChild(tooltip);
|
||||||
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchUptimeAndGenerateBarGraph(instances=10) {
|
function fetchUptimeAndGenerateBarGraph() {
|
||||||
const graph = document.getElementById('bar-graph');
|
const graph = document.getElementById('bar-graph');
|
||||||
|
|
||||||
const event = createEvent()
|
fetch('/uptime')
|
||||||
|
.then(resp => resp.json())
|
||||||
|
.then(uptimeEvents => {
|
||||||
|
uptimeEvents.map(event => {
|
||||||
|
const eventElement = createEvent(event);
|
||||||
|
if (event.isOk == false)
|
||||||
|
eventElement.className += ' error'
|
||||||
|
|
||||||
for (var i = instances; i >= 0; i--) {
|
graph.appendChild(eventElement)
|
||||||
const clone = event.cloneNode(true)
|
})
|
||||||
Math.random() > 0.95 ? clone.className += ' error' : null;
|
})
|
||||||
graph.appendChild(clone)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fetchUptimeAndGenerateBarGraph()
|
||||||
// fetchUptimeAndGenerateBarGraph(20)
|
|
||||||
fetchUptimeAndGenerateBarGraph(60)
|
|
||||||
Reference in New Issue
Block a user