Permalink
Browse files

Contribution by Andrew Tinits

  • Loading branch information...
1 parent be71f25 commit 136ae248b93380549a52e2b507961e3d25f7b7cd Andrew Tinits committed with jolynch Aug 17, 2012
View
@@ -1,5 +1,5 @@
._*
*.pyc
-
+*.sqlite
*.yaml
!config.yaml.example
View
@@ -1,15 +1,15 @@
from __future__ import with_statement
import datetime
-
+import hashlib
import re
import signal
import simplejson as json
import socket
import sqlite3
-
+import sys
import time
import util
@@ -93,7 +93,7 @@ def get_params(self):
'area_graph': area_graph}}
-
+class DataHandler(GraphBaseHandler):
"""Handler for json graph data"""
@token_authed
@@ -1,10 +1,10 @@
import colorsys
-
+import math
import os
import os.path
import subprocess
-
-
+import tornado.web
+import xml.etree.cElementTree as ET
import firefly.data_source
@@ -3,8 +3,8 @@ html, body {height:100%;padding:0; margin:0; overflow-y:auto;overflow-x:hidden;}
html {font-family:"Inconsolata",sans-serif;background:#fff url(../img/stripez5.png);background:#222 url(../img/stripez4.png);}
body, input {color:#666;}
a, button.pseudo-link {color:#aaa;cursor:pointer;text-decoration:none;border:0;background:0;padding:0;}
-
-
+a:hover, button.pseudo-link:hover {color:#0cf;}
+a:focus, button.pseudo-link:focus, button.pseudo-link::-moz-focus-inner {outline:none;border:0;}
/** main graph table **/
.graphs {height:100%;}
@@ -14,7 +14,7 @@ a, button.pseudo-link {color:#aaa;cursor:pointer;text-decoration:none;border:0;b
.graph .graph-content-container {overflow:hidden; position:relative;}
#graphs .graph h2 {display:none;}
-
+.graph .graph-title {padding:5px;min-height:1em;}
#graphs .graph .graph-title {z-index:0;position:absolute;background-color:rgba(32, 32, 32, 0.6);}
.graph .actual-graph {line-height:0;}
@@ -24,16 +24,16 @@ a, button.pseudo-link {color:#aaa;cursor:pointer;text-decoration:none;border:0;b
.legend .color {width:1em;height:1em;float:left;margin-right:2px;margin-bottom:5px;}
.legend .sourcename {padding-left:5px;}
-
+/** graphedit dialog **/
.graphedit {width:95%; min-width:916px; height:90%; min-height:500px;background:#222 url(../img/stripez4.png);border-radius:3px;box-shadow:5px 5px 10px #222;}
-
-
-
+.graphedit *::-webkit-scrollbar {width: 12px;}
+.graphedit *::-webkit-scrollbar-track {border-radius: 10px;-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);background-color: rgba(200, 200, 200, 0.2);}
+.graphedit *::-webkit-scrollbar-thumb {border-radius: 10px;-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.8);}
.graphedit .pane {float:left;}
.graphedit .controls > h2, .graphedit .temp-graph > h2 {border-left:1px solid #222;}
.graphedit .pane > h2 {margin:0;padding:10px;border-bottom:1px solid #222;}
-
+.graphedit .pane > div {padding:0px 10px 0;margin-top:10px;overflow-y:auto;}
.graphedit .data-sources {width:30%;}
.graphedit .temp-graph {width:45%;}
@@ -43,29 +43,29 @@ a, button.pseudo-link {color:#aaa;cursor:pointer;text-decoration:none;border:0;b
.graphedit .graph h2 {display:block;font-size:1.0em;margin-bottom:5px;}
.graphedit .graph .graph-title-container, .graphedit .graph .graph-region-container {margin-bottom:10px;}
.graphedit .graph .graph-title {position:static;}
-
-
+.graphedit .controls label:hover {cursor:pointer;color:#0cf;}
+.graphedit .controls span {margin-left:4px;}
.graphedit .source-selector {cursor:move;background-color:rgba(200,200,200,0.2);margin-bottom:5px;padding:5px;border:1px solid #222;border-radius:3px;}
.graphedit .source-selector:last-of-type {margin-bottom:0;}
-
+.graphedit select {float:left;clear:left;width:300px;}
.graphedit .source-selector footer {clear:left;text-align:right;}
.graphedit .source-selector footer button {margin-left:10px;}
-
+.graphedit .footer {position:absolute;bottom:10px;right:10px;}
.graphedit .footer button {padding:10px;margin-left:10px;border:1px solid #222;border-radius:3px;}
+.graphedit .footer button[rel="save-edits"] {background-color:rgba(200,200,200,0.2)}
-
-
+/** context menu **/
.contextmenu {position: absolute;font-size: 14px;cursor: default;white-space: nowrap;border-radius: 3px;background: #222;border: 1px solid #111;box-shadow: 2px 2px 5px #111;}
+.contextmenu span, .contextmenu a {padding: 2px 5px 2px 10px;}
+.contextmenu span.header {padding-left: 5px;}
+.contextmenu a {display: block;}
-
-
-
-
-
-
-
-
+/** SVG styles **/
+.line {fill: none;}
+.current {stroke-width: 1.5;}
+.previous {stroke-dasharray: 3,2;}
+.area {fill-opacity: 0.4;}
.guide-line {stroke-width: 1; stroke: #aaa}
.guide-dots circle {fill: red;}
@@ -76,11 +76,11 @@ a, button.pseudo-link {color:#aaa;cursor:pointer;text-decoration:none;border:0;b
.guide-tooltip .historical {color: #aaa;}
.guide-tooltip {white-space: nowrap;}
-
+.axis {shape-rendering: crispEdges;}
.axis text {fill: #bbb;}
.axis line {stroke: #444;}
-
-
+.x.axis line.minor {stroke-opacity: 0.5;}
+.axis .domain {fill: none;}
.annotation {fill: none; stroke-width: 1; stroke: #ff3; stroke-opacity: 0.6;}
.annotation-tooltip {position: absolute; background-color: #ff3; color: #000; padding: 2px;font-size:0.7em;font-weight:bold; opacity:0.7; white-space: nowrap; line-height:1; margin-left:10px;}
@@ -207,7 +207,7 @@ firefly.Graph.prototype.setDOMAsPopulated = function() {
$(title).inplace({
'onSave': function(newTitle) {
that.setTitle(newTitle);
-
+ }
});
container.appendChild(title);
graphContainer.appendChild(container);
@@ -275,5 +275,5 @@ firefly.Graph.prototype.resizeGraph = function() {
if (this.renderer) {
this.renderer.resize();
this.renderer.render(this._sourcesNormalized, this.zoom, this._options);
-
+ }
};
@@ -163,7 +163,7 @@ firefly.Dashboard.prototype.observeEvents = function() {
dataType: 'json',
success: function(data) {
dashboard.sync(data);
-
+ }
});
}
} else {
@@ -196,7 +196,7 @@ firefly.Dashboard.prototype.unpauseUpdates_ = function() {
dashboard.iterGraphs_(function(graph) {
graph.updateGraph();
-
+ });
}, this.REGULAR_REFRESH_INTERVAL);
};
@@ -602,7 +602,7 @@ firefly.DashboardView.prototype.addTableRow = function(anchorRow, serializedGrap
for (var i=0; i < this.columnCount; i++ ) {
var cell = $('<td class="graph">');
cell.appendTo(row);
-
+ }
}
anchorRow && $(anchorRow).after(row) || $(this.tbody).prepend(row);
@@ -33,14 +33,14 @@
showSubMenu.apply(this, [children, evt]);
}
};
-
-
-
-
-
-
+ $(holder).mouseenter(evtHandlerFactory(item.children));
+ $(li).mouseleave( function () {
+ $(this).data('collapse', true);
+ var that = this;
+ var collapseMe = function() { if ( $(that).data('collapse') ) $(that).children('ul').remove(); };
+ window.setTimeout(collapseMe, 250);
});
-
+ $(li).mouseenter( function () { $(this).data('collapse', false); });
}
li.appendChild(holder);
ul.appendChild(li);
@@ -50,87 +50,87 @@
};
-
+ var showSubMenu = function(menu, evt) {
var ul = constructMenuDOM(menu, evt);
var parentMenu = $(this).closest('ul');
-
+ var parentTop = parentMenu.offset().top - $(window).scrollTop();
var thisPos = $(this).position();
-
-
+ this.parentNode.appendChild(ul);
+ var topval = (parentTop + thisPos.top > $(window).height() - $(ul).height()) ? thisPos.top - $(ul).height() + $(this).height() : thisPos.top;
$(ul).css({
'left': thisPos.left + $(parentMenu).width() + 'px',
-
-
+ 'top': topval + 'px'
+ });
};
+ var showMenu = function(menu, evt, touchMode) {
+ if (menuEl) closeMenu();
-
-
-
-
+ var ul = constructMenuDOM(menu, evt);
+ document.body.appendChild(ul);
menuEl = ul;
+ var clientY = evt.clientY || evt.originalEvent.touches[0].clientY;
+ var pageY = evt.pageY || evt.originalEvent.touches[0].pageY;
+ var pageX = evt.pageX || evt.originalEvent.touches[0].pageX;
+ if (clientY + $(ul).height() > $(window).height()) {
+ var topval = pageY - $(ul).height();
+ } else {
+ var topval = pageY;
+ }
+ $(ul).css({'left': pageX + 'px', 'top': topval + 'px'});
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ if (!touchMode) {
+ $(window).one('mousedown', function(evt) {
+ closeMenu();
+ });
+ }
+ $(menuEl).mousedown(function(evt) {
+ evt.cancelBubble = true;
+ if (evt.stopPropagation) evt.stopPropagation();
+ });
$(menuEl).click(function(evt) {
-
+ closeMenu();
});
};
-
+ var closeMenu = function(items) {
$(menuEl).remove();
menuEl = null;
};
$.fn.contextmenu = function(options) {
options = options || {};
return this.each(function() {
+ var lastStart, fingerMoved, stillTouching;
-
-
-
-
+ function checkTouchHold(start, evt) {
+ if (stillTouching && !fingerMoved && start === lastStart) {
+ showMenu(options.menu, evt, true);
}
+ }
-
-
-
+ $(this).bind("contextmenu", function(evt) {
+ if (evt.metaKey) return true;
showMenu(options.menu, evt);
return false;
});
+ $(this).bind("touchstart", function(evt) {
+ var now = Date.now();
+ lastStart = now;
+ fingerMoved = false;
+ stillTouching = true;
-
-
-
-
-
-
-
-
-
-
-
-
-
+ setTimeout(function() { checkTouchHold(now, evt); }, 1000);
+ });
+ $(this).bind("touchmove", function(evt) {
+ fingerMoved = true;
+ });
+ $(this).bind("touchend", function(evt) {
+ stillTouching = false;
+ });
});
};
}(jQuery));
@@ -205,7 +205,7 @@ firefly.Renderer.prototype.positionGuide = function() {
} else {
return d.value + ' @ ' + renderer.longDateFormatter_(d.date);
}
-
+ });
// tooltip: position it by the mouse
d3.select(this.tooltip_)
@@ -261,7 +261,7 @@ firefly.Renderer.prototype.getDataCoords_ = function(layers, axes, timeAtMouseX)
if (Math.abs(thisPoint.x - localTimeAtMouseX) > Math.abs(lastPoint.x - localTimeAtMouseX)) {
closestDataIndexToTime -= 1;
}
-
+ }
// then translate that to a pixel coord by looking it up
// and getting the x value.
@@ -361,7 +361,7 @@ firefly.Renderer.prototype._redraw = function (data) {
var sub = [];
for (var i=0;i<data.currentLayers[j].data.length;i++){
sub.push(data.currentLayers[j].data[i].x);
-
+ }
this.lastData.currentLayersXAxes.push(sub);
}
@@ -370,7 +370,7 @@ firefly.Renderer.prototype._redraw = function (data) {
var sub = [];
for (var i=0;i<data.previousLayers[j].data.length;i++){
sub.push(data.previousLayers[j].data[i].x);
-
+ }
this.lastData.previousLayersXAxes.push(sub);
}
Oops, something went wrong.

0 comments on commit 136ae24

Please sign in to comment.