Final Improvement for CV Editor
All checks were successful
Neutral/pipeline/head This commit looks good
All checks were successful
Neutral/pipeline/head This commit looks good
This commit is contained in:
parent
12b340e0f1
commit
eafa16e46d
@ -89,8 +89,8 @@
|
|||||||
<div style="color: rgb(255, 76, 76);" id="cv-project-add-info"></div>
|
<div style="color: rgb(255, 76, 76);" id="cv-project-add-info"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="cv-upload-section">
|
<div class="cv-upload-section">
|
||||||
<p style="font-size: 14px;">Image : <span>NAMTEST.png</span> <button style="margin-left: 10%;" class="cv-upload"><i class="fa fa-upload"></i> Upload</button></p>
|
<p style="font-size: 14px;">Image : <span id="cv-upload-name">NULL_NAME</span> <button id="cv-upload-btn" style="margin-left: 10%;" class="cv-upload"><i class="fa fa-upload"></i> Upload</button></p>
|
||||||
|
<input id='cv-upload-file' type='file' hidden/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<button onclick="getPage('cv.html')" id="cv-project-add-close" class="cv_add_close">Annuler</button>
|
<button onclick="getPage('cv.html')" id="cv-project-add-close" class="cv_add_close">Annuler</button>
|
||||||
@ -120,6 +120,10 @@
|
|||||||
const projectAddConfirm = document.getElementById("cv-project-add-confirm")
|
const projectAddConfirm = document.getElementById("cv-project-add-confirm")
|
||||||
const projectAddInfo = document.getElementById("cv-project-add-info")
|
const projectAddInfo = document.getElementById("cv-project-add-info")
|
||||||
|
|
||||||
|
const projectUploadFile = document.getElementById("cv-upload-file")
|
||||||
|
const projectUploadBtn = document.getElementById("cv-upload-btn")
|
||||||
|
const projectUploadName = document.getElementById("cv-upload-name")
|
||||||
|
|
||||||
var sectionSelectedMD = null;
|
var sectionSelectedMD = null;
|
||||||
var projectSelectedMD = null;
|
var projectSelectedMD = null;
|
||||||
|
|
||||||
@ -130,6 +134,8 @@
|
|||||||
|
|
||||||
projectAddInfo.innerHTML = ""
|
projectAddInfo.innerHTML = ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const refusedChar = ['\\','/' ,':' ,'*','?' ,'"','<','>','|']
|
const refusedChar = ['\\','/' ,':' ,'*','?' ,'"','<','>','|']
|
||||||
var wrongName = true;
|
var wrongName = true;
|
||||||
|
|
||||||
@ -171,12 +177,48 @@
|
|||||||
projectDialog.close()
|
projectDialog.close()
|
||||||
getProjects(projectSelector)
|
getProjects(projectSelector)
|
||||||
loadText(projectTextArea, projectAddInput.value)
|
loadText(projectTextArea, projectAddInput.value)
|
||||||
|
projectSelector.value = projectAddInput.value
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(projectUploadFile.files.length > 0) {
|
||||||
|
|
||||||
|
const file_acc = new FormData();
|
||||||
|
file_acc.append("apic", projectUploadFile.files[0])
|
||||||
|
|
||||||
|
fetch('/upload', {
|
||||||
|
method: 'POST',
|
||||||
|
mode:"cors",
|
||||||
|
cache:"no-cache",
|
||||||
|
credentials:"same-origin",
|
||||||
|
headers: {
|
||||||
|
"uploadforproject": projectAddInput.value
|
||||||
|
|
||||||
|
},
|
||||||
|
referrerPolicy:"no-referrer",
|
||||||
|
redirect: 'follow',
|
||||||
|
body: file_acc
|
||||||
|
}).then(response => response.json())
|
||||||
|
.then(response => resupload(response))
|
||||||
|
|
||||||
|
function resupload(response) {
|
||||||
|
|
||||||
|
|
||||||
|
if(response.result == "ERROR") {
|
||||||
|
projectInfo.innerHTML = "L'image n'a pas été upload !"
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -190,6 +232,23 @@
|
|||||||
|
|
||||||
projectDialog.showModal()
|
projectDialog.showModal()
|
||||||
|
|
||||||
|
projectAddInput.value = ""
|
||||||
|
projectUploadName.innerHTML = "Aucune image."
|
||||||
|
projectUploadFile.value = null;
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
projectUploadFile.addEventListener("change", () => {
|
||||||
|
|
||||||
|
projectUploadName.innerHTML = projectUploadFile.files[0].name
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
projectUploadBtn.addEventListener("click", () => {
|
||||||
|
|
||||||
|
projectUploadFile.click()
|
||||||
})
|
})
|
||||||
|
|
||||||
projectDelete.addEventListener("click", () => {
|
projectDelete.addEventListener("click", () => {
|
||||||
|
12
routes/cv.js
12
routes/cv.js
@ -428,7 +428,15 @@ router.post("/", function(req, res, next) {
|
|||||||
|
|
||||||
fs.readdirSync("../MD_TEST/project/").forEach((file) => {
|
fs.readdirSync("../MD_TEST/project/").forEach((file) => {
|
||||||
|
|
||||||
allProject.push((file).replace(".md", ""))
|
|
||||||
|
if(fs.statSync("../MD_TEST/project/" + file).isDirectory()) {
|
||||||
|
console.log(file)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
allProject.push((file).replace(".md", ""))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -513,7 +521,7 @@ router.post("/", function(req, res, next) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
fs.writeFile(projectFolder + bod.value + ".md", "**" + bod.value + "**" ,(err) => {
|
fs.writeFile("../MD_TEST/project/" + bod.value + ".md", "**" + bod.value + "**" ,(err) => {
|
||||||
|
|
||||||
if(err) {
|
if(err) {
|
||||||
res.send({"result":"success", "content":"ERROR_NOT_PERMITTED"})
|
res.send({"result":"success", "content":"ERROR_NOT_PERMITTED"})
|
||||||
|
@ -164,6 +164,42 @@ router.post("/", function(req, res, next) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else if(req.headers.uploadforproject != null) {
|
||||||
|
|
||||||
|
const projectFolder = "/home/gitlab-ci/cv/dashboard-raphael/public/images/"
|
||||||
|
|
||||||
|
if(fs.existsSync(projectFolder)) {
|
||||||
|
|
||||||
|
image.mv(projectFolder + req.headers.uploadforproject + ".png", (error) => {
|
||||||
|
|
||||||
|
if(error) {
|
||||||
|
res.send({"result":"ERROR"})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
res.send({"result":"SUCCESS"})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
const mdtestfolder = "../MD_TEST/project/image/"
|
||||||
|
|
||||||
|
image.mv(mdtestfolder + req.headers.uploadforproject + ".png", (error) => {
|
||||||
|
|
||||||
|
if(error) {
|
||||||
|
res.send({"result":"ERROR"})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
res.send({"result":"SUCCESS"})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,5 +9,5 @@
|
|||||||
"livableToken": true,
|
"livableToken": true,
|
||||||
"createdAt": 1679260759114
|
"createdAt": 1679260759114
|
||||||
},
|
},
|
||||||
"lastconnexion": 1680106107373
|
"lastconnexion": 1680108499963
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user