diff options
author | Rafal Szczesniak <mimir@samba.org> | 2007-04-17 23:10:57 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:51:02 -0500 |
commit | 671d785c16f2c5fbd9644ef8f169f66b9517a557 (patch) | |
tree | abd7d42e8d73f711242594d2b1d696e854b9ace2 /webapps | |
parent | 4a23a696b957639a9f9ffbdd0121ce1ff453d20c (diff) | |
download | samba-671d785c16f2c5fbd9644ef8f169f66b9517a557.tar.gz samba-671d785c16f2c5fbd9644ef8f169f66b9517a557.tar.bz2 samba-671d785c16f2c5fbd9644ef8f169f66b9517a557.zip |
r22324: Another step closer to nice listing of user accounts.
rafal
(This used to be commit 3f717e7fc7b0876de01cac375ef3151700066e0d)
Diffstat (limited to 'webapps')
-rw-r--r-- | webapps/swat/source/class/swat/module/netmgr/Fsm.js | 62 | ||||
-rw-r--r-- | webapps/swat/source/class/swat/module/netmgr/Gui.js | 147 |
2 files changed, 185 insertions, 24 deletions
diff --git a/webapps/swat/source/class/swat/module/netmgr/Fsm.js b/webapps/swat/source/class/swat/module/netmgr/Fsm.js index f35e644241..56cc244912 100644 --- a/webapps/swat/source/class/swat/module/netmgr/Fsm.js +++ b/webapps/swat/source/class/swat/module/netmgr/Fsm.js @@ -70,7 +70,13 @@ qx.Proto.buildFsm = function(module) "changeSelection" : { "tree" : - "Transition_Idle_to_AwaitRpcResult_via_tree_selection_changed" + "Transition_Idle_to_Idle_via_tree_selection_changed" + }, + + "changeNetCtx" : + { + "swat.module.netmgr.Gui" : + "Transition_Idle_to_AwaitRpcResult_via_netCtx_changed" } } }); @@ -85,6 +91,7 @@ qx.Proto.buildFsm = function(module) "ontransition" : function(fsm, event) { + // Create default NetContext var request = _this.callRpc(fsm, "samba.ejsnet", "NetContext", []); request.setUserData("requestType", "NetContext"); } @@ -111,9 +118,9 @@ qx.Proto.buildFsm = function(module) state.addTransition(trans); var trans = new qx.util.fsm.Transition( - "Transition_Idle_to_AwaitRpcResult_via_tree_selection_changed", + "Transition_Idle_to_Idle_via_tree_selection_changed", { - "nextState" : "State_AwaitRpcResult", + "nextState" : "State_Idle", "ontransition" : function(fsm, event) { @@ -122,8 +129,38 @@ qx.Proto.buildFsm = function(module) var gui = swat.module.netmgr.Gui.getInstance(); var parentNode = gui.getParentNode(module, selectedNode); - - var params = (parentNode.credentials == undefined) ? [] : [ parentNode.credentials ]; + + // Change current NetContext if necessary for this host + if (parentNode.netCtx != undefined) + { + module.setNetCtx(parentNode.netCtx); + } + + var nodeName = selectedNode.label; + var callName = undefined; // rpc call name + var callArgs = [ gui.getNetCtx() ]; // NetContex goes first + + switch (nodeName) + { + case "Users": + callName = "UserMgr"; + break; + + case "Groups": + case "Domain": + case "Services": + alert("View not implemented yet"); + break; + + default: + alert("Undefined call selected for node=['" + nodeName + "']"); + } + + // Bail out if no appropriate call name has been found + if (callName == undefined) return; + + var req = _this.callRpc(fsm, "samba.ejsnet", callName, callArgs); + req.setUserData("requestType", "UserMgr"); } }); @@ -131,6 +168,21 @@ qx.Proto.buildFsm = function(module) // Add the new transition state.addTransition(trans); + var trans = new qx.util.fsm.Transition( + "Transition_Idle_to_AwaitRpcResult_via_netCtx_changed", + { + "nextState" : "State_AwaitRpcResult", + + "ontransition" : function(fsm, event) + { + var netCtxId = 0; + var req = _this.callRpc(fsm, "samba.ejsnet", "NetContextCreds", [ netCtxId ]); + req.setUserData("requestType", "NetContextCreds"); + } + }); + + state.addTransition(trans); + blockedEvents = { "appear": diff --git a/webapps/swat/source/class/swat/module/netmgr/Gui.js b/webapps/swat/source/class/swat/module/netmgr/Gui.js index 44bba3f5ab..b78d484f51 100644 --- a/webapps/swat/source/class/swat/module/netmgr/Gui.js +++ b/webapps/swat/source/class/swat/module/netmgr/Gui.js @@ -5,20 +5,38 @@ /** * Swat Net Manager class graphical user interface */ -qx.OO.defineClass("swat.module.netmgr.Gui", qx.core.Object, +qx.OO.defineClass("swat.module.netmgr.Gui", qx.core.Target, function() { - qx.core.Object.call(this); + qx.core.Target.call(this); }); //qx.OO.addProperty({ name : "_tree", type : "object" }); //qx.OO.addProperty({ name : "_panel", type : "object" }); +//qx.OO.addProperty({ name : "_view", type : "object" }); +//qx.OO.addProperty({ name : "_txtDomain", type : "object" }); +//qx.OO.addProperty({ name : "_txtUsername", type : "object" }); + +/* NetContex resource number assigned on the server side. + Necessary for every ejsnet call */ +qx.OO.addProperty({ name : "netCtx", type : "number" }); + qx.Proto.buildGui = function(module) { var fsm = module.fsm; + + // Main layout composing the whole form + var vlayout = new qx.ui.layout.VerticalBoxLayout(); + vlayout.set({ + top: 20, + left: 20, + width: "100%", + bottom: 20 + }); + // Horizontal layout holding TreeView and a "panel" for ListView var hlayout = new qx.ui.layout.HorizontalBoxLayout(); hlayout.set({ top: 0, @@ -55,38 +73,105 @@ qx.Proto.buildGui = function(module) panel.set({ top: 0, - right: 20, + left: 10, width: "80%", height: "100%" }); + + // Setup some initial columns and (empty) item list - to be replaced soon + // with default view loading + var columns = { name : { label: "Name", width: 120, type: "text" }}; + var items = []; + + // Setup the list view + this._view = new qx.ui.listview.ListView(items, columns); + var view = this._view; + view.setBorder(qx.renderer.border.BorderPresets.getInstance().shadow); + view.setBackgroundColor("white"); + view.set({ + top: 0, + left: 0, + width: "80%", + height: "100%" + }); + + // Give a list view name to handle + fsm.addObject("view", view); + + // and the list view to the panel + panel.add(view); // Add the tree view and panel for list view to the layout hlayout.add(tree); hlayout.add(panel); + // Status layout containing informative labels and status information var statusLayout = new qx.ui.layout.HorizontalBoxLayout(); statusLayout.set({ - top: 0, + top: 10, left: 0, right: 0, height: "100%" }); - var vlayout = new qx.ui.layout.VerticalBoxLayout(); - vlayout.set({ - top: 20, - left: 20, - width: "100%", - bottom: 20 - }); + // First "column" of status fields + var colALayout = new qx.ui.layout.VerticalBoxLayout(); + colALayout.set({ + top: 0, + left: 0, + width: 150, + height: "100%" + }); + + // Domain name (credentials) - label and text box + var statusDomain = new qx.ui.layout.HorizontalBoxLayout(); + statusDomain.set({ top: 0, left: 0, width: "100%", height: 20, + verticalChildrenAlign: "middle" }); + + var lblDomain = new qx.ui.basic.Atom(); + lblDomain.setLabel("Domain:"); + lblDomain.set({ width: 70, right: 5, horizontalChildrenAlign: "right" }); + + var txtDomain = new qx.ui.form.TextField(); + txtDomain.set({ width: 80, readOnly: true }); + this._txtDomain = txtDomain; + statusDomain.add(lblDomain); + statusDomain.add(txtDomain); + + // Username (credentials) - label and text box + var statusUsername = new qx.ui.layout.HorizontalBoxLayout(); + statusUsername.set({ top: 0, left: 0, width: "100%", height: 20, + verticalChildrenAlign: "middle" }); + + var lblUsername = new qx.ui.basic.Atom(); + lblUsername.setLabel("Username:"); + lblUsername.set({ width: 70, right: 5, horizontalChildrenAlign: "right" }); + + var txtUsername = new qx.ui.form.TextField(); + txtUsername.set({ width: 80, readOnly: true }); + this._txtUsername = txtUsername; + + statusUsername.add(lblUsername); + statusUsername.add(txtUsername); + + colALayout.add(statusDomain); + colALayout.add(statusUsername); + + statusLayout.add(colALayout); + vlayout.add(hlayout); vlayout.add(statusLayout); vlayout.addEventListener("appear", fsm.eventListener, fsm); fsm.addObject("vlayout", vlayout); + // place everything on canvas module.canvas.add(vlayout); + + // Add event handler to netCtx property change + this.addEventListener("changeNetCtx", fsm.eventListener, fsm); + fsm.addObject("swat.module.netmgr.Gui", this); }; @@ -107,13 +192,21 @@ qx.Proto.displayData = function(module, rpcRequest) switch (requestType) { case "hostname": - // Add local host node - this._addHostNode(module, rpcRequest, true); - break; + // Add local host node + this._addHostNode(module, rpcRequest, true); + break; case "NetContext": - this._initNetContext(module, rpcRequest); - break; + this._initNetContext(module, rpcRequest); + break; + + case "NetContextCreds": + this._updateNetContextCreds(module, rpcRequest); + break; + + case "UserMgr": + this._initUserManager(module, rpcRequest); + break; } qx.ui.core.Widget.flushGlobalQueues(); @@ -163,8 +256,8 @@ qx.Proto._addHostNode = function(module, rpcRequest, local) var hostNode = dataModel.getData()[hostNodeId]; // Set host-specific properties - hostNode.credentials = undefined; - hostNode.local = local + hostNode.netCtx = undefined; + hostNode.local = local; }; @@ -172,7 +265,23 @@ qx.Proto._initNetContext = function(module, rpcRequest) { // Gather obtained NetContext handle var result = rpcRequest.getUserData("result").data; - module.netCtx = result; + this.setNetCtx(result); +}; + + +qx.Proto._updateNetContextCreds = function(module, rpcRequest) +{ + // Get requested credentials from the current NetContext + var result = rpcRequest.getUserData("result").data; + this._txtUsername.setValue(result.username); + this._txtDomain.setValue(result.domain); +}; + + +qx.Proto._initUserManager = function(module, rpcRequest) +{ + // Get obtained UsrCtx handle + var result = rpcRequest.getUserData("result").data; }; |