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
34 changes: 32 additions & 2 deletions public/callback/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,52 @@ window.onload = async function () {
}

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

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

const gitLabPipelineId = parameters.get("gitlab_pipeline_id");
const gitLabJobId = parameters.get("gitlab_job_id");

if(get_latest != 1){
await registerPipeline(gitLabProjectId, gitLabPipelineId, gitLabJobId);
}

if (showDebugInformation) {
await new Promise(r => setTimeout(r, 5000));
}

const token = localStorage.getItem("gitlab-api-token");
if (token) {
window.location = "/software-card/dashboard/";
if(get_latest==1){
await latest(gitLabProjectId, token);
}else{
window.location = "../dashboard/";
}
return;
} else {
alert("Please set up the GitLab connection, then go to the dashboard!");
window.location = "/software-card/gitlab-setup/";
window.location = "../gitlab-setup/";
return;
}


}

async function latest(projectId, token) {
const jobResponse = await fetch(
`https://codebase.helmholtz.cloud/api/v4/projects/${projectId}/jobs/`,
{ headers: { "Content-Type": "application/json", "PRIVATE-TOKEN": token } }
);

if (!jobResponse.ok) {
alert("Fetching pipeline failed");
return;
}

const jobData = await jobResponse.json();
const jobId = jobData[0]["id"];
const pipelineId = jobData[0]["pipeline"]["id"];

window.location = `../callback?gitlab_project_id=${projectId}&gitlab_pipeline_id=${pipelineId}&gitlab_job_id=${jobId}&latest=2`;
//gitlab_pipeline_id=618554&gitlab_job_id=2513432
}
2 changes: 1 addition & 1 deletion public/dashboard/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ window.onload = async function () {
const token = localStorage.getItem("gitlab-api-token");
if (!token) {
alert("Please set up the GitLab connection first!");
window.location = "/";
window.location = "./";
return;
}

Expand Down
2 changes: 1 addition & 1 deletion public/gitlab-setup/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ window.onload = async function () {
localStorage.setItem("gitlab-name", userData["name"]);
localStorage.setItem("gitlab-api-token", token);

window.location = "./";
window.location = "../";
return;
}
};
Expand Down
5 changes: 4 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" href="/software-card/style.css">
<link rel="stylesheet" href="./style.css">
<link rel="icon" href="./pictures/Logo.png" type="image/icon type">

<script type="module" src="./main.js"></script>
Expand All @@ -22,13 +22,16 @@ <h3>Welcome<span id="welcome-username"></span></h3>
<li>Set up the <a href="./gitlab-setup/">connection to your GitLab account</a>.</li>
<li>Load an <a href="./callback?gitlab_project_id=17500&gitlab_pipeline_id=570319&gitlab_job_id=2350529">
example CI pipeline</a>.</li>
<li>Load the <a href="./callback?gitlab_project_id=17500&latest=1">
newest CI pipeline</a>.</li>
<li>See your <a href="./dashboard/">dashboard</a>.</li>
<li>See your <a href="./curation/">curation view</a>.</li>
<li>See your <a href="./reporting/">reporting view</a>.</li>
</ol>
</p>
<hr>
<button id="clear-all-data-button">Clear all data</button>
<button id="clear-pipeline-button">Clear pipeline data</button>
</body>

</html>