use animation best practices in dbmon
This commit is contained in:
parent
2f7c4983f3
commit
4a4bd7a548
8 changed files with 48 additions and 2299 deletions
3
examples/dbmonster/angular/app.js
vendored
3
examples/dbmonster/angular/app.js
vendored
|
|
@ -32,9 +32,10 @@ var AppComponent = ng.core.Component({selector: "my-app"})
|
|||
this.update()
|
||||
},
|
||||
update: function() {
|
||||
requestAnimationFrame(function() {self.update()})
|
||||
|
||||
var self = this
|
||||
self.databases = ENV.generateData().toArray()
|
||||
setTimeout(function() {self.update()}, ENV.timeout)
|
||||
|
||||
if (renderStage === 0) {
|
||||
renderStage = 1
|
||||
|
|
|
|||
|
|
@ -1,44 +0,0 @@
|
|||
"use strict"
|
||||
|
||||
var data = []
|
||||
|
||||
var root = document.getElementById("app")
|
||||
update()
|
||||
|
||||
function update() {
|
||||
data = ENV.generateData().toArray()
|
||||
|
||||
Monitoring.renderRate.ping()
|
||||
|
||||
m.redraw();
|
||||
|
||||
setTimeout(update, ENV.timeout)
|
||||
}
|
||||
|
||||
m.mount(root, {
|
||||
view : function() {
|
||||
return m("div", [
|
||||
m("table", { className: "table table-striped latest-data" }, [
|
||||
m("tbody",
|
||||
data.map(function(db) {
|
||||
return m("tr", {key: db.dbname}, [
|
||||
m("td", { className: "dbname" }, db.dbname),
|
||||
m("td", { className: "query-count" }, [
|
||||
m("span", { className: db.lastSample.countClassName }, db.lastSample.nbQueries)
|
||||
]),
|
||||
db.lastSample.topFiveQueries.map(function(query) {
|
||||
return m("td", { className: query.elapsedClassName }, [
|
||||
m("span", query.formatElapsed),
|
||||
m("div", { className: "popover left" }, [
|
||||
m("div", { className: "popover-content" }, query.query),
|
||||
m("div", { className: "arrow" })
|
||||
])
|
||||
])
|
||||
})
|
||||
])
|
||||
})
|
||||
)
|
||||
])
|
||||
])
|
||||
}
|
||||
});
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="description" content="DBMON Mithril 0.2.x" />
|
||||
<meta charset="utf-8">
|
||||
<link href="../styles.css" rel="stylesheet" type="text/css" />
|
||||
<title>dbmon (Mithril 0.2.x)</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script src="./mithril-0.2.4.js"></script>
|
||||
<script src="../ENV.js"></script>
|
||||
<script src="../memory-stats.js"></script>
|
||||
<script src="../monitor.js"></script>
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -35,13 +35,13 @@ m.mount(document.getElementById("app"), {
|
|||
})
|
||||
|
||||
function update() {
|
||||
requestAnimationFrame(update)
|
||||
|
||||
data = ENV.generateData().toArray()
|
||||
|
||||
perfMonitor.startProfile("render")
|
||||
m.redraw()
|
||||
perfMonitor.endProfile("render")
|
||||
|
||||
setTimeout(update, ENV.timeout)
|
||||
}
|
||||
|
||||
update()
|
||||
|
|
|
|||
|
|
@ -38,14 +38,13 @@ var DBMon = React.createClass({
|
|||
|
||||
var root = document.getElementById("app")
|
||||
function update() {
|
||||
requestAnimationFrame(update)
|
||||
|
||||
data = ENV.generateData().toArray()
|
||||
|
||||
perfMonitor.startProfile("render")
|
||||
ReactDOM.render(h(DBMon, null), root)
|
||||
|
||||
perfMonitor.endProfile("render")
|
||||
|
||||
setTimeout(update, ENV.timeout)
|
||||
}
|
||||
|
||||
update()
|
||||
|
|
|
|||
|
|
@ -4,48 +4,48 @@ perfMonitor.startMemMonitor()
|
|||
perfMonitor.initProfiler("render")
|
||||
|
||||
var vm = new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
databases: [],
|
||||
},
|
||||
methods: {
|
||||
update: function () {
|
||||
this.databases = ENV.generateData().toArray()
|
||||
setTimeout(this.update.bind(this), ENV.timeout)
|
||||
el: '#app',
|
||||
data: {
|
||||
databases: [],
|
||||
},
|
||||
methods: {
|
||||
update: function () {
|
||||
requestAnimationFrame(this.update.bind(this))
|
||||
this.databases = ENV.generateData().toArray()
|
||||
|
||||
if (renderStage === 0) {
|
||||
renderStage = 1
|
||||
perfMonitor.startProfile('render')
|
||||
}
|
||||
},
|
||||
},
|
||||
updated: function () {
|
||||
if (renderStage === 1) {
|
||||
renderStage = 0
|
||||
perfMonitor.endProfile('render')
|
||||
}
|
||||
},
|
||||
template: '<div>' +
|
||||
'<table class="table table-striped latest-data">' +
|
||||
'<tbody>' +
|
||||
'<tr v-for="db of databases">' +
|
||||
'<td class="dbname">{{ db.dbname }}</td>' +
|
||||
'<td class="query-count">' +
|
||||
'<span v-bind:class="[ db.lastSample.countClassName ]">' +
|
||||
'{{ db.lastSample.nbQueries}}' +
|
||||
'</span>' +
|
||||
'</td>' +
|
||||
'<td v-for="q of db.lastSample.topFiveQueries" v-bind:class="[ q.elapsedClassName ]">' +
|
||||
'{{ q.formatElapsed }}' +
|
||||
'<div class="popover left">' +
|
||||
'<div className="popover-content">{{ q.query }}</div>' +
|
||||
'<div className="arrow"></div>' +
|
||||
'</div>' +
|
||||
'</td>' +
|
||||
'</tr>' +
|
||||
'</tbody>' +
|
||||
'</table>' +
|
||||
'</div>',
|
||||
if (renderStage === 0) {
|
||||
renderStage = 1
|
||||
perfMonitor.startProfile('render')
|
||||
}
|
||||
},
|
||||
},
|
||||
updated: function () {
|
||||
if (renderStage === 1) {
|
||||
renderStage = 0
|
||||
perfMonitor.endProfile('render')
|
||||
}
|
||||
},
|
||||
template: '<div>' +
|
||||
'<table class="table table-striped latest-data">' +
|
||||
'<tbody>' +
|
||||
'<tr v-for="db of databases">' +
|
||||
'<td class="dbname">{{ db.dbname }}</td>' +
|
||||
'<td class="query-count">' +
|
||||
'<span v-bind:class="[ db.lastSample.countClassName ]">' +
|
||||
'{{ db.lastSample.nbQueries}}' +
|
||||
'</span>' +
|
||||
'</td>' +
|
||||
'<td v-for="q of db.lastSample.topFiveQueries" v-bind:class="[ q.elapsedClassName ]">' +
|
||||
'{{ q.formatElapsed }}' +
|
||||
'<div class="popover left">' +
|
||||
'<div className="popover-content">{{ q.query }}</div>' +
|
||||
'<div className="arrow"></div>' +
|
||||
'</div>' +
|
||||
'</td>' +
|
||||
'</tr>' +
|
||||
'</tbody>' +
|
||||
'</table>' +
|
||||
'</div>',
|
||||
})
|
||||
|
||||
vm.update()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script src="//vuejs.org/js/vue.min.js"></script>
|
||||
<script src="https://vuejs.org/js/vue.min.js"></script>
|
||||
<script src="../ENV.js"></script>
|
||||
<script src="https://localvoid.github.io/perf-monitor/0.1/perf-monitor.js"></script>
|
||||
<script src="app.js"></script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue