Skip to content
Open
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
22 changes: 19 additions & 3 deletions public/callback/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,24 @@ window.onload = async function () {
technicalInformationTextArea.value += key + ": " + value + "\n";
});
}
const token = localStorage.getItem("gitlab-api-token");

if(parameters.get("type")=="github"){
const owner = parameters.get("owner");
const repo = parameters.get("repo");
const artifactId = parameters.get("artifactId");
console.log(owner, repo, artifactId);
localStorage.setItem("owner", owner);
localStorage.setItem("repo", repo);
localStorage.setItem("artifactId", artifactId);
window.location = "../dashboard/";


}else{

const gitLabProjectId = parameters.get("gitlab_project_id");

const get_latest = parameters.get("latest");
let get_latest = parameters.get("latest");

const gitLabPipelineId = parameters.get("gitlab_pipeline_id");
const gitLabJobId = parameters.get("gitlab_job_id");
Expand All @@ -27,7 +41,6 @@ window.onload = async function () {
await new Promise(r => setTimeout(r, 5000));
}

const token = localStorage.getItem("gitlab-api-token");
if (token) {
if(get_latest==1){
await latest(gitLabProjectId, token);
Expand All @@ -37,9 +50,12 @@ window.onload = async function () {
return;
} else {
alert("Please set up the GitLab connection, then go to the dashboard!");
window.location = "../gitlab-setup/";
window.location = "../git-login/";
return;
}
}




}
Expand Down
46 changes: 30 additions & 16 deletions public/curation/curation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import { addToBatch } from "./safe_comments.js";
* Fetches json_document and displays their contents in a table.
* @param {Path} json_document - document do fetch data from.
*/
export function displayJSON(json_document){
fetch(json_document)
.then(response => response.json())
.then(data => {
export function displayJSON(data){
const colorPalette = ["rgb(34, 198, 227)", "purple", "rgb(23, 124, 207)", "rgb(116, 75, 196)", "pink"];
let colorPolicies = {"Curation": "red"};
if(data["policies"]){
Expand All @@ -18,10 +15,12 @@ export function displayJSON(json_document){
console.log(colorPolicies);
//Get data snippet from url
const params = new URLSearchParams(location.search);
if(params.has("id")){
const id = params.get("id")
data = get_data_snippet(data, "@id", id);

if(params.size > 0){
for (const [key, value] of params) {
console.log("search for",key, value);
data = get_data_snippet(data, key, value);
}

//If your seeing a data snippet, create button to go back
const back = document.createElement("button");
back.innerText = "Back to Overview";
Expand All @@ -43,10 +42,15 @@ export function displayJSON(json_document){


keys.forEach(element => {

// Get a something with Name as p Header
if(element.toLowerCase().includes("name")){
if(!Array.isArray(data[element])){
document.getElementById("project-name").innerHTML = element.charAt(0).toUpperCase() + element.slice(1) +' <b> '+data[element]+'</b>';
}else{
document.getElementById("project-name").innerHTML = element.charAt(0).toUpperCase() + element.slice(1) +' <b> '+data[element][0]+'</b>';
}
}
}
// Apply and fill in the template for Policies
if(element=="policies"){
header.style.display = "block";
Expand Down Expand Up @@ -107,22 +111,26 @@ export function displayJSON(json_document){
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)=>{
slcomment.addEventListener('click', (event)=>{
event.stopPropagation();
console.log("clicked");
if (event.target !== slcomment) {
return;
}
slcommentPopup.style.visibility = "visible";
})
mvalue.querySelector('input[type="submit"]').addEventListener("click", () => {
addToBatch(element, data[element], input.value);
slcommentPopup.style.visibility = "hidden";
});

document.addEventListener('click', function(e) {
if ( slcommentPopup.style.visibility === "visible" && !slcommentPopup.contains(e.target) ) {
slcommentPopup.style.visibility = "hidden";
}
})

})
})

//Extend Checkbox for metadata source
const checkbox = document.querySelector("#extended");
checkbox.addEventListener('change', (event)=>{
Expand Down Expand Up @@ -152,9 +160,15 @@ function get_data_snippet(data, skey, svalue){
const obj = stack.pop();
for(let i=0; i<Object.keys(obj).length; i++){
let key = Object.keys(obj)[i];
if(key==skey && obj[key][0]==svalue){
if(!Array.isArray(obj[key])){
if(key==skey && obj[key]==svalue){
return obj;
}
}else{
if(key==skey && obj[key][0]==svalue){
return obj;
}
}
if (typeof obj[key] === 'object' && obj[key] !== null) {
stack.push(obj[key]);
}
Expand Down
27 changes: 25 additions & 2 deletions public/curation/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ function extract_info(cell, obj, tag, colorPolicies){
tooltip.onclick = function(){link_to_person(e)};
const tooltiptext = document.createElement("div");
tooltiptext.classList.add("swc-tooltiptext");
Object.keys(e).forEach(k => {
if(!Array.isArray(e[k]) && typeof e[k] === "string"){
e[k] = [e[k]];
}
})

const text = document.createTextNode(`${e.familyName[0]}, ${e.givenName[0]} `);
tooltiptag.appendChild(document.createTextNode("See Details"));
tooltiptag.appendChild(document.createElement("br"));
Expand All @@ -75,14 +81,20 @@ function extract_info(cell, obj, tag, colorPolicies){
if(!Array.isArray(e[k])){
for (let key in e[k]) {
const pair_in_list = document.createElement("p");
if(!Array.isArray(e[k][key]) && typeof e[k][key] === "string"){
names.push(`${k}:${key}: ${e[k][key]}`);
pair_in_list.appendChild(document.createTextNode(`${k}:${key}: ${e[k][key]}`));

}
else{
names.push(`${k}:${key}: ${e[k][key][0]}`);
pair_in_list.appendChild(document.createTextNode(`${k}:${key}: ${e[k][key][0]}`));
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"]];
hasConfict = true;

}
}}
pair.appendChild(pair_in_list);
}
}else{
Expand All @@ -105,7 +117,18 @@ function extract_info(cell, obj, tag, colorPolicies){
}

function link_to_person(data){
window.location.href += `?id=${data["@id"][0]}`;
if(data["@id"]){
if(!Array.isArray(data["@id"])){
data["@id"] = [data["@id"]];
}
window.location.href += `?@id=${data["@id"][0]}`;
}else{
if(!Array.isArray(data["familyName"])){
data["familyName"] = [data["familyName"]];
}
window.location.href += `?familyName=${data["familyName"][0]}`;
}

}

export {extract_info};
68 changes: 68 additions & 0 deletions public/curation/github_artifacts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { BlobReader, TextWriter, ZipReader } from "https://cdn.jsdelivr.net/npm/@zip.js/zip.js@2.7.72/+esm";
import { Octokit } from "https://esm.sh/@octokit/rest";
import { displayJSON } from "./curation.js";

const showDebugInformation = false;

window.onload = async function () {
const token = localStorage.getItem("gitlab-api-token");
if (!token) {
alert("Please set up the GitLab connection first");
window.location = "../";
return;
}
const owner = localStorage.getItem("owner");
const repo = localStorage.getItem("repo");
const artifactId = localStorage.getItem("artifactId");

const octokit = new Octokit({
auth: token
})

//https://softwarepub.github.io/software-card/callback?type=github&owner=softwarepub&repo=software-card-showcase&artifactId=7291062769
//https://github.com/softwarepub/software-card-showcase/actions/runs/26636754684/artifacts/7290497137
// --- Job artifacts ---
const artifact = await octokit.request(`GET /repos/${owner}/${repo}/actions/artifacts/${artifactId}/zip`, {
owner: `${owner}`,
repo: `${repo}`,
artifact_id: `${artifactId}`,
archive_format: 'zip',
headers: {
'X-GitHub-Api-Version': '2026-03-10'
}
})
if (artifact.status !== 200) {
alert("Fetching artifacts failed");
}


const response = await fetch(artifact.url);


// this is a zip file :-(
const artifactsData = await response.blob();


const zipFileReader = new BlobReader(artifactsData);
const zipReader = new ZipReader(zipFileReader);
const fileEntries = await zipReader.getEntries();


do {
var fileEntry = fileEntries.shift();
if (showDebugInformation) {
console.log(fileEntry);
}
} while (fileEntry["filename"] != "hermes.json");

const reportWriter = new TextWriter();
const reportText = await fileEntry.getData(reportWriter);
await zipReader.close();

console.log(reportText);
displayJSON(JSON.parse(reportText)["curate"]);

//const reportContentsTextArea = document.getElementById("report-contents");
//reportContentsTextArea.value = reportText;

};
1 change: 1 addition & 0 deletions public/curation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,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>
<script type="module" src="./github_artifacts.js"></script>

</body>
</html>
7 changes: 6 additions & 1 deletion public/curation/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ drawRadar(ctx, canvas.offsetWidth/2,canvas.offsetHeight/2, [15,15,10,15,15,12],
drawRadar(ctx, canvas.offsetWidth/2,canvas.offsetHeight/2, [20,20,9,10,20,15], "blue", "rgba(94, 148, 215, 0.34)");

//View for Curation
displayJSON("../.hermes/process/transport.json");
/*
fetch("../.hermes/process/transport.json")
.then(response => response.json())
.then(data => {
displayJSON(data);
})*/
10 changes: 6 additions & 4 deletions public/curation/send_report.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,22 @@ const response = await fetch(
);

const data = await response.json();
alert("Send to GitLab");

}
async function issueGithub(token, username, message){
const owner = localStorage.getItem("owner");
const repo = localStorage.getItem("repo");
//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',
await octokit.request(`POST /repos/${owner}/${repo}/issues`, {
owner: `${owner}`,
repo: `${repo}`,
title: `Curation Report`,
labels: ['curation'],
body: message,
headers: {
'X-GitHub-Api-Version': '2022-11-28'
Expand Down
14 changes: 12 additions & 2 deletions public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,11 @@ border-color: transparent transparent #555 transparent;
position: absolute;
visibility: hidden;
background-color: #bababa;
color: white;
padding: 5px;
border-radius: 12px;
top: 17px;
left: -250px;
top: 25px;
left: -300%;
z-index: 1;
}
.single-line-comment-popup::after {
Expand All @@ -292,6 +293,15 @@ border-width: 5px;
border-style: solid;
border-color: transparent transparent #bababa transparent;
}
.single-line-comment-popup [type=submit] {
top: 100%;
border-radius: 12px;
background-color: rgb(23, 124, 207) ;
color: white;
border-color: white;
padding: 4px;
margin-top: 5px;
}

input[type=text]{
width:500px;
Expand Down