diff --git a/plugins/face/faceManagerCustomAutoLoadLibrary/index.js b/plugins/face/faceManagerCustomAutoLoadLibrary/index.js index 8dbbf425..761d306a 100644 --- a/plugins/face/faceManagerCustomAutoLoadLibrary/index.js +++ b/plugins/face/faceManagerCustomAutoLoadLibrary/index.js @@ -144,7 +144,7 @@ module.exports = function(s,config,lang,app,io){ })) },res,req) }) - app.post(config.webPaths.superApiPrefix+':auth/faceManager/image/:name/:image', fileUpload(), function (req,res){ + app.post(config.webPaths.superApiPrefix+':auth/faceManager/image/:name', fileUpload(), function (req,res){ s.superAuth(req.params,function(resp){ res.setHeader('Content-Type', 'application/json') var fileKeys = Object.keys(req.files || {}) @@ -152,8 +152,7 @@ module.exports = function(s,config,lang,app,io){ return res.status(400).send('No files were uploaded.') } var filesUploaded = [] - fileKeys.forEach(function(key){ - var file = req.files[key] + var checkFile = (file) => { if(file.name.indexOf('.jpg') > -1 || file.name.indexOf('.jpeg') > -1){ filesUploaded.push(file.name) if(!fs.existsSync(config.facesFolder + req.params.name)){ @@ -169,6 +168,21 @@ module.exports = function(s,config,lang,app,io){ }) }) } + } + fileKeys.forEach(function(key){ + var file = req.files[key] + try{ + if(file instanceof Array){ + file.forEach(function(fileOfFile){ + checkFile(fileOfFile) + }) + }else{ + checkFile(file) + } + }catch(err){ + console.log(file) + console.log(err) + } }) var response = { ok: true, diff --git a/plugins/face/faceManagerCustomAutoLoadLibrary/web/libs/js/super.faceManager.js b/plugins/face/faceManagerCustomAutoLoadLibrary/web/libs/js/super.faceManager.js index f810183f..57adf785 100644 --- a/plugins/face/faceManagerCustomAutoLoadLibrary/web/libs/js/super.faceManager.js +++ b/plugins/face/faceManagerCustomAutoLoadLibrary/web/libs/js/super.faceManager.js @@ -105,6 +105,14 @@ $(document).ready(function(){ revert: "invalid" }); } + var createFaceImageBlock = function(row,faceName,fileName){ + var existingBlock = row.find(`[face="${faceName}"][image="${fileName}"]`) + if(existingBlock.length > 0){ + existingBlock.draggable('destroy') + existingBlock.remove() + } + row.prepend(getFaceImageHtml(faceName,fileName)) + } faceManagerModal.on('shown.bs.modal',function(){ drawFaceImages() }) @@ -132,21 +140,17 @@ $(document).ready(function(){ return false; }) $('#fileinput').change(function(){ - for(var i = 0; i\ ' + lang.faceManager + '\ @@ -160,7 +164,7 @@ $(document).ready(function(){ row = faceManagerImages.find(`.row[face="${d.faceName}"]`) activateDroppableContainer(d.faceName) } - row.prepend(getFaceImageHtml(d.faceName,d.fileName)) + createFaceImageBlock(row,d.faceName,d.fileName) activateDraggableImages() prettySizeFaceImages() break;