Skip to content

Commit

Permalink
added RE:DOM
Browse files Browse the repository at this point in the history
  • Loading branch information
pakastin committed Oct 11, 2016
1 parent 57e2d5c commit aa7f955
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 2 deletions.
5 changes: 3 additions & 2 deletions frzr/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
$(function () {
(function () {
'use strict'
var el = frzr.el;
var mount = frzr.mount;
var List = frzr.List;
Expand Down Expand Up @@ -79,4 +80,4 @@ $(function () {
update();
}, ENV.timeout);
}
});
})()
1 change: 1 addition & 0 deletions lib/redom.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 80 additions & 0 deletions redom/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/* global ENV, redom, Monitoring */
'use strict'

;(function () {
var el = redom.el
var mount = redom.mount
var List = redom.List

function Cell (initData, data, index) {
if (index === 0) {
this.el = el('td.dbname')
} else if (index === 1) {
this.el = el('td.queryCount',
this.count = el('span')
)
} else {
this.el = el('td',
this.span = el('span'),
el('div.popover.left',
this.popover = el('div.popover-content'),
el('div.arrow')
)
)
}
}

Cell.prototype.update = function (data, index) {
if (index === 0) {
this.el.textContent = data
} else if (index === 1) {
this.count.textContent = data[0]
this.count.className = data[1]
} else {
this.el.className = data.elapsedClassName
this.span.textContent = data.formatElapsed
this.popover.textContent = data.query
}
}

function Row () {
this.el = new List('tr', Cell)
}

Row.prototype.update = function (db) {
this.el.update(
[
db.dbname,
[ db.lastSample.nbQueries, db.lastSample.countClassName ]
].concat(db.lastSample.topFiveQueries)
)
}

function Table () {
this.el = el('div',
el('table.table.table-striped.latest-data',
this.rows = new List('tbody', Row)
)
)
}

Table.prototype.update = function (data) {
this.rows.update(data)
}

function update () {
var data = ENV.generateData().toArray()

Monitoring.renderRate.ping()
table.update(data)

setTimeout(function () {
update()
}, ENV.timeout)
}

var table = new Table()

update()
mount(document.getElementById('app'), table)
})()
19 changes: 19 additions & 0 deletions redom/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="DBMON RE:DOM" />
<meta charset="utf-8">
<link href="../styles.css" rel="stylesheet" type="text/css" />
<title>dbmon (RE:DOM)</title>
</head>
<body>
<div id="app"></div>
<script src="../lib/jquery-2.1.0.min.js"></script>
<script src="../lib/redom.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>

0 comments on commit aa7f955

Please sign in to comment.