Commit 6447e044 authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

add default logo

parent 6e6719ea
This commit is part of merge request !78. Comments created here will be created in the context of that merge request.
Showing with 36 additions and 30 deletions
+36 -30
public/default/logo.png

84.7 KB

...@@ -12,6 +12,7 @@ const async = require('async') ...@@ -12,6 +12,7 @@ const async = require('async')
const crypto = require('crypto') const crypto = require('crypto')
const mailer = require('./mailer') const mailer = require('./mailer')
const logoDir = 'public/upload/' const logoDir = 'public/upload/'
const defaultLogo = 'public/default/logo.png'
const tpGitlabURL = 'https://transfer.hft-stuttgart.de/gitlab/' const tpGitlabURL = 'https://transfer.hft-stuttgart.de/gitlab/'
const tpGitlabPagesURL = 'https://transfer.hft-stuttgart.de/pages/' const tpGitlabPagesURL = 'https://transfer.hft-stuttgart.de/pages/'
...@@ -493,46 +494,49 @@ module.exports = function (app, config, passport, i18n) { ...@@ -493,46 +494,49 @@ module.exports = function (app, config, passport, i18n) {
let projectDesc = req.body.description let projectDesc = req.body.description
let projectTemplate = req.body.template let projectTemplate = req.body.template
let newInformation = new projectInformation(loggedInUser.getGitlabUserId(), null, projectName, projectDesc, null, null) let newInformation = new projectInformation(loggedInUser.getGitlabUserId(), null, projectName, projectDesc, null, null)
let newLogoFile = defaultLogo
if (!req.files) {
res.flash('error', 'Bitte geben Sie ein Projektlogo an.') if (req.files) { newLogoFile = req.files.logo }
res.redirect('/account/newInformation')
} else { async.waterfall([
let newLogoFile = req.files.logo function(callback){ // upload logo
async.waterfall([ if (!req.files) {
function(callback){ // upload logo callback(null, newLogoFile)
} else {
newLogoFile.mv(logoDir + newLogoFile.name, function(err) { newLogoFile.mv(logoDir + newLogoFile.name, function(err) {
newLogoFile = logoDir+newLogoFile.name newLogoFile = logoDir+newLogoFile.name
callback(err, newLogoFile) callback(err, newLogoFile)
}) })
}, }
async function(newLogoFile){ // create a new GitLab Page },
let newPages = await gitlab.createNewPages(newInformation, newLogoFile, projectTemplate) async function(newLogoFile){ // create a new GitLab Page
if (newPages.error) { let newPages = await gitlab.createNewPages(newInformation, newLogoFile, projectTemplate)
if(newPages.data.message.name == "has already been taken") { if (newPages.error) {
res.flash("error", "Der Projektname '"+newInformation.getName()+"' ist bereits vergeben, bitte wählen Sie einen anderen Namen.") if(newPages.data.message.name == "has already been taken") {
} else { res.flash("error", "Der Projektname '"+newInformation.getName()+"' ist bereits vergeben, bitte wählen Sie einen anderen Namen.")
res.flash("error", "Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut. ")
}
res.redirect('/account/newInformation')
} else { } else {
let newPagesData = newPages.data res.flash("error", "Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut. ")
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)
} }
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) ], function (err) {
// remove logo if(err) console.log(err)
// remove logo
if (req.files) {
fs.unlink(newLogoFile, (err) => { fs.unlink(newLogoFile, (err) => {
if(err) console.log(err) if(err) console.log(err)
}) })
}) }
} })
} }
} }
}) })
......
...@@ -80,6 +80,7 @@ html(lang="de") ...@@ -80,6 +80,7 @@ html(lang="de")
img(src=defaultLogo, width="100" height="100") img(src=defaultLogo, width="100" height="100")
div(class="form-group row px-3") div(class="form-group row px-3")
input#logo(name="logo", class="form-control-file", type="file") input#logo(name="logo", class="form-control-file", type="file")
p <small>(Max file size is 80 KB.)</small>
input(type="submit", class="btn btn-primary", value="Senden") input(type="submit", class="btn btn-primary", value="Senden")
hr hr
div(class="mx-4", style="color: gray;") div(class="mx-4", style="color: gray;")
......
...@@ -67,6 +67,7 @@ html(lang="de") ...@@ -67,6 +67,7 @@ html(lang="de")
img(src=information.logo, width="100" height="100") img(src=information.logo, width="100" height="100")
div(class="form-group row") div(class="form-group row")
input#logo(name="logo", class="form-control-file", type="file") input#logo(name="logo", class="form-control-file", type="file")
p <small>(Max file size is 80 KB.)</small>
input(type="submit", class="btn btn-primary", value="Speichern") input(type="submit", class="btn btn-primary", value="Speichern")
hr hr
div(class="mx-4") div(class="mx-4")
......
Supports Markdown
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