Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds in diffHTML example #45

Merged
merged 1 commit into from
Feb 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions diffhtml/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const element = document.querySelector('#dbmon tbody');
const cached = _.template(`
<% databases.map(function(database) { %>
<tr>
<td class="dbname">
<%= database.dbname %>
</td>
<td class="query-count">
<span class="<%= database.lastSample.countClassName %>">
<%= database.lastSample.nbQueries %>
</span>
</td>
<% database.lastSample.topFiveQueries.map(function(sample) { %>
<td class="Query <%= sample.elapsedClassName %>">
<%= sample.formatElapsed %>
<div class="popover left">
<div class="popover-content"><%- sample.query %></div>
<div class="arrow"></div>
</div>
</td>
<% }); %>
</tr>
<% }); %>
`);

function template(databases) {
return cached({ databases });
}

function render() {
var databases = ENV.generateData().toArray();
Monitoring.renderRate.ping();

setTimeout(render, ENV.timeout);

diff.innerHTML(element, template(databases));
}

render();
27 changes: 27 additions & 0 deletions diffhtml/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="DBMON DIFFHTML" />
<meta charset="utf-8">
<link href="../lib/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="../styles.css" rel="stylesheet" type="text/css" />
<title>dbmon (diffHTML)</title>
</head>
<body>
<div id="dbmon">
<div>
<table class="table table-striped latest-data">
<tbody></tbody>
</table>
</div>
</div>

<script src="../lib/underscore-min.js"></script>
<script src="../lib/diffhtml.min.js"></script>
<script src="../ENV.js"></script>
<script src="../lib/memory-stats.js"></script>
<script src="../lib/monitor.js"></script>
<script src="./app.js"></script>
<script src="../ga.js"></script>
</body>
</html>
3 changes: 3 additions & 0 deletions lib/diffhtml.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions library-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
{ type: 'naive', id: 'domvm', url: './domvm/index.html', label: 'DBMON domvm' },
{ type: 'naive', id: 'once', url: './once/index.html', label: 'DBMON once' },
{ type: 'naive', id: 'ripple', url: './ripple/index.html', label: 'DBMON ripple' },
{ type: 'naive', id: 'diffhtml', url: './diffhtml/index.html', label: 'DBMON diffHTML' },
{ type: 'optimized', id: 'react', url: './react/opt.html', label: 'DBMON React' },
{ type: 'optimized', id: 'preact', url: './preact', label: 'DBMON Preact' },
{ type: 'naive', id: 'preact-functional', url: './preact/functional.html', label: 'DBMON Preact (Functional)' },
Expand Down