Show most recent pipeline per user

This commit is contained in:
Marcel van Remmerden 2021-06-09 00:57:54 +02:00
parent a0dc5db451
commit c87f39b976
3 changed files with 27 additions and 10 deletions

View File

@ -5,11 +5,12 @@
<title>Hello World!</title>
<link rel="stylesheet" href="style.css">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Inter&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
</head>
<body>
<img id="header-logo" src="https://about.gitlab.com/images/press/logo/svg/gitlab-icon-1-color-white-rgb.svg" /></br>
<div id="test"></div>
<div id="pipeline"></div>
<div id="history"></div>
<script src="./renderer.js"></script>
</body>
</html>

View File

@ -41,12 +41,7 @@ if (access_token && user_id && username) {
mb.on('show', () => {
getRecentlyVisited()
fetch('https://gitlab.com/api/v4/projects/278964/pipelines?username=mvanremmerden&per_page=5&access_token=' + access_token).then(result => {
return result.json()
}).then(result => {
console.log(result)
})
getLastPipeline()
})
} else {
setupSecondaryMenu()
@ -113,8 +108,26 @@ function getRecentlyVisited() {
}
}
})
console.log(recentlyVisitedArray)
mb.window.webContents.executeJavaScript('document.getElementById("test").innerHTML = "' + recentlyVisitedString + '"')
mb.window.webContents.executeJavaScript('document.getElementById("history").innerHTML = "' + recentlyVisitedString + '"')
})
}
function getLastPipeline() {
fetch('https://gitlab.com/api/v4/events?action=pushed&per_page=5&access_token=' + access_token).then(result => {
return result.json()
}).then(commits => {
console.log(commits)
fetch('https://gitlab.com/api/v4/projects/' + commits[0].project_id + '/pipelines?&username=mvanremmerden&per_page=1&access_token=' + access_token).then(result => {
return result.json()
}).then(pipelines => {
console.log(pipelines[0])
fetch('https://gitlab.com/api/v4/projects/' + commits[0].project_id + '/repository/commits/' + pipelines[0].sha +'?access_token=' + access_token).then(result => {
return result.json()
}).then(commit => {
console.log(commit)
mb.window.webContents.executeJavaScript('document.getElementById("pipeline").innerHTML = "<a href=\\"' + pipelines[0].web_url + '\\" target=\\"_blank\\">' + commit.title + '</a></br></br>"')
})
})
})
}

View File

@ -12,4 +12,7 @@ a {
#header-logo {
width: 40px;
margin: -8px 0 0 -8px;
}
#pipeline {
font-weight: bold;
}