Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
7daccf6690 | |||
493b6973c5 | |||
7877729100 | |||
c9f45ef82f | |||
3bee5b2aed | |||
bf3c216ee0 | |||
be3107b7a8 | |||
77946ad1eb | |||
bbd50f6f4a | |||
2f7c9abdc8 | |||
f27c7a03f3 | |||
6e0958d45b | |||
7e5753900c | |||
d6d6332da2 | |||
e48e9ae2fc | |||
428963b352 | |||
1aba9a71d7 | |||
80a7ce8f19 | |||
2d285f47fd | |||
6169272093 | |||
cb1e881450 |
39
Jenkinsfile
vendored
39
Jenkinsfile
vendored
@ -2,36 +2,9 @@ pipeline {
|
|||||||
agent any
|
agent any
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('[Neutral] - Check Version') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
def commit_name = env.TAG_NAME
|
|
||||||
if(commit_name) {
|
|
||||||
echo "[Neutral] - Deployement version reconnu"
|
|
||||||
|
|
||||||
} else {
|
|
||||||
currentBuild.result = 'ABORTED'
|
|
||||||
echo "[Neutral] - Deployement version non reconnu"
|
|
||||||
return
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('[Neutral] - Test') {
|
stage('[Neutral] - Test') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
def commit_name = env.TAG_NAME
|
|
||||||
if(commit_name) {
|
|
||||||
echo "[Neutral] - Deployement version reconnu"
|
|
||||||
|
|
||||||
} else {
|
|
||||||
currentBuild.result = 'ABORTED'
|
|
||||||
echo "[Neutral] - Deployement version non reconnu"
|
|
||||||
return
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "[Neutral-Deploy] - Test Stage"
|
echo "[Neutral-Deploy] - Test Stage"
|
||||||
sh "rm -rf neutral"
|
sh "rm -rf neutral"
|
||||||
sh "git clone https://git.raphix.fr/infrastructure/neutral.git"
|
sh "git clone https://git.raphix.fr/infrastructure/neutral.git"
|
||||||
@ -40,24 +13,12 @@ pipeline {
|
|||||||
sh "ENV='TEST' node bin/www"
|
sh "ENV='TEST' node bin/www"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('[Neutral] - Déploiement') {
|
stage('[Neutral] - Déploiement') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
|
|
||||||
def commit_name = env.TAG_NAME
|
|
||||||
if(commit_name) {
|
|
||||||
echo "[Neutral] - Deployement version reconnu"
|
|
||||||
|
|
||||||
} else {
|
|
||||||
currentBuild.result = 'ABORTED'
|
|
||||||
echo "[Neutral] - Deployement version non reconnu"
|
|
||||||
return
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
def doesJavaRock = input(message: 'Confirmation de Déploiement', ok: 'Déployer')
|
def doesJavaRock = input(message: 'Confirmation de Déploiement', ok: 'Déployer')
|
||||||
echo "[Neutral-Deploy] - Deploy Stage"
|
echo "[Neutral-Deploy] - Deploy Stage"
|
||||||
sh "ssh raphix@raphix.fr sudo apt update -y"
|
sh "ssh raphix@raphix.fr sudo apt update -y"
|
||||||
|
2
app.js
2
app.js
@ -20,6 +20,7 @@ var uploadRouter = require('./routes/upload');
|
|||||||
var userManagerRouter = require('./routes/usermanager');
|
var userManagerRouter = require('./routes/usermanager');
|
||||||
var linkRouter = require('./routes/link');
|
var linkRouter = require('./routes/link');
|
||||||
var fileRouter = require("./routes/filemanager")
|
var fileRouter = require("./routes/filemanager")
|
||||||
|
var downloadRouter = require("./routes/download")
|
||||||
|
|
||||||
|
|
||||||
var app = express();
|
var app = express();
|
||||||
@ -47,6 +48,7 @@ app.use('/upload', uploadRouter)
|
|||||||
app.use('/usermanager', userManagerRouter)
|
app.use('/usermanager', userManagerRouter)
|
||||||
app.use('/link', linkRouter)
|
app.use('/link', linkRouter)
|
||||||
app.use("/filemanager", fileRouter)
|
app.use("/filemanager", fileRouter)
|
||||||
|
app.use("/download", downloadRouter)
|
||||||
|
|
||||||
|
|
||||||
// catch 404 and forward to error handler
|
// catch 404 and forward to error handler
|
||||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "neutral",
|
"name": "neutral",
|
||||||
"version": "DEV_3.0",
|
"version": "DEV_5.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "neutral",
|
"name": "neutral",
|
||||||
"version": "DEV_3.0",
|
"version": "DEV_5.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@popperjs/core": "^2.11.6",
|
"@popperjs/core": "^2.11.6",
|
||||||
"bootstrap": "^5.2.2",
|
"bootstrap": "^5.2.2",
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "neutral",
|
"name": "neutral",
|
||||||
"version": "DEV_5.0",
|
"version": "DEV_5",
|
||||||
"private": true,
|
"private": true,
|
||||||
"nodemonConfig": {
|
"nodemonConfig": {
|
||||||
"ext": "js",
|
"ext": "js, html",
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"*.json"
|
"*.json"
|
||||||
],
|
],
|
||||||
|
@ -153,10 +153,6 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.viewbar {
|
.viewbar {
|
||||||
|
|
||||||
display: block !important;
|
display: block !important;
|
||||||
@ -216,7 +212,7 @@ body {
|
|||||||
|
|
||||||
}
|
}
|
||||||
.edropdown-content {
|
.edropdown-content {
|
||||||
text-align: center;
|
|
||||||
display: none;
|
display: none;
|
||||||
background-color: rgb(80, 80, 80);
|
background-color: rgb(80, 80, 80);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -289,10 +285,25 @@ body {
|
|||||||
|
|
||||||
.sidebar-content {
|
.sidebar-content {
|
||||||
|
|
||||||
text-align: center;
|
|
||||||
height: 83%;
|
height: 83%;
|
||||||
padding-top: 50%;
|
display: flex;
|
||||||
padding-bottom: 50%;
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.middle {
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
justify-content: start;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar:hover .middle {
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,7 +429,6 @@ body {
|
|||||||
|
|
||||||
}
|
}
|
||||||
.edropdown-content {
|
.edropdown-content {
|
||||||
text-align: center;
|
|
||||||
display: none;
|
display: none;
|
||||||
background-color: rgb(80, 80, 80);
|
background-color: rgb(80, 80, 80);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<div class="files">
|
<div class="files">
|
||||||
<h1>Gestionnnaire de fichiers</h1>
|
<h1>Gestionnaire de fichiers</h1>
|
||||||
</br>
|
</br>
|
||||||
<div class="homepanel">
|
<div class="homepanel">
|
||||||
<div class="row w-100">
|
<div class="row w-100">
|
||||||
@ -7,13 +7,15 @@
|
|||||||
<div class="fi_act">
|
<div class="fi_act">
|
||||||
<h1><i class="fa fa-folder"></i> Fichiers</h1>
|
<h1><i class="fa fa-folder"></i> Fichiers</h1>
|
||||||
<div>
|
<div>
|
||||||
<button class="fi_act_btn"><i class="fa fa-folder"></i> Nouveau dossier</button>
|
<button id="fi_new_folder" class="fi_act_btn"><i class="fa fa-folder"></i> Nouveau dossier</button>
|
||||||
<button class="fi_act_btn"><i class="fa fa-upload"></i> Upload</button>
|
<input id='fi_upload_file' type='file' hidden multiple />
|
||||||
|
<button id="fi_upload" class="fi_act_btn"><i class="fa fa-upload"></i> Upload</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fi_current_directory">
|
<div class="fi_current_directory">
|
||||||
<input id="fi_current_directory" class="fi_current_p" value="C:\Users\picot\OneDrive\Bureau\Developement\Neutral\neutral" type="text">
|
<input id="fi_current_directory" class="fi_current_p" value="/" type="text">
|
||||||
</div>
|
</div>
|
||||||
|
<p id="fi_info" style="text-align: start; color: rgb(255, 48, 48);"></p>
|
||||||
<div id="fileExplorer" class="fi_container">
|
<div id="fileExplorer" class="fi_container">
|
||||||
<p style="text-align: start; color: rgb(255, 48, 48);">Le répertoire n'existe pas ou est vide.</p>
|
<p style="text-align: start; color: rgb(255, 48, 48);">Le répertoire n'existe pas ou est vide.</p>
|
||||||
</div>
|
</div>
|
||||||
@ -22,6 +24,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="fi_dialog_input">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<dialog class="fi_addfolder" id="fi_new_folder_dialog">
|
||||||
|
<h1><i class="fa fa-folder"></i> Créer un dossier</h1>
|
||||||
|
<p>Nom du dossier :</p>
|
||||||
|
<input class="inp" id="fi_add_name" type="text">
|
||||||
|
<div style="color: rgb(255, 76, 76);" id="fi_folder_info"></div>
|
||||||
|
</div>
|
||||||
|
<button id="fi_add_close" class="fi_add_close">Annuler</button>
|
||||||
|
<button id="fi_add_confirm" class="fi_add_confirm">Ajouter</button>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
if(typeof currentDir == "undefined") {
|
if(typeof currentDir == "undefined") {
|
||||||
@ -29,9 +46,182 @@
|
|||||||
const currentDir = document.getElementById("fi_current_directory")
|
const currentDir = document.getElementById("fi_current_directory")
|
||||||
const fileExplorer = document.getElementById("fileExplorer")
|
const fileExplorer = document.getElementById("fileExplorer")
|
||||||
const fileExplorerError = '<div id="last_directory" class="fi_file"><p style="margin-left: 1vw;text-align:start;margin-bottom: 1vw !important;"><i class="fa fa-arrow-left"></i> Revenir au dossier parent</p></div>' + fileExplorer.outerHTML
|
const fileExplorerError = '<div id="last_directory" class="fi_file"><p style="margin-left: 1vw;text-align:start;margin-bottom: 1vw !important;"><i class="fa fa-arrow-left"></i> Revenir au dossier parent</p></div>' + fileExplorer.outerHTML
|
||||||
|
const fiInfo = document.getElementById("fi_info")
|
||||||
|
|
||||||
getDirectory(currentDir.value)
|
getDirectory(currentDir.value)
|
||||||
|
|
||||||
|
const newFolderBtn = document.getElementById("fi_new_folder")
|
||||||
|
const newFolderDialog = document.getElementById("fi_new_folder_dialog")
|
||||||
|
const newFolderConfirm = document.getElementById("fi_add_confirm")
|
||||||
|
const newFolderName = document.getElementById("fi_add_name")
|
||||||
|
const newFolderInfo = document.getElementById("fi_folder_info")
|
||||||
|
const dialogInput = document.getElementById("fi_dialog_input")
|
||||||
|
|
||||||
|
|
||||||
|
const newFolderClose = document.getElementById("fi_add_close")
|
||||||
|
|
||||||
|
newFolderClose.addEventListener("click", () => {
|
||||||
|
|
||||||
|
newFolderDialog.close()
|
||||||
|
getDirectory(currentDir.value)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
newFolderBtn.addEventListener("click", () => {
|
||||||
|
|
||||||
|
newFolderDialog.showModal()
|
||||||
|
newFolderName.value = ""
|
||||||
|
newFolderInfo.value = ""
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
newFolderConfirm.addEventListener("click", () => {
|
||||||
|
|
||||||
|
const folderDir = currentDir + newFolderName.value
|
||||||
|
newFolderInfo.value = ""
|
||||||
|
var wrongName = true
|
||||||
|
var justspace = false
|
||||||
|
|
||||||
|
const refusedChar = ['\\','/' ,':' ,'*','?' ,'"','<','>','|']
|
||||||
|
|
||||||
|
for(var char of refusedChar) {
|
||||||
|
|
||||||
|
if(newFolderName.value.includes(char)) {
|
||||||
|
wrongName = false
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < newFolderName.value.length; i++) {
|
||||||
|
var char = newFolderName.value.charAt(i)
|
||||||
|
|
||||||
|
if(char != " ") {
|
||||||
|
|
||||||
|
justspace = true
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(wrongName == false) {
|
||||||
|
|
||||||
|
newFolderInfo.innerHTML = "<p>Le nom du dossier est invalide car il contient des caractères interdits !</p>"
|
||||||
|
|
||||||
|
} else if(justspace == false) {
|
||||||
|
|
||||||
|
newFolderInfo.innerHTML = "<p>Le nom du dossier ne peut être vide !</p>"
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
fetch('/filemanager', {
|
||||||
|
method: 'POST',
|
||||||
|
redirect: 'follow',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({"request":"addfolder", "value": newFolderName.value, "currentDir" : currentDir.value})
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(response => res(response))
|
||||||
|
|
||||||
|
function res(response) {
|
||||||
|
if(response.result == "failed") {
|
||||||
|
content.innerHTML = ' <h1 style="color:red;"><i style="color:yellow; font-size: 2vw;" class="fa fa-warning"></i> Erreur de chargement des données - Erreur : ' + response.content + '</h1>'
|
||||||
|
console.log("FAILED")
|
||||||
|
|
||||||
|
} else if(response.result == "success") {
|
||||||
|
|
||||||
|
if(response.content == "ERROR_ALREADY_EXIST") {
|
||||||
|
newFolderInfo.innerHTML = "<p>Le nom du dossier est déjà existant !</p>"
|
||||||
|
|
||||||
|
|
||||||
|
} else if(response.content == "ERROR_NOT_MAKEABLE") {
|
||||||
|
newFolderInfo.innerHTML = "<p>Vous n'avez pas la permission !</p>"
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
newFolderDialog.close()
|
||||||
|
getDirectory(currentDir.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
const uploadBtn = document.getElementById("fi_upload")
|
||||||
|
const uploadFiles = document.getElementById("fi_upload_file")
|
||||||
|
|
||||||
|
|
||||||
|
uploadBtn.addEventListener("click", () => {
|
||||||
|
|
||||||
|
uploadFiles.click()
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
uploadFiles.addEventListener("change", () => {
|
||||||
|
|
||||||
|
var stopSend = false
|
||||||
|
fiInfo.innerHTML = ""
|
||||||
|
|
||||||
|
for(var file of uploadFiles.files) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(stopSend == false) {
|
||||||
|
const file_acc = new FormData();
|
||||||
|
file_acc.append("apic", file)
|
||||||
|
|
||||||
|
fetch('/upload', {
|
||||||
|
method: 'POST',
|
||||||
|
mode:"cors",
|
||||||
|
cache:"no-cache",
|
||||||
|
credentials:"same-origin",
|
||||||
|
headers: {
|
||||||
|
"uploadfiledirectory": currentDir.value
|
||||||
|
|
||||||
|
},
|
||||||
|
referrerPolicy:"no-referrer",
|
||||||
|
redirect: 'follow',
|
||||||
|
body: file_acc
|
||||||
|
}).then(response => response.json())
|
||||||
|
.then(response => resupload(response))
|
||||||
|
|
||||||
|
function resupload(response) {
|
||||||
|
|
||||||
|
|
||||||
|
if(response.result == "ERROR") {
|
||||||
|
fiInfo.innerHTML = "Les fichiers n'ont pas pu être uploadés !"
|
||||||
|
stopSend = true
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
getDirectory(currentDir.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
uploadFiles.value = null
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
currentDir.addEventListener("change", () => {
|
currentDir.addEventListener("change", () => {
|
||||||
|
|
||||||
@ -41,7 +231,10 @@
|
|||||||
|
|
||||||
function getDirectory(directory) {
|
function getDirectory(directory) {
|
||||||
|
|
||||||
|
fiInfo.innerHTML = ""
|
||||||
|
|
||||||
var fileExplorerList = new Array()
|
var fileExplorerList = new Array()
|
||||||
|
var dialogExlorerList = new Array()
|
||||||
|
|
||||||
fetch('/filemanager', {
|
fetch('/filemanager', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@ -74,11 +267,68 @@
|
|||||||
if(response.content == "ERROR_NOT_EXIST") {
|
if(response.content == "ERROR_NOT_EXIST") {
|
||||||
|
|
||||||
fileExplorer.innerHTML = fileExplorerError
|
fileExplorer.innerHTML = fileExplorerError
|
||||||
|
const last_dir = document.getElementById("last_directory")
|
||||||
|
|
||||||
|
last_dir.addEventListener("click", () => {
|
||||||
|
|
||||||
|
var cdSplit = currentDir.value.split("/")
|
||||||
|
|
||||||
|
if(cdSplit.slice(-1) == "") {
|
||||||
|
|
||||||
|
cdSplit.pop()
|
||||||
|
cdSplit.pop()
|
||||||
|
|
||||||
|
} else {
|
||||||
|
cdSplit.pop()
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
currentDir.value = cdSplit.join("/")
|
||||||
|
|
||||||
|
if(currentDir.value == "") {
|
||||||
|
currentDir.value = "/"
|
||||||
|
}
|
||||||
|
|
||||||
|
getDirectory(currentDir.value)
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
console.log("DENY")
|
console.log("DENY")
|
||||||
|
|
||||||
} else if(response.content == "ERROR_NOT_PERMITTED") {
|
} else if(response.content == "ERROR_NOT_PERMITTED") {
|
||||||
|
|
||||||
fileExplorer.innerHTML = '<p style="text-align: start; padding: 1vw; color: rgb(255, 48, 48);">Vous n\'avez pas la permission de regarder ce dossier.</p>'
|
fileExplorer.innerHTML = '<div id="last_directory" class="fi_file"><p style="margin-left: 1vw;text-align:start;margin-bottom: 1vw !important;"><i class="fa fa-arrow-left"></i> Revenir au dossier parent</p></div>' +'<p style="text-align: start; padding: 1vw; color: rgb(255, 48, 48);">Vous n\'avez pas la permission de regarder ce dossier.</p>'
|
||||||
|
const last_dir = document.getElementById("last_directory")
|
||||||
|
|
||||||
|
last_dir.addEventListener("click", () => {
|
||||||
|
|
||||||
|
var cdSplit = currentDir.value.split("/")
|
||||||
|
|
||||||
|
if(cdSplit.slice(-1) == "") {
|
||||||
|
|
||||||
|
cdSplit.pop()
|
||||||
|
cdSplit.pop()
|
||||||
|
|
||||||
|
} else {
|
||||||
|
cdSplit.pop()
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
currentDir.value = cdSplit.join("/")
|
||||||
|
|
||||||
|
if(currentDir.value == "") {
|
||||||
|
currentDir.value = "/"
|
||||||
|
}
|
||||||
|
|
||||||
|
getDirectory(currentDir.value)
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
console.log("DENY")
|
console.log("DENY")
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -119,8 +369,8 @@
|
|||||||
|
|
||||||
if(file.directory == true) {
|
if(file.directory == true) {
|
||||||
|
|
||||||
fileExplorerList.push('<div id="' + file.name + '_directory" class="fi_file row"> <p class="col-lg"><i style="color:yellow;" class="fa fa-folder"></i> ' + file.name + '</p> <p class="col-lg"><i class="fa fa-calendar"></i> Dernière édition : ' + lastedition + '</p> <p class="col-lg"><i class="fas fa-weight-hanging"></i> Taille : ' + file.size + ' octet(s)</p> <div class="col-lg fi_file_btn"> <button id="' + file.name + '_rename" class="fi_rename"><i class="fas fa-terminal"></i></button> <button id="' + file.name + '_delete" class="fi_delete"><i class="fa fa-trash"></i></button> </div> </div>')
|
fileExplorerList.push('<div id="' + file.name + '_directory" class="fi_file row"> <p class="col-lg"><i style="color:yellow;" class="fa fa-folder"></i> ' + file.name + '</p> <p class="col-lg"><i class="fa fa-calendar"></i> Dernière édition : ' + lastedition + '</p> <p class="col-lg"><i class="fas fa-weight-hanging"></i> Taille : ' + file.size + ' octet(s)</p> <div class="col-lg fi_file_btn"> <button id="' + file.name + '_rename" class="fi_rename"><i id="' + file.name + '_trename" class="fas fa-terminal"></i></button> <button id="' + file.name + '_delete" class="fi_delete"><i id="' + file.name + '_tdelete" class="fa fa-trash"></i></button> </div> </div>')
|
||||||
|
dialogExlorerList.push(' <dialog class="fi_addfolder" id="' + file.name + '_rename_dialog"> <h1><i class="fa fa-terminal"></i> Renommer un dossier</h1> <p><span id="' + file.name + '_old_name"></span></p> <p>Nouveau lien :</p> <input class="inp" id="' + file.name + '_rename_name" type="text"> </div><p id="' + file.name +'_rename_info" style="text-align: start; color: rgb(255, 48, 48);"></p> <button id="' + file.name + '_rename_close" class="fi_add_close">Annuler</button> <button id="' + file.name + '_rename_confirm" class="fi_add_confirm">Editer</button> </dialog>')
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,13 +478,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
fileExplorerList.push('<div id="' + file.name + '_directory" class="fi_file row"> <p class="col-lg">' + icon+ '</i> ' + file.name + '</p> <p class="col-lg"><i class="fa fa-calendar"></i> Dernière édition : ' + lastedition + '</p> <p class="col-lg"><i class="fas fa-weight-hanging"></i> Taille : ' + file.size + ' octet(s)</p> <div class="col-lg fi_file_btn"> <button id="' + file.name + '_rename" class="fi_rename"><i class="fas fa-terminal"></i></button> <button id="' + file + '_download" class="fi_rename"><i class="fas fa-download"></i></button><button id="' + file.name + '_delete" class="fi_delete"><i class="fa fa-trash"></i></button> </div> </div>')
|
fileExplorerList.push('<div id="' + file.name + '_directory" class="fi_file row"> <p class="col-lg">' + icon+ '</i> ' + file.name + '</p> <p class="col-lg"><i class="fa fa-calendar"></i> Dernière édition : ' + lastedition + '</p> <p class="col-lg"><i class="fas fa-weight-hanging"></i> Taille : ' + file.size + ' octet(s)</p> <div class="col-lg fi_file_btn"> <button id="' + file.name + '_rename" class="fi_rename"><i id="' + file.name + '_trename" class="fas fa-terminal"></i></button> <button id="' + file.name + '_download" class="fi_rename"><i id="' + file.name + '_tdownload" class="fas fa-download"></i></button><button id="' + file.name + '_delete" class="fi_delete"><i id="' + file.name + '_tdelete" class="fa fa-trash"></i></button> </div> </div>')
|
||||||
|
dialogExlorerList.push(' <dialog class="fi_addfolder" id="' + file.name + '_rename_dialog"> <h1><i class="fa fa-terminal"></i> Renommer un fichier</h1> <p><span id="' + file.name + '_old_name"></span></p> <p>Nouveau lien :</p> <input class="inp" id="' + file.name + '_rename_name" type="text"> </div> <p id="' + file.name +'_rename_info" style="text-align: start; color: rgb(255, 48, 48);"></p><button id="' + file.name + '_rename_close" class="fi_add_close">Annuler</button> <button id="' + file.name + '_rename_confirm" class="fi_add_confirm">Editer</button> </dialog>')
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileExplorer.innerHTML = fileExplorerList.join('')
|
fileExplorer.innerHTML = fileExplorerList.join('')
|
||||||
|
dialogInput.innerHTML = dialogExlorerList.join('')
|
||||||
|
|
||||||
const last_dir = document.getElementById("last_directory")
|
const last_dir = document.getElementById("last_directory")
|
||||||
|
|
||||||
@ -275,17 +526,14 @@
|
|||||||
|
|
||||||
const deleteBtn = document.getElementById(file.name + "_delete")
|
const deleteBtn = document.getElementById(file.name + "_delete")
|
||||||
const renameBtn = document.getElementById(file.name + "_rename")
|
const renameBtn = document.getElementById(file.name + "_rename")
|
||||||
|
const renameDialog = document.getElementById(file.name + "_rename_dialog")
|
||||||
|
const renameOldName = document.getElementById(file.name + "_old_name")
|
||||||
|
const renameName = document.getElementById(file.name + "_rename_name")
|
||||||
|
const renameClose = document.getElementById(file.name + "_rename_close")
|
||||||
|
const renameConfirm = document.getElementById(file.name + "_rename_confirm")
|
||||||
|
const renameInfo = document.getElementById(file.name + "_rename_info")
|
||||||
|
|
||||||
|
|
||||||
deleteBtn.addEventListener("click", () => {
|
|
||||||
|
|
||||||
console.log(file.name)
|
|
||||||
})
|
|
||||||
|
|
||||||
renameBtn.addEventListener("click", () => {
|
|
||||||
|
|
||||||
console.log(file.name)
|
|
||||||
})
|
|
||||||
|
|
||||||
if(file.directory == true) {
|
if(file.directory == true) {
|
||||||
|
|
||||||
@ -293,9 +541,9 @@
|
|||||||
|
|
||||||
dir.addEventListener("click", (event) => {
|
dir.addEventListener("click", (event) => {
|
||||||
|
|
||||||
console.log(event.target.id != file.name + "_delete" && event.target.id != file.name + "_rename")
|
console.log(event.target)
|
||||||
|
|
||||||
if((event.target.id != file.name + "_delete" & event.target.id != file.name + "_rename") == true) {
|
if(event.target.id != file.name + "_delete" && event.target.id != file.name + "_rename" && event.target.id != file.name + "_trename" && event.target.id != file.name + "_tdelete") {
|
||||||
|
|
||||||
if(currentDir.value.slice(-1) != "\\" && currentDir.value.slice(-1) != "/") {
|
if(currentDir.value.slice(-1) != "\\" && currentDir.value.slice(-1) != "/") {
|
||||||
|
|
||||||
@ -320,7 +568,170 @@
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
const downloadBtn = document.getElementById(file.name + "_download")
|
||||||
|
|
||||||
|
downloadBtn.addEventListener("click", () => {
|
||||||
|
|
||||||
|
fiInfo.innerHTML = ""
|
||||||
|
|
||||||
|
fetch('/download', {
|
||||||
|
method: 'GET',
|
||||||
|
redirect: 'follow',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'FileRequest': file.fileDirectory
|
||||||
}
|
}
|
||||||
|
}).then(resp => resp.blob())
|
||||||
|
.then(blob => {
|
||||||
|
const url = window.URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement("a");
|
||||||
|
a.style.display = "none";
|
||||||
|
a.href = url;
|
||||||
|
a.download = file.name;
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
|
||||||
|
})
|
||||||
|
.catch(() => fiInfo.innerHTML = "Une erreur est survenue lors du téléchargement");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteBtn.addEventListener("click", () => {
|
||||||
|
|
||||||
|
fiInfo.innerHTML = ""
|
||||||
|
|
||||||
|
fetch('/filemanager', {
|
||||||
|
method: 'POST',
|
||||||
|
redirect: 'follow',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({"request":"del", "value": file})
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(response => res(response, file))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function res(response, file) {
|
||||||
|
|
||||||
|
console.log(file)
|
||||||
|
|
||||||
|
if(response.result == "failed") {
|
||||||
|
|
||||||
|
content.innerHTML = ' <h1 style="color:red;"><i style="color:yellow; font-size: 2vw;" class="fa fa-warning"></i> Erreur de chargement des données - Erreur : ' + response.content + '</h1>'
|
||||||
|
console.log("FAILED")
|
||||||
|
|
||||||
|
} else if(response.result == "success") {
|
||||||
|
|
||||||
|
if(response.content == "ERROR_NOT_MAKEABLE") {
|
||||||
|
fiInfo.innerHTML = "<p>Vous n'avez pas la permission !</p>"
|
||||||
|
|
||||||
|
|
||||||
|
} else if(response.content == "ERROR_NOT_EXIST") {
|
||||||
|
console.log("ERROR NOT EXIST")
|
||||||
|
getDirectory(currentDir.value)
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
newFolderDialog.close()
|
||||||
|
getDirectory(currentDir.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
renameBtn.addEventListener("click", () => {
|
||||||
|
|
||||||
|
renameDialog.showModal()
|
||||||
|
renameOldName.innerHTML = file.fileDirectory
|
||||||
|
renameName.value = file.fileDirectory
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
renameClose.addEventListener("click" ,() => {
|
||||||
|
renameDialog.close()
|
||||||
|
getDirectory(currentDir.value)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
renameConfirm.addEventListener("click" ,() => {
|
||||||
|
var rnjustspace = false
|
||||||
|
renameInfo.innerHTML = ""
|
||||||
|
|
||||||
|
for (var i = 0; i < renameName.value.length; i++) {
|
||||||
|
var char = renameName.value.charAt(i)
|
||||||
|
|
||||||
|
if(char != " ") {
|
||||||
|
|
||||||
|
rnjustspace = true
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(rnjustspace == false) {
|
||||||
|
|
||||||
|
renameInfo.innerHTML = "Le nom du dossier ne peut être vide !"
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
fetch('/filemanager', {
|
||||||
|
method: 'POST',
|
||||||
|
redirect: 'follow',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({"request":"rename", "value": renameName.value, "currentDir" : renameOldName.outerText})
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(response => res(response))
|
||||||
|
|
||||||
|
function res(response) {
|
||||||
|
if(response.result == "failed") {
|
||||||
|
content.innerHTML = ' <h1 style="color:red;"><i style="color:yellow; font-size: 2vw;" class="fa fa-warning"></i> Erreur de chargement des données - Erreur : ' + response.content + '</h1>'
|
||||||
|
console.log("FAILED")
|
||||||
|
|
||||||
|
} else if(response.result == "success") {
|
||||||
|
|
||||||
|
if(response.content == "ERROR_ALREADY_EXIST") {
|
||||||
|
renameInfo.innerHTML = "<p>Le nom du dossier est déjà existant !</p>"
|
||||||
|
|
||||||
|
|
||||||
|
} else if(response.content == "ERROR_NOT_MAKEABLE") {
|
||||||
|
renameInfo.innerHTML = "<p>Vous n'avez pas la permission !</p>"
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
renameDialog.close()
|
||||||
|
getDirectory(currentDir.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -428,7 +839,6 @@
|
|||||||
background-color: rgb(32, 32, 32) ;
|
background-color: rgb(32, 32, 32) ;
|
||||||
border-radius: 1vw;
|
border-radius: 1vw;
|
||||||
padding: 1vw;
|
padding: 1vw;
|
||||||
text-align: center;
|
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
|
||||||
@ -554,6 +964,93 @@ table {
|
|||||||
margin-bottom: 0.5vw !important;
|
margin-bottom: 0.5vw !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fi_addfolder {
|
||||||
|
|
||||||
|
border-radius: 1vw;
|
||||||
|
border-color: transparent;
|
||||||
|
background-color: rgb(80, 80, 80);
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.fi_add_close {
|
||||||
|
|
||||||
|
border-radius: 1vw;
|
||||||
|
border-color: rgb(255, 48, 48);
|
||||||
|
border-width: 1%;
|
||||||
|
border-style: solid;
|
||||||
|
color: white;
|
||||||
|
background-color: transparent;
|
||||||
|
transition: all 0.2s ease 0s;
|
||||||
|
margin: 0.5vw;
|
||||||
|
padding: 0.5vw;
|
||||||
|
font-size: 1vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fi_add_close:hover {
|
||||||
|
box-shadow: 1px 1px 10px rgb(255, 48, 48);
|
||||||
|
background-color: rgb(255, 48, 48);
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fi_add_close:active {
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.fi_add_confirm {
|
||||||
|
|
||||||
|
border-radius: 1vw;
|
||||||
|
border-color: rgb(0, 174, 255);
|
||||||
|
border-width: 1%;
|
||||||
|
border-style: solid;
|
||||||
|
color: white;
|
||||||
|
background-color: transparent;
|
||||||
|
transition: all 0.2s ease 0s;
|
||||||
|
margin: 0.5vw;
|
||||||
|
padding: 0.5vw;
|
||||||
|
font-size: 1vw;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.fi_add_confirm:hover {
|
||||||
|
box-shadow: 1px 1px 10px rgb(0, 174, 255);
|
||||||
|
background-color: rgb(0, 174, 255);
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fi_add_confirm:active {
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.inp {
|
||||||
|
|
||||||
|
border-style: hidden;
|
||||||
|
border-radius: 1vw;
|
||||||
|
padding: 0.2vw;
|
||||||
|
padding-left: 1vw;
|
||||||
|
transition: all 0.2s ease 0s;
|
||||||
|
margin-bottom: 0.5vw;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.inp:hover {
|
||||||
|
|
||||||
|
box-shadow: 2px 2px 5px rgba(255, 255, 255, 0.477) ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.inp:focus {
|
||||||
|
|
||||||
|
box-shadow: 5px 5px 5px rgba(0, 174, 255, 0.477) ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
@ -78,7 +78,7 @@
|
|||||||
|
|
||||||
for(var link of links) {
|
for(var link of links) {
|
||||||
|
|
||||||
linksContent.push('<div class="row lk_line"> <p class="col-lg"><i class="fas fa-sticky-note"></i> Nom du raccourci : ' + link.name + '</p> <p class="col-lg"><i class="fa-sharp fa-solid fa-link"></i> Lien raccourci : <a href="http://localhost/link/' + link.dest + '">http://localhost/link/' + link.dest + '</a></p> <p class="col-lg"><i class="fa-solid fa-up-right-from-square"></i> Lien réel : <a href="' + link.src + '"><strong>Vers le lien</strong></a></p> <div class="col-lg "> <button id="' + link.name + '_edit_btn" class="lk_edit"><i class="fa fa-pen"></i></button> <button id="' + link.name + '_delete" class="lk_delete"><i class="fa fa-trash"></i></button> </div> </div>')
|
linksContent.push('<div class="row lk_line"> <p class="col-lg"><i class="fas fa-sticky-note"></i> Nom du raccourci : ' + link.name + '</p> <p class="col-lg"><i class="fa-sharp fa-solid fa-link"></i> Lien raccourci : <a href="https://neutral.raphix.fr/link/' + link.dest + '">https://neutral.raphix.fr/link/' + link.dest + '</a></p> <p class="col-lg"><i class="fa-solid fa-up-right-from-square"></i> Lien réel : <a href="' + link.src + '"><strong>Vers le lien</strong></a></p> <div class="col-lg "> <button id="' + link.name + '_edit_btn" class="lk_edit"><i class="fa fa-pen"></i></button> <button id="' + link.name + '_delete" class="lk_delete"><i class="fa fa-trash"></i></button> </div> </div>')
|
||||||
dialogContent.push('<dialog class="lk_adduser" id="' + link.name + '_dialog"> <h1><i class="fa fa-pen"></i> Editer un lien raccourci</h1> <p>Nom du raccourci :</p> <input class="inp" id="' + link.name + '_edit_name" type="text"> <p>Lien à raccourcir :</p> <input class="inp" id="' + link.name + '_edit_src" type="text"> <p>Nouveau lien (neutral.raphix.fr/link/<i>votrelien</i>):</p> <input class="inp" id="' + link.name + '_edit_dest" type="text"> <div style="color: rgb(255, 76, 76);" id="' + link.name + '_edit_info"></div> </div> <button onclick="getPage(\'link.html\')" id="lk_add_close" class="lk_add_close">Annuler</button> <button id="' + link.name + '_edit_confirm" class="lk_add_confirm">Editer</button> </dialog>')
|
dialogContent.push('<dialog class="lk_adduser" id="' + link.name + '_dialog"> <h1><i class="fa fa-pen"></i> Editer un lien raccourci</h1> <p>Nom du raccourci :</p> <input class="inp" id="' + link.name + '_edit_name" type="text"> <p>Lien à raccourcir :</p> <input class="inp" id="' + link.name + '_edit_src" type="text"> <p>Nouveau lien (neutral.raphix.fr/link/<i>votrelien</i>):</p> <input class="inp" id="' + link.name + '_edit_dest" type="text"> <div style="color: rgb(255, 76, 76);" id="' + link.name + '_edit_info"></div> </div> <button onclick="getPage(\'link.html\')" id="lk_add_close" class="lk_add_close">Annuler</button> <button id="' + link.name + '_edit_confirm" class="lk_add_confirm">Editer</button> </dialog>')
|
||||||
|
|
||||||
lkcontent.innerHTML = linksContent.join("")
|
lkcontent.innerHTML = linksContent.join("")
|
||||||
|
@ -183,6 +183,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else if(user_fullname.value != "") {
|
} else if(user_fullname.value != "") {
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<div class="users">
|
<div class="users">
|
||||||
<h1>Gestionnnaire des utilisateurs</h1>
|
<h1>Gestionnaire des utilisateurs</h1>
|
||||||
</br>
|
</br>
|
||||||
<div class="homepanel">
|
<div class="homepanel">
|
||||||
<div class="row w-100">
|
<div class="row w-100">
|
||||||
|
48
routes/download.js
Normal file
48
routes/download.js
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
var express = require('express');
|
||||||
|
var router = express.Router();
|
||||||
|
var ntr = require("../neutral-functions.js");
|
||||||
|
var fs = require("fs")
|
||||||
|
var path = require("path")
|
||||||
|
|
||||||
|
router.get("/", function(req,res,next) {
|
||||||
|
|
||||||
|
var check = ntr.checkToken(req, res)
|
||||||
|
|
||||||
|
if(check.name != false) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(req.headers.filerequest != null && check.permLevel >= 3) {
|
||||||
|
if(fs.existsSync(req.headers.filerequest)) {
|
||||||
|
|
||||||
|
res.download(req.headers.filerequest, (error) => {
|
||||||
|
|
||||||
|
if(error) {
|
||||||
|
|
||||||
|
res.send({"result":"ERROR"})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
res.send({"result":"ERROR"})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
res.redirect("/")
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
res.render('login', {error: ""});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
|
|
@ -3,7 +3,8 @@ var router = express.Router();
|
|||||||
var ntr = require("../neutral-functions.js")
|
var ntr = require("../neutral-functions.js")
|
||||||
var fs = require("fs")
|
var fs = require("fs")
|
||||||
var path = require("path")
|
var path = require("path")
|
||||||
var mime = require('mime-types')
|
var mime = require('mime-types');
|
||||||
|
const { compileString } = require('sass');
|
||||||
|
|
||||||
/* GET home page. */
|
/* GET home page. */
|
||||||
router.get('/', function(req, res, next) {
|
router.get('/', function(req, res, next) {
|
||||||
@ -59,7 +60,7 @@ router.post("/", function(req, res, next) {
|
|||||||
|
|
||||||
const stat = fs.statSync(directory.replace("/", path.sep.replace("\\", path.sep)) + path.sep + file)
|
const stat = fs.statSync(directory.replace("/", path.sep.replace("\\", path.sep)) + path.sep + file)
|
||||||
|
|
||||||
files.push({"name":file, "type":mime.lookup(file), "size":stat.size, "lastedition":stat.mtimeMs, "directory":stat.isDirectory()})
|
files.push({"name":file, "fileDirectory" :directory.replace("/", path.sep.replace("\\", path.sep)) + path.sep + file , "type":mime.lookup(file), "size":stat.size, "lastedition":stat.mtimeMs, "directory":stat.isDirectory()})
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -83,11 +84,80 @@ router.post("/", function(req, res, next) {
|
|||||||
|
|
||||||
} else if(bod.request == "del") {
|
} else if(bod.request == "del") {
|
||||||
|
|
||||||
res.send({"result":"failed", "content":"ERROR_NOT_MAKE"})
|
const file = bod.value
|
||||||
|
|
||||||
|
if(fs.existsSync(bod.value.fileDirectory) == false) {
|
||||||
|
res.send({"result":"success", "content":"ERROR_NOT_EXIST"})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if(file.directory == true) {
|
||||||
|
fs.rmdirSync(file.fileDirectory , { recursive: true, force: true })
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fs.rmSync(file.fileDirectory)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
console.log("DELETED")
|
||||||
|
res.send({"result":"success", "content":"DELETED"})
|
||||||
|
|
||||||
|
} catch(error) {
|
||||||
|
|
||||||
|
console.log(error)
|
||||||
|
console.log("NOT DELETED")
|
||||||
|
res.send({"result":"success", "content":"ERROR_NOT_MAKEABLE"})
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("NOT DELETED")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} else if(bod.request == "rename") {
|
} else if(bod.request == "rename") {
|
||||||
|
|
||||||
res.send({"result":"failed", "content":"ERROR_NOT_MAKE"})
|
if(fs.existsSync(bod.value) == true) {
|
||||||
|
res.send({"result":"success", "content":"ERROR_ALREADY_EXIST"})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
fs.renameSync(bod.currentDir, bod.value)
|
||||||
|
res.send({"result":"success", "content":"RENAMED"})
|
||||||
|
|
||||||
|
} catch(error) {
|
||||||
|
console.log(error)
|
||||||
|
res.send({"result":"success", "content":"ERROR_NOT_MAKEABLE"})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else if(bod.request == "addfolder") {
|
||||||
|
|
||||||
|
|
||||||
|
if(fs.existsSync(bod.currentDir + path.sep + bod.value) == true) {
|
||||||
|
res.send({"result":"success", "content":"ERROR_ALREADY_EXIST"})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(bod.currentDir + path.sep + bod.value)
|
||||||
|
res.send({"result":"success", "content":"CREATED"})
|
||||||
|
|
||||||
|
} catch(error) {
|
||||||
|
console.log(error)
|
||||||
|
res.send({"result":"success", "content":"ERROR_NOT_MAKEABLE"})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
res.send({"result":"failed", "content":"ERROR_REQUEST_MISSING_FIELDS", "additional": "REQUEST_MISSING"})
|
res.send({"result":"failed", "content":"ERROR_REQUEST_MISSING_FIELDS", "additional": "REQUEST_MISSING"})
|
||||||
|
@ -6,6 +6,7 @@ var CryptoJS = require("crypto-js");
|
|||||||
var uuid = require("uuid")
|
var uuid = require("uuid")
|
||||||
var ntr = require("../neutral-functions.js");
|
var ntr = require("../neutral-functions.js");
|
||||||
const Jimp = require("jimp");
|
const Jimp = require("jimp");
|
||||||
|
const { compileString } = require('sass');
|
||||||
|
|
||||||
/* GET home page. */
|
/* GET home page. */
|
||||||
router.get('/', function(req, res, next) {
|
router.get('/', function(req, res, next) {
|
||||||
@ -46,6 +47,7 @@ router.post("/", function(req, res, next) {
|
|||||||
var uploadPath = "";
|
var uploadPath = "";
|
||||||
var uploadDir = __dirname.replace("routes","public" + path.sep + "images" + path.sep + "userspics" + path.sep)
|
var uploadDir = __dirname.replace("routes","public" + path.sep + "images" + path.sep + "userspics" + path.sep)
|
||||||
|
|
||||||
|
|
||||||
if(req.files.apic.mimetype == "image/png") {
|
if(req.files.apic.mimetype == "image/png") {
|
||||||
|
|
||||||
uploadPath = req.headers.uploadforuser + ".png"
|
uploadPath = req.headers.uploadforuser + ".png"
|
||||||
@ -56,7 +58,7 @@ router.post("/", function(req, res, next) {
|
|||||||
uploadPath = req.headers.uploadforuser+ ".jpg"
|
uploadPath = req.headers.uploadforuser+ ".jpg"
|
||||||
}
|
}
|
||||||
|
|
||||||
image.mv(uploadPath, function(err) {
|
image.mv(__dirname.replace("routes", "") + path.sep + uploadPath, function(err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
res.send({"result":"success", "content": "La photo de profil n'a pas pu être chargé."})
|
res.send({"result":"success", "content": "La photo de profil n'a pas pu être chargé."})
|
||||||
console.log(err)
|
console.log(err)
|
||||||
@ -76,7 +78,10 @@ router.post("/", function(req, res, next) {
|
|||||||
if(req.files.apic.mimetype == "image/jpeg") {
|
if(req.files.apic.mimetype == "image/jpeg") {
|
||||||
Jimp.read(uploadDir + uploadPath, function (err, image) {
|
Jimp.read(uploadDir + uploadPath, function (err, image) {
|
||||||
image.resize(200,200, function(err){
|
image.resize(200,200, function(err){
|
||||||
if (err) throw err;
|
if (err) {
|
||||||
|
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
}).write(uploadDir + uploadPath.replace("jpg", "png"))
|
}).write(uploadDir + uploadPath.replace("jpg", "png"))
|
||||||
fs.rmSync(uploadDir + req.headers.uploadforuser + ".jpg")
|
fs.rmSync(uploadDir + req.headers.uploadforuser + ".jpg")
|
||||||
|
|
||||||
@ -91,7 +96,10 @@ router.post("/", function(req, res, next) {
|
|||||||
} else if(req.files.apic.mimetype == "image/png") {
|
} else if(req.files.apic.mimetype == "image/png") {
|
||||||
Jimp.read(uploadDir + uploadPath, function (err, image) {
|
Jimp.read(uploadDir + uploadPath, function (err, image) {
|
||||||
image.resize(200,200, function(err){
|
image.resize(200,200, function(err){
|
||||||
if (err) throw err;
|
if (err) {
|
||||||
|
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
}).write(uploadDir + uploadPath)
|
}).write(uploadDir + uploadPath)
|
||||||
|
|
||||||
res.send({"result":"success", "content": "<span style='color:rgb(130, 255, 163);'>La photo de profil a été changé avec succès.</span>",})
|
res.send({"result":"success", "content": "<span style='color:rgb(130, 255, 163);'>La photo de profil a été changé avec succès.</span>",})
|
||||||
@ -133,6 +141,28 @@ router.post("/", function(req, res, next) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else if(req.headers.uploadfiledirectory != null) {
|
||||||
|
|
||||||
|
if(fs.existsSync(req.headers.uploadfiledirectory)) {
|
||||||
|
image.mv(req.headers.uploadfiledirectory + path.sep + req.files.apic.name, (error) => {
|
||||||
|
|
||||||
|
if(error) {
|
||||||
|
res.send({"result":"ERROR"})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
res.send({"result":"SUCCESS"})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
res.send({"result":"ERROR"})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
@ -151,7 +181,7 @@ router.post("/", function(req, res, next) {
|
|||||||
uploadPath = ntr.checkToken(req, res).name + ".jpg"
|
uploadPath = ntr.checkToken(req, res).name + ".jpg"
|
||||||
}
|
}
|
||||||
|
|
||||||
image.mv(uploadPath, function(err) {
|
image.mv(__dirname.replace("routes", "") + path.sep + uploadPath, function(err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
res.send({"result":"success", "content": "La photo de profil n'a pas pu être chargé."})
|
res.send({"result":"success", "content": "La photo de profil n'a pas pu être chargé."})
|
||||||
console.log(err)
|
console.log(err)
|
||||||
@ -171,7 +201,10 @@ router.post("/", function(req, res, next) {
|
|||||||
if(req.files.apic.mimetype == "image/jpeg") {
|
if(req.files.apic.mimetype == "image/jpeg") {
|
||||||
Jimp.read(uploadDir + uploadPath, function (err, image) {
|
Jimp.read(uploadDir + uploadPath, function (err, image) {
|
||||||
image.resize(200,200, function(err){
|
image.resize(200,200, function(err){
|
||||||
if (err) throw err;
|
if (err) {
|
||||||
|
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
}).write(uploadDir + uploadPath.replace("jpg", "png"))
|
}).write(uploadDir + uploadPath.replace("jpg", "png"))
|
||||||
fs.rmSync(uploadDir + ntr.checkToken(req, res).name + ".jpg")
|
fs.rmSync(uploadDir + ntr.checkToken(req, res).name + ".jpg")
|
||||||
|
|
||||||
@ -186,7 +219,10 @@ router.post("/", function(req, res, next) {
|
|||||||
} else if(req.files.apic.mimetype == "image/png") {
|
} else if(req.files.apic.mimetype == "image/png") {
|
||||||
Jimp.read(uploadDir + uploadPath, function (err, image) {
|
Jimp.read(uploadDir + uploadPath, function (err, image) {
|
||||||
image.resize(200,200, function(err){
|
image.resize(200,200, function(err){
|
||||||
if (err) throw err;
|
if (err) {
|
||||||
|
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
}).write(uploadDir + uploadPath)
|
}).write(uploadDir + uploadPath)
|
||||||
|
|
||||||
res.send({"result":"success", "content": "<span style='color:rgb(130, 255, 163);'>La photo de profil a été changé avec succès.</span>",})
|
res.send({"result":"success", "content": "<span style='color:rgb(130, 255, 163);'>La photo de profil a été changé avec succès.</span>",})
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
"fullname": "Raphael PICOT",
|
"fullname": "Raphael PICOT",
|
||||||
"permissionLevel": 4,
|
"permissionLevel": 4,
|
||||||
"token": {
|
"token": {
|
||||||
"tokenID": "748eac04-7725-4da3-a5ce-e02655e9a320",
|
"tokenID": "571ecb2b-726f-442f-9ec7-bc19205847b7",
|
||||||
"livableToken": true,
|
"livableToken": true,
|
||||||
"createdAt": 1677602543822
|
"createdAt": 1679260759114
|
||||||
},
|
},
|
||||||
"lastconnexion": 1677602755015
|
"lastconnexion": 1679595671060
|
||||||
}
|
}
|
@ -4,10 +4,6 @@
|
|||||||
"uuid": "c8f353a4-d0df-4c10-bccc-d4f47daf0f51",
|
"uuid": "c8f353a4-d0df-4c10-bccc-d4f47daf0f51",
|
||||||
"fullname": "Administrateur",
|
"fullname": "Administrateur",
|
||||||
"permissionLevel": 4,
|
"permissionLevel": 4,
|
||||||
"token": {
|
"token": {},
|
||||||
"tokenID": "c750c10a-f69d-4dd2-8a35-65d8a74897bb",
|
|
||||||
"livableToken": false,
|
|
||||||
"createdAt": 1677339320398
|
|
||||||
},
|
|
||||||
"lastconnexion": 1677339336836
|
"lastconnexion": 1677339336836
|
||||||
}
|
}
|
@ -8,7 +8,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="sidebar" class="sidebar">
|
<div id="sidebar" class="sidebar">
|
||||||
<img class=" logo img-fluid" src="images/logo.png"></img>
|
<img class=" logo img-fluid" src="images/logo.png"></img>
|
||||||
<div class="sidebar-content align-items-center">
|
<div class="sidebar-content">
|
||||||
<div class="middle">
|
<div class="middle">
|
||||||
<div class="sidebar-item" id="s-home">
|
<div class="sidebar-item" id="s-home">
|
||||||
<i class="fa-solid fa-home"></i>
|
<i class="fa-solid fa-home"></i>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Neutron - Login</title>
|
<title>Neutral - Login</title>
|
||||||
<script src="neutron.bundle.js"></script>
|
<script src="neutron.bundle.js"></script>
|
||||||
<link rel='stylesheet' href='/stylesheets/style.css'>
|
<link rel='stylesheet' href='/stylesheets/style.css'>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
Reference in New Issue
Block a user