Skip to content

Commit

Permalink
Use tracks instead of groups for clarity, add sections and dataset id…
Browse files Browse the repository at this point in the history
… to minimal example
  • Loading branch information
guerler committed Sep 5, 2024
1 parent a24ac91 commit b90d022
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 12 deletions.
2 changes: 1 addition & 1 deletion client/src/mvc/visualization/chart/views/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions client/src/mvc/visualization/chart/views/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -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...");
Expand Down Expand Up @@ -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();
Expand Down
17 changes: 17 additions & 0 deletions config/plugins/visualizations/example/config/example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,21 @@
<param type="dataset" var_name_in_template="hda" required="true">dataset_id</param>
</params>
<entry_point entry_point_type="script" src="script.js" />
<settings>
<input>
<name>setting_input</name>
<help>setting help</help>
<type>setting_type</type>
</input>
</settings>
<specs>
<spec_name>spec_value</spec_name>
</specs>
<tracks>
<input>
<name>track_input</name>
<help>track help</help>
<type>track_type</type>
</input>
</tracks>
</visualization>
15 changes: 10 additions & 5 deletions config/plugins/visualizations/example/static/script.js
Original file line number Diff line number Diff line change
@@ -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);
6 changes: 3 additions & 3 deletions lib/galaxy/visualization/plugins/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/visualization/plugins/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}

Expand Down

0 comments on commit b90d022

Please sign in to comment.