Commit e5ea1126 authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

Project list experiment

parent c16ddf93
const express = require('express') const express = require('express')
const path = require('path') const path = require('path')
const passport = require('passport') //const passport = require('passport')
const morgan = require('morgan') const morgan = require('morgan')
const cookieParser = require('cookie-parser') const cookieParser = require('cookie-parser')
const bodyParser = require('body-parser') const bodyParser = require('body-parser')
...@@ -30,8 +30,8 @@ app.use(session( ...@@ -30,8 +30,8 @@ app.use(session(
} }
)) ))
app.use(passport.initialize()) //app.use(passport.initialize())
app.use(passport.session()) //app.use(passport.session())
app.use(flash()) app.use(flash())
app.use((req, res, next) => { app.use((req, res, next) => {
...@@ -55,7 +55,8 @@ app.use(function(req, res, next) { ...@@ -55,7 +55,8 @@ app.use(function(req, res, next) {
}) })
//require('./routes/routes-account')(app, config, passport, i18n); //require('./routes/routes-account')(app, config, passport, i18n);
require('./routes/routes-project')(app, config, passport) //require('./routes/routes-project')(app, config, passport)
require('./routes/routes-project')(app, config)
// Handle 404 // Handle 404
app.use(function (req, res, next) { app.use(function (req, res, next) {
......
This diff is collapsed.
...@@ -26,20 +26,20 @@ ...@@ -26,20 +26,20 @@
"test": "" "test": ""
}, },
"dependencies": { "dependencies": {
"body-parser": "1.15.1", "async": "^3.2.0",
"body-parser": "^1.19.0",
"cookie-parser": "1.4.3", "cookie-parser": "1.4.3",
"errorhandler": "1.4.3", "errorhandler": "1.4.3",
"express": "4.13.4", "express": "^4.17.1",
"express-fileupload": "^1.1.7-alpha.2", "express-fileupload": "^1.1.7-alpha.2",
"express-flash": "0.0.2", "express-flash": "0.0.2",
"express-session": "1.13.0", "express-session": "^1.17.1",
"fs": "0.0.1-security", "fs": "0.0.1-security",
"morgan": "1.7.0", "morgan": "^1.10.0",
"mysql": "^2.18.1", "mysql": "^2.18.1",
"nodemon": "1.9.2", "nodemon": "^2.0.4",
"passport": "0.3.2", "pug": "^2.0.4",
"passport-saml": "0.15.0", "request": "^2.88.2"
"pug": "^2.0.4"
}, },
"engines": { "engines": {
"node": ">= 4.0.0" "node": ">= 4.0.0"
......
const mysql = require('mysql') const mysql = require('mysql')
var env = process.env.NODE_ENV || 'development'; var env = process.env.NODE_ENV || 'testing';
const config = require('../config/config')[env] const config = require('../config/config')[env]
// ==== USER ACOOUNT DB CONNECTION ==== // ==== USER ACOOUNT DB CONNECTION ====
......
const fs = require('fs') const fs = require('fs')
const SamlStrategy = require('passport-saml').Strategy //const SamlStrategy = require('passport-saml').Strategy
const dbconn = require('./dbconn') const dbconn = require('./dbconn')
const methods = require('./methods') const methods = require('./methods')
// pwd encryption // pwd encryption
...@@ -13,6 +13,7 @@ const async = require('async') ...@@ -13,6 +13,7 @@ const async = require('async')
const helpers = require('./helpers') const helpers = require('./helpers')
const pictSizeLimit = 1000000 // 1 MB const pictSizeLimit = 1000000 // 1 MB
const request = require('request')
module.exports = function (app) { module.exports = function (app) {
...@@ -51,7 +52,7 @@ module.exports = function (app) { ...@@ -51,7 +52,7 @@ module.exports = function (app) {
} }
]) ])
}) })
/*
app.get('/project_', function (req, res) { app.get('/project_', function (req, res) {
async.waterfall([ async.waterfall([
// get all projects from projectdb // get all projects from projectdb
...@@ -104,14 +105,14 @@ module.exports = function (app) { ...@@ -104,14 +105,14 @@ module.exports = function (app) {
} }
]) ])
}) })
*/
app.get('/', function (req, res) { app.get('/', function (req, res) {
res.render(lang+'/project/project-simplified', { res.render(lang+'/project/project-simplified', {
isUserAuthenticated: req.isAuthenticated(), isUserAuthenticated: req.isAuthenticated(),
user: req.user user: req.user
}); });
}) })
/*
app.get('/addprojectoverview', function (req, res) { app.get('/addprojectoverview', function (req, res) {
if (req.isAuthenticated()) { if (req.isAuthenticated()) {
res.render(lang+'/project/addProjectOverview') res.render(lang+'/project/addProjectOverview')
...@@ -253,9 +254,9 @@ module.exports = function (app) { ...@@ -253,9 +254,9 @@ module.exports = function (app) {
}); });
} }
/* RS: Temporary solution while Project DB is still in early phase. // RS: Temporary solution while Project DB is still in early phase.
When User DB and Project DB are integrated and quite stabil, this operation should be done in 1 transaction. // When User DB and Project DB are integrated and quite stabil, this operation should be done in 1 transaction.
*/
var userId // todo: make this global variable? var userId // todo: make this global variable?
async.waterfall([ async.waterfall([
// get userId by email from userdb // get userId by email from userdb
...@@ -310,7 +311,7 @@ module.exports = function (app) { ...@@ -310,7 +311,7 @@ module.exports = function (app) {
app.post('/updateprojectoverview', function (req, res) { app.post('/updateprojectoverview', function (req, res) {
// only their own project // only their own project
}) })
*/
app.get('/projectoverview', function(req, res){ app.get('/projectoverview', function(req, res){
async.waterfall([ async.waterfall([
function(done) { function(done) {
...@@ -355,4 +356,27 @@ module.exports = function (app) { ...@@ -355,4 +356,27 @@ module.exports = function (app) {
]) ])
}) })
app.get('/projectlist', function(req, res){
request.get('https://transfer.hft-stuttgart.de/gitlab/api/v4/projects', function(error, response, body){
if(!error) {
let result = JSON.parse(body)
let projectArr = []
console.log('number of projects:'+result.length)
for(let i = 0; i < result.length; i++){
let project = {
logo: result[i].avatar_url,
name: result[i].name,
desc: result[i].description
}
projectArr.push(project)
}
res.render(lang+'/project/projectList', {
project: projectArr
})
}
})
})
}; };
\ 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")
// Non-active projects
h3(class="mb-3 font-weight-bold") Projekte
table(class="table table-striped")
thead
tr
th Logo
th Name
th Description
tbody
for item in project
tr
//td #{item.status}
td
img(src=item.logo, width="40", height="40")
td #{item.name}
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