summaryrefslogtreecommitdiff
path: root/swat/apps
diff options
context:
space:
mode:
authorDerrell Lipman <derrell@samba.org>2006-12-16 19:07:37 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:29:23 -0500
commitff8ef6c280a7107ce521eee57df9218b4cac0465 (patch)
treefbe240b4d3107db5c98bcd508624826d579f243c /swat/apps
parent5249de851976e274ea02fefc3b71cddb4b5ab207 (diff)
downloadsamba-ff8ef6c280a7107ce521eee57df9218b4cac0465.tar.gz
samba-ff8ef6c280a7107ce521eee57df9218b4cac0465.tar.bz2
samba-ff8ef6c280a7107ce521eee57df9218b4cac0465.zip
r20220: Apply patch from Brad Henry with some additional qooxdoo/json-rpc SWAT
functionality: basic admin console. (This used to be commit 23f8dd44cbf85e05e4b3d38de9ed7798dd21defb)
Diffstat (limited to 'swat/apps')
-rw-r--r--swat/apps/plug-ins/echo.js71
-rw-r--r--swat/apps/plug-ins/nbt_stats.js62
-rw-r--r--swat/apps/samba/utils/admin_console.html258
3 files changed, 391 insertions, 0 deletions
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 @@
+<HTML>
+
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <TITLE>Samba Admin Console</TITLE>
+
+ <LINK type="text/css" rel="stylesheet" href="../../resource/css/layout-samba.css"/>
+ <!--[if IE]>
+ <LINK
+ type="text/css" rel="stylesheet" href="../../resource/css/layout-samba.css"/>
+ <![endif]-->
+ <SCRIPT type="text/javascript" src="../../script/qx.js"></SCRIPT>
+
+ <!--> Include plug-in applications <!-->
+ <SCRIPT type="text/javascript" src="../../plug-ins/echo.js"></SCRIPT>
+ <SCRIPT type="text/javascript" src="../../plug-ins/nbt_stats.js"></SCRIPT>
+</HEAD>
+
+<BODY>
+ <SCRIPT type="text/javascript" src="../../script/layout-samba.js"></SCRIPT>
+ <DIV style="position: absolute; background-color: transparent; right:0; top:0; z-index: 1000000001;">
+ <IMG src="../../../images/logo.png">
+ </DIV>
+
+ <DIV id="demoHead">
+ Samba Administrative Console
+ </DIV>
+ <SCRIPT type="text/javascript">
+
+// All global variables will be members of this object.
+globals = new Object();
+
+//paneWidget is the split-pane.
+globals.paneWidget = qx.ui.splitpane.SplitPane;
+
+//appTree is paneWidget's left pane.
+globals.appTree = new Object();
+
+//appInstance is paneWidget's right pane.
+globals.appInstance = new qx.ui.layout.CanvasLayout();
+
+function createApplicationTree() {
+ var app_treeRowStructure =
+ qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard(
+ "Plug-in Apps",
+ "icon/16/desktop.png",
+ "icon/16/dictionary.png");
+ var app_tree = new
+ qx.ui.treefullcontrol.Tree(app_treeRowStructure);
+
+ with (app_tree) {
+ setBackgroundColor(255);
+ setBorder(qx.renderer.border.BorderPresets.getInstance().inset);
+ setOverflow("scrollY");
+ setWidth("100%");
+ setHeight("100%");
+ };
+
+ app_tree.getManager().addEventListener("changeSelection", function(e) {
+ sel = new Object();
+ sel = app_tree.getSelectedElement();
+ var appName = sel.getUserData("PlugIn Name");
+ this.debug("changeSelection: " + appName);
+ var obj = sel.getUserData("PlugIn Object");
+
+ obj.display(globals.appInstance);
+
+ });
+
+ return app_tree;
+}
+
+function addButtonClickHandler(addMenu, el, e) {
+ if (addMenu.isSeeable()) {
+ addMenu.hide();
+ } else {
+ addMenu.setLeft(qx.dom.DomLocation.getPageBoxLeft(el));
+ addMenu.setTop(qx.dom.DomLocation.getPageBoxBottom(el));
+ addMenu.show();
+ };
+}
+
+function removeButtonExecuteHandler() {
+ // Get list of installed plug-in applications.
+ // Display list as a menu
+}
+
+function aboutButtonExecuteHandler(aboutWindow) {
+ aboutWindow.open();
+}
+
+function addMenuButtonExecuteHandler(plugInName, plugIn) {
+ treeRowStructure =
+ qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard(plugInName);
+ var treeElement =
+ new qx.ui.treefullcontrol.TreeFolder(treeRowStructure);
+
+ treeElement.setUserData("PlugIn Name", plugInName);
+ treeElement.setUserData("PlugIn Object", plugIn);
+
+ globals.appTree.add(treeElement);
+
+ // Select the most recently added plugin in the tree-menu.
+ globals.appTree.setSelectedElement(globals.appTree.getLastTreeChild());
+
+ plugIn.display(globals.appInstance);
+}
+
+function createConsoleButtons(mainWindow) {
+ // Get list of available plug-in applications.
+ // Display list of applications as a menu.
+ var addMenu = new qx.ui.menu.Menu();
+ var descriptionMenuButton =
+ new qx.ui.menu.MenuButton("Select a plug-in.");
+ var menuSeparator = new qx.ui.menu.MenuSeparator();
+ var echoMenuButton = new qx.ui.menu.MenuButton("Echo");
+
+ with (echoMenuButton) {
+ addEventListener("execute", function(e) {
+ this.debug("executed: " + this.getLabel());
+ var plugIn = new EchoPlugIn();
+ addMenuButtonExecuteHandler("Echo Test", plugIn);
+ });
+ };
+
+ var NBTStatsMenuButton =
+ new qx.ui.menu.MenuButton("NBT Packet Statistics");
+
+ with (NBTStatsMenuButton) {
+ addEventListener("execute", function(e) {
+ this.debug("executed: " + this.getLabel());
+ var plugIn = new NBTStatsPlugIn();
+ addMenuButtonExecuteHandler("NBT Packet Statistics", plugIn);
+ });
+ };
+
+ addMenu.add(descriptionMenuButton);
+ addMenu.add(menuSeparator);
+ addMenu.add(echoMenuButton);
+ addMenu.add(NBTStatsMenuButton);
+
+ mainWindow.add(addMenu);
+
+ var addButton = new qx.ui.form.Button("Add Plug-in");
+
+ with (addButton) {
+ setTop(0);
+ setLeft(0);
+
+ addEventListener("click", function(e) {
+ this.debug("clicked: " + this.getLabel());
+ var el = this.getElement();
+ addButtonClickHandler(addMenu, el);
+ e.setPropagationStopped(true);
+ });
+
+ addEventListener("mousedown", function(e) {
+ this.debug("mousedown: " + this.getLabel());
+ e.setPropagationStopped(true);
+ });
+
+ setEnabled(true);
+ };
+
+ var removeButton = new qx.ui.form.Button("Remove Plug-in");
+ with (removeButton) {
+ setTop(0);
+ setLeft(66);
+
+ addEventListener("execute", function(e) {
+ this.debug("Executed: " + this.getLabel());
+ removeButtonExecuteHandler();
+ });
+
+ setEnabled(true);
+ };
+
+ var aboutWindow = new qx.ui.window.Window("About");
+ aboutWindow.setSpace(100, "auto", 100, "auto");
+ aboutWindow.setModal(false);
+ aboutWindow.setShowMinimize(false);
+ aboutWindow.setShowMaximize(false);
+
+ var aboutText = new qx.ui.basic.Label("Blah.");
+ aboutWindow.add(aboutText);
+
+ mainWindow.add(aboutWindow);
+
+ var aboutButton = new qx.ui.form.Button("About");
+
+ with (aboutButton) {
+ setTop(0);
+ setLeft(154);
+ addEventListener("execute", function(e) {
+ this.debug("Executed: " + this.getLabel());
+ aboutButtonExecuteHandler(aboutWindow);
+ });
+ setEnabled(true);
+ };
+
+ mainWindow.add(addButton);
+ mainWindow.add(removeButton);
+ mainWindow.add(aboutButton);
+}
+
+qx.core.Init.getInstance().defineMain(
+ function() {
+ // Enable JSON-RPC debugging.
+ qx.Settings.setCustomOfClass("qx.io.Json", "enableDebug", true);
+
+ var consoleFrame = new qx.ui.layout.CanvasLayout;
+ consoleFrame.setLocation(0,60);
+ consoleFrame.setBottom(120);
+ consoleFrame.setRight(280);
+ consoleFrame.setPadding(20);
+
+ consoleFrame.addToDocument();
+
+ var mainWindow = new qx.ui.window.Window("Console");
+ mainWindow.setSpace(0, 700, 0, 400);
+ mainWindow.allowMinimize = false;
+ mainWindow.showMinimize = false;
+
+ // The default window move method is slow.
+ mainWindow.setMoveMethod("frame");
+
+ consoleFrame.add(mainWindow);
+
+ // We need buttons to add and remove plug-ins.
+ createConsoleButtons(mainWindow);
+
+ // Make a splitpane.
+ globals.paneWidget = new qx.ui.splitpane.HorizontalSplitPane("1*","2*");
+ globals.paneWidget.setEdge(28,0);
+ globals.paneWidget.setLiveResize(true);
+
+ mainWindow.add(globals.paneWidget);
+
+ // plug-in application tree is on the left.
+ globals.appTree = createApplicationTree();
+
+ globals.paneWidget.addLeft(globals.appTree);
+
+ // What is drawn in the right pane is up to the plug-in.
+ // It is a blank canvas for now.
+ globals.appInstance.setTop(0);
+ globals.appInstance.setLeft(0);
+ globals.appInstance.setBottom(50);
+ globals.appInstance.setRight(20);
+
+ globals.paneWidget.addRight(globals.appInstance);
+
+ mainWindow.open();
+ }
+);
+ </SCRIPT>
+</BODY>
+</HTML>