Skip to content

Commit

Permalink
Merge pull request #45 from tbranyen/diffhtml-upstream
Browse files Browse the repository at this point in the history
Adds in diffHTML example
  • Loading branch information
mathieuancelin committed Feb 12, 2016
2 parents e4324ea + c774a58 commit b908759
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
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

0 comments on commit b908759

Please sign in to comment.