1
0
mirror of https://github.com/samba-team/samba.git synced 2025-11-14 12:23:52 +03:00

r22499: UsrCtx should be created within UsersView. Tree widget just

opens it and passes the domain name(s) to operate on (selectable
via combo box).

rafal
This commit is contained in:
Rafal Szczesniak
2007-04-24 08:36:41 +00:00
committed by Gerald (Jerry) Carter
parent 43deee4f93
commit c438284adf
3 changed files with 92 additions and 20 deletions

View File

@@ -73,6 +73,13 @@ qx.Proto.buildFsm = function(module)
"Transition_Idle_to_Idle_via_tree_selection_changed"
},
"changeSelected":
{
// this one is dispatched from UsersView widget
"domainName":
"Transition_Idle_to_AwaitRpcResult_via_domainName_changed"
},
"changeNetCtx" :
{
"swat.module.netmgr.Gui" :
@@ -120,7 +127,7 @@ qx.Proto.buildFsm = function(module)
var trans = new qx.util.fsm.Transition(
"Transition_Idle_to_Idle_via_tree_selection_changed",
{
"nextState" : "State_AwaitRpcResult",
"nextState" : "State_Idle",
"ontransition" : function(fsm, event)
{
@@ -135,15 +142,14 @@ qx.Proto.buildFsm = function(module)
{
module.setNetCtx(parentNode.netCtx);
}
var domainName = parentNode.label;
var nodeName = selectedNode.label;
var callName = undefined; // rpc call name
var callArgs = [ gui.getNetCtx() ]; // NetContex goes first
switch (nodeName)
{
case "Users":
callName = "UserMgr";
gui.openUserManager(module, domainName);
break;
case "Groups":
@@ -155,18 +161,30 @@ qx.Proto.buildFsm = function(module)
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");
}
});
// Add the new transition
state.addTransition(trans);
var trans = new qx.util.fsm.Transition(
"Transition_Idle_to_AwaitRpcResult_via_domainName_changed",
{
"nextState" : "State_AwaitRpcResult",
"ontransition" : function(fsm, event)
{
var domainName = fsm.getObject("domainName").getValue();
var netCtxId = swat.module.netmgr.Gui.getInstance().getNetCtx();
var req = _this.callRpc(fsm, "samba.ejsnet", "UserMgr", [ netCtxId, domainName ]);
req.setUserData("requestType", "UserMgr");
}
});
// Add the new transition
state.addTransition(trans);
var trans = new qx.util.fsm.Transition(
"Transition_Idle_to_AwaitRpcResult_via_netCtx_changed",
@@ -175,7 +193,8 @@ qx.Proto.buildFsm = function(module)
"ontransition" : function(fsm, event)
{
var netCtxId = 0;
var netCtxId = swat.module.netmgr.Gui.getInstance().getNetCtx();
var req = _this.callRpc(fsm, "samba.ejsnet", "NetContextCreds", [ netCtxId ]);
req.setUserData("requestType", "NetContextCreds");
}

View File

@@ -213,6 +213,20 @@ qx.Proto.getParentNode = function(module, node)
};
qx.Proto.openUserManager = function(module, domainName)
{
// Remove existing panel if there is any
if (this._panel.getChildrenLength() > 0)
{
this._panel.removeAll();
}
// Create user view, pass the context and the view to the panel
var view = new swat.module.netmgr.UsersView(module.fsm, domainName);
this._panel.add(view);
};
qx.Proto._addHostNode = function(module, rpcRequest, local)
{
var fsm = module.fsm;
@@ -260,14 +274,8 @@ qx.Proto._updateNetContextCreds = function(module, rpcRequest)
qx.Proto._initUserManager = function(module, rpcRequest)
{
// Get obtained UsrCtx handle
// Get obtained usrCtx handle
var usrCtx = rpcRequest.getUserData("result").data;
// Create user view and pass the context
var view = new swat.module.netmgr.UsersView(module.fsm);
view.setUsrCtx(usrCtx);
this._panel.add(view);
};

View File

@@ -11,7 +11,7 @@
* Users View
*/
qx.OO.defineClass("swat.module.netmgr.UsersView", qx.ui.layout.HorizontalBoxLayout,
function(fsm)
function(fsm, domainName)
{
qx.ui.layout.HorizontalBoxLayout.call(this);
@@ -38,6 +38,39 @@ function(fsm)
var cmbDomain = new qx.ui.form.ComboBox();
cmbDomain.setEditable(false);
// there's always BUILTIN domain so add it to the list
var item = new qx.ui.form.ListItem("BUILTIN");
cmbDomain.add(item);
var selectedItem = undefined;
// Simply add the domain name if it is passed as a string
if (typeof(domainName) == "string")
{
item = new qx.ui.form.ListItem(domainName);
cmbDomain.add(item);
selectedItem = item;
}
else // if it's not a string we assume it is a list of strings
{
for (var s in domainName)
{
item = new qx.ui.form.ListItem(s);
cmbDomain.add(s);
}
selectedItem = new qx.ui.form.ListItem(domainName[0]);
}
// Add event handling
cmbDomain.addEventListener("changeSelected", fsm.eventListener, fsm);
fsm.addObject("domainName", cmbDomain);
// Set default selection and dispatch the respective event to initialise the view
cmbDomain.setSelected(selectedItem);
cmbDomain.dispatchEvent(new qx.event.type.Event("changeSelected"), true);
// Create an empty list view with sample column
this._columns = { username : { label: "Username", width: 150, type: "text" }};
this._items = [];
@@ -60,3 +93,15 @@ function(fsm)
// UsrMgr context is required for any operation on user accounts
qx.OO.addProperty({ name : "usrCtx", type : "number" });
qx.Proto.refreshView = function()
{
}
qx.Proto._initUserManager = function(module, rpcRequest)
{
// Get obtained UsrCtx handle
var usrCtx = rpcRequest.getUserData("result").data;
};