diff --git a/bin/files.js b/bin/files.js index 2cea76b..68b34d8 100644 --- a/bin/files.js +++ b/bin/files.js @@ -163,15 +163,8 @@ module.exports.getFile = function(root) { if(fs.existsSync(root)) { try { - - // Check if the file is an image and if it is return the base64 - if(mime.lookup(root).includes("image")) { - return "data:" + mime.lookup(root) + ";base64," + fs.readFileSync(root, "base64") - } else { - return fs.readFileSync(root, "utf-8") - } - - + + return fs.readFileSync(root, "utf-8") } catch(err) { console.log(err) return "NOT_PERMITTED" diff --git a/package.json b/package.json index 430c07d..6471c9d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "neutral", - "version": "1.1.0", + "version": "1.0.3", "description": "Panel d'administration de Raphix", "main": "index.js", "scripts": { diff --git a/public/javascripts/filexplorer.js b/public/javascripts/filexplorer.js index bb3e59c..1f1ae17 100644 --- a/public/javascripts/filexplorer.js +++ b/public/javascripts/filexplorer.js @@ -590,7 +590,6 @@ explorer.createWindow(() => { }) } else { // Make Download using result - const element = document.createElement('a'); element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(result)); element.setAttribute('download', file.name); @@ -598,6 +597,7 @@ explorer.createWindow(() => { document.body.appendChild(element); element.click(); document.body.removeChild(element); + } }) }) @@ -614,15 +614,7 @@ explorer.createWindow(() => { function editFile() { const reqFiles = post("FX_GETFILE", file.fileDirectory) - //Create a popup for the loading - - View.createPopup({ - title: ` Editeur`, - content: `
Chargement en cours ...
` - }) - reqFiles.then((result) => { - View.destroyPopup(` Editeur}`) if(result == "NOT_PERMITTED") { View.createPopup({ title: ` Erreur`, @@ -632,65 +624,58 @@ explorer.createWindow(() => { const editor = new ViewWindow({ title: ` Editeur - ${file.fileDirectory}`, width: "1000px", - height: "650px" + height: "600px" }) - - if(file.type == "image/png" | file.type == "image/jpeg") { - editor.setContent(` -Vous n'avez pas les permissions pour éditer ce fichier.
` - }) - } else { - editor.createPopup({ - title: ` Erreur`, - content: `Une erreur est survenue.
` - }) - } - }) + const reqFiles = post("FX_SAVEFILE", {root: files.root, name: file.name, content: editorContent.value}) + reqFiles.then((result) => { + if(result == "OK") { + editor.destroy() + const reqFiles = post("FX_GET", files.root) + reqFiles.then((result) => { + loadFiles(result) + }) + } else if(result == "NOT_PERMITTED") { + editor.createPopup({ + title: ` Erreur`, + content: `Vous n'avez pas les permissions pour éditer ce fichier.
` + }) + } else { + editor.createPopup({ + title: ` Erreur`, + content: `Une erreur est survenue.
` + }) + } }) + }) - //forbid textarea resize - editorContent.style.resize = "none" + //forbid textarea resize + editorContent.style.resize = "none" + + + - } - - } })