forked from WebReflection/hyperHTML
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbmonster.html
More file actions
95 lines (87 loc) · 2.96 KB
/
Copy pathdbmonster.html
File metadata and controls
95 lines (87 loc) · 2.96 KB
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
90
91
92
93
94
95
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="dbmonster.css">
<script src="https://unpkg.com/perf-monitor@0.3.0/dist/umd/perf-monitor.js"></script>
<script src="../min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
var
// retrieve a wire or create one, based on lists of data
// necessary if you have JSON data to deal with
// since weak reference won't bring in any benefit
render = (arr, i) => arr[i] || (arr[i] = hyperHTML.wire()),
// table render
renderTABLE = hyperHTML.bind(document.querySelector('#app')),
TRs = [],
TDs = [],
Top5 = []
;
function updateTable(dbs) {
renderTABLE`
<table class="table table-striped latest-data">
<tbody>${dbs.map((db, i) => render(TRs, i)`
<tr key="${db.dbname}">${render(TDs, i)`
<td class="dbname">
${db.dbname}
</td>
<td class="query-count">
<span class="${db.lastSample.countClassName}">
${db.lastSample.nbQueries}
</span>
</td>`.concat(db.lastSample.topFiveQueries.map((query, j, a) =>
render(Top5, a.length * i + j)`
<td class="${query.elapsedClassName}">
<span class="foo">
${query.formatElapsed}
</span>
<div class="popover left">
<div class="popover-content">
${query.query}
</div>
<div class="arrow"></div>
</div>
</td>`
))
}</tr>`
)}</tbody>
</table>`;
}
updateTable(ENV.generateData().toArray());
if (!window.perfMonitor) {
perfMonitor = {
endProfile: function () {},
initProfiler: function () {},
startFPSMonitor: function () {},
startMemMonitor: function () {},
startProfile: function () {}
};
}
perfMonitor.startFPSMonitor();
perfMonitor.startMemMonitor();
// perfMonitor.initProfiler('data update');
perfMonitor.initProfiler('view update');
function update() {
// perfMonitor.startProfile('data update');
var data = ENV.generateData().toArray();
// perfMonitor.endProfile('data update');
perfMonitor.startProfile('view update');
updateTable(data);
perfMonitor.endProfile('view update');
setTimeout(update, ENV.timeout);
}
update();
}, {once: true});
</script>
</head>
<body>
<div id="range"></div>
<div id="app"></div>
<div id="link">
You're looking at hyperHTML<br>
version of <a href="https://dbmonster.firebaseapp.com/">DBMonster</a>.
</div>
</body>
<script src="./dbmonster.js"></script>
</html>