Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
m4lab_tv1
Project Page
Commits
06731bd6
Commit
06731bd6
authored
Aug 28, 2020
by
Rosanny Sihombing
Browse files
show project list
parent
44e50d44
Changes
3
Hide whitespace changes
Inline
Side-by-side
routes/routes-project.js
View file @
06731bd6
...
@@ -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,83 +400,41 @@ module.exports = function (app) {
...
@@ -375,83 +400,41 @@ 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
=
{
logo
:
projectData
[
i
].
avatar_url
,
// website
name
:
projectData
[
i
].
name
,
if
(
projectData
[
i
].
tag_list
.
includes
(
'
website
'
))
{
weburl
:
projectData
[
i
].
web_url
,
let
website
=
{
desc
:
projectData
[
i
].
description
logo
:
projectData
[
i
].
avatar_url
,
}
name
:
projectData
[
i
].
name
,
projectArr
.
push
(
project
)
weburl
:
"
https://transfer.hft-stuttgart.de/pages/
"
+
projectData
[
i
].
name
,
}
desc
:
projectData
[
i
].
description
}
firstId
=
projectData
[
projectData
.
length
-
1
].
id
websiteArr
.
push
(
website
)
//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"
}
let project = {
logo: projectData[i].avatar_url,
name: projectData[i].name,
weburl: projectData[i].web_url,
desc: projectData[i].description
}
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
}
}
// project repo
else
{
else
{
firstId = result[9].id
console.log(firstId)
}
for(let i = 0; i < result.length; i++){
if (result[i].avatar_url == null) {
result[i].avatar_url = "https://m4lab.hft-stuttgart.de/img/footer/M4_LAB_LOGO_Graustufen.png"
}
let
project
=
{
let
project
=
{
logo:
result
[i].avatar_url,
logo
:
projectData
[
i
].
avatar_url
,
name:
result
[i].name,
name
:
projectData
[
i
].
name
,
weburl:
result
[i].web_url,
weburl
:
projectData
[
i
].
web_url
,
desc:
result
[i].description
desc
:
projectData
[
i
].
description
}
}
projectArr
.
push
(
project
)
projectArr
.
push
(
project
)
}
}
}
}
})
firstId
=
projectData
[
projectData
.
length
-
1
].
id
}
}
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
views/DE/project/projectList.pug
View file @
06731bd6
...
@@ -7,35 +7,65 @@ html(lang="de")
...
@@ -7,35 +7,65 @@ 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")
for item in project
- var colCounter = 0
if colCounter == 0
for item in project
- colCounter = 1
if colCounter == 0
| <div class="py-4 row">
- colCounter = 1
if colCounter <= 3
| <div class="py-4 row">
div(class="col-sm")
if colCounter <= 3
div(class="card", style="width: 18rem;")
div(class="col-sm")
img(class="card-img-top", src=item.logo, alt="Project logo")
div(class="card", style="width: 18rem;")
div(class="card-body")
//img(class="card-img-top", src=item.logo, alt="Project logo")
h5(class="card-title") #{item.name}
//h5(class="card-title") #{item.name}
div(class="row")
div(class="col-9")
div(class="title-container")
p(class="card-text") #{item.desc}
h5(class="card-title-bottom-left") #{item.name}
div(class="col-3")
img(class="card-img-top", src=item.logo)
svg(class="bi bi-chevron-right", width="32", height="32", viewBox="0 0 20 20", fill="currentColor", xmlns="http://www.w3.org/2000/svg")
| <a xlink:href="#{item.weburl}" target="_blank"><path fill-rule="evenodd" d="M6.646 3.646a.5.5 0 01.708 0l6 6a.5.5 0 010 .708l-6 6a.5.5 0 01-.708-.708L12.293 10 6.646 4.354a.5.5 0 010-.708z"></path></a>
div(class="card-body")
- colCounter++
div(class="row")
if colCounter == 4
div(class="col-9")
| </div>
p(class="card-text") #{item.desc}
- colCounter = 0
div(class="col-3")
svg(class="bi bi-chevron-right", width="32", height="32", viewBox="0 0 20 20", fill="currentColor", xmlns="http://www.w3.org/2000/svg")
| <a xlink:href="#{item.weburl}" target="_blank"><path fill-rule="evenodd" d="M6.646 3.646a.5.5 0 01.708 0l6 6a.5.5 0 010 .708l-6 6a.5.5 0 01-.708-.708L12.293 10 6.646 4.354a.5.5 0 010-.708z"></path></a>
- colCounter++
if colCounter == 4
| </div>
- 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")
...
@@ -43,4 +73,6 @@ html(lang="de")
...
@@ -43,4 +73,6 @@ html(lang="de")
// Bootstrap
// Bootstrap
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")
\ No newline at end of file
// search: https://www.w3schools.com/howto/howto_js_filter_lists.asp
\ No newline at end of file
views/DE/project/projectList_table.pug
0 → 100644
View file @
06731bd6
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment