From ff8ef6c280a7107ce521eee57df9218b4cac0465 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 16 Dec 2006 19:07:37 +0000 Subject: r20220: Apply patch from Brad Henry with some additional qooxdoo/json-rpc SWAT functionality: basic admin console. (This used to be commit 23f8dd44cbf85e05e4b3d38de9ed7798dd21defb) --- swat/apps/plug-ins/echo.js | 71 +++++++++ swat/apps/plug-ins/nbt_stats.js | 62 ++++++++ swat/apps/samba/utils/admin_console.html | 258 +++++++++++++++++++++++++++++++ swat/menu.js | 1 + 4 files changed, 392 insertions(+) create mode 100644 swat/apps/plug-ins/echo.js create mode 100644 swat/apps/plug-ins/nbt_stats.js create mode 100644 swat/apps/samba/utils/admin_console.html (limited to 'swat') diff --git a/swat/apps/plug-ins/echo.js b/swat/apps/plug-ins/echo.js new file mode 100644 index 0000000000..1a32c5c320 --- /dev/null +++ b/swat/apps/plug-ins/echo.js @@ -0,0 +1,71 @@ + +// This function takes the main pane widget and jams its widget in the right +// sub-pane. + +function _asyncEchoHandler(result, ex, id, paneWidget) { + var replyTextArea = null; + var refreshButton = null; + var echoTextField = null; + + if (ex == null) { + // We need to remove anything previously drawn in this area. + paneWidget.removeAll(); + + echoTextField = new qx.ui.form.TextField(); + echoTextField.setTop(0); + echoTextField.setLeft(0); + + refreshButton = new qx.ui.form.Button("Refresh"); + refreshButton.setTop(0); + refreshButton.setLeft(150); + + replyTextArea = new + qx.ui.form.TextArea(result); + replyTextArea.setWrap(true); + replyTextArea.setWidth("100%"); + replyTextArea.setHeight("50%"); + replyTextArea.setTop(30); + replyTextArea.setBottom(50); + replyTextArea.setLeft(0); + replyTextArea.setRight(20); + } else { + alert("Async(" + id + ") exception: " + ex); + } + paneWidget.add(replyTextArea); + paneWidget.add(refreshButton); + paneWidget.add(echoTextField); + + // Provide a handler for the button. + with (refreshButton) { + addEventListener("execute", function(e) { + this.debug("executed: " + this.getLabel()); + this.debug("echoTextField.getValue(): " + echoTextField.getValue()); + _echoPlugInDisplay(paneWidget, echoTextField.getValue()); + }); + }; +} + +function _echoPlugInDisplay(paneWidget, echoText) { + if (echoText == null) { + echoText = "Hello World!"; + } + + var rpc = new qx.io.remote.Rpc(); + rpc.setTimeout(60000); + rpc.setUrl("/services/"); + rpc.setServiceName("samba.adm"); + rpc.setCrossDomain(false); + + mycall = rpc.callAsync( + function(result, ex, id) { + _asyncEchoHandler(result, ex, id, paneWidget); + }, + "echo", + echoText); +} + +function EchoPlugIn() { + var o = new Object(); + o.display = _echoPlugInDisplay; + return o; +} diff --git a/swat/apps/plug-ins/nbt_stats.js b/swat/apps/plug-ins/nbt_stats.js new file mode 100644 index 0000000000..f9de19004f --- /dev/null +++ b/swat/apps/plug-ins/nbt_stats.js @@ -0,0 +1,62 @@ + +// This function takes the main pane widget and jams its widget in the right +// sub-pane. + +function _asyncNBTStatsHandler(result, ex, id, paneWidget) { + var statusTextArea = null; + + var listData = []; + listData.push({ + server_status : { text : result.server_status }, + total_received : { text : result.total_received.toString() }, + total_sent : { text : result.total_sent.toString() }, + query_count : { text : result.query_count.toString() }, + release_count : { text : result.release_count.toString() }, + register_count : { text : result.register_count.toString() } + }); + + if (ex == null) { + // We need to remove anything previously drawn in this area. + paneWidget.removeAll(); + + statusTextArea = new + qx.ui.form.TextArea("Server Status: " + + result.server_status.toString() + "\n" + + "Total Received: " + + result.total_received.toString() + "\n" + + "Total Sent: " + + result.total_sent.toString() + "\n" + + "Query Count: " + + result.query_count.toString() + "\n" + + "Release Count: " + + result.release_count.toString() + "\n" + + "Register Count: " + + result.register_count.toString() + "\n"); + statusTextArea.setWrap(true); + statusTextArea.setWidth("100%"); + statusTextArea.setHeight("100%"); + } else { + alert("Async(" + id + ") exception: " + ex); + } + paneWidget.add(statusTextArea); +} + +function _NBTStatsPlugInDisplay(paneWidget) { + var rpc = new qx.io.remote.Rpc(); + rpc.setTimeout(60000); + rpc.setUrl("/services/"); + rpc.setServiceName("samba.adm"); + rpc.setCrossDomain(false); + + mycall = rpc.callAsync( + function(result, ex, id) { + _asyncNBTStatsHandler(result, ex, id, paneWidget); + }, + "NBTPacketStats"); +} + +function NBTStatsPlugIn() { + var o = new Object(); + o.display = _NBTStatsPlugInDisplay; + return o; +} diff --git a/swat/apps/samba/utils/admin_console.html b/swat/apps/samba/utils/admin_console.html new file mode 100644 index 0000000000..c314c8fc5b --- /dev/null +++ b/swat/apps/samba/utils/admin_console.html @@ -0,0 +1,258 @@ + + + + + Samba Admin Console + + + + + + Include plug-in applications + + + + + + +
+ +
+ +
+ Samba Administrative Console +
+ + + diff --git a/swat/menu.js b/swat/menu.js index 255723b95a..3a32e3f3c7 100644 --- a/swat/menu.js +++ b/swat/menu.js @@ -38,6 +38,7 @@ swat_menus.esptest = simple_menu( swat_menus.json = simple_menu( "JSON Tests", "ldb browser", session_uri("/apps/samba/utils/ldbbrowse.html"), + "admin console", session_uri("/apps/samba/utils/admin_console.html"), "qooxdoo examples", session_uri("/apps/qooxdoo-examples/index.html")); -- cgit