Skip to content

Commit

Permalink
Added pid-component as export option, added missing data type in mapp…
Browse files Browse the repository at this point in the history
…ing, reduced graph simulation speed
  • Loading branch information
ThomasJejkal committed Dec 12, 2023
1 parent 1066e26 commit 68acb87
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
37 changes: 36 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
integrity="sha512-uXfi0GwpQZcHIhGOMMHeNYtBSjt7qDXjXHmjShWSp+RWMSmjdy69N7M/pufinvQLv6rSYlpbSXqSnLRzWE952w=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdn.jsdelivr.net/npm/d3@7.6.1/dist/d3.min.js"></script>
<script type='module' src='https://unpkg.com/@kit-data-manager/pid-component'></script>

<script src="./js/mappings.js"></script>
<script src="./js/ArcGraph.js"></script>
Expand Down Expand Up @@ -129,6 +130,21 @@ <h4 class="ui header">
<div class="ui segment">
<svg id="tree"/>
</div>

<h4 class="ui header">
<i class="html5 icon"></i>
<div class="content">
PID Component
</div>
</h4>
<div class="ui segment">
<pid-component id="pidcom" value="None"></pid-component><br/>
<div id="copycode" class="ui labeled button">
<div class="ui button">
<i class="code icon"></i> Copy Code
</div>
</div>
</div>
</div>


Expand Down Expand Up @@ -272,11 +288,29 @@ <h4 class="ui header">
navigator.clipboard.writeText(getBadgeElement(pid, value)).then(function () {
addMessage(0, "Badge copied to clipboard.");
}, function (err) {
addMessage(1, "Failed to copy badge clipboard.");
addMessage(1, "Failed to copy badge to clipboard.");
});
}
});

$('#copycode').click(() => {
let code = "<html>\n";
code += "<head>\n";
code += "\<script type='module' src='https://unpkg.com/@kit-data-manager/pid-component'\>\</script\>\n";
code += "</head>\n";
code += "<body>\n";
code += "<pid-component value=\"" + $("#pidcom").attr("value") + "\"></pid-component>\n";
code += "</body>\n";
code += "</html>";

navigator.clipboard.writeText(code).then(function () {
addMessage(0, "Code copied to clipboard.");
}, function (err) {
addMessage(1, "Failed to copy code clipboard.");
});

});


/**Renderer function for PID record table cells. This function is used on the one hand for the type column to
* determine the type name obtained from 'js/mappings.js' in interactive mode, on the other hand to render the
Expand Down Expand Up @@ -351,6 +385,7 @@ <h4 class="ui header">
*/
function loadPid() {
pid = document.getElementById("pid_input").value;
$("#pidcom").attr("value", pid);

if (pid.startsWith("sandboxed")) {
resolver = new TPMLoader();
Expand Down
2 changes: 1 addition & 1 deletion js/ArcGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function ArcGraph({
let drag = simulation => {

function dragstarted(event, d) {
if (!event.active) simulation.alphaTarget(0.3).restart();
if (!event.active) simulation.alphaTarget(0.1).restart();
d.fx = d.x;
d.fy = d.y;
}
Expand Down
11 changes: 9 additions & 2 deletions js/mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ function renderHdl(type,value){
break;
}
}
}
},
error: function (status) {

}
});

if(isType){
Expand All @@ -31,7 +34,10 @@ function renderHdl(type,value){
}else if(isFairDO) {
addChildFdo(type, value, profilePid, pid);
return "<a href='#' onClick=resolveFDO(\'" + value + "\')>" + value + "&nbsp;<i class=\"fa-solid fa-arrows-rotate\"></i></a>";
}
}/*else if(value.startsWith("sandboxed")) {
addChildFdo(type, value, "21.T11148/b9b76f887845e32d29f7", pid);
return "<a href='#' onClick=resolveFDO(\'" + value + "\')>" + value + "&nbsp;<i class=\"fa-solid fa-arrows-rotate\"></i></a>";
}*/
}

function renderText(type, value){
Expand All @@ -49,6 +55,7 @@ let dataTypes = new Map();
//HelmholtzKIP
dataTypes.set("21.T11148/076759916209e5d62bd5", {'name': 'kernelInformationProfile', 'class':'fa-solid fa-table-list', 'renderer': renderHdl});
dataTypes.set("21.T11148/397d831aa3a9d18eb52c", {'name': 'dateModified', 'class':'fa-solid fa-file-pen', 'renderer': renderText});
dataTypes.set("21.T11148/dcd4e99d26a00b8132f8", {'name': 'accessProtocol', 'class':'fa-solid fa-right-left', 'renderer': renderText});
dataTypes.set("21.T11148/82e2503c49209e987740", {'name': 'checksum', 'class':'fa-solid fa-hashtag', 'renderer': renderText});
dataTypes.set("21.T11148/29f92bd203dd3eaa5a1f", {'name': 'dateCreated', 'class':'fa-solid fa-file-circle-plus', 'renderer': renderText});
dataTypes.set("21.T11148/b8457812905b83046284", {'name': 'digitalObjectLocation', 'class':'fa-solid fa-location-dot', 'renderer': renderUrl});
Expand Down

0 comments on commit 68acb87

Please sign in to comment.