Add automatic refresh support back.

This commit is contained in:
AreWeFastYet 2012-12-03 11:39:52 +00:00
Родитель 31a5c3c6e0
Коммит bc9f2d0ef7
4 изменённых файлов: 58 добавлений и 13 удалений

Просмотреть файл

@ -2,7 +2,7 @@
"use strict";
var AWFY = { };
AWFY.refreshTime = 1000 * 60 * 5;
AWFY.refreshTime = 60 * 5;
AWFY.machineId = 0;
AWFY.hasLegend = false;
AWFY.panes = [];
@ -12,6 +12,7 @@ AWFY.xhr = [];
AWFY.view = 'none';
AWFY.suiteName = null;
AWFY.lastHash = null;
AWFY.lastRefresh = 0;
AWFY.request = function (files, callback) {
var url = window.location.protocol + '//' +
@ -102,11 +103,13 @@ AWFY.displayNewGraph = function (name, graph) {
var elt = $('#' + name + '-graph');
var display = elt.data('awfy-display');
if (!display) {
display = new Display(this, name, elt, graph);
display = new Display(this, name, elt);
elt.data('awfy-display', display);
}
display.setup(graph);
display.draw();
if (display.shouldRefresh()) {
display.setup(graph);
display.draw();
}
this.aggregate[name] = graph;
}
@ -434,6 +437,7 @@ AWFY.showOverview = function () {
];
this.request(['aggregate-' + this.machineId], this.computeAggregate.bind(this));
this.lastRefresh = Date.now();
}
AWFY.showBreakdown = function (name) {
@ -476,12 +480,10 @@ AWFY.showBreakdown = function (name) {
var file = 'bk-aggregate-' + id + '-' + this.machineId;
this.request([file], callback);
}
this.lastRefresh = Date.now();
}
AWFY.changeMachine = function (machine_id) {
this.reset(this.view);
this.machineId = machine_id;
AWFY.requestRedraw = function () {
if (this.view == 'overview') {
this.request(['aggregate-' + this.machineId],
this.computeAggregate.bind(this));
@ -499,6 +501,13 @@ AWFY.changeMachine = function (machine_id) {
this.request([file], callback);
}
}
this.lastRefresh = Date.now();
}
AWFY.changeMachine = function (machine_id) {
this.reset(this.view);
this.machineId = machine_id;
this.requestRedraw();
}
AWFY.reset = function (view) {
@ -531,6 +540,12 @@ AWFY.onHashChange = function () {
this.parseURL();
}
AWFY.refresh = function () {
if (Date.now() - this.lastRefresh >= this.refreshTime)
this.requestRedraw();
window.setTimeout(this.refresh.bind(this), this.refreshTime * 1000);
}
AWFY.parseURL = function () {
if (this.lastHash == window.location.hash)
return;
@ -707,5 +722,7 @@ AWFY.startup = function () {
$(window).hashchange(this.onHashChange.bind(this));
$(window).bind('popstate', this.onHashChange.bind(this));
window.setTimeout(this.refresh.bind(this), this.refreshTime * 1000);
}

Просмотреть файл

@ -1,20 +1,20 @@
// vim: set ts=4 sw=4 tw=99 et:
"use strict";
function Display(awfy, id, elt, graph)
function Display(awfy, id, elt)
{
this.awfy = awfy;
this.id = id;
this.elt = elt;
this.attachedTips = [];
this.graph = null;
this.plot = null;
this.hovering = null;
}
Display.prototype.setup = function (graph) {
this.graph = graph;
// The last hovering tooltip we displayed, that has not been clicked.
this.hovering = null;
this.selectDelay = null;
if (graph.aggregate)
@ -43,7 +43,27 @@ Display.prototype.shutdown = function () {
this.elt.unbind('plotclick');
this.elt.unbind('plotselected');
this.elt.unbind('dblclick');
if (this.hovering) {
this.hovering.remove();
this.hovering = null;
}
this.detachTips();
this.plot = null;
this.graph = null;
}
Display.prototype.shouldRefresh = function () {
if (this.graph) {
for (var i = 0; i < this.attachedTips.length; i++) {
var tooltip = this.attachedTips[i];
if (tooltip.attached())
return false;
}
if (this.zoomInfo.level != 'aggregate')
return false;
this.shutdown();
}
return true;
}
Display.prototype.setHistoricalMidpoint = function () {
@ -334,6 +354,7 @@ Display.prototype.unzoom = function () {
this.plot.enableSelection();
this.plot.clearSelection();
this.detachTips();
this.zoomInfo.level = 'aggregate';
}
Display.prototype.detachTips = function () {

Просмотреть файл

@ -71,6 +71,7 @@
<li>Use the "view" menu to drill down into individual benchmarks.</li>
<li>You can click and highlight any area of any graph to zoom in. It might pause to download data.</li>
<li>You can unzoom by double-clicking inside a graph.</li>
<li>A graph will refresh every 5 minutes if it is not zoomed in and has no attached tooltips.</li>
</ul>
<strong>FAQ:</strong>
<ul>

Просмотреть файл

@ -9,7 +9,7 @@ function ToolTip(x, y, item, contents)
this.contents = contents;
}
ToolTip.prototype.drawFloating = function () {
ToolTip.prototype.drawFloating = function (list) {
var text = '<div class="tooltip closeable"></div>';
this.elt = $(text);
@ -88,6 +88,12 @@ ToolTip.prototype.draw = function (expanded) {
this.elt.appendTo('body').fadeIn(200);
}
ToolTip.prototype.attached = function () {
if (this.svg)
return true;
return false;
}
ToolTip.prototype.detach = function () {
if (this.svg) {
this.svg.remove();