Commit 9fb60ffd authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

Merge branch 'devel' into 'testing'

Refactoring and codes cleaning

See merge request !144
parents 961ab112 4450156e
Pipeline #6621 failed with stage
in 20 seconds
const menu = [{ name: 'Informationen', combos: [{ name: 'Projekte', link: '/project' }, { name: 'Über das M4_LAB', link: '/projectoverview?projectID=1' }], type: 'dropdown', link: '#' }, { name: 'Zusammenarbeit', combos: [{ name: 'Mailinglisten', link: '/mailinglists' }, { name: 'Videokonferenzen', link: '/videoconference.html' }/* {'name':'...', 'link':'#'} */], type: 'dropdown', link: '#' }, { name: 'Events', combos: [{ name: 'Veranstaltungen der HfT', link: 'http://www.hft-stuttgart.de/Aktuell/Veranstaltungen/' }/*, {'name':'...', 'link':'#'} */], type: 'dropdown', link: '#' }, /* {'name':'Bürgerbeteiligung', 'combos':[{'name':'...', 'link':'#'}, {'name':'...', 'link':'#'}], 'type':'dropdown', 'link':'#'}, */{ name: 'Logout', combos: [], type: 'logoutbutton', link: '/logout' }]
const hft_links = [{ url: 'http://www.hft-stuttgart.de/Forschung/M4-Lab/Team/index.html/de', name: 'Kontakt' }, { url: 'http://www.hft-stuttgart.de/Hochschule/Impressum.html/de', name: 'Impressum' }, { url: 'http://www.hft-stuttgart.de/Einrichtungen/Datenschutz/Datenschutz-Homepage', name: 'Datenschutz' }]
const socialmedias = [{ url: 'https://twitter.com/InnolabM4', name: 'fa-twitter' }, { url: 'https://www.facebook.com/HfTStuttgart/', name: 'fa-facebook-square' }, { url: 'https://www.instagram.com/m4_lab/', name: 'fa-instagram' }, { url: 'https://de.linkedin.com/school/hochschule-f%C3%BCr-technik-stuttgart-%E2%80%93-university-of-applied-sciences/', name: 'fa-linkedin' }, { url: 'https://www.youtube.com/channel/UCi0_JfF2qMZbOhOnNH5PyHA', name: 'fa-youtube' }]
const footer_images = [{ src: '/images/demo/Innovative_Hochschule_Initiative_BMBF_GWK_RGB.jpg', alt: 'Innovative Hochschule' }]
function prependChild (parent, child) {
parent.insertBefore(child, parent.childNodes[0])
}
function userAuthenticated () {
const params = new URLSearchParams(window.location.search)
if (params.get('isAuthenticatedUser')) {
return true
} else if (document.getElementById('loginswitch')) { // relikt login via OAuth
if (document.getElementById('loginswitch').getAttribute('authenticated') == '1') {
return true
}
} else {
return false
}
}
function readCookie (cname) {
const name = cname + '='
const decodedCookie = decodeURIComponent(document.cookie)
const ca = decodedCookie.split(';')
for (let i = 0; i < ca.length; i++) {
let c = ca[i]
while (c.charAt(0) == ' ') {
c = c.substring(1)
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length)
}
}
return ''
}
function sendRequest (URL) {
console.log(document.cookie)
const xhr = new XMLHttpRequest()
xhr.open('POST', URL, true)
const token = readCookie('XSRF-TOKEN')
// Send the proper header information along with the request
xhr.setRequestHeader('X-CSRF-TOKEN', token)
xhr.send()
}
/* function head()
* creates header and prepends it to the documents body
*/
function head () {
const headerdiv = document.createElement('div')
const alertdiv = document.createElement('div')
headerdiv.classList.add('wrapper', 'row1')
const navheader = document.createElement('header')
navheader.id = 'header'
navheader.classList.add('clear')
const alertbutton = document.createElement('button')
alertbutton.type = 'button'
alertbutton.classList.add('close')
alertbutton.setAttribute('data-dismiss', 'alert')
alertbutton.innerHTML = '&times;'
alertdiv.innerHTML = '<strong>Disclaimer</strong> This website is under construction and in prototype-phase. It is not for public use.'
prependChild(alertdiv, alertbutton)
alertdiv.classList.add('alert', 'alert-danger', 'alert-dismissible', 'fade', 'show', 'text-center')
// alertdiv.style = "text-align:center;";
navheader.appendChild(alertdiv)
const navbar = document.createElement('nav')
navbar.classList.add('navbar', 'navbar-default')
const fluiddiv = document.createElement('div')
fluiddiv.classList.add('container-fluid')
const navbardiv = document.createElement('div')
navbardiv.classList.add('navbar-header')
const navelements = document.createElement('ul')
navelements.id = 'navelemente'
const logos = document.createElement('li')
const link_m4lab = document.createElement('a')
link_m4lab.href = '/'
link_m4lab.innerHTML = "<img src='/images/demo/m4lab_logo.jpg' alt='Logo Innovationslabor M4_LAB'>"
logos.appendChild(link_m4lab)
navelements.appendChild(logos)
for (let j = 0; j < menu.length; j++) {
const headitem = document.createElement('li')
const itemtype = menu[j].type
headitem.classList.add('nav-item')
const headlink = document.createElement('a')
headlink.href = menu[j].link
headlink.id = 'navbarDropdown' + j
headlink.classList.add('nav-link')
headlink.setAttribute('role', 'button')
if (itemtype == 'dropdown') {
headitem.classList.add('dropdown')
headlink.classList.add('dropdown-toggle')
headlink.setAttribute('data-toggle', 'dropdown')
headlink.setAttribute('aria-haspopup', 'true')
headlink.setAttribute('aria-expanded', 'false')
}
headlink.innerHTML = menu[j].name
if (itemtype == 'dropdown') {
const combodiv = document.createElement('div')
combodiv.id = headlink.id + '_par'
combodiv.setAttribute('aria-labelledby', headlink.id)
combodiv.classList.add('dropdown-menu')
for (let k = 0; k < menu[j].combos.length; k++) {
const combolink = document.createElement('a')
combolink.classList.add('dropdown-item')
if (userAuthenticated() || typeof user !== 'undefined') { // either logged in the old way or logged in using SAML
if (menu[j].combos[k].link.includes('?')) {
combolink.href = menu[j].combos[k].link + '&isAuthenticatedUser=true'
} else {
combolink.href = menu[j].combos[k].link + '?isAuthenticatedUser=true'
}
} else {
combolink.href = menu[j].combos[k].link
}
combolink.innerHTML = menu[j].combos[k].name
combodiv.appendChild(combolink)
}
headitem.appendChild(combodiv)
} else if (itemtype == 'logoutbutton') {
/* if(userAuthenticated()){
headlink.innerHTML="Account";
headlink.href="/account/";
} */
headlink.innerHTML = 'Logout'
headlink.href = '/logout'
headlink.classList.remove('nav-link')
headlink.classList.add('btn')
headlink.classList.add('btn-outline-danger')
}
headitem.appendChild(headlink)
navelements.appendChild(headitem)
}
/* let searchitem = document.createElement('li');
searchitem.classList.add("nav-item");
let searchinput = document.createElement('input');
searchinput.value='Suche...'
searchinput.type="text";
searchinput.classList.add("nav-item-suchfeld");
searchinput.setAttribute('onFocus', "this.value=(this.value=='search...')? '' : this.value");
searchitem.appendChild(searchinput);
let magnifier = document.createElement('input');
magnifier.type="image"
magnifier.src="/images/Lupe_grau.png";
magnifier.width="25";
magnifier.height="25";
magnifier.alt="";
magnifier.id="sf_submit";
magnifier.value="search";
searchitem.appendChild(magnifier);
navelements.appendChild(searchitem); */
navbardiv.appendChild(navelements)
fluiddiv.appendChild(navbardiv)
navbar.appendChild(fluiddiv)
navheader.appendChild(navbar)
headerdiv.appendChild(navheader)
prependChild(document.body, headerdiv)
};
/* function foot()
* creates footer and appends it to the documents body
*/
function foot () {
const footerdiv = document.createElement('div')
footerdiv.id = 'homepage'
footerdiv.classList.add('last', 'clear')
footerdiv.innerHTML = '<hr>'
const containerdiv = document.createElement('div')
containerdiv.classList.add('flex-container')
const hftlink = document.createElement('a')
hftlink.classList.add('col-md-3')
hftlink.setAttribute('style', 'flex-basis: 400px;')
hftlink.href = 'https://www.hft-stuttgart.de'
const hftimage = document.createElement('img')
hftimage.src = '/images/demo/hft_logo.jpg'
hftimage.alt = 'Logo der Hochschule für Technik Stuttgart'
hftimage.height = '75'
hftlink.appendChild(hftimage)
containerdiv.appendChild(hftlink)
const contactdiv = document.createElement('div')
contactdiv.classList.add('col-md-3', 'footer-unten')
contactdiv.setAttribute('style', 'flex-basis:400px')
contactdiv.innerHTML = 'Hochschule für Technik Stuttgart'
const rowdiv = document.createElement('div')
rowdiv.classList.add('row')
for (let i = 0; i < hft_links.length; i++) {
const coldiv = document.createElement('div')
coldiv.classList.add('contactrow', 'footer-unten')
const collink = document.createElement('a')
collink.innerHTML = hft_links[i].name
collink.classList.add('contact-lower')
collink.href = hft_links[i].url
coldiv.appendChild(collink)
rowdiv.appendChild(coldiv)
}
contactdiv.appendChild(rowdiv)
containerdiv.appendChild(contactdiv)
const socialdiv = document.createElement('div')
socialdiv.classList.add('col-md-3')
socialdiv.setAttribute('style', 'flex-basis: 400px;')
const socialrow = document.createElement('div')
socialrow.id = 'socialmediabuttons'
for (let j = 0; j < socialmedias.length; j++) {
const sociallink = document.createElement('a')
sociallink.href = socialmedias[j].url
const socialcontent = document.createElement('i')
socialcontent.classList.add('fab', socialmedias[j].name)
sociallink.appendChild(socialcontent)
socialrow.appendChild(sociallink)
socialrow.innerHTML += '&nbsp;'
}
socialdiv.appendChild(socialrow)
containerdiv.appendChild(socialdiv)
const imagediv = document.createElement('div')
imagediv.classList.add('col-md-3')
imagediv.setAttribute('style', 'flex-basis:400px;')
for (let k = 0; k < footer_images.length; k++) {
const image = document.createElement('img')
image.src = footer_images[k].src
image.width = '300'
image.height = '73'
image.alt = footer_images[k].alt
imagediv.appendChild(image)
}
containerdiv.appendChild(imagediv)
footerdiv.appendChild(containerdiv)
document.body.appendChild(footerdiv)
};
head()
foot()
let isEmailValid = false
let isPasswordValid = false
// check if email already exist
$('#inputEmail').change(function () {
const email = $('#inputEmail').val()
$.get('email/' + email, function (data) {
$('#emailWarning').empty()
isEmailValid = data
if (!isEmailValid) {
$('#emailWarning').html('Mit dieser E-Mail-Adresse existiert bereits ein Benutzerkonto in unserem Transferportal.')
}
switchSubmitButton()
})
.fail(function () {
console.log('cannot check email')
})
})
// check password
$('#inputPassword').on('keyup', function () {
isPasswordValid = checkPasswordReq($('#inputPassword').val())
$('#passwordWarning').empty()
if (!isPasswordValid) {
// $('#passwordWarning').html('Must be at least 8 characters')
$('#passwordWarning').html('Das Passwort muss mindestens 8 Zeichen haben')
}
switchSubmitButton()
})
function switchSubmitButton () {
if (isEmailValid && isPasswordValid) {
$('#submitBtn').prop('disabled', false)
} else {
$('#submitBtn').prop('disabled', true)
}
}
// check password and password confirmation input fields
// used in Security and Reset Password
$('#inputNewPwd, #inputConfirm').on('keyup', function () {
let isBest, isMatch
isBest = checkPasswordReq($('#inputNewPwd').val())
$('#recommendation').empty()
if (!isBest) {
// $('#recommendation').html('Must be at least 8 characters').css('color', 'red');
$('#recommendation').html('Das Passwort muss mindestens 8 Zeichen haben').css('color', 'red')
}
// match or not?
if ($('#inputNewPwd').val() === $('#inputConfirm').val()) {
// $('#message').html('Matching').css('color', 'green');
$('#message').html('Übereinstimmend').css('color', 'green')
isMatch = true
} else {
// $('#message').html('Not Matching').css('color', 'red');
$('#message').html('Nicht übereinstimmend').css('color', 'red')
isMatch = false
}
// enable/disable update button
if (isBest && isMatch) {
$('#updateBtn').prop('disabled', false)
} else {
$('#updateBtn').prop('disabled', true)
}
})
This diff is collapsed.
import { publicController } from '../controller/publicController'
module.exports = function (app: any, config: any, lang: any) {
// ================== NEW USERS REGISTRATION ======================
app.get('/registration', function (req: any, res: any) {
publicController.showRegistrationPage(res, lang)
})
app.post('/registration', function (req: any, res: any) {
publicController.registerUser(req, res, config)
})
// to check whether or not an account is already exist
app.get('/email/:email', async function (req: any, res: any) {
publicController.checkUserEmail(req, res)
})
// =================== USERS VERIFICATION =========================
app.get('/verifyAccount', async function (req: any, res: any) {
publicController.verifyAccount(req, res, lang)
})
// ==================== FORGOT PASSWORD ===========================
app.get('/forgotPwd', function (req: any, res: any) {
publicController.showForgotPwdPage(req, res, lang)
})
app.post('/forgotPwd', function (req: any, res: any) {
publicController.generateNewToken(req, res, config)
})
// reset
app.get('/reset/:token', async function (req: any, res: any) {
publicController.showResetPassword(req, res, lang)
})
app.post('/reset/:token', async function (req: any, res: any) {
publicController.resetPassword(req, res)
})
// ======================= CONTACT FORM ===========================
app.get('/contact', function (req: any, res: any) {
publicController.showContactPage(req, res, lang)
})
app.post('/contact', function (req: any, res: any) {
publicController.sendContactMessage(req, res)
})
}
......@@ -28,7 +28,7 @@ html(lang="de")
i(class="fa fa-lock fa-fw")
span(class="d-none d-md-inline") Sicherheitseinstellungen
li(class="nav-item")
a(class="nav-link pl-0" href="/account/services")
a(class="nav-link pl-0" href="/services")
i(class="fa fa-tasks fa-fw")
span(class="d-none d-md-inline") Projekte und Dienste
li(class="nav-item")
......
......@@ -23,7 +23,7 @@ html(lang="de")
a(class="nav-link pl-0 text-nowrap" href="/account/")
span(class="font-weight-bold color_black") #{user.firstName} #{user.lastName}
li(class="nav-item")
a(class="nav-link pl-0" href="/account/profile")
a(class="nav-link pl-0" href="/profile")
i(class="fa fa-user fa-fw")
span(class="d-none d-md-inline") Benutzerprofil
li(class="nav-item")
......@@ -31,7 +31,7 @@ html(lang="de")
i(class="fa fa-lock fa-fw color_black")
span(class="d-none d-md-inline color_black") Sicherheitseinstellungen
li(class="nav-item")
a(class="nav-link pl-0" href="/account/services")
a(class="nav-link pl-0" href="/services")
i(class="fa fa-tasks fa-fw")
span(class="d-none d-md-inline") Projekte und Dienste
li(class="nav-item")
......
......@@ -19,7 +19,7 @@ html(lang="de")
a(class="nav-link pl-0 text-nowrap" href="/")
span(class="font-weight-bold color_black") #{user.firstName} #{user.lastName}
li(class="nav-item")
a(class="nav-link pl-0" href="/account/profile")
a(class="nav-link pl-0" href="/profile")
i(class="fa fa-user fa-fw")
span(class="d-none d-md-inline") Benutzerprofil
if user.is_m4lab_idp
......@@ -78,6 +78,9 @@ html(lang="de")
div(class="col text-right")
button(type="button", class="btn btn-sm btn-success" disabled) Neuer Projektdatensatz
table(class="table")
if gitlabRepos.length == 0
tr
td Currently you have no project codes/data
for item in gitlabRepos
- let img = item.logo
tr
......@@ -95,4 +98,4 @@ html(lang="de")
script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous")
// M4_LAB
script(src="/js/headfoot.js")
script(src="/js/mobile.js")
\ No newline at end of file
script(src="/js/mobile.js")
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