Skip to content

Commit

Permalink
Update minimal plugin example
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Sep 5, 2024
1 parent 3365ead commit a24ac91
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions config/plugins/visualizations/example/static/script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
var element = document.getElementById("app");
var div = document.createElement('div');
div.innerText = JSON.stringify(JSON.parse(element.getAttribute("data-incoming")));
document.body.appendChild(div);
const { visualization_plugin: 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,
style: "height: 3rem"
});

div.appendChild(img);

Object.entries(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
});
row.appendChild(spanKey);
row.appendChild(spanValue);
div.appendChild(row);
});

document.body.appendChild(div);

0 comments on commit a24ac91

Please sign in to comment.