Add automatic refresh support back.
This commit is contained in:
Родитель
31a5c3c6e0
Коммит
bc9f2d0ef7
|
@ -2,7 +2,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
var AWFY = { };
|
var AWFY = { };
|
||||||
|
|
||||||
AWFY.refreshTime = 1000 * 60 * 5;
|
AWFY.refreshTime = 60 * 5;
|
||||||
AWFY.machineId = 0;
|
AWFY.machineId = 0;
|
||||||
AWFY.hasLegend = false;
|
AWFY.hasLegend = false;
|
||||||
AWFY.panes = [];
|
AWFY.panes = [];
|
||||||
|
@ -12,6 +12,7 @@ AWFY.xhr = [];
|
||||||
AWFY.view = 'none';
|
AWFY.view = 'none';
|
||||||
AWFY.suiteName = null;
|
AWFY.suiteName = null;
|
||||||
AWFY.lastHash = null;
|
AWFY.lastHash = null;
|
||||||
|
AWFY.lastRefresh = 0;
|
||||||
|
|
||||||
AWFY.request = function (files, callback) {
|
AWFY.request = function (files, callback) {
|
||||||
var url = window.location.protocol + '//' +
|
var url = window.location.protocol + '//' +
|
||||||
|
@ -102,11 +103,13 @@ AWFY.displayNewGraph = function (name, graph) {
|
||||||
var elt = $('#' + name + '-graph');
|
var elt = $('#' + name + '-graph');
|
||||||
var display = elt.data('awfy-display');
|
var display = elt.data('awfy-display');
|
||||||
if (!display) {
|
if (!display) {
|
||||||
display = new Display(this, name, elt, graph);
|
display = new Display(this, name, elt);
|
||||||
elt.data('awfy-display', display);
|
elt.data('awfy-display', display);
|
||||||
}
|
}
|
||||||
display.setup(graph);
|
if (display.shouldRefresh()) {
|
||||||
display.draw();
|
display.setup(graph);
|
||||||
|
display.draw();
|
||||||
|
}
|
||||||
this.aggregate[name] = graph;
|
this.aggregate[name] = graph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,6 +437,7 @@ AWFY.showOverview = function () {
|
||||||
];
|
];
|
||||||
|
|
||||||
this.request(['aggregate-' + this.machineId], this.computeAggregate.bind(this));
|
this.request(['aggregate-' + this.machineId], this.computeAggregate.bind(this));
|
||||||
|
this.lastRefresh = Date.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
AWFY.showBreakdown = function (name) {
|
AWFY.showBreakdown = function (name) {
|
||||||
|
@ -476,12 +480,10 @@ AWFY.showBreakdown = function (name) {
|
||||||
var file = 'bk-aggregate-' + id + '-' + this.machineId;
|
var file = 'bk-aggregate-' + id + '-' + this.machineId;
|
||||||
this.request([file], callback);
|
this.request([file], callback);
|
||||||
}
|
}
|
||||||
|
this.lastRefresh = Date.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
AWFY.changeMachine = function (machine_id) {
|
AWFY.requestRedraw = function () {
|
||||||
this.reset(this.view);
|
|
||||||
this.machineId = machine_id;
|
|
||||||
|
|
||||||
if (this.view == 'overview') {
|
if (this.view == 'overview') {
|
||||||
this.request(['aggregate-' + this.machineId],
|
this.request(['aggregate-' + this.machineId],
|
||||||
this.computeAggregate.bind(this));
|
this.computeAggregate.bind(this));
|
||||||
|
@ -499,6 +501,13 @@ AWFY.changeMachine = function (machine_id) {
|
||||||
this.request([file], callback);
|
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) {
|
AWFY.reset = function (view) {
|
||||||
|
@ -531,6 +540,12 @@ AWFY.onHashChange = function () {
|
||||||
this.parseURL();
|
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 () {
|
AWFY.parseURL = function () {
|
||||||
if (this.lastHash == window.location.hash)
|
if (this.lastHash == window.location.hash)
|
||||||
return;
|
return;
|
||||||
|
@ -707,5 +722,7 @@ AWFY.startup = function () {
|
||||||
|
|
||||||
$(window).hashchange(this.onHashChange.bind(this));
|
$(window).hashchange(this.onHashChange.bind(this));
|
||||||
$(window).bind('popstate', 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:
|
// vim: set ts=4 sw=4 tw=99 et:
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function Display(awfy, id, elt, graph)
|
function Display(awfy, id, elt)
|
||||||
{
|
{
|
||||||
this.awfy = awfy;
|
this.awfy = awfy;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.elt = elt;
|
this.elt = elt;
|
||||||
this.attachedTips = [];
|
this.attachedTips = [];
|
||||||
|
this.graph = null;
|
||||||
|
this.plot = null;
|
||||||
|
this.hovering = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Display.prototype.setup = function (graph) {
|
Display.prototype.setup = function (graph) {
|
||||||
this.graph = graph;
|
this.graph = graph;
|
||||||
|
|
||||||
// The last hovering tooltip we displayed, that has not been clicked.
|
|
||||||
this.hovering = null;
|
|
||||||
|
|
||||||
this.selectDelay = null;
|
this.selectDelay = null;
|
||||||
|
|
||||||
if (graph.aggregate)
|
if (graph.aggregate)
|
||||||
|
@ -43,7 +43,27 @@ Display.prototype.shutdown = function () {
|
||||||
this.elt.unbind('plotclick');
|
this.elt.unbind('plotclick');
|
||||||
this.elt.unbind('plotselected');
|
this.elt.unbind('plotselected');
|
||||||
this.elt.unbind('dblclick');
|
this.elt.unbind('dblclick');
|
||||||
|
if (this.hovering) {
|
||||||
|
this.hovering.remove();
|
||||||
|
this.hovering = null;
|
||||||
|
}
|
||||||
this.detachTips();
|
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 () {
|
Display.prototype.setHistoricalMidpoint = function () {
|
||||||
|
@ -334,6 +354,7 @@ Display.prototype.unzoom = function () {
|
||||||
this.plot.enableSelection();
|
this.plot.enableSelection();
|
||||||
this.plot.clearSelection();
|
this.plot.clearSelection();
|
||||||
this.detachTips();
|
this.detachTips();
|
||||||
|
this.zoomInfo.level = 'aggregate';
|
||||||
}
|
}
|
||||||
|
|
||||||
Display.prototype.detachTips = function () {
|
Display.prototype.detachTips = function () {
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
<li>Use the "view" menu to drill down into individual benchmarks.</li>
|
<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 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>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>
|
</ul>
|
||||||
<strong>FAQ:</strong>
|
<strong>FAQ:</strong>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
@ -9,7 +9,7 @@ function ToolTip(x, y, item, contents)
|
||||||
this.contents = contents;
|
this.contents = contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolTip.prototype.drawFloating = function () {
|
ToolTip.prototype.drawFloating = function (list) {
|
||||||
var text = '<div class="tooltip closeable"></div>';
|
var text = '<div class="tooltip closeable"></div>';
|
||||||
this.elt = $(text);
|
this.elt = $(text);
|
||||||
|
|
||||||
|
@ -88,6 +88,12 @@ ToolTip.prototype.draw = function (expanded) {
|
||||||
this.elt.appendTo('body').fadeIn(200);
|
this.elt.appendTo('body').fadeIn(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ToolTip.prototype.attached = function () {
|
||||||
|
if (this.svg)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ToolTip.prototype.detach = function () {
|
ToolTip.prototype.detach = function () {
|
||||||
if (this.svg) {
|
if (this.svg) {
|
||||||
this.svg.remove();
|
this.svg.remove();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче