-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathreport.html
90 lines (77 loc) · 2.93 KB
/
report.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html lang="en">
<head>
<title>OpenStack Third party CI Report</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.8.1/bootstrap-table.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.8.1/bootstrap-table.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.8.1/extensions/filter-control/bootstrap-table-filter-control.js"></script>
</head>
<script>
var oneDay = 24 * 60 * 60 * 1000;
var oneHour = 60 * 60 * 1000;
function timeFormatter(value, row, index) {
var diff = Date.now() - value*1000;
if (Math.floor(diff/oneDay)<1) {
return Math.floor(diff/oneHour) + " Hours"
}
return Math.floor(diff/oneDay) + " Days"
}
function isDataStale(time) {
var diff = Date.now() - time*1000;
var days = Math.floor(diff/oneDay);
var hours = Math.floor(diff/oneHour);
if (days === 1) {
return "Warning: data is " + days + " day old";
} else if (days > 1) {
return "Warning: data is " + days + " days old";
} else if (hours === 1) {
return "Warning: Data is " + hours + " hour old";
} else if (hours > 1) {
return "Warning: Data is " + hours + " hours old";
} else {
return "Data is up to date";
}
}
function timeStyle(value, row, index) {
if (value.indexOf("Days") > 0) {
return {classes: 'danger'}
}
return {}
}
function rateStyle(value, row, index) {
if (typeof value === 'undefined'){
return {classes: 'danger'}
}
var num = parseInt(value.substring(0,value.length - 1))
if (num < 60 ) {
return {classes: 'danger'}
}
return {}
}
function responseHandler(res) {
document.getElementById("stale").innerHTML = isDataStale(res.timestamp);
return res.rows
}
</script>
<body>
<div class="container">
<h1>OpenStack Third Party CI Report</h1>
<p id="stale"></p>
<table data-toggle="table" data-url="lastcomment.json" data-filter-control="true" data-response-handler="responseHandler">
<thead>
<tr>
<th data-field="name" data-filter-control="input">Name</th>
<th data-field="project" data-filter-control="select">Project</th>
<th data-field="last" data-formatter="timeFormatter" data-cell-style="timeStyle" data-sortable="true">Last Seen</th>
<th data-field="rate" data-cell-style="rateStyle" data-sortable="true">Success Rate</th>
</tr>
</thead>
</table>
</div>
</body>
</html>