diff options
Diffstat (limited to 'qooxdoo/source/class')
-rw-r--r-- | qooxdoo/source/class/Smokeping/Application.js | 26 | ||||
-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.js | 5 | ||||
-rw-r--r-- | qooxdoo/source/class/Smokeping/ui/GraphList.js | 16 | ||||
-rw-r--r-- | qooxdoo/source/class/Smokeping/ui/Mover.js | 8 | ||||
-rw-r--r-- | qooxdoo/source/class/Smokeping/ui/Navigator.js | 26 | ||||
-rw-r--r-- | qooxdoo/source/class/Smokeping/ui/TargetTree.js | 39 |
7 files changed, 62 insertions, 92 deletions
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' ){ |