|
4 | 4 | <title>Status</title> |
5 | 5 | <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> |
6 | 6 | <style> |
7 | | - td > span.badge { |
| 7 | + #results div.container:first-child { |
| 8 | + border-top-left-radius: 3px; |
| 9 | + border-top-right-radius: 3px; |
| 10 | + } |
| 11 | + #results div.container:last-child { |
| 12 | + border-bottom-left-radius: 3px; |
| 13 | + border-bottom-right-radius: 3px; |
| 14 | + border-bottom-width: 1px; |
| 15 | + border-color: #dee2e6; |
| 16 | + border-style: solid; |
| 17 | + } |
| 18 | + .status-ok { |
8 | 19 | display: inline-block; |
9 | | - width: 20px; |
10 | | - cursor: default; |
11 | | - margin-right: 2px; |
| 20 | + width: 1%; |
| 21 | + height: 20px; |
| 22 | + margin-right: 4px; |
| 23 | + background-color: #28a745; |
12 | 24 | } |
13 | 25 | </style> |
14 | 26 | </head> |
|
17 | 29 | <div class="text-center mb-3"> |
18 | 30 | <div class="display-4">Status</div> |
19 | 31 | </div> |
20 | | - <div class="table-responsive"> |
21 | | - <table class="table"> |
22 | | - <thead> |
23 | | - <tr> |
24 | | - <th scope="col">Name</th> |
25 | | - <th scope="col">Status</th> |
26 | | - <th scope="col">Hostname</th> |
27 | | - <th scope="col">Response time</th> |
28 | | - </tr> |
29 | | - </thead> |
30 | | - <tbody id="results"> |
31 | | - </tbody> |
32 | | - </table> |
| 32 | + <div id="results"> |
33 | 33 | </div> |
34 | 34 | </div> |
35 | 35 |
|
|
38 | 38 | <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> |
39 | 39 |
|
40 | 40 | <script> |
41 | | - const OK = "<span class='badge badge-success' title='__RESPONSE_TIME____CONDITIONS____ERRORS__'>✓</span>"; |
42 | | - const NOK = "<span class='badge badge-danger' title='__RESPONSE_TIME____CONDITIONS____ERRORS__'>X</span>"; |
| 41 | + //const OK = "<div class='status-ok' title='__RESPONSE_TIME____CONDITIONS____ERRORS__'></div>" |
| 42 | + const OK = "<span class='badge badge-success ml-1' style='width: 5%' title='__RESPONSE_TIME____CONDITIONS____ERRORS__'>✓</span>"; |
| 43 | + const NOK = "<span class='badge badge-danger ml-1' style='width: 5%' title='__RESPONSE_TIME____CONDITIONS____ERRORS__'>X</span>"; |
43 | 44 |
|
44 | 45 | function generateServiceResultBox(serviceResult) { |
45 | 46 | let output = (serviceResult.success ? OK : NOK); |
|
62 | 63 | return output; |
63 | 64 | } |
64 | 65 |
|
65 | | - function refreshTable() { |
| 66 | + function refreshResults() { |
66 | 67 | $.getJSON("/api/v1/results", function (data) { |
67 | | - let tableBody = ""; |
| 68 | + let output = ""; |
68 | 69 | for (let serviceName in data) { |
69 | 70 | let serviceStatusOverTime = ""; |
70 | 71 | let hostname = data[serviceName][data[serviceName].length-1].hostname |
|
82 | 83 | maxResponseTime = responseTime; |
83 | 84 | } |
84 | 85 | } |
85 | | - tableBody += "" |
86 | | - + "<tr>" |
87 | | - + " <td>" + serviceName + "</td>" |
88 | | - + " <td>" + serviceStatusOverTime + "</td>" |
89 | | - + " <td><a href=\"//" + hostname + "\">" + hostname + "</a></td>" |
90 | | - + " <td>" + (minResponseTime === maxResponseTime ? minResponseTime : (minResponseTime + "-" + maxResponseTime)) + "ms</td>" |
91 | | - + "</tr>"; |
| 86 | + output += "" |
| 87 | + + "<div class='container p-2 border-left border-right border-top border-black'>" |
| 88 | + + " <div class='row mb-2'>" |
| 89 | + + " <div class='col-8'>" |
| 90 | + + " <span class='font-weight-bold'>" + serviceName + "</span> <span class='text-secondary font-weight-lighter'>- " + hostname + "</span>" |
| 91 | + + " </div>" |
| 92 | + + " <div class='col-4 text-right'>" |
| 93 | + + " <span class='font-weight-lighter'>" + (minResponseTime === maxResponseTime ? minResponseTime : (minResponseTime + "-" + maxResponseTime)) + "ms</span>" |
| 94 | + + " </div>" |
| 95 | + + " </div>" |
| 96 | + + " <div class='row'>" |
| 97 | + + " <div class='col-12 d-flex flex-row-reverse'>" |
| 98 | + + " " + serviceStatusOverTime |
| 99 | + + " </div>" |
| 100 | + + " </div>" |
| 101 | + + "</div>"; |
92 | 102 | } |
93 | | - $("#results").html(tableBody); |
| 103 | + $("#results").html(output); |
94 | 104 | }); |
95 | 105 | } |
96 | 106 |
|
97 | | - refreshTable(); |
| 107 | + refreshResults(); |
98 | 108 | setInterval(function() { |
99 | | - refreshTable(); |
| 109 | + refreshResults(); |
100 | 110 | }, 10000); |
101 | 111 | </script> |
102 | 112 | </body> |
|
0 commit comments