-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add naive version of vidom implementation
- Loading branch information
Showing
5 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
var node = vidom.node; | ||
|
||
var DBMon = vidom.createComponent({ | ||
onInit: function() { | ||
this.loadSamples = this.loadSamples.bind(this); | ||
}, | ||
|
||
onInitialStateRequest: function() { | ||
return { | ||
databases: [] | ||
}; | ||
}, | ||
|
||
loadSamples: function () { | ||
this.setState({ databases: ENV.generateData().toArray() }); | ||
Monitoring.renderRate.ping(); | ||
setTimeout(this.loadSamples, ENV.timeout); | ||
}, | ||
|
||
onMount: function() { | ||
this.loadSamples(); | ||
}, | ||
|
||
onRender: function() { | ||
return ( | ||
node('div').children([ | ||
node('table').attrs({ className: 'table table-striped latest-data' }).children([ | ||
node('tbody').children(this.getState().databases.map(function(database) { | ||
var children = [ | ||
node('td').key('dbname').attrs({ className: 'dbname' }).children(database.dbname), | ||
node('td').key('query-count').attrs({ className: 'query-count' }).children([ | ||
node('span') | ||
.attrs({ className: database.lastSample.countClassName }) | ||
.children(database.lastSample.nbQueries) | ||
])]; | ||
|
||
database.lastSample.topFiveQueries.forEach(function(query, index) { | ||
children.push( | ||
node('td') | ||
.key('top' + index) | ||
.attrs({ className: 'Query ' + query.elapsedClassName }) | ||
.children([ | ||
node('span').key('elapsed').children(query.formatElapsed), | ||
node('div') | ||
.key('content') | ||
.attrs({ className : 'popover left' }) | ||
.children([ | ||
node('div').key('content').attrs({ className: 'popover-content' }).children(query.query), | ||
node('div').key('arrow').attrs({ className: 'arrow' }) | ||
]) | ||
])); | ||
}); | ||
|
||
return node('tr').key(database.dbname).children(children); | ||
})) | ||
]) | ||
]) | ||
); | ||
} | ||
}); | ||
|
||
vidom.mountToDom(document.getElementById('dbmon'), node(DBMon)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta name="description" content="DBMON VIDOM" /> | ||
<meta charset="utf-8"> | ||
<link href="../styles.css" rel="stylesheet" type="text/css" /> | ||
<title>dbmon (vidom)</title> | ||
</head> | ||
<body> | ||
<div id="dbmon"></div> | ||
<script src="../lib/jquery-2.1.0.min.js"></script> | ||
<script src="../lib/vidom.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> |