Commit 06731bd6 authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

show project list

parent 44e50d44
...@@ -358,15 +358,40 @@ module.exports = function (app) { ...@@ -358,15 +358,40 @@ module.exports = function (app) {
async function getProjectsFromGitlab(perPage, idAfter) { async function getProjectsFromGitlab(perPage, idAfter) {
// public projects // public projects
return await axios.get('https://transfer.hft-stuttgart.de/gitlab/api/v4/projects?visibility=public&pagination=keyset&per_page='+perPage+'&order_by=id&sort=asc&id_after='+idAfter) return await axios.get('https://transfer.hft-stuttgart.de/gitlab/api/v4/projects?visibility=public&pagination=keyset&per_page='+
perPage+'&order_by=id&sort=asc&id_after='+idAfter)
}
async function getProjectsRunnersFromGitlab() {
// runners
// https://github.com/axios/axios/issues/638
/*
return await axios.get('https://transfer.hft-stuttgart.de/gitlab/api/v4/runners/7',
{
params:{},
headers: { 'Authorization': '33eBjByS2p-Pye8tzY7j' }
})*/
axios.get('https://transfer.hft-stuttgart.de/gitlab/api/v4/runners/7', { headers: { Authorization: '33eBjByS2p-Pye8tzY7j' } }).then(response => {
// If request is good...
console.log(response.data);
})
.catch((error) => {
console.log('error 3 ' + error);
});
} }
app.get('/projectlist', async function(req, res){ app.get('/projectlist', async function(req, res){
let projectArr = [] let projectArr = []
let websiteArr = []
let isProject = true let isProject = true
let firstId = 0 let firstId = 0
while (isProject == true) { while (isProject == true) {
//
//let runners = await getProjectsRunnersFromGitlab()
//console.log(runners)
//
let projects = await getProjectsFromGitlab(10, firstId) let projects = await getProjectsFromGitlab(10, firstId)
let projectData = projects.data let projectData = projects.data
...@@ -375,37 +400,22 @@ module.exports = function (app) { ...@@ -375,37 +400,22 @@ module.exports = function (app) {
} }
else { else {
for(let i = 0; i < projectData.length; i++){ for(let i = 0; i < projectData.length; i++){
//console.log(projectData[i].id)
if (projectData[i].avatar_url == null) { if (projectData[i].avatar_url == null) {
projectData[i].avatar_url = "https://m4lab.hft-stuttgart.de/img/footer/M4_LAB_LOGO_Graustufen.png" projectData[i].avatar_url = "https://m4lab.hft-stuttgart.de/img/footer/M4_LAB_LOGO_Graustufen.png"
} }
let project = {
// website
if (projectData[i].tag_list.includes('website')) {
let website = {
logo: projectData[i].avatar_url, logo: projectData[i].avatar_url,
name: projectData[i].name, name: projectData[i].name,
weburl: projectData[i].web_url, weburl: "https://transfer.hft-stuttgart.de/pages/"+projectData[i].name,
desc: projectData[i].description desc: projectData[i].description
} }
projectArr.push(project) websiteArr.push(website)
}
firstId = projectData[projectData.length-1].id
//console.log('firstId: '+firstId)
}
}
res.render(lang+'/project/projectList', {
project: projectArr
// http://pagination.js.org
})
/*
let projects = await getProjectsFromGitlab(10, 0)
let projectData = projects.data
for(let i = 0; i < projectData.length; i++){
console.log(projectData[i].name)
if (projectData[i].avatar_url == null) {
projectData[i].avatar_url = "https://m4lab.hft-stuttgart.de/img/footer/M4_LAB_LOGO_Graustufen.png"
} }
// project repo
else {
let project = { let project = {
logo: projectData[i].avatar_url, logo: projectData[i].avatar_url,
name: projectData[i].name, name: projectData[i].name,
...@@ -414,44 +424,17 @@ module.exports = function (app) { ...@@ -414,44 +424,17 @@ module.exports = function (app) {
} }
projectArr.push(project) projectArr.push(project)
} }
res.render(lang+'/project/projectList', {
project: projectArr
})
*/
/*
request.get('https://transfer.hft-stuttgart.de/gitlab/api/v4/projects?pagination=keyset&per_page=100&order_by=id&sort=asc&id_after='+firstId, function(error, response, body){
if(!error) {
let result = JSON.parse(body)
if (result.length == 1) {
marker = true
}
else {
firstId = result[9].id
console.log(firstId)
} }
for(let i = 0; i < result.length; i++){ firstId = projectData[projectData.length-1].id
if (result[i].avatar_url == null) {
result[i].avatar_url = "https://m4lab.hft-stuttgart.de/img/footer/M4_LAB_LOGO_Graustufen.png"
}
let project = {
logo: result[i].avatar_url,
name: result[i].name,
weburl: result[i].web_url,
desc: result[i].description
}
projectArr.push(project)
} }
} }
})
res.render(lang+'/project/projectList', { res.render(lang+'/project/projectList', {
project: projectArr project: projectArr,
website: websiteArr
// http://pagination.js.org
}) })
*/
}) })
}; };
\ No newline at end of file
...@@ -7,13 +7,28 @@ html(lang="de") ...@@ -7,13 +7,28 @@ html(lang="de")
link(rel="stylesheet", type="text/css", href="https://transfer.hft-stuttgart.de/css/bootstrap.min.css") link(rel="stylesheet", type="text/css", href="https://transfer.hft-stuttgart.de/css/bootstrap.min.css")
link(rel="stylesheet", type="text/css", href="https://transfer.hft-stuttgart.de/css/m4lab.css") link(rel="stylesheet", type="text/css", href="https://transfer.hft-stuttgart.de/css/m4lab.css")
link(rel="stylesheet", href="https://use.fontawesome.com/releases/v5.8.2/css/all.css", integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay", crossorigin="anonymous") link(rel="stylesheet", href="https://use.fontawesome.com/releases/v5.8.2/css/all.css", integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay", crossorigin="anonymous")
style.
.title-container {
position: relative;
color: white;
}
.card-title-bottom-left {
position: absolute;
bottom: 0px;
width: 100%;
color: black;
font-weight: bold;
background: rgb(255, 255, 255, 0.5);
text-align: left;
padding: 5px
}
body body
div(class="container") div(class="container")
h3(class="mb-3 font-weight-bold") Projekte h3(class="mb-3 font-weight-bold") Projekte
- var colCounter = 0
div(class="container") div(class="container")
- var colCounter = 0
for item in project for item in project
if colCounter == 0 if colCounter == 0
- colCounter = 1 - colCounter = 1
...@@ -21,9 +36,14 @@ html(lang="de") ...@@ -21,9 +36,14 @@ html(lang="de")
if colCounter <= 3 if colCounter <= 3
div(class="col-sm") div(class="col-sm")
div(class="card", style="width: 18rem;") div(class="card", style="width: 18rem;")
img(class="card-img-top", src=item.logo, alt="Project logo") //img(class="card-img-top", src=item.logo, alt="Project logo")
//h5(class="card-title") #{item.name}
div(class="title-container")
h5(class="card-title-bottom-left") #{item.name}
img(class="card-img-top", src=item.logo)
div(class="card-body") div(class="card-body")
h5(class="card-title") #{item.name}
div(class="row") div(class="row")
div(class="col-9") div(class="col-9")
p(class="card-text") #{item.desc} p(class="card-text") #{item.desc}
...@@ -36,6 +56,16 @@ html(lang="de") ...@@ -36,6 +56,16 @@ html(lang="de")
- colCounter = 0 - colCounter = 0
//h3(class="mb-3 font-weight-bold") Websites //h3(class="mb-3 font-weight-bold") Websites
if website.length > 0
div(class="container")
h3(class="mb-3 font-weight-bold") Websites
table(class="table table-striped")
for item in website
tr
td
img(src=item.logo, width="40", height="40")
td <a href="#{item.weburl}" target="_blank">#{item.name}</a>
td #{item.desc}
// jQuery // jQuery
script(src="https://code.jquery.com/jquery-3.3.1.min.js") script(src="https://code.jquery.com/jquery-3.3.1.min.js")
...@@ -44,3 +74,5 @@ html(lang="de") ...@@ -44,3 +74,5 @@ html(lang="de")
script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous") script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous")
// Header // Header
script(src="https://transfer.hft-stuttgart.de/js/headfoot.js") script(src="https://transfer.hft-stuttgart.de/js/headfoot.js")
// search: https://www.w3schools.com/howto/howto_js_filter_lists.asp
\ No newline at end of file
doctype html
html(lang="de")
head
title= "Project List"
meta(charset="UTF-8")
meta(name="viewport", content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no")
link(rel="stylesheet", type="text/css", href="https://transfer.hft-stuttgart.de/css/bootstrap.min.css")
link(rel="stylesheet", type="text/css", href="https://transfer.hft-stuttgart.de/css/m4lab.css")
link(rel="stylesheet", href="https://use.fontawesome.com/releases/v5.8.2/css/all.css", integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay", crossorigin="anonymous")
body
div(class="container")
h3(class="mb-3 font-weight-bold") Projekte
table(class="table table-striped")
tbody
for item in project
tr
td
img(src=item.logo, width="40", height="40")
td <a href="#{item.weburl}" target="_blank">#{item.name}</a>
td #{item.desc}
if website.length > 0
h3(class="mb-3 font-weight-bold") Websites
table(class="table table-striped")
for item in website
tr
td
img(src=item.logo, width="40", height="40")
td <a href="#{item.weburl}" target="_blank">#{item.name}</a>
td #{item.desc}
// jQuery
script(src="https://code.jquery.com/jquery-3.3.1.min.js")
script(src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js", integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1", crossorigin="anonymous")
// Bootstrap
script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous")
// Header
script(src="https://transfer.hft-stuttgart.de/js/headfoot.js")
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment