Skip to content

Commit

Permalink
Add sections and dataset id to example
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Sep 5, 2024
1 parent a24ac91 commit 4e3eebd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
19 changes: 18 additions & 1 deletion 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" />
</visualization>
<settings>
<input>
<name>setting_input</name>
<help>setting help</help>
<type>setting_type</type>
</input>
</settings>
<groups>
<input>
<name>group_input</name>
<help>group help</help>
<type>group_type</type>
</input>
</groups>
<specs>
<spec_name>spec_value</spec_name>
</specs>
</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);

0 comments on commit 4e3eebd

Please sign in to comment.