diff --git a/webapp/app.py b/webapp/app.py index ce90135e..12b252fc 100644 --- a/webapp/app.py +++ b/webapp/app.py @@ -226,23 +226,8 @@ def set_config(session_id): return jsonify() -@app.route("/sessions//emane/models") -def get_emane_models(session_id): - session = coreemu.sessions.get(session_id) - if not session: - return jsonify(error="session does not exist"), 404 - - models = [] - for model in session.emane._modelclsmap.keys(): - if len(model.split("_")) != 2: - continue - models.append(model) - - return jsonify(models=models) - - -@app.route("/sessions//emane/options") -def get_emane_options(session_id): +@app.route("/sessions//config") +def get_config(session_id): session = coreemu.sessions.get(session_id) if not session: return jsonify(error="session does not exist"), 404 @@ -251,14 +236,16 @@ def get_emane_options(session_id): if node_id.isdigit(): node_id = int(node_id) + name = request.args["name"] + config_data = ConfigData( node=node_id, - object="emane", + object=name, type=ConfigFlags.REQUEST.value ) replies = session.config_object(config_data) if len(replies) != 1: - return jsonify(error="failure getting emane options"), 404 + return jsonify(error="failure getting config options"), 404 config_groups = replies[0] captions = config_groups.captions.split("|") @@ -266,7 +253,7 @@ def get_emane_options(session_id): possible_values = config_groups.possible_values.split("|") groups = config_groups.groups.split("|") - emane_options = [] + config_options = [] for i, data_type in enumerate(config_groups.data_types): data_value = data_values[i].split("=") value = None @@ -281,14 +268,14 @@ def get_emane_options(session_id): label = captions[i] - emane_option = { + config_option = { "label": label, "name": name, "value": value, "type": data_type, "select": select } - emane_options.append(emane_option) + config_options.append(config_option) config_groups = [] for group in groups: @@ -298,12 +285,27 @@ def get_emane_options(session_id): stop = indexes[1] config_groups.append({ "name": name, - "options": emane_options[start: stop] + "options": config_options[start: stop] }) return jsonify(groups=config_groups) +@app.route("/sessions//emane/models") +def get_emane_models(session_id): + session = coreemu.sessions.get(session_id) + if not session: + return jsonify(error="session does not exist"), 404 + + models = [] + for model in session.emane._modelclsmap.keys(): + if len(model.split("_")) != 2: + continue + models.append(model) + + return jsonify(models=models) + + @app.route("/sessions//nodes", methods=["POST"]) @synchronized def create_node(session_id): diff --git a/webapp/static/corerest.js b/webapp/static/corerest.js index 1f5de080..ed3ae567 100644 --- a/webapp/static/corerest.js +++ b/webapp/static/corerest.js @@ -69,8 +69,8 @@ class CoreRest { return await $.getJSON(`/sessions/${this.currentSession}/emane/models`); } - async getEmaneOptions(nodeId) { - return await $.getJSON(`/sessions/${this.currentSession}/emane/options`, {node: nodeId}); + async getConfig(config) { + return await $.getJSON(`/sessions/${this.currentSession}/config`, config); } async setConfig(config) { diff --git a/webapp/static/coreui.js b/webapp/static/coreui.js index 7ea98e11..51bac75c 100644 --- a/webapp/static/coreui.js +++ b/webapp/static/coreui.js @@ -96,7 +96,7 @@ class ConfigModel { const nodeId = this.$nodeEditModal.data('node'); this.$modal.data('type', 'emane'); this.$title.text('EMANE Options'); - const config = await this.coreRest.getEmaneOptions(nodeId); + const config = await this.coreRest.getConfig({node: nodeId, name: 'emane'}); console.log('emane options clicked: ', config); this.$tabHeaders.html(''); this.$tabContent.html('');