summaryrefslogtreecommitdiffstats
path: root/qooxdoo
diff options
context:
space:
mode:
Diffstat (limited to 'qooxdoo')
-rw-r--r--qooxdoo/Makefile2
-rw-r--r--qooxdoo/source/class/Smokeping/Application.js26
-rw-r--r--qooxdoo/source/class/Smokeping/Server.js (renamed from qooxdoo/source/class/Smokeping/io/Rpc.js)34
-rw-r--r--qooxdoo/source/class/Smokeping/ui/Graph.js5
-rw-r--r--qooxdoo/source/class/Smokeping/ui/GraphList.js16
-rw-r--r--qooxdoo/source/class/Smokeping/ui/Mover.js8
-rw-r--r--qooxdoo/source/class/Smokeping/ui/Navigator.js26
-rw-r--r--qooxdoo/source/class/Smokeping/ui/TargetTree.js39
-rwxr-xr-xqooxdoo/source/jsonrpc.cgi26
-rwxr-xr-xqooxdoo/source/smokeping.cgi73
10 files changed, 136 insertions, 119 deletions
diff --git a/qooxdoo/Makefile b/qooxdoo/Makefile
index 16598db..8af3baf 100644
--- a/qooxdoo/Makefile
+++ b/qooxdoo/Makefile
@@ -50,7 +50,7 @@ APPLICATION_NAMESPACE = Smokeping
# Files that will be copied from the source directory into the build
# directory (space separated list). The default list is empty.
#
-APPLICATION_FILES = index.html jsonrpc.cgi perl grapher.cgi
+APPLICATION_FILES = index.html smokeping.cgi perl
# APPLICATION_BUILD_LOG_LEVEL = debug
APPLICATION_BUILD_LOG_LEVEL = off
diff --git a/qooxdoo/source/class/Smokeping/Application.js b/qooxdoo/source/class/Smokeping/Application.js
index 90e2f32..917b608 100644
--- a/qooxdoo/source/class/Smokeping/Application.js
+++ b/qooxdoo/source/class/Smokeping/Application.js
@@ -21,38 +21,38 @@ qx.Class.define('Smokeping.Application',
'SP', qx.core.Setting.get('Smokeping.resourceUri')
);
- // this will provide access to the server side of this app
-// var rpc = new Smokeping.io.Rpc('http://localhost/~oetiker/smq/');
- var rpc = new Smokeping.io.Rpc('http://johan.oetiker.ch/~oetiker/smq/');
-
- var base_url = rpc.getBaseUrl();
-
- var prime = new qx.ui.layout.VerticalBoxLayout();
- with(prime){
+ // if we run with a file:// url make sure
+ // the app finds the smokeping service (smokeping.cgi)
+ Smokeping.Server.getInstance().setLocalUrl(
+ 'http://localhost/~oetiker/smq/'
+ );
+
+ var base_layout = new qx.ui.layout.VerticalBoxLayout();
+ with(base_layout){
setPadding(8);
setLocation(0,0);
setWidth('100%');
setHeight('100%');
setSpacing(10);
};
- prime.addToDocument();
+ base_layout.addToDocument();
var title = new qx.ui.basic.Atom(this.tr('Smokeping Viewer'));
with(title){
setTextColor('#b0b0b0');
setFont(qx.ui.core.Font.fromString('16px bold sans-serif'));
}
- prime.add(title);
+ base_layout.add(title);
var splitpane = new qx.ui.splitpane.HorizontalSplitPane(200, '1*');
splitpane.setEdge(0);
splitpane.setHeight('1*');
splitpane.setShowKnob(true);
- prime.add(splitpane);
+ base_layout.add(splitpane);
- var tree = new Smokeping.ui.TargetTree(rpc);
+ var tree = new Smokeping.ui.TargetTree();
splitpane.addLeft(tree);
- var graphlist = new Smokeping.ui.GraphList(rpc.getBaseUrl());
+ var graphlist = new Smokeping.ui.GraphList();
splitpane.addRight(graphlist);
diff --git a/qooxdoo/source/class/Smokeping/io/Rpc.js b/qooxdoo/source/class/Smokeping/Server.js
index 327d2c4..ebc938d 100644
--- a/qooxdoo/source/class/Smokeping/io/Rpc.js
+++ b/qooxdoo/source/class/Smokeping/Server.js
@@ -6,9 +6,10 @@
* A smokeping specific rpc call which works
*/
-qx.Class.define('Smokeping.io.Rpc',
+qx.Class.define('Smokeping.Server',
{
extend: qx.io.remote.Rpc,
+ type: "singleton",
/*
*****************************************************************************
@@ -25,25 +26,10 @@ qx.Class.define('Smokeping.io.Rpc',
with(this){
base(arguments);
setTimeout(7000000);
- setUrl('jsonrpc.cgi');
+ setUrl('smokeping.cgi');
setServiceName('Smokeping');
}
-
- var our_href = new String(document.location.href);
- var last_slash = our_href.lastIndexOf("/");
- this.__base_url = our_href.substring(0,last_slash+1);
-
- // look for services on the localhost if we access the
- // application locally
-
- if ( document.location.host === '' ) {
- with(this){
- __base_url = local_url;
- setUrl(__base_url + 'jsonrpc.cgi');
- setCrossDomain(true);
- }
- }
-
+
return this;
},
@@ -74,7 +60,17 @@ qx.Class.define('Smokeping.io.Rpc',
getBaseUrl: function(){
return this.__base_url;
- }
+ },
+
+ setLocalUrl: function(local_url){
+ if ( document.location.host === '' ) {
+ with(this){
+ setUrl(local_url+'smokeping.cgi');
+ setCrossDomain(true);
+ }
+ }
+ }
+
}
});
diff --git a/qooxdoo/source/class/Smokeping/ui/Graph.js b/qooxdoo/source/class/Smokeping/ui/Graph.js
index 1d12cdf..506f158 100644
--- a/qooxdoo/source/class/Smokeping/ui/Graph.js
+++ b/qooxdoo/source/class/Smokeping/ui/Graph.js
@@ -20,7 +20,7 @@ qx.Class.define('Smokeping.ui.Graph',
*/
/**
- * @param object {GraphShadow} What happens when the SNCF conductors tamazing.
+ * @param object {file} What happens when the SNCF conductors tamazing.
*
*/
@@ -43,7 +43,8 @@ qx.Class.define('Smokeping.ui.Graph',
this._highlight();
var loader = new Smokeping.ui.LoadingAnimation();
this.add(loader);
- this._preloader = qx.io.image.PreloaderManager.getInstance().create(this._graph.getSrc());
+ this._preloader = qx.io.image.PreloaderManager.getInstance().create(Smokeping.Server.getInstance().getUrl()
+ + '?g='+graph+';s=now-1d;e=now;t=100000;b=0;w=200;h=100');
if (this._preloader.isLoaded()){
qx.client.Timer.once(this._image_loader,this,0);
} else {
diff --git a/qooxdoo/source/class/Smokeping/ui/GraphList.js b/qooxdoo/source/class/Smokeping/ui/GraphList.js
index 5d9bc58..c49b601 100644
--- a/qooxdoo/source/class/Smokeping/ui/GraphList.js
+++ b/qooxdoo/source/class/Smokeping/ui/GraphList.js
@@ -21,7 +21,7 @@ qx.Class.define('Smokeping.ui.GraphList',
*
*/
- construct: function (url) {
+ construct: function () {
with(this){
base(arguments);
@@ -36,7 +36,6 @@ qx.Class.define('Smokeping.ui.GraphList',
padding: 10
})
};
- this._url = url;
qx.event.message.Bus.subscribe('sp.menu.folder',this._load_graphs,this);
},
@@ -45,18 +44,7 @@ qx.Class.define('Smokeping.ui.GraphList',
var files = m.getData()
this.removeAll();
for(var i=0;i<files.length;i++){
- var shadow = new Smokeping.GraphShadow();
- shadow.set({
- width: 150,
- height: 75,
- start: Math.round((new Date()).getTime()/1000)-(3600*24*3),
- end: Math.round((new Date()).getTime()/1000),
- top: 1000000,
- bottom: 0,
- cgi: this._url + 'grapher.cgi',
- data: files[i]
- });
- var image = new Smokeping.ui.Graph(shadow);
+ var image = new Smokeping.ui.Graph(files[i]);
this.add(image);
}
}
diff --git a/qooxdoo/source/class/Smokeping/ui/Mover.js b/qooxdoo/source/class/Smokeping/ui/Mover.js
index f212708..2d1d5f0 100644
--- a/qooxdoo/source/class/Smokeping/ui/Mover.js
+++ b/qooxdoo/source/class/Smokeping/ui/Mover.js
@@ -36,11 +36,13 @@ qx.Class.define('Smokeping.ui.Mover',
construct: function (target,src,width,height,top,right,start,end) {
this._target = target;
- this._width = width;
this._src = src;
- this._height = height; // some where the calc is 1 off. this fixes it
+ this._width = width;
+ this._height = height;
this._top = top;
this._right = right;
+ this._start = start;
+ this._end = end;
with(this){
base(arguments);
set({
@@ -81,7 +83,7 @@ qx.Class.define('Smokeping.ui.Mover',
width: this._width,
height: this._height+17,
left: this._width * i,
- source: this._src+';w='+this._width+';h='+this._height+';s='+(this._start+(duration*(i-2)))+'e='+(this._end+(duration*(i-2)))
+ source: this._src+';w='+this._width+';h='+this._height+';s='+(this._start+(duration*(i-2)))+';e='+(this._end+(duration*(i-2)))
});
this.add(tile);
}
diff --git a/qooxdoo/source/class/Smokeping/ui/Navigator.js b/qooxdoo/source/class/Smokeping/ui/Navigator.js
index dc28d3e..eb799e7 100644
--- a/qooxdoo/source/class/Smokeping/ui/Navigator.js
+++ b/qooxdoo/source/class/Smokeping/ui/Navigator.js
@@ -23,23 +23,26 @@ qx.Class.define('Smokeping.ui.Navigator',
construct: function (graph) {
this._graph = graph;
-
with(this){
base(arguments,tr("Smokeping Graph Navigator"));
set({
showMaximize: false,
showMinimize: false,
- width: graph.getWidth(),
- height: graph.getHeight(),
- minWidth: 120,
- minHeight: 80,
+ width: 300,
+ height: 200,
+ minWidth: 300,
+ minHeight: 200,
backgroundColor: '#f0f0f0'
});
}
+ this._graph_width = 300;
+ this._graph_height = 200;
this._lastrun = 0;
this._loader = new Smokeping.ui.LoadingAnimation();
+ this._url = Smokeping.Server.getInstance().getUrl();
this._update_image();
},
+
members: {
// resizable objects have a changeWidth method
// which we can override to take part in the fun
@@ -52,6 +55,7 @@ qx.Class.define('Smokeping.ui.Navigator',
this._graph_width = this._graph_width + diff;
qx.client.Timer.once(this._update_image,this,250);
},
+
_changeHeight: function(newHeight) {
var diff = newHeight - this.getBoxHeight();
this.base(arguments, newHeight);
@@ -60,10 +64,15 @@ qx.Class.define('Smokeping.ui.Navigator',
qx.client.Timer.once(this._update_image,this,250);
},
+
+ _get_url: function(){
+ return this._url+ '?g='+this._graph+';s=now-1d;e=now;t=100000;b=0;w='+this._graph_width+';h='+this._graph_height;
+ },
+
_update_image: function(){
var now = (new Date()).getTime();
if (this._lastrun + 1000 < now) {
- this._preloader = qx.io.image.PreloaderManager.getInstance().create(this._graph.getSrc());
+ this._preloader = qx.io.image.PreloaderManager.getInstance().create(this._get_url())
if (this._preloader.isLoaded()){
qx.client.Timer.once(this._show_image,this,0);
} else {
@@ -75,6 +84,7 @@ qx.Class.define('Smokeping.ui.Navigator',
this.debug('Skipping update since previous update less tahn 1 second')
}
},
+
_show_image: function(e){
with(this){
set({
@@ -86,9 +96,9 @@ qx.Class.define('Smokeping.ui.Navigator',
qx.io.image.PreloaderManager.getInstance().remove(this._preloader);
removeAll();
add(image);
- var zoomer = new Smokeping.ui.Zoomer(image,this._graph,33,30);
+ var zoomer = new Smokeping.ui.Zoomer(image,this._graph_width,this._graph_height,33,30);
add(zoomer);
- var mover = new Smokeping.ui.Mover(image,this._graph,33,30);
+ var mover = new Smokeping.ui.Mover(image,this._url+ '?g='+this._graph,this._graph_width,this._graph_height,33,30,1201680005,1201686005);
add(mover);
}
}
diff --git a/qooxdoo/source/class/Smokeping/ui/TargetTree.js b/qooxdoo/source/class/Smokeping/ui/TargetTree.js
index fbd5004..0e97a08 100644
--- a/qooxdoo/source/class/Smokeping/ui/TargetTree.js
+++ b/qooxdoo/source/class/Smokeping/ui/TargetTree.js
@@ -16,14 +16,8 @@ qx.Class.define('Smokeping.ui.TargetTree',
*****************************************************************************
*/
- /**
- * @param root_node {String} Name of the root node
- * where will we find our RPC server.
- *
- * @param rpc {rpcObject} An rpc object providing access to the Smokeping service
- */
- construct: function (rpc) {
+ construct: function () {
with(this){
base(arguments,'root node');
set({
@@ -42,14 +36,14 @@ qx.Class.define('Smokeping.ui.TargetTree',
if (exc == null){
var nodes = data.length;
for(var i=0;i<nodes;i++){
- Smokeping.ui.TargetTree._fill_folder(self,data[i]);
+ self._fill_folder(self,data[i]);
}
}
else {
alert(exc);
}
};
- rpc.callAsync(fill_tree,'get_tree');
+ Smokeping.Server.getInstance().callAsync(fill_tree,'get_tree');
},
/*
@@ -57,26 +51,7 @@ qx.Class.define('Smokeping.ui.TargetTree',
Statics
*****************************************************************************
*/
-
- statics :
- {
-
- /*
- ---------------------------------------------------------------------------
- CORE METHODS
- ---------------------------------------------------------------------------
- */
-
- /**
- * Create the tree based on input from the Server
- *
- * @type member
- *
- * @param {void}
- *
- * @return BaseUrl {Strings}
- */
-
+ members: {
_fill_folder: function(node,data){
// in data[0] we have the id of the folder
@@ -86,7 +61,7 @@ qx.Class.define('Smokeping.ui.TargetTree',
var length = data.length;
for (var i=2;i<length;i++){
if(qx.util.Validation.isValidArray(data[i])){
- Smokeping.ui.TargetTree._fill_folder(folder,data[i]);
+ this._fill_folder(folder,data[i]);
} else {
i++; // skip the node id for now
var file = new qx.ui.tree.TreeFile(data[i]);
@@ -95,10 +70,8 @@ qx.Class.define('Smokeping.ui.TargetTree',
}
}
folder.setUserData('ids',files);
- }
+ },
- },
- members: {
_send_event: function(e) {
if (e.getData().length > 0) {
if ( e.getData()[0].basename == 'TreeFolder' ){
diff --git a/qooxdoo/source/jsonrpc.cgi b/qooxdoo/source/jsonrpc.cgi
deleted file mode 100755
index 372273d..0000000
--- a/qooxdoo/source/jsonrpc.cgi
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/sepp/bin/perl-5.8.8 -w
-use strict;
-use lib qw( perl );
-
-use CGI;
-use CGI::Session;
-use Qooxdoo::JSONRPC;
-
-$Qooxdoo::JSONRPC::debug=1;
-
-# Change this space-separated list of directories to include
-# Qooxdoo::JSONRPC.pm and co-located Services
-
-# If this module can't be found, the previous line is incorrect
-
-# Instantiating the CGI module which parses the HTTP request
-
-my $cgi = new CGI;
-my $session = new CGI::Session;
-
-# You can customise this harness here to handle cases before treating
-# the request as being JSON-RPC
-
-Qooxdoo::JSONRPC::handle_request ($cgi, $session);
-
-
diff --git a/qooxdoo/source/smokeping.cgi b/qooxdoo/source/smokeping.cgi
new file mode 100755
index 0000000..6af461d
--- /dev/null
+++ b/qooxdoo/source/smokeping.cgi
@@ -0,0 +1,73 @@
+#!/usr/sepp/bin/perl-5.8.8 -w
+use strict;
+use lib qw( perl );
+
+use CGI;
+use CGI::Session;
+use Qooxdoo::JSONRPC;
+use lib qw(/home/oetiker/scratch/rrd-13dev/lib/perl);
+use lib qw(/usr/pack/rrdtool-1.2.23-mo/lib/perl/);
+use RRDs;
+
+$Qooxdoo::JSONRPC::debug=1;
+
+# Change this space-separated list of directories to include
+# Qooxdoo::JSONRPC.pm and co-located Services
+
+# If this module can't be found, the previous line is incorrect
+
+# Instantiating the CGI module which parses the HTTP request
+
+my $cgi = new CGI;
+my $session = new CGI::Session;
+
+# You can customise this harness here to handle cases before treating
+# the request as being JSON-RPC
+if ($cgi->param('g')){
+ my $graph = $cgi->param('g');
+ my $width = $cgi->param('w');
+ my $height = $cgi->param('h');
+ my $start = $cgi->param('s');
+ my $end = $cgi->param('e');
+ my $top = $cgi->param('t');
+ my $bottom = $cgi->param('b');
+ warn "groesse: $width $height\n";
+ RRDs::graph("/tmp/$$.tmpgraph",
+ '--title' => "Demo ".$graph,
+ '--vertical-label' => "Bytes/s",
+ '--start' => $start,
+ '--end' => $end,
+ '--upper-limit' => $top,
+ '--lower-limit' => $bottom,
+ '--rigid',
+# '--zoom' => '0.75',
+ '--width' => $width,
+ '--height' => $height,
+ '--color' => 'BACK#f0f0f0ff',
+ '--color' => 'SHADEA#f0f0f0ff',
+ '--color' => 'SHADEB#f0f0f0ff',
+ 'DEF:in=lan.rrd:out:AVERAGE',
+ 'CDEF:green=in,100000,LT,in,100000,IF',
+ 'AREA:green#00ff00',
+ 'CDEF:red=in,50000,LT,in,50000,IF',
+ 'AREA:red#ff0000',
+ 'LINE1:in#2020ff:Input',
+ 'CDEF:flip=LTIME,172800,%,86400,LT,in,UNKN,IF',
+ 'AREA:flip#00000088');
+ my $ERROR = RRDs::error();
+ die $ERROR if $ERROR;
+ if (open (my $fh,"</tmp/$$.tmpgraph")){
+ local $/=undef;
+ my $image = <$fh>;
+ unlink "/tmp/$$.tmpgraph";
+ close $fh;
+ print "Content-Type: image/png\n";
+ print "Expires: Thu, 15 Apr 2010 20:00:00 GMT\n";
+ print "Length: ".length($image)."\n";
+ print "\n";
+ print $image;
+ };
+} else {
+ Qooxdoo::JSONRPC::handle_request ($cgi, $session);
+}
+