diff options
Diffstat (limited to 'qooxdoo/source/class')
-rw-r--r-- | qooxdoo/source/class/Smokeping/Application.js | 22 | ||||
-rw-r--r-- | qooxdoo/source/class/Smokeping/ui/TargetTree.js | 52 |
2 files changed, 52 insertions, 22 deletions
diff --git a/qooxdoo/source/class/Smokeping/Application.js b/qooxdoo/source/class/Smokeping/Application.js index 49a151d..6578393 100644 --- a/qooxdoo/source/class/Smokeping/Application.js +++ b/qooxdoo/source/class/Smokeping/Application.js @@ -17,8 +17,8 @@ qx.Class.define( var self=this; this.base(arguments); - // this will provide access to the server side of this app - var rpc = new Smokeping.io.Rpc('http://localhost/~oetiker/smq'); + // this will provide access to the server side of this app + var rpc = new Smokeping.io.Rpc('http://localhost/~oetiker/smq/'); var base_url = rpc.getBaseUrl(); @@ -39,25 +39,23 @@ qx.Class.define( prime.add(title); var splitpane = new qx.ui.splitpane.HorizontalSplitPane('1*', '3*'); - splitpane.setEdge(1); + splitpane.setEdge(0); splitpane.setHeight('1*'); splitpane.setShowKnob(true); prime.add(splitpane); - var tree = new Smokeping.ui.TargetTree(rpc,this.tr("Root Node")); + var tree = new Smokeping.ui.TargetTree(rpc); splitpane.addLeft(tree); - var graphs = new qx.ui.layout.VerticalBoxLayout(); - with(graphs){ - setBackgroundColor('white'); - setBorder('inset'); - setWidth('100%'); - setHeight('100%'); - }; + tree.getManager().addEventListener("changeSelection", function(e) { + if (e.getData().length > 0) { + this.debug(e.getData()[0].getUserData('id')); + } + },this); + var graphs = new Smokeping.ui.Graphs(rpc.getBaseUrl()); splitpane.addRight(graphs); - }, close : function(e) diff --git a/qooxdoo/source/class/Smokeping/ui/TargetTree.js b/qooxdoo/source/class/Smokeping/ui/TargetTree.js index 6c47398..6d72ad1 100644 --- a/qooxdoo/source/class/Smokeping/ui/TargetTree.js +++ b/qooxdoo/source/class/Smokeping/ui/TargetTree.js @@ -23,27 +23,43 @@ qx.Class.define('Smokeping.ui.TargetTree', * @param rpc {rpcObject} An rpc object providing access to the Smokeping service */ - construct: function (rpc,root_node) { + construct: function (rpc) { with(this){ - base(arguments,root_node); + base(arguments,'root node'); setBackgroundColor('white'); setBorder('inset'); +// setOverflow('scrollY'); setWidth('100%'); setHeight('100%'); setPadding(5); - } + setHideNode(true); + }; - return this; + var self = this; + + var fill_tree = function(data,exc,id){ + if (exc == null){ + var nodes = data.length; + for(var i=0;i<nodes;i++){ + Smokeping.ui.TargetTree.__fill_folder(self,data[i]); + } + } + else { + alert(exc); + } + }; + + rpc.callAsync(fill_tree,'get_tree'); }, /* ***************************************************************************** - MEMBERS + Statics ***************************************************************************** */ - members : + statics : { /* @@ -53,7 +69,7 @@ qx.Class.define('Smokeping.ui.TargetTree', */ /** - * Tell about the BaseUrl we found. + * Create the tree based on input from the Server * * @type member * @@ -62,9 +78,25 @@ qx.Class.define('Smokeping.ui.TargetTree', * @return BaseUrl {Strings} */ -// getBaseUrl: function(){ -// return this.__base_url; -// } + + __fill_folder: function(node,data){ + // in data[0] we have the id of the folder + var folder = new qx.ui.tree.TreeFolder(data[1]); + folder.setUserData('id',data[0]); + node.add(folder); + 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]); + } else { + i++; // skip the node id for now + var file = new qx.ui.tree.TreeFile(data[i]); + file.setUserData('id',data[i-1]); + folder.add(file); + } + } + } + } }); |