Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/curation/click.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ function filterFunction() {
a[i].style.display = "none";
}
}
}
}
95 changes: 95 additions & 0 deletions public/curation/conflict/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="stylesheet" href="../../style.css">
<title>Software CaRD</title>
<link rel="icon" href="../../pictures/Logo.png" type="image/icon type">

</head>
<body>
<div id="header">
<h1><a href="../">Software CaRD</a>
</h1>
<canvas onclick="location.href = '../reporting/';" id="radar" width="80" height="80">
</canvas>
</div>




<p id="project-name"><b>Curation Conflict</b></p>

<!--
"@id": ["https://orcid.org/0000-0001-6372-3853",
{
"plugin": "cff",
"local_path": "CITATION.cff",
"timestamp": "2025-03-18T13:28:37.657148",
"harvester": "cff",
"alternative_source":{"plugin": "codemeta",
"value": "https://orcid.org/0000-0001-2345-6789",
"local_path": "codemeta.md",
"timestamp": "2025-04-18T13:28:37.657148",
"harvester": "codemeta"}
},
{"conflict": "Curation"}
-->
<div id="content">
<p>See the conflict in the folling tables:</p>
<div id="conflict">
<table class="table table-striped">
<colgroup>
<col id="col0">
<col id="col1">
</colgroup>

<tbody id="metadata">
<tr >
<th colspan="2">CITATION.cff</th>
</tr>
<tr>
<td id="key">@id</td>
<td id="value">
https://orcid.org/0000-0001-6372-3853
</td>
</tr>

</tbody>
</table>
<table class="table table-striped">
<colgroup>
<col id="col0">
<col id="col1">
</colgroup>
<tbody id="metadata">
<tr >
<th colspan="2">codemeta.md</th>
</tr>
<tr>
<td id="key">@id</td>
<td id="value">
https://orcid.org/0000-0001-2345-6789
</td>
</tr>

</tbody>
</table>
</div>
</div>
<p>


</p>
<div class="comment">
<p>Add comment to conflict</p>
<textarea rows="2" cols="70"></textarea>
<button>Add Comment</button>
</div>

</body>
</html>
21 changes: 21 additions & 0 deletions public/curation/curation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { extract_info } from "./extract.js";
import { addToBatch } from "./safe_comments.js";

/**
* Fetches json_document and displays their contents in a table.
Expand Down Expand Up @@ -102,6 +103,24 @@ export function displayJSON(json_document){
extract_info(mvalue, data[element], mtag, colorPolicies);

tbody.appendChild(row);

const slcomment = mvalue.querySelector("#single-line-comment"),
slcommentPopup = mvalue.querySelector("#single-line-comment-popup");
const input = mvalue.querySelector("#comment");
mvalue.querySelector('input[type="submit"]').addEventListener("click", () => {
addToBatch(element, data[element], input.value);
});
slcomment.addEventListener('click', (event)=>{
event.stopPropagation();
console.log("clicked");
slcommentPopup.style.visibility = "visible";
})
document.addEventListener('click', function(e) {
if ( slcommentPopup.style.visibility === "visible" && !slcommentPopup.contains(e.target) ) {
slcommentPopup.style.visibility = "hidden";
}
})

})
})
//Extend Checkbox for metadata source
Expand All @@ -117,6 +136,8 @@ export function displayJSON(json_document){

}



/**
* Function to get a smaller object from the orginal object.
* searches through data till skey and svalue match and return the data from this point.
Expand Down
15 changes: 9 additions & 6 deletions public/curation/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ function extract_info(cell, obj, tag, colorPolicies){
element.style.color = colorPolicies[obj[2]["conflict"]];
element.appendChild(document.createTextNode(` ${obj[0]}`));
cell.appendChild(element);
console.log("parent: "+cell.parentNode)
//cell.parentNode.style.background = colorPolicies[obj[2]["conflict"]];
}else{
cell.appendChild(document.createTextNode(` ${obj[0]}`));
}
Expand Down Expand Up @@ -53,12 +55,13 @@ function extract_info(cell, obj, tag, colorPolicies){
}

function extract_person(e, element, tag, colorPolicies){
let hasConfict = false;
const tooltip = document.createElement("div");
const tooltiptag = document.createElement("div");
tooltip.classList.add("tooltip");
tooltip.classList.add("swc-tooltip");
tooltip.onclick = function(){link_to_person(e)};
const tooltiptext = document.createElement("div");
tooltiptext.classList.add("tooltiptext");
tooltiptext.classList.add("swc-tooltiptext");
const text = document.createTextNode(`${e.familyName[0]}, ${e.givenName[0]} `);
tooltiptag.appendChild(document.createTextNode("See Details"));
tooltiptag.appendChild(document.createElement("br"));
Expand All @@ -77,8 +80,8 @@ function extract_info(cell, obj, tag, colorPolicies){
if(e[k][key][2] && e[k][key][2]["conflict"]){
pair_in_list.style.color = colorPolicies[e[k][key][2]["conflict"]];
tooltiptag.style.color = colorPolicies[e[k][key][2]["conflict"]];
/*pair_in_list.className += " error";
tooltiptag.className += " error";*/
hasConfict = true;

}
pair.appendChild(pair_in_list);
}
Expand All @@ -89,8 +92,7 @@ function extract_info(cell, obj, tag, colorPolicies){
if(e[k][2] && e[k][2]["conflict"]){
pair.style.color = colorPolicies[e[k][2]["conflict"]];
tooltiptag.style.color = colorPolicies[e[k][2]["conflict"]];
//pair.className += " error";
//tooltiptag.className += " error";
hasConfict = true;
}
}
tooltiptext.appendChild(pair);
Expand All @@ -99,6 +101,7 @@ function extract_info(cell, obj, tag, colorPolicies){
tooltip.appendChild(tooltiptext);
tooltip.appendChild(text);
element.appendChild(tooltip);
return hasConfict;
}

function link_to_person(data){
Expand Down
44 changes: 37 additions & 7 deletions public/curation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">


<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="stylesheet" href="../style.css">
<title>Software CaRD</title>
<link rel="icon" href="../pictures/Logo.png" type="image/icon type">


</head>
<body>
Expand All @@ -19,14 +18,32 @@ <h1><a href="../">Software CaRD</a>
<canvas onclick="location.href = '../reporting/';" id="radar" width="80" height="80">
</canvas>
</div>
<div class="navigation">
<div>
<a class="notes">&#x270D; <!-- Or &#x1F4AC; -->
<p class="notes-desc">Start to gather curation notes</p>
</a>
</div>
<div>
<a class="notes" id="sendReport">&#x1F4C3; <!-- Or &#x1F3AB; -->
<p class="notes-desc">Send Issue Report to GitLab/GitHub</p>
</a>
</div>
<div id="user-login">
<a class="notes" href="../gitlab-setup/"> &#x1F464; <!-- Or &#x1F4AC; -->
<p class="notes-desc">Authentificate to GitLab/GitHub</p>
<a>
</div>

</div>

<p id="project-name"><b>Metadata</b></p>
<div class="operators">



<div class="dropdown">
<button onclick="showFilter()" class="dropbtn">Filter</button>
<button onclick="showFilter()" class="btn btn-primary dropbtn">Filter</button>
<div id="filterDropdown" class="dropdown-content">
<input type="text" placeholder="Search.." id="myInput" onkeyup="filterFunction()">
<a>&#10004; Select all</a>
Expand All @@ -36,14 +53,15 @@ <h1><a href="../">Software CaRD</a>
</template>
</div>
</div>

<input type="checkbox" id="extended" name="extended" value=1 checked>
<label for="extended">Extended view</label><br>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="extended" name="extended" role="switch" value=1 checked>
<label class="form-check-label" for="extended">Extended view</label><br>
</div>
</div>

<div id="content">
<div id="hermes">
<table>
<table class="table table-striped">
<colgroup>
<col id="col0">
<col id="col1">
Expand All @@ -54,6 +72,17 @@ <h1><a href="../">Software CaRD</a>
<tr>
<td id="key"></td>
<td id="value">
<div class="single-line-comment" id="single-line-comment">+
<p class="hover-text">Comment on this row</p>

<div class="single-line-comment-popup" id="single-line-comment-popup">
<div class="label-input">
<label for="name">Comment:</label><br>
<input type="text" id="comment" name="comment" required><br>
</div>
<input type="submit" value="Add to batch">
</div>
</div>
</td>
<td id="tag"></td>
</tr>
Expand Down Expand Up @@ -88,6 +117,7 @@ <h3 id="header-policies">Policy Report</h3>

<script type="module" src="./script.js"></script>
<script src="./click.js"></script>
<script type="module" src="./send_report.js"></script>

</body>
</html>
5 changes: 5 additions & 0 deletions public/curation/safe_comments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { addComment } from '../modules/storage.js'

export async function addToBatch(value, data, comment){
addComment(value, data, comment);
}
85 changes: 85 additions & 0 deletions public/curation/send_report.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { retrieveComment, retrievePipeline } from "../modules/storage.js";
import { Octokit } from "https://esm.sh/@octokit/rest";


const report = document.getElementById("sendReport");
report.addEventListener("click", sendReport);
async function sendReport(){
var message = "In [Software-CaRD](https://software-metadata.pub/software-card/) the following notes were added.\n";
var comment = await retrieveComment();
while (comment !== null) {

message += `
### ${comment.value}

${comment.comment}
<table><tr>
<td>${comment.value}</td><td>${json.stringify(comment.data[0])}</td>
</tr></table>

`;

comment = await retrieveComment();
}

console.log(message);


const token = localStorage.getItem("gitlab-api-token");
const username = localStorage.getItem("gitlab-username");
var [projectId, pipelineId, jobId] = await retrievePipeline();
if(token.startsWith("glpat")){
issueGitlab(token, projectId, message);
}else{
issueGithub(token, username, message);
}
}

async function issueGitlab(token, projectId, message){
const response = await fetch(
`https://codebase.helmholtz.cloud/api/v4/projects/${projectId}/issues`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
"PRIVATE-TOKEN": token
},
body: JSON.stringify({
title: "Software CaRD Report",
description: message
})
}
);

const data = await response.json();

}
async function issueGithub(token, username, message){
//TODO Test for Github
const octokit = new Octokit({
auth: token
})

try{
await octokit.request('POST /repos/SKernchen/SoftwareCaRD-Test/issues', {
owner: `${username}`,
repo: 'SoftwareCaRD-test',
title: `Curation Report`,
labels: ['curation'],
body: message,
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
})
alert("Send to GitHub");
}catch(error){
if (error.response) {
console.error(`Error! Status: ${error.response.status}. Message: ${error.response.data.message}`)
}
console.error(error)
document.body.innerHTML = `<h1>Oooopsie</h1><div class="main"><p>Your Report could not get sended to GitHub! Consider sending this: </p><p style="color:blue">${message}<p> another way.</p>
<p>Error message: ${error}</p>
<a id="for" href="../"><i class="arrow left"></i>Back to Dashboard</a>
</div>`;
}
}
Loading