From b90d0224bf7bd730ff061e951181609ff03fa0d2 Mon Sep 17 00:00:00 2001 From: guerler Date: Thu, 5 Sep 2024 09:47:09 +0300 Subject: [PATCH] Use tracks instead of groups for clarity, add sections and dataset id to minimal example --- .../src/mvc/visualization/chart/views/editor.js | 2 +- .../src/mvc/visualization/chart/views/groups.js | 4 ++-- .../visualizations/example/config/example.xml | 17 +++++++++++++++++ .../visualizations/example/static/script.js | 15 ++++++++++----- .../visualization/plugins/config_parser.py | 6 +++--- lib/galaxy/visualization/plugins/plugin.py | 2 +- 6 files changed, 34 insertions(+), 12 deletions(-) diff --git a/client/src/mvc/visualization/chart/views/editor.js b/client/src/mvc/visualization/chart/views/editor.js index 3c9c21bb3f32..3b0a3f026285 100644 --- a/client/src/mvc/visualization/chart/views/editor.js +++ b/client/src/mvc/visualization/chart/views/editor.js @@ -36,7 +36,7 @@ export default Backbone.View.extend({ ) .append(new Settings(this.app).$el), }); - if (this.chart.plugin.groups) { + if (this.chart.plugin.tracks) { this.tabs.add({ id: "groups", icon: "fa-database", diff --git a/client/src/mvc/visualization/chart/views/groups.js b/client/src/mvc/visualization/chart/views/groups.js index fa3f68f4f8be..b262c9968fbe 100644 --- a/client/src/mvc/visualization/chart/views/groups.js +++ b/client/src/mvc/visualization/chart/views/groups.js @@ -25,7 +25,7 @@ var GroupView = Backbone.View.extend({ }, render: function () { var self = this; - var inputs = Utils.clone(this.chart.plugin.groups) || []; + var inputs = Utils.clone(this.chart.plugin.tracks) || []; var dataset_id = this.chart.get("dataset_id"); if (dataset_id) { this.chart.state("wait", "Loading metadata..."); @@ -127,7 +127,7 @@ export default Backbone.View.extend({ }); }, render: function () { - if (_.size(this.chart.plugin.groups) > 0) { + if (_.size(this.chart.plugin.tracks) > 0) { this.repeat.$el.show(); } else { this.repeat.$el.hide(); diff --git a/config/plugins/visualizations/example/config/example.xml b/config/plugins/visualizations/example/config/example.xml index 7dbd35772190..984058c44440 100644 --- a/config/plugins/visualizations/example/config/example.xml +++ b/config/plugins/visualizations/example/config/example.xml @@ -13,4 +13,21 @@ dataset_id + + + setting_input + setting help + setting_type + + + + spec_value + + + + track_input + track help + track_type + + \ No newline at end of file diff --git a/config/plugins/visualizations/example/static/script.js b/config/plugins/visualizations/example/static/script.js index 2a299587cf65..e17270b74957 100644 --- a/config/plugins/visualizations/example/static/script.js +++ b/config/plugins/visualizations/example/static/script.js @@ -1,28 +1,33 @@ -const { visualization_plugin: plugin, root } = JSON.parse(document.getElementById("app").dataset.incoming); +const { visualization_config, visualization_plugin, root } = JSON.parse(document.getElementById("app").dataset.incoming); const div = Object.assign(document.createElement("div"), { style: "border: 2px solid #25537b; border-radius: 1rem; padding: 1rem" }); const img = Object.assign(document.createElement("img"), { - src: root + plugin.logo, + src: root + visualization_plugin.logo, style: "height: 3rem" }); - div.appendChild(img); -Object.entries(plugin).forEach(([key, value]) => { +Object.entries(visualization_plugin).forEach(([key, value]) => { const row = document.createElement("div"); const spanKey = Object.assign(document.createElement("span"), { innerText: `${key}: `, style: "font-weight: bold" }); const spanValue = Object.assign(document.createElement("span"), { - innerText: value + innerText: JSON.stringify(value) }); row.appendChild(spanKey); row.appendChild(spanValue); div.appendChild(row); }); +const dataset = Object.assign(document.createElement("div"), { + innerText: `You have selected dataset: ${visualization_config.dataset_id}.`, + style: "font-weight: bold; padding-top: 1rem;" +}); +div.appendChild(dataset); + document.body.appendChild(div); diff --git a/lib/galaxy/visualization/plugins/config_parser.py b/lib/galaxy/visualization/plugins/config_parser.py index 160f52acef2c..9790b188552b 100644 --- a/lib/galaxy/visualization/plugins/config_parser.py +++ b/lib/galaxy/visualization/plugins/config_parser.py @@ -151,9 +151,9 @@ def parse_visualization(self, xml_tree): if (specs_section := xml_tree.find("specs")) is not None: returned["specs"] = DictParser(specs_section) - # load group specifiers - if (groups_section := xml_tree.find("groups")) is not None: - returned["groups"] = ListParser(groups_section) + # load tracks specifiers (allow 'groups' tag for backward compatibility) + if (tracks_section := xml_tree.find("tracks") or xml_tree.find("groups")) is not None: + returned["tracks"] = ListParser(tracks_section) # load settings specifiers if (settings_section := xml_tree.find("settings")) is not None: diff --git a/lib/galaxy/visualization/plugins/plugin.py b/lib/galaxy/visualization/plugins/plugin.py index c53f7977834a..e3bdf0e03d3c 100644 --- a/lib/galaxy/visualization/plugins/plugin.py +++ b/lib/galaxy/visualization/plugins/plugin.py @@ -125,8 +125,8 @@ def to_dict(self): "embeddable": self.config.get("embeddable"), "entry_point": self.config.get("entry_point"), "settings": self.config.get("settings"), - "groups": self.config.get("groups"), "specs": self.config.get("specs"), + "tracks": self.config.get("tracks"), "href": self._get_url(), }