From 106d7fae809e11baee99a446489367060866f498 Mon Sep 17 00:00:00 2001 From: "Kernchen, Sophie" Date: Fri, 5 Jun 2026 12:28:38 +0200 Subject: [PATCH 1/7] Get artifacts from github --- public/callback/main.js | 22 +++++++-- public/curation/curation.js | 22 +++++---- public/curation/extract.js | 7 ++- public/curation/github_artifacts.js | 70 +++++++++++++++++++++++++++++ public/curation/index.html | 1 + public/curation/script.js | 2 +- public/curation/send_report.js | 8 ++-- 7 files changed, 115 insertions(+), 17 deletions(-) create mode 100644 public/curation/github_artifacts.js diff --git a/public/callback/main.js b/public/callback/main.js index 395b862..faa8186 100644 --- a/public/callback/main.js +++ b/public/callback/main.js @@ -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"); @@ -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); @@ -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; } +} + + } diff --git a/public/curation/curation.js b/public/curation/curation.js index 80186cd..477213e 100644 --- a/public/curation/curation.js +++ b/public/curation/curation.js @@ -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"]){ @@ -18,10 +15,16 @@ 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); - + console.log(params); + 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"; @@ -122,7 +125,7 @@ export function displayJSON(json_document){ }) }) - }) + //Extend Checkbox for metadata source const checkbox = document.querySelector("#extended"); checkbox.addEventListener('change', (event)=>{ @@ -160,5 +163,6 @@ function get_data_snippet(data, skey, svalue){ } } } + console.log(data); return data; } diff --git a/public/curation/extract.js b/public/curation/extract.js index 6685e48..30e7c36 100644 --- a/public/curation/extract.js +++ b/public/curation/extract.js @@ -105,7 +105,12 @@ function extract_info(cell, obj, tag, colorPolicies){ } function link_to_person(data){ - window.location.href += `?id=${data["@id"][0]}`; + if(data["@id"]){ + window.location.href += `?@id=${data["@id"][0]}`; + }else{ + window.location.href += `?familyName=${data["familyName"][0]}`; + } + } export {extract_info}; diff --git a/public/curation/github_artifacts.js b/public/curation/github_artifacts.js new file mode 100644 index 0000000..8284907 --- /dev/null +++ b/public/curation/github_artifacts.js @@ -0,0 +1,70 @@ +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"); + } + +console.log(artifact, artifact.data); + +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(); + console.log(fileEntry) + 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; + +}; diff --git a/public/curation/index.html b/public/curation/index.html index 1e9051e..3db83ca 100644 --- a/public/curation/index.html +++ b/public/curation/index.html @@ -118,6 +118,7 @@

Policy Report

+ diff --git a/public/curation/script.js b/public/curation/script.js index 41f9d41..a33e677 100644 --- a/public/curation/script.js +++ b/public/curation/script.js @@ -16,4 +16,4 @@ 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"); +//displayJSON("../.hermes/process/transport.json"); diff --git a/public/curation/send_report.js b/public/curation/send_report.js index 1ed4172..20a772d 100644 --- a/public/curation/send_report.js +++ b/public/curation/send_report.js @@ -59,15 +59,17 @@ const response = await fetch( } 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, From cf991aeb5021e1307fecef559f646bf9c1616b75 Mon Sep 17 00:00:00 2001 From: "Kernchen, Sophie" Date: Fri, 5 Jun 2026 14:47:19 +0200 Subject: [PATCH 2/7] Fix namestrings --- public/curation/curation.js | 19 ++++++++++++++----- public/curation/extract.js | 20 +++++++++++++++++++- public/curation/script.js | 7 ++++++- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/public/curation/curation.js b/public/curation/curation.js index 477213e..a3b08a7 100644 --- a/public/curation/curation.js +++ b/public/curation/curation.js @@ -22,9 +22,6 @@ export function displayJSON(data){ 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"; @@ -46,10 +43,16 @@ export function displayJSON(data){ keys.forEach(element => { + // Get a something with Name as p Header + console.log(element); if(element.toLowerCase().includes("name")){ + if(!Array.isArray(data[element])){ + document.getElementById("project-name").innerHTML = element.charAt(0).toUpperCase() + element.slice(1) +' '+data[element]+''; + }else{ document.getElementById("project-name").innerHTML = element.charAt(0).toUpperCase() + element.slice(1) +' '+data[element][0]+''; - } + } + } // Apply and fill in the template for Policies if(element=="policies"){ header.style.display = "block"; @@ -155,9 +158,15 @@ function get_data_snippet(data, skey, svalue){ const obj = stack.pop(); for(let i=0; i { + 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")); @@ -75,6 +81,12 @@ 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"]){ @@ -82,7 +94,7 @@ function extract_info(cell, obj, tag, colorPolicies){ tooltiptag.style.color = colorPolicies[e[k][key][2]["conflict"]]; hasConfict = true; - } + }} pair.appendChild(pair_in_list); } }else{ @@ -106,8 +118,14 @@ function extract_info(cell, obj, tag, colorPolicies){ function link_to_person(data){ 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]}`; } diff --git a/public/curation/script.js b/public/curation/script.js index a33e677..34fad8b 100644 --- a/public/curation/script.js +++ b/public/curation/script.js @@ -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); + })*/ \ No newline at end of file From 1c857e4bffb1be43fd3a789e534843ac3bca0f7a Mon Sep 17 00:00:00 2001 From: "Kernchen, Sophie" Date: Fri, 5 Jun 2026 15:06:30 +0200 Subject: [PATCH 3/7] Small fixes --- public/curation/curation.js | 4 ---- public/curation/github_artifacts.js | 2 -- public/curation/send_report.js | 1 - 3 files changed, 7 deletions(-) diff --git a/public/curation/curation.js b/public/curation/curation.js index a3b08a7..a665b2a 100644 --- a/public/curation/curation.js +++ b/public/curation/curation.js @@ -15,7 +15,6 @@ export function displayJSON(data){ console.log(colorPolicies); //Get data snippet from url const params = new URLSearchParams(location.search); - console.log(params); if(params.size > 0){ for (const [key, value] of params) { console.log("search for",key, value); @@ -45,7 +44,6 @@ export function displayJSON(data){ keys.forEach(element => { // Get a something with Name as p Header - console.log(element); if(element.toLowerCase().includes("name")){ if(!Array.isArray(data[element])){ document.getElementById("project-name").innerHTML = element.charAt(0).toUpperCase() + element.slice(1) +' '+data[element]+''; @@ -118,7 +116,6 @@ export function displayJSON(data){ }); slcomment.addEventListener('click', (event)=>{ event.stopPropagation(); - console.log("clicked"); slcommentPopup.style.visibility = "visible"; }) document.addEventListener('click', function(e) { @@ -172,6 +169,5 @@ function get_data_snippet(data, skey, svalue){ } } } - console.log(data); return data; } diff --git a/public/curation/github_artifacts.js b/public/curation/github_artifacts.js index 8284907..578dacb 100644 --- a/public/curation/github_artifacts.js +++ b/public/curation/github_artifacts.js @@ -35,7 +35,6 @@ if (artifact.status !== 200) { alert("Fetching artifacts failed"); } -console.log(artifact, artifact.data); const response = await fetch(artifact.url); @@ -51,7 +50,6 @@ const response = await fetch(artifact.url); do { var fileEntry = fileEntries.shift(); - console.log(fileEntry) if (showDebugInformation) { console.log(fileEntry); } diff --git a/public/curation/send_report.js b/public/curation/send_report.js index 20a772d..87d2e5e 100644 --- a/public/curation/send_report.js +++ b/public/curation/send_report.js @@ -71,7 +71,6 @@ try{ owner: `${owner}`, repo: `${repo}`, title: `Curation Report`, - labels: ['curation'], body: message, headers: { 'X-GitHub-Api-Version': '2022-11-28' From a3e6fad05216826a66e37536186bc5944adc0eb4 Mon Sep 17 00:00:00 2001 From: "Kernchen, Sophie" Date: Fri, 5 Jun 2026 15:37:39 +0200 Subject: [PATCH 4/7] Popup closes after adding to batch and style --- public/curation/curation.js | 15 +++++++++++---- public/curation/send_report.js | 1 + public/style.css | 14 ++++++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/public/curation/curation.js b/public/curation/curation.js index a665b2a..26030a2 100644 --- a/public/curation/curation.js +++ b/public/curation/curation.js @@ -111,13 +111,20 @@ export function displayJSON(data){ 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(); + if (event.target !== slcomment.textContent) { + return; + } slcommentPopup.style.visibility = "visible"; + console.log("open"); }) + mvalue.querySelector('input[type="submit"]').addEventListener("click", () => { + addToBatch(element, data[element], input.value); + slcommentPopup.style.visibility = "hidden"; + console.log("hopen"); + }); + document.addEventListener('click', function(e) { if ( slcommentPopup.style.visibility === "visible" && !slcommentPopup.contains(e.target) ) { slcommentPopup.style.visibility = "hidden"; diff --git a/public/curation/send_report.js b/public/curation/send_report.js index 87d2e5e..8cb9977 100644 --- a/public/curation/send_report.js +++ b/public/curation/send_report.js @@ -56,6 +56,7 @@ const response = await fetch( ); const data = await response.json(); + alert("Send to GitLab"); } async function issueGithub(token, username, message){ diff --git a/public/style.css b/public/style.css index 9449a16..562c4fa 100644 --- a/public/style.css +++ b/public/style.css @@ -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: 22px; + left: -300%; z-index: 1; } .single-line-comment-popup::after { @@ -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; From 1af864da00e19160eb1e7762b4008af464fced67 Mon Sep 17 00:00:00 2001 From: "Kernchen, Sophie" Date: Fri, 5 Jun 2026 15:41:24 +0200 Subject: [PATCH 5/7] Improve style --- public/curation/curation.js | 4 +--- public/style.css | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/public/curation/curation.js b/public/curation/curation.js index 26030a2..baf2450 100644 --- a/public/curation/curation.js +++ b/public/curation/curation.js @@ -113,16 +113,14 @@ export function displayJSON(data){ const input = mvalue.querySelector("#comment"); slcomment.addEventListener('click', (event)=>{ event.stopPropagation(); - if (event.target !== slcomment.textContent) { + if (event.target !== slcomment) { return; } slcommentPopup.style.visibility = "visible"; - console.log("open"); }) mvalue.querySelector('input[type="submit"]').addEventListener("click", () => { addToBatch(element, data[element], input.value); slcommentPopup.style.visibility = "hidden"; - console.log("hopen"); }); document.addEventListener('click', function(e) { diff --git a/public/style.css b/public/style.css index 562c4fa..6ef05a8 100644 --- a/public/style.css +++ b/public/style.css @@ -278,7 +278,7 @@ border-color: transparent transparent #555 transparent; color: white; padding: 5px; border-radius: 12px; - top: 22px; + top: 25px; left: -300%; z-index: 1; } From f0fdcb30e72364ac3999174303c7e0952155580c Mon Sep 17 00:00:00 2001 From: SKernchen Date: Thu, 11 Jun 2026 11:28:54 +0200 Subject: [PATCH 6/7] Fix callback link --- public/callback/main.js | 4 ++-- public/curation/github_artifacts.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/callback/main.js b/public/callback/main.js index faa8186..710a7ce 100644 --- a/public/callback/main.js +++ b/public/callback/main.js @@ -12,7 +12,7 @@ window.onload = async function () { }); } const token = localStorage.getItem("gitlab-api-token"); - + console.log(window.location.search); if(parameters.get("type")=="github"){ const owner = parameters.get("owner"); const repo = parameters.get("repo"); @@ -21,7 +21,7 @@ window.onload = async function () { localStorage.setItem("owner", owner); localStorage.setItem("repo", repo); localStorage.setItem("artifactId", artifactId); - window.location = "../dashboard/"; + window.location = "../curation/"; }else{ diff --git a/public/curation/github_artifacts.js b/public/curation/github_artifacts.js index 578dacb..5fe088c 100644 --- a/public/curation/github_artifacts.js +++ b/public/curation/github_artifacts.js @@ -19,7 +19,7 @@ window.onload = async function () { auth: token }) -//https://softwarepub.github.io/software-card/callback?type=github&owner=softwarepub&repo=software-card-showcase&artifactId=7291062769 +//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`, { From 81f97db91e4f4ec5978f3db548c8071143698925 Mon Sep 17 00:00:00 2001 From: "Kernchen, Sophie" Date: Tue, 23 Jun 2026 17:43:06 +0200 Subject: [PATCH 7/7] Gitlab support --- public/callback/main.js | 23 +++++++++--- public/curation/github_artifacts.js | 4 +- public/curation/gitlab_artifacts.js | 57 +++++++++++++++++++++++++++++ public/curation/index.html | 1 - public/curation/safe_comments.js | 1 + public/curation/script.js | 16 +++++--- public/curation/send_report.js | 2 +- 7 files changed, 90 insertions(+), 14 deletions(-) create mode 100644 public/curation/gitlab_artifacts.js diff --git a/public/callback/main.js b/public/callback/main.js index faa8186..ef9be74 100644 --- a/public/callback/main.js +++ b/public/callback/main.js @@ -12,8 +12,9 @@ window.onload = async function () { }); } const token = localStorage.getItem("gitlab-api-token"); - - if(parameters.get("type")=="github"){ + const instanceType = parameters.get("type"); + localStorage.setItem("instance-type", instanceType); + if(instanceType=="github"){ const owner = parameters.get("owner"); const repo = parameters.get("repo"); const artifactId = parameters.get("artifactId"); @@ -21,12 +22,23 @@ window.onload = async function () { localStorage.setItem("owner", owner); localStorage.setItem("repo", repo); localStorage.setItem("artifactId", artifactId); - window.location = "../dashboard/"; + window.location = "../curation/"; }else{ + const url = parameters.get("url"); + const repo = parameters.get("repo"); + const artifactId = parameters.get("artifactId"); + console.log(url, repo, artifactId); + localStorage.setItem("url", url); + localStorage.setItem("repo", repo); + localStorage.setItem("artifactId", artifactId); + window.location = "../curation/"; - const gitLabProjectId = parameters.get("gitlab_project_id"); + + } + + /* const gitLabProjectId = parameters.get("gitlab_project_id"); let get_latest = parameters.get("latest"); @@ -52,13 +64,12 @@ window.onload = async function () { alert("Please set up the GitLab connection, then go to the dashboard!"); window.location = "../git-login/"; return; - } + }*/ } -} async function latest(projectId, token) { const jobResponse = await fetch( diff --git a/public/curation/github_artifacts.js b/public/curation/github_artifacts.js index 578dacb..1bafbe5 100644 --- a/public/curation/github_artifacts.js +++ b/public/curation/github_artifacts.js @@ -4,7 +4,7 @@ import { displayJSON } from "./curation.js"; const showDebugInformation = false; -window.onload = async function () { +async function githubArtifacts() { const token = localStorage.getItem("gitlab-api-token"); if (!token) { alert("Please set up the GitLab connection first"); @@ -66,3 +66,5 @@ const response = await fetch(artifact.url); //reportContentsTextArea.value = reportText; }; + +export {githubArtifacts}; \ No newline at end of file diff --git a/public/curation/gitlab_artifacts.js b/public/curation/gitlab_artifacts.js new file mode 100644 index 0000000..c08488f --- /dev/null +++ b/public/curation/gitlab_artifacts.js @@ -0,0 +1,57 @@ +import { BlobReader, TextWriter, ZipReader } from "https://cdn.jsdelivr.net/npm/@zip.js/zip.js@2.7.72/+esm"; +import { displayJSON } from "./curation.js"; + +const showDebugInformation = false; + +async function gitlabArtifacts () { + const token = localStorage.getItem("gitlab-api-token"); + if (!token) { + alert("Please set up the GitLab connection first!"); + window.location = "../"; + return; + } + + const url = localStorage.getItem("url"); + const repo = localStorage.getItem("repo"); + const artifactId = localStorage.getItem("artifactId"); + + //https://softwarepub.github.io/software-card/callback?type=gitlab&url=https://codebase.helmholtz.cloud&repo=21313&artifactId=3159194 + + // --- Job artifacts --- + + const jobArtifactsResponse = await fetch( + `https://codebase.helmholtz.cloud/api/v4/projects/${repo}/jobs/${artifactId}/artifacts`, + { headers: { "Content-Type": "application/json", "PRIVATE-TOKEN": token } } + ); + + if (!jobArtifactsResponse.ok) { + alert("Fetching artifacts failed"); + return; + } + console.log(jobArtifactsResponse); + + // this is a zip file :-( + const artifactsData = await jobArtifactsResponse.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/curate/hermes.json"); + + const reportWriter = new TextWriter(); + const reportText = await fileEntry.getData(reportWriter); + await zipReader.close(); + + + console.log(reportText); + displayJSON(JSON.parse(reportText)); + +} + + export {gitlabArtifacts}; \ No newline at end of file diff --git a/public/curation/index.html b/public/curation/index.html index 3db83ca..1e9051e 100644 --- a/public/curation/index.html +++ b/public/curation/index.html @@ -118,7 +118,6 @@

Policy Report

- diff --git a/public/curation/safe_comments.js b/public/curation/safe_comments.js index d386673..76d4f45 100644 --- a/public/curation/safe_comments.js +++ b/public/curation/safe_comments.js @@ -1,5 +1,6 @@ import { addComment } from '../modules/storage.js' export async function addToBatch(value, data, comment){ + //TODO: Value is first of string right now addComment(value, data, comment); } diff --git a/public/curation/script.js b/public/curation/script.js index 34fad8b..4c878d3 100644 --- a/public/curation/script.js +++ b/public/curation/script.js @@ -1,6 +1,7 @@ import {drawHexagon, drawRadar } from "../radar.js"; import { displayJSON } from "./curation.js"; - +import { githubArtifacts } from "./github_artifacts.js"; +import { gitlabArtifacts } from "./gitlab_artifacts.js"; //Draw radar plot const canvas = document.getElementById('radar'); @@ -16,9 +17,14 @@ 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 -/* - fetch("../.hermes/process/transport.json") +const type = localStorage.getItem("instance-type"); +if(type=="github"){ + githubArtifacts(); +}else if(type=="gitlab"){ + gitlabArtifacts(); +}else{ + fetch("../.hermes/process/transport.json") .then(response => response.json()) .then(data => { - displayJSON(data); - })*/ \ No newline at end of file + displayJSON(data);}) +} \ No newline at end of file diff --git a/public/curation/send_report.js b/public/curation/send_report.js index 8cb9977..0e7f465 100644 --- a/public/curation/send_report.js +++ b/public/curation/send_report.js @@ -30,7 +30,7 @@ ${comment.comment} const username = User.getUsername(); const platform = User.getGitPlatform(); console.log(platform); - var [projectId, pipelineId, jobId] = await retrievePipeline(); + const projectId = localStorage.getItem("repo"); if(platform.host == "github"){ issueGithub(token, username, message); }else{