diff --git a/corefx/src/main/java/com/core/client/ICoreClient.java b/corefx/src/main/java/com/core/client/ICoreClient.java index 94cdc907..1e8796f7 100644 --- a/corefx/src/main/java/com/core/client/ICoreClient.java +++ b/corefx/src/main/java/com/core/client/ICoreClient.java @@ -36,15 +36,15 @@ public interface ICoreClient { boolean setServiceFile(CoreNode node, String serviceName, ServiceFile serviceFile) throws IOException; - GetConfig getEmaneModelConfig(CoreNode node, String model) throws IOException; - GetConfig getEmaneConfig(CoreNode node) throws IOException; GetEmaneModels getEmaneModels() throws IOException; boolean setEmaneConfig(CoreNode node, List options) throws IOException; - boolean setEmaneModelConfig(CoreNode node, String model, List options) throws IOException; + GetConfig getEmaneModelConfig(Integer id, String model) throws IOException; + + boolean setEmaneModelConfig(Integer id, String model, List options) throws IOException; boolean isRunning(); diff --git a/corefx/src/main/java/com/core/client/rest/CoreRestClient.java b/corefx/src/main/java/com/core/client/rest/CoreRestClient.java index fe929e1e..651e555c 100644 --- a/corefx/src/main/java/com/core/client/rest/CoreRestClient.java +++ b/corefx/src/main/java/com/core/client/rest/CoreRestClient.java @@ -238,10 +238,10 @@ public class CoreRestClient implements ICoreClient { } @Override - public GetConfig getEmaneModelConfig(CoreNode node, String model) throws IOException { + public GetConfig getEmaneModelConfig(Integer id, String model) throws IOException { String url = getUrl(String.format("sessions/%s/emane/model/config", sessionId)); Map args = new HashMap<>(); - args.put("node", node.getId().toString()); + args.put("node", id.toString()); args.put("name", model); return WebUtils.getJson(url, GetConfig.class, args); } @@ -264,10 +264,10 @@ public class CoreRestClient implements ICoreClient { } @Override - public boolean setEmaneModelConfig(CoreNode node, String model, List options) throws IOException { + public boolean setEmaneModelConfig(Integer id, String model, List options) throws IOException { String url = getUrl(String.format("sessions/%s/emane/model/config", sessionId)); SetEmaneModelConfig setEmaneModelConfig = new SetEmaneModelConfig(); - setEmaneModelConfig.setNode(node.getId()); + setEmaneModelConfig.setNode(id); setEmaneModelConfig.setName(model); setEmaneModelConfig.setValues(options); return WebUtils.putJson(url, setEmaneModelConfig); diff --git a/corefx/src/main/java/com/core/ui/NodeDetails.java b/corefx/src/main/java/com/core/ui/NodeDetails.java index c0f57a2c..298dfc59 100644 --- a/corefx/src/main/java/com/core/ui/NodeDetails.java +++ b/corefx/src/main/java/com/core/ui/NodeDetails.java @@ -48,6 +48,8 @@ public class NodeDetails extends ScrollPane { } catch (IOException ex) { throw new RuntimeException(ex); } + + setPrefWidth(500); } public void setNode(CoreNode node) { @@ -67,8 +69,12 @@ public class NodeDetails extends ScrollPane { addSeparator(); - addRow("X", node.getPosition().getX().toString()); - addRow("Y", node.getPosition().getY().toString()); + if (node.getPosition().getX() != null) { + addRow("X", node.getPosition().getX().toString()); + } + if (node.getPosition().getY() != null) { + addRow("Y", node.getPosition().getY().toString()); + } for (CoreLink link : controller.getNetworkGraph().getGraph().getIncidentEdges(node)) { CoreNode linkedNode; @@ -87,13 +93,23 @@ public class NodeDetails extends ScrollPane { addSeparator(); if (linkedNode.getType() == NodeType.EMANE) { - addButton(linkedNode.getName(), event -> controller.getNodeEmaneDialog().showDialog(linkedNode)); + String emaneModel = linkedNode.getEmane(); + String linkedLabel = String.format("%s - %s", linkedNode.getName(), emaneModel); + addButton(linkedLabel, event -> controller.getNodeEmaneDialog() + .displayEmaneModelConfig(linkedNode.getId(), emaneModel)); + String nodeLabel = String.format("%s - %s", node.getName(), emaneModel); + addButton(nodeLabel, event -> controller.getNodeEmaneDialog() + .displayEmaneModelConfig(node.getId(), emaneModel)); + String interfaceLabel = String.format("%s - %s", coreInterface.getName(), emaneModel); + Integer interfaceId = 1000 * node.getId() + coreInterface.getId(); + addButton(interfaceLabel, event -> controller.getNodeEmaneDialog() + .displayEmaneModelConfig(interfaceId, emaneModel)); } if (linkedNode.getType() == NodeType.WLAN) { addButton(linkedNode.getName(), event -> controller.getNodeWlanDialog().showDialog(linkedNode)); } - addInterface(coreInterface); + addInterface(coreInterface, linkedNode); } @@ -132,7 +148,8 @@ public class NodeDetails extends ScrollPane { GridPane.setMargin(separator, new Insets(10, 0, 0, 0)); } - private void addInterface(CoreInterface coreInterface) { + private void addInterface(CoreInterface coreInterface, CoreNode linkedNode) { + addRow("Linked To", linkedNode.getName()); addRow("Interface", coreInterface.getName()); if (coreInterface.getMac() != null) { addRow("MAC", coreInterface.getMac()); diff --git a/corefx/src/main/java/com/core/ui/NodeEmaneDialog.java b/corefx/src/main/java/com/core/ui/NodeEmaneDialog.java index 06a419aa..36dde607 100644 --- a/corefx/src/main/java/com/core/ui/NodeEmaneDialog.java +++ b/corefx/src/main/java/com/core/ui/NodeEmaneDialog.java @@ -68,26 +68,30 @@ public class NodeEmaneDialog extends StageDialog { } }); } catch (IOException ex) { - logger.error("error getting emane model config", ex); + Toast.error("error getting emane model config", ex); } } private void emaneModelButtonHandler(ActionEvent event) { String model = modelCombo.getSelectionModel().getSelectedItem(); + displayEmaneModelConfig(coreNode.getId(), model); + } + + public void displayEmaneModelConfig(Integer id, String model) { try { - GetConfig getConfig = getCoreClient().getEmaneModelConfig(coreNode, model); + GetConfig getConfig = getCoreClient().getEmaneModelConfig(id, model); logger.debug("emane model config: {}", getConfig); - String title = String.format("%s %s Config", coreNode.getName(), model); + String title = String.format("EMANE(%s) %s Config", id, model); getController().getConfigDialog().showDialog(title, getConfig, () -> { List options = getController().getConfigDialog().getOptions(); try { - getCoreClient().setEmaneModelConfig(coreNode, model, options); + getCoreClient().setEmaneModelConfig(id, model, options); } catch (IOException ex) { - logger.error("set emane model config error", ex); + Toast.error("set emane model config error", ex); } }); } catch (IOException ex) { - logger.error("error getting emane model config", ex); + Toast.error("error getting emane model config", ex); } } diff --git a/webapp/emane_routes.py b/webapp/emane_routes.py index 1f650f03..a386b11f 100644 --- a/webapp/emane_routes.py +++ b/webapp/emane_routes.py @@ -24,7 +24,7 @@ def set_emane_model_config(session_id): session = core_utils.get_session(coreemu, session_id) data = request.get_json() or {} model_name = data["name"] - node_id = data.get("node") + node_id = data["node"] values = data["values"] config = {x["name"]: x["value"] for x in values} session.emane.set_model_config(node_id, model_name, config) @@ -63,7 +63,7 @@ def get_emane_config(session_id): @api.route("/sessions//emane/model/config") def get_emane_model_config(session_id): session = core_utils.get_session(coreemu, session_id) - node_id = core_utils.get_node_id(request.args.get("node")) + node_id = core_utils.get_node_id(request.args["node"]) model_name = request.args["name"] model = session.emane.models[model_name]