diff --git a/public/default/logo.png b/public/default/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..49d1a2c4816f76a799d3063b4c3f8fb37962f709 Binary files /dev/null and b/public/default/logo.png differ diff --git a/routes/routes-account.js b/routes/routes-account.js index dc18b3d9e114919314c2ff83824084206c99befa..24502b7ad61612d3424429ceeb305f66778da7ae 100644 --- a/routes/routes-account.js +++ b/routes/routes-account.js @@ -12,6 +12,7 @@ const async = require('async') const crypto = require('crypto') const mailer = require('./mailer') const logoDir = 'public/upload/' +const defaultLogo = 'public/default/logo.png' const tpGitlabURL = 'https://transfer.hft-stuttgart.de/gitlab/' const tpGitlabPagesURL = 'https://transfer.hft-stuttgart.de/pages/' @@ -493,45 +494,49 @@ module.exports = function (app, config, passport, i18n) { let projectDesc = req.body.description let projectTemplate = req.body.template let newInformation = new projectInformation(loggedInUser.getGitlabUserId(), null, projectName, projectDesc, null, null) - - if (!req.files) { - res.flash('error', 'Bitte geben Sie ein Projektlogo an.') - res.redirect('/account/newInformation') - } else { - let newLogoFile = req.files.logo - async.waterfall([ - function(callback){ // upload logo + let newLogoFile = defaultLogo + + if (req.files) { newLogoFile = req.files.logo } + + async.waterfall([ + function(callback){ // upload logo + if (!req.files) { + callback(null, newLogoFile) + } else { newLogoFile.mv(logoDir + newLogoFile.name, function(err) { newLogoFile = logoDir+newLogoFile.name callback(err, newLogoFile) }) - }, - async function(newLogoFile){ // create a new GitLab Page - let newPages = await gitlab.createNewPages(newInformation, newLogoFile, projectTemplate) - if (newPages.error) { - if(newPages.data.message.name == "has already been taken") { - res.flash("error", "Der Projektname '"+newInformation.getName()+"' ist bereits vergeben, bitte wählen Sie einen anderen Namen.") - } else { - res.flash("error", "Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut. ") - } - res.redirect('/account/newInformation') + } + }, + async function(newLogoFile){ // create a new GitLab Page + let newPages = await gitlab.createNewPages(newInformation, newLogoFile, projectTemplate) + if (newPages.error) { + if(newPages.data.message.name == "has already been taken") { + res.flash("error", "Der Projektname '"+newInformation.getName()+"' ist bereits vergeben, bitte wählen Sie einen anderen Namen.") } else { - let newPagesData = newPages.data - - //res.flash("success", "Ihre Webseite wurde erstellt, aber noch nicht veröffentlicht. Bitte fahren Sie mit Schritten 2 und 3 fort, um Ihre Webseite zu veröffentlichen.") - res.flash("success", "Your website will be published AFTER you complete your website by following the provided guideline below."+ - "\r\n Your website URL: "+tpGitlabPagesURL+newPagesData.path_with_namespace+"/home/") - res.redirect('/account/updateInformation?id='+newPagesData.id) + res.flash("error", "Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut. ") } + res.redirect('/account/newInformation') + } else { + let newPagesData = newPages.data + + res.flash("success", "Ihre Webseite wurde erstellt, aber noch nicht veröffentlicht. Um Ihre Webseite endgültig zu veröffentlichen, "+ + "schließen Sie die Einrichtung gemäß unten stehender Anleitung ab.") + /* res.flash("success", "Your website will be published AFTER you complete your website by following the provided guideline below."+ + "\r\n Your website URL: "+tpGitlabPagesURL+newPagesData.path_with_namespace+"/home/") */ + res.redirect('/account/updateInformation?id='+newPagesData.id) } - ], function (err) { - if(err) console.log(err) - // remove logo + } + ], function (err) { + if(err) console.log(err) + // remove logo + if (req.files) { fs.unlink(newLogoFile, (err) => { if(err) console.log(err) }) - }) - } + } + }) } } }) @@ -595,7 +600,7 @@ module.exports = function (app, config, passport, i18n) { async function(newLogoFile, callback){ // update gitlab page let updatedPages = await gitlab.updateProject(updatedInformation, newLogoFile) let pagesData = updatedPages.data - if (pagesData.error) { + if (updatedPages.error) { if(pagesData.message.name == "has already been taken") { res.flash("error", "Der Projektname ist bereits vergeben, bitte wählen Sie einen anderen Namen.") } else { diff --git a/views/DE/account/home.pug b/views/DE/account/home.pug index 33bc0392997c84d84767fecdb6e973c5724b51d6..e476d871e1acb02fc7ef20b4c53b45e6b8fc70e3 100644 --- a/views/DE/account/home.pug +++ b/views/DE/account/home.pug @@ -25,7 +25,7 @@ html(lang="de") ul(class="flex-md-column flex-row navbar-nav w-100 justify-content-between") li(class="nav-item") a(class="nav-link pl-0 text-nowrap" href="#") - span(class="font-weight-bold color_black") #{user.firstname} #{user.lastname} + span(class="font-weight-bold color_black") #{user.firstName} #{user.lastName} li(class="nav-item") a(class="nav-link pl-0" href="/account/profile") i(class="fa fa-user fa-fw") diff --git a/views/DE/account/newInformation.pug b/views/DE/account/newInformation.pug index b2b9051668b279bc88c28e89a4087d4201d70a9d..14fead832e85203b5cde6cf1e30a5a77e26c8bde 100644 --- a/views/DE/account/newInformation.pug +++ b/views/DE/account/newInformation.pug @@ -16,7 +16,7 @@ html(lang="de") ul(class="flex-md-column flex-row navbar-nav w-100 justify-content-between") li(class="nav-item") a(class="nav-link pl-0 text-nowrap" href="/account/") - span(class="font-weight-bold" style="color:black;") #{user.firstName} #{user.lastName} - #{user.gitlabUserId} + span(class="font-weight-bold" style="color:black;") #{user.firstName} #{user.lastName} li(class="nav-item") a(class="nav-link pl-0" href="/account/profile") i(class="fa fa-user fa-fw") @@ -80,6 +80,7 @@ html(lang="de") img(src=defaultLogo, width="100" height="100") div(class="form-group row px-3") input#logo(name="logo", class="form-control-file", type="file") + p (Max file size is 80 KB.) input(type="submit", class="btn btn-primary", value="Senden") hr div(class="mx-4", style="color: gray;") diff --git a/views/DE/account/services.pug b/views/DE/account/services.pug index 9103c77c7141cb50c9244705174df63aff2c79ca..4702916d9d3e2bfd6f15432b8747559a50b59932 100644 --- a/views/DE/account/services.pug +++ b/views/DE/account/services.pug @@ -16,7 +16,7 @@ html(lang="de") ul(class="flex-md-column flex-row navbar-nav w-100 justify-content-between") li(class="nav-item") a(class="nav-link pl-0 text-nowrap" href="/") - span(class="font-weight-bold color_black") #{user.firstname} #{user.lastname} + span(class="font-weight-bold color_black") #{user.firstName} #{user.lastName} li(class="nav-item") a(class="nav-link pl-0" href="/account/profile") i(class="fa fa-user fa-fw") diff --git a/views/DE/account/updateInformation.pug b/views/DE/account/updateInformation.pug index d2a4fd152b4ce07d531453c54d907661ba40100e..acd0a143ac6807f3058dc20e7ef90343e3a0d368 100644 --- a/views/DE/account/updateInformation.pug +++ b/views/DE/account/updateInformation.pug @@ -67,6 +67,7 @@ html(lang="de") img(src=information.logo, width="100" height="100") div(class="form-group row") input#logo(name="logo", class="form-control-file", type="file") + p (Max file size is 80 KB.) input(type="submit", class="btn btn-primary", value="Speichern") hr div(class="mx-4")