r22499: UsrCtx should be created within UsersView. Tree widget just
authorRafal Szczesniak <mimir@samba.org>
Tue, 24 Apr 2007 08:36:41 +0000 (08:36 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:51:34 +0000 (14:51 -0500)
opens it and passes the domain name(s) to operate on (selectable
via combo box).

rafal
(This used to be commit c438284adf17faff2cd76d14c9de252e995166bd)

webapps/swat/source/class/swat/module/netmgr/Fsm.js
webapps/swat/source/class/swat/module/netmgr/Gui.js
webapps/swat/source/class/swat/module/netmgr/UsersView.js

index 70f84904ef7709299b13aaff81e66844c7e0fcea..c2e499a18f6d23562e3b7cb493008e5ad37aee0f 100644 (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,14 +161,26 @@ 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;
+  // Add the new transition
+  state.addTransition(trans);
 
-       var req = _this.callRpc(fsm, "samba.ejsnet", callName, callArgs);
+  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
@@ -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");
       }
index 8e92f4753d3621fd630e3aec3d92b6c21c513307..8f9f664a74ebb8e34c7609d2475631dcc6982164 100644 (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);
 };
 
 
index b1b16b61bd665589bf70247d8389d22efeb7698d..2e87a27b4b18294ca164a5f4b7b8e5bf1f406baf 100644 (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;
+};