From 74783005860524bbdf1be4fe0ec2924e650c1652 Mon Sep 17 00:00:00 2001 From: Tobi Oetiker Date: Wed, 30 Jan 2008 17:02:27 +0000 Subject: updated ... working --- qooxdoo/Makefile | 2 +- qooxdoo/source/class/Smokeping/Application.js | 26 ++++---- qooxdoo/source/class/Smokeping/Server.js | 76 +++++++++++++++++++++++ qooxdoo/source/class/Smokeping/io/Rpc.js | 80 ------------------------- qooxdoo/source/class/Smokeping/ui/Graph.js | 5 +- qooxdoo/source/class/Smokeping/ui/GraphList.js | 16 +---- qooxdoo/source/class/Smokeping/ui/Mover.js | 8 ++- qooxdoo/source/class/Smokeping/ui/Navigator.js | 26 +++++--- qooxdoo/source/class/Smokeping/ui/TargetTree.js | 39 ++---------- qooxdoo/source/jsonrpc.cgi | 26 -------- qooxdoo/source/smokeping.cgi | 73 ++++++++++++++++++++++ 11 files changed, 197 insertions(+), 180 deletions(-) create mode 100644 qooxdoo/source/class/Smokeping/Server.js delete mode 100644 qooxdoo/source/class/Smokeping/io/Rpc.js delete mode 100755 qooxdoo/source/jsonrpc.cgi create mode 100755 qooxdoo/source/smokeping.cgi 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/Server.js b/qooxdoo/source/class/Smokeping/Server.js new file mode 100644 index 0000000..ebc938d --- /dev/null +++ b/qooxdoo/source/class/Smokeping/Server.js @@ -0,0 +1,76 @@ +/* ************************************************************************ +#module(Smokeping) +************************************************************************ */ + +/** + * A smokeping specific rpc call which works + */ + +qx.Class.define('Smokeping.Server', +{ + extend: qx.io.remote.Rpc, + type: "singleton", + + /* + ***************************************************************************** + CONSTRUCTOR + ***************************************************************************** + */ + + /** + * @param local_url {String} When running the application in file:// mode. + * where will we find our RPC server. + */ + construct: function (local_url) { + + with(this){ + base(arguments); + setTimeout(7000000); + setUrl('smokeping.cgi'); + setServiceName('Smokeping'); + } + + return this; + }, + + /* + ***************************************************************************** + MEMBERS + ***************************************************************************** + */ + + members : + { + + /* + --------------------------------------------------------------------------- + CORE METHODS + --------------------------------------------------------------------------- + */ + + /** + * Tell about the BaseUrl we found. + * + * @type member + * + * @param {void} + * + * @return BaseUrl {Strings} + */ + + 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/io/Rpc.js b/qooxdoo/source/class/Smokeping/io/Rpc.js deleted file mode 100644 index 327d2c4..0000000 --- a/qooxdoo/source/class/Smokeping/io/Rpc.js +++ /dev/null @@ -1,80 +0,0 @@ -/* ************************************************************************ -#module(Smokeping) -************************************************************************ */ - -/** - * A smokeping specific rpc call which works - */ - -qx.Class.define('Smokeping.io.Rpc', -{ - extend: qx.io.remote.Rpc, - - /* - ***************************************************************************** - CONSTRUCTOR - ***************************************************************************** - */ - - /** - * @param local_url {String} When running the application in file:// mode. - * where will we find our RPC server. - */ - construct: function (local_url) { - - with(this){ - base(arguments); - setTimeout(7000000); - setUrl('jsonrpc.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; - }, - - /* - ***************************************************************************** - MEMBERS - ***************************************************************************** - */ - - members : - { - - /* - --------------------------------------------------------------------------- - CORE METHODS - --------------------------------------------------------------------------- - */ - - /** - * Tell about the BaseUrl we found. - * - * @type member - * - * @param {void} - * - * @return BaseUrl {Strings} - */ - - getBaseUrl: function(){ - return this.__base_url; - } - } -}); - 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 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,"; + 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); +} + -- cgit v1.2.3-24-g4f1b