Skip to content

Commit db79299

Browse files
committed
feat: Add navigation via details pane
1 parent 2221132 commit db79299

File tree

1 file changed

+49
-13
lines changed

1 file changed

+49
-13
lines changed

index.js

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,45 @@ function showDetails(data, outgoers) {
1212
const details = document.getElementById("details");
1313
// Basic description
1414
if (data === null) {
15-
details.innerHTML = "<br />"
16-
details.innerHTML += "<h2>Using this resource</h2>"
17-
details.innerHTML += "<ul>"
18-
details.innerHTML += "<li>Use the 'Filter Toggle' button to activate the simulation engine filter.</li>"
19-
details.innerHTML += "<li>Select what simulation engines you would like to show in the graph.</li>"
20-
details.innerHTML += "<li>Select a node/edge to see its ecosystem in the graph.</li>"
21-
details.innerHTML += "<li>Double click/tap on a node/edge to see details of the tool.</li>"
22-
details.innerHTML += "<li>Click outside to unselect nodes.</li>"
23-
details.innerHTML += "</ul>"
24-
details.innerHTML += "<h2 class='mt-3'>Contributing</h2>"
15+
details.innerHTML = "<br />";
16+
details.innerHTML += "<h2>Using this resource</h2>";
17+
details.innerHTML += "<ul>";
18+
details.innerHTML += "<li>Use the 'Toggle Filters' button to activate the simulation engine filter.</li>";
19+
details.innerHTML += "<li>Select what simulation engines you would like to show in the graph.</li>";
20+
details.innerHTML += "<li>Select a node/edge to see its ecosystem in the graph.</li>";
21+
details.innerHTML += "<li>Double click/tap on a node/edge to see details of the tool.</li>";
22+
details.innerHTML += "<li>Click outside to unselect nodes.</li>";
23+
details.innerHTML += "</ul>";
24+
details.innerHTML += "<h3 class='mt-3'>Contributing</h2>";
2525
details.innerHTML += `<p>Contributions are welcome! If you have anything to add or correct in the data,
2626
please follow the link at the end of the tool's details view to edit the data on GitHub.
27-
You can also open an <a href='${REPO_URL}/issues'>issue on the GitHub repository</a>.</p>`
27+
You can also open an <a href='${REPO_URL}/issues'>issue on the GitHub repository</a>.</p>`;
28+
details.innerHTML += "<h3 class='mt-3'>List of simulators</h2>";
29+
details.innerHTML += "<div class='d-flex'>";
30+
for (const sim of SIMULATORS) {
31+
const quoted_sim = `[id='${sim}']`;
32+
details.innerHTML += `<button class='btn btn-secondary m-1' onclick="cy.nodes('#simulators').unselect(); let node = cy.nodes('${quoted_sim.replace(/'/g, "\\'")}'); node.select(); showNodeDetails(node);">${TOOL_DESCRIPTIONS[sim].short_name}</button>`;
33+
}
34+
details.innerHTML += "</div>";
35+
2836
}
2937
else {
30-
details.innerHTML = "<h2>" + data["full_name"] + "</h2>";
38+
if (data["features"].includes("simulator")) {
39+
const quoted_sim = `[id='${data.id}']`;
40+
details.innerHTML = `<div class='d-flex justify-content-between align-items-center'>
41+
<h2>${data["full_name"]}</h2>
42+
<button class='btn btn-outline-primary align-middle' title='Center ${data["short_name"]} in the graph' onclick="highlightNode(cy.nodes('${quoted_sim.replace(/'/g, "\\'")}'));">
43+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bullseye" viewBox="0 0 16 16">
44+
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/>
45+
<path d="M8 13A5 5 0 1 1 8 3a5 5 0 0 1 0 10m0 1A6 6 0 1 0 8 2a6 6 0 0 0 0 12"/>
46+
<path d="M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6m0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8"/>
47+
<path d="M9.5 8a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0"/>
48+
</svg>
49+
</button>
50+
</div>`;
51+
} else {
52+
details.innerHTML = `<h2>${data["full_name"]}</h2>`;
53+
}
3154
details.innerHTML += "<p>" + data["description"] + "</p>";
3255
}
3356
// Relations
@@ -59,6 +82,19 @@ function showDetails(data, outgoers) {
5982
details.appendChild(urlButton(text, url));
6083
}
6184
}
85+
// Back to simulators
86+
back_p = document.createElement("p");
87+
back_p.classList.add("mt-3");
88+
back_button = document.createElement("a");
89+
back_button.href = "#";
90+
back_button.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-counterclockwise" viewBox="0 0 16 16">
91+
<path fill-rule="evenodd" d="M8 3a5 5 0 1 1-4.546 2.914.5.5 0 0 0-.908-.417A6 6 0 1 0 8 2z"/>
92+
<path d="M8 4.466V.534a.25.25 0 0 0-.41-.192L5.23 2.308a.25.25 0 0 0 0 .384l2.36 1.966A.25.25 0 0 0 8 4.466"/>
93+
</svg>&nbsp;Back to simulators`;
94+
back_button.classList.add("btn", "btn-secondary");
95+
back_button.onclick = function() { cy.nodes(`[id = '${data.id}']`).unselect(); cy.nodes("#simulators").select(); unhighlightNode(); };
96+
back_p.appendChild(back_button);
97+
details.appendChild(back_p);
6298
// Edit footer
6399
edit_p = document.createElement("p");
64100
edit_p.classList.add("mt-3", "text-end");
@@ -131,7 +167,7 @@ Promise.all([
131167
description[name] = description[name].split(",").map(x => x.trim());
132168
}
133169
description["full_name"] = description["name"];
134-
description["short_name"] = description["short_name"] || description["name"];
170+
description["short_name"] = name;
135171
description["description"] = description["summary"];
136172
TOOL_DESCRIPTIONS[name] = description;
137173
}

0 commit comments

Comments
 (0)