From ff7b9de82908baf1d5f9af71e35dad2369bfdc2f Mon Sep 17 00:00:00 2001 From: Tobi Oetiker Date: Wed, 14 Nov 2007 17:33:19 +0000 Subject: initial qooxdoo drop for smokeping --- qooxdoo/source/class/Smokeping/Application.js | 106 ++++++++++++++++++++++++ qooxdoo/source/class/Smokeping/io/Rpc.js | 80 ++++++++++++++++++ qooxdoo/source/class/Smokeping/ui/TargetTree.js | 71 ++++++++++++++++ 3 files changed, 257 insertions(+) create mode 100644 qooxdoo/source/class/Smokeping/Application.js create mode 100644 qooxdoo/source/class/Smokeping/io/Rpc.js create mode 100644 qooxdoo/source/class/Smokeping/ui/TargetTree.js (limited to 'qooxdoo/source/class') diff --git a/qooxdoo/source/class/Smokeping/Application.js b/qooxdoo/source/class/Smokeping/Application.js new file mode 100644 index 0000000..49a151d --- /dev/null +++ b/qooxdoo/source/class/Smokeping/Application.js @@ -0,0 +1,106 @@ +/* ************************************************************************ + +#module(Smokeping) +#resource(Smokeping.image:image) +#embed(Smokeping.image/*) + +************************************************************************ */ + +qx.Class.define( + 'Smokeping.Application', { + extend: qx.application.Gui, + + members: + { + main: function() + { + 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'); + + var base_url = rpc.getBaseUrl(); + + var prime = new qx.ui.layout.VerticalBoxLayout(); + with(prime){ + setPadding(8); + setLocation(0,0); + setWidth('100%'); + setHeight('100%'); + setSpacing(10); + }; + prime.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); + + var splitpane = new qx.ui.splitpane.HorizontalSplitPane('1*', '3*'); + splitpane.setEdge(1); + splitpane.setHeight('1*'); + splitpane.setShowKnob(true); + prime.add(splitpane); + + var tree = new Smokeping.ui.TargetTree(rpc,this.tr("Root Node")); + splitpane.addLeft(tree); + + var graphs = new qx.ui.layout.VerticalBoxLayout(); + with(graphs){ + setBackgroundColor('white'); + setBorder('inset'); + setWidth('100%'); + setHeight('100%'); + }; + + splitpane.addRight(graphs); + + + }, + + close : function(e) + { + this.base(arguments); + // return "Smokeping Web UI: " + // + "Do you really want to close the application?"; + }, + + + terminate : function(e) { + this.base(arguments); + }, + + /******************************************************************** + * Functional Block Methods + ********************************************************************/ + + /** + * Get the base url of this page + * + * @return {String} the base url of the page + */ + + __getBaseUrl: function() { + var our_href = new String(document.location.href); + var last_slash = our_href.lastIndexOf("/"); + return our_href.substring(0,last_slash+1); + } + }, + + + + + /* + ***************************************************************************** + SETTINGS + ***************************************************************************** + */ + + settings : { + 'Smokeping.resourceUri' : './resource' + } + } +); + diff --git a/qooxdoo/source/class/Smokeping/io/Rpc.js b/qooxdoo/source/class/Smokeping/io/Rpc.js new file mode 100644 index 0000000..327d2c4 --- /dev/null +++ b/qooxdoo/source/class/Smokeping/io/Rpc.js @@ -0,0 +1,80 @@ +/* ************************************************************************ +#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/TargetTree.js b/qooxdoo/source/class/Smokeping/ui/TargetTree.js new file mode 100644 index 0000000..6c47398 --- /dev/null +++ b/qooxdoo/source/class/Smokeping/ui/TargetTree.js @@ -0,0 +1,71 @@ +/* ************************************************************************ +#module(Smokeping) +************************************************************************ */ + +/** + * a widget showing the smokeping target tree + */ + +qx.Class.define('Smokeping.ui.TargetTree', +{ + extend: qx.ui.tree.Tree, + + /* + ***************************************************************************** + CONSTRUCTOR + ***************************************************************************** + */ + + /** + * @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,root_node) { + + with(this){ + base(arguments,root_node); + setBackgroundColor('white'); + setBorder('inset'); + setWidth('100%'); + setHeight('100%'); + setPadding(5); + } + + 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; +// } + } +}); + + -- cgit v1.2.3-24-g4f1b