summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--webapps/swat/source/class/swat/module/netmgr/Fsm.js41
-rw-r--r--webapps/swat/source/class/swat/module/netmgr/Gui.js42
2 files changed, 69 insertions, 14 deletions
diff --git a/webapps/swat/source/class/swat/module/netmgr/Fsm.js b/webapps/swat/source/class/swat/module/netmgr/Fsm.js
index 09e8316fef..b5844ced37 100644
--- a/webapps/swat/source/class/swat/module/netmgr/Fsm.js
+++ b/webapps/swat/source/class/swat/module/netmgr/Fsm.js
@@ -43,7 +43,7 @@ qx.Proto.buildFsm = function(module)
result.data.origin == origins.Server &&
result.data.code == serverErrors.ResourceError)
{
- this.debug("error" + result);
+ alert("Error when receiving rpc: '" + result.id + "'" + " exception: " + result.data);
}
else
{
@@ -63,7 +63,13 @@ qx.Proto.buildFsm = function(module)
{
"swat.main.canvas" :
"Transition_Idle_to_AwaitRpcResult_via_canvas_appear"
- }
+ },
+
+ "changeSelection" :
+ {
+ "tree" :
+ "Transition_Idle_to_AwaitRpcResult_via_tree_selection_changed"
+ }
}
});
@@ -87,6 +93,37 @@ qx.Proto.buildFsm = function(module)
// Add the new transition
state.addTransition(trans);
+ var trans = new qx.util.fsm.Transition(
+ "Transition_Idle_to_AwaitRpcResult_via_tree_selection_changed",
+ {
+ "nextState" : "State_AwaitRpcResult",
+
+ "ontransition" :
+ function(fsm, event)
+ {
+ var nodes = event.getData();
+ var selectedNode = nodes[0];
+
+ var gui = swat.module.netmgr.Gui.getInstance();
+ var parentNode = gui.getParentNode(module, selectedNode);
+
+ if (typeof(parentNode.credentials) == "object")
+ {
+ var creds = parentNode.credentials;
+ var request = _this.callRpc("samba.ejsnet", "NetContext", [ creds ]);
+ request.setUserData("requestType", "NetContext");
+ }
+ else
+ {
+ // TODO: display a login dialog
+ }
+ }
+
+ });
+
+ // Add the new transition
+ 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 d1376ab4c6..74a6eede33 100644
--- a/webapps/swat/source/class/swat/module/netmgr/Gui.js
+++ b/webapps/swat/source/class/swat/module/netmgr/Gui.js
@@ -85,6 +85,26 @@ qx.Proto.displayData = function(module, rpcRequest)
};
+qx.Proto.getParentNode = function(module, node)
+{
+ var tree = this._tree;
+ var nodes = tree.getTableModel().getData();
+ if (nodes == undefined)
+ {
+ return undefined;
+ }
+
+ if (node.parentNodeId == 0)
+ {
+ // there is no parent node
+ return node;
+ }
+
+ var parentNode = nodes[node.parentNodeId];
+ return parentNode;
+};
+
+
qx.Proto._addHostNode = function(module, rpcRequest)
{
var fsm = module.fsm;
@@ -93,22 +113,20 @@ qx.Proto._addHostNode = function(module, rpcRequest)
// Get the tree widget
var tree = this._tree;
var dataModel = tree.getDataModel();
-
- // Add new host and its service branches
+
+ // Add new host and its service leaves
var hostNodeId = dataModel.addBranch(null, hostname, false);
- var domainNodeId = dataModel.addBranch(hostNodeId, "Domain", false);
- var usersNodeId = dataModel.addBranch(hostNodeId, "Users", false);
- var groupsNodeId = dataModel.addBranch(hostNodeId, "Groups", false);
- var srvcsNodeId = dataModel.addBranch(hostNodeId, "Services", false);
-
- // Services don't expand
- dataModel.setState(domainNodeId, { bHideOpenClose : true });
- dataModel.setState(usersNodeId, { bHideOpenClose : true });
- dataModel.setState(groupsNodeId, { bHideOpenClose : true });
- dataModel.setState(srvcsNodeId, { bHideOpenClose : true });
+ var domainNodeId = dataModel.addLeaf(hostNodeId, "Domain", false);
+ var usersNodeId = dataModel.addLeaf(hostNodeId, "Users", false);
+ var groupsNodeId = dataModel.addLeaf(hostNodeId, "Groups", false);
+ var srvcsNodeId = dataModel.addLeaf(hostNodeId, "Services", false);
dataModel.setData();
+ tree.addEventListener("changeSelection", fsm.eventListener, fsm);
+
+ var hostNode = dataModel.getData()[hostNodeId];
+ hostNode.credentials = undefined;
};