diff --git a/capsule-prototype/css/popup.css b/capsule-prototype/css/popup.css index 0e6eb0d64d210b5e5def82cb843b7e916baa938f..baea1c74f1b9dcb4b9e696a84661e0bbda25e4b7 100644 --- a/capsule-prototype/css/popup.css +++ b/capsule-prototype/css/popup.css @@ -599,7 +599,7 @@ color: #FFF; } -#popupSetHighlight:hover { +#popupSetHighlight:hover, #editAnnotationPic:hover, #linkToOriginalImage:hover { color: rgba(255,255,255,.25); /*#142E33; */ } @@ -608,7 +608,7 @@ color: rgba(255,255,255,.75); /*#FFF; */ } -#popupEditSupprimer { +#popupEditSupprimer, #editAnnotationPic, #linkToOriginalImage { font-weight: 400; color: rgba(255,255,255,.75); font-size: 0.6em; diff --git a/capsule-prototype/js/online-rekall/Tag.js b/capsule-prototype/js/online-rekall/Tag.js index f45f159d8e854f8c03b57c1d176fbdffed96efa0..f6cd7fe6bfd0195d6e861e3b3cee41cf94f72d0b 100644 --- a/capsule-prototype/js/online-rekall/Tag.js +++ b/capsule-prototype/js/online-rekall/Tag.js @@ -101,6 +101,9 @@ Tag.prototype.downloadFile = function() { Tag.prototype.getDownloadLink = function(original = false) { return this.document.getDownloadLink(original); } +Tag.prototype.getFileName = function() { + return this.document.getFileName(); +} Tag.prototype.openBrowser = function() { return this.document.openBrowser(); } diff --git a/capsule-prototype/js/online-script.js b/capsule-prototype/js/online-script.js index 250e4cc7283809d6f18dd055bbe6d4d83339018f..c28f5559ce0d0f6c0298865a27a4013287a31799 100644 --- a/capsule-prototype/js/online-script.js +++ b/capsule-prototype/js/online-script.js @@ -558,9 +558,7 @@ function setEditionControls() { window.my_current_markerjs_data_in_ugly_global = state; markerArea.close(true); setMetaFromDom(keyDoc.value, "Rekall->MarkerjsState", btoa(JSON.stringify(state))); - setMetaFromDom(keyDoc.value, "Rekall->EditedImage", event.dataUrl); - /* this will create another annotation with edited image (as raw file, not b64 data) var b64img = event.dataUrl; var data = b64img.match(/data:([a-z]+)\/([a-z]+);base64,(.*)/); var type = data[1], subtype = data[2], b64data = data[3]; @@ -568,11 +566,9 @@ function setEditionControls() { var n = b64data.length; var uar = new Uint8Array(n); while (n--) uar[n] = bin_str.charCodeAt(n); - var file = new File([uar], 'edited_' + Math.floor(Math.random()*100) + '.' + subtype, {type: type+'/'+subtype}); + var file = new File([uar], keyDoc.value.substr(1), {type: type+'/'+subtype}); $('#left_menu_item_btn_addfile').files = [file]; - uploadFiles([file]); - */ - + uploadFiles([file], {'edited': 1}); }); markerArea.addEventListener('close', () => $('#edit_pic_modal').hide()); markerArea.renderAtNaturalSize = true; @@ -989,7 +985,7 @@ function fillPopupEdit(tag) { $("#popupImg").attr("src","../shared/css/images/img-note.png"); } else { if(tag.thumbnail.url){ - $("#popupImg").attr("src", tag.getMetadata('Rekall->EditedImage') || tag.thumbnail.url); + $("#popupImg").attr("src", tag.getDownloadLink() || tag.thumbnail.url); $('#annotation_img_edit').attr('src', tag.getDownloadLink(true)); } else { if(type.indexOf("image") > -1) $("#popupImg").attr("src","../shared/css/images/img-image.png") @@ -1021,7 +1017,7 @@ function fillPopupEdit(tag) { $('#editAnnotationPic').show(); $('#linkToOriginalImage').show(); $('#linkToOriginalImage').unbind('click'); - $('#linkToOriginalImage').click(() => tag.openBrowser()); + $('#linkToOriginalImage').click(() => window.open(tag.getDownloadLink(true), '_blank')); var data = tag.getMetadata('Rekall->MarkerjsState'); if (data) window.my_current_markerjs_data_in_ugly_global = JSON.parse(atob(data)); @@ -1217,7 +1213,7 @@ function deleteFromDomFinished() { //Gestion d'upload var filesToUpload = [], fileIsUploading = false; -function uploadFiles(files) { +function uploadFiles(files, additionnal_post_data={}) { $.each(files, function(index, file) { var formData = new FormData(); @@ -1254,6 +1250,7 @@ function uploadFiles(files) { formData.append("author", rekall_common.owner.author); formData.append("locationGps", rekall_common.owner.locationGps); formData.append("locationName", rekall_common.owner.locationName); + Object.keys(additionnal_post_data).forEach(k => formData.append(k, additionnal_post_data[k])); if(formData != undefined) { filesToUpload.push({ diff --git a/capsule-prototype/js/rekall/Document.js b/capsule-prototype/js/rekall/Document.js index 5627a3c5e97bd8d965490744f69f1eeedcd307b7..0582b29727c393f3e72c6fd3eba6d2499a8ecd55 100644 --- a/capsule-prototype/js/rekall/Document.js +++ b/capsule-prototype/js/rekall/Document.js @@ -88,9 +88,11 @@ Document.prototype.isLink = function(version) { } Document.prototype.getDownloadLink = function(original = false) { var path = Utils.getLocalFilePath(this, "file"); - if (original) - path = path.replace('file.php?r=', 'file.php?r=original_'); - return path; + return original ? path.replace('file.php?r=', 'file.php?r=original_') : path; +} +Document.prototype.getFileName = function() { + var path = Utils.getLocalFilePath(this, "file"); + return path.replace(/.*r=(.*)/, (f, m) => m); } diff --git a/capsule-prototype/php/upload.php b/capsule-prototype/php/upload.php index 36e882d75cb639c108d36723146c12fabd654701..7f5cb52206c2a694da541c18883e6196c0e3c6a2 100644 --- a/capsule-prototype/php/upload.php +++ b/capsule-prototype/php/upload.php @@ -58,14 +58,16 @@ if(is_uploaded_file($_FILES[$fileinfo]['tmp_name'])) { if(file_exists($_FILES[$fileinfo]['tmp_name'])) { if(is_writable($uploadFolder)) { - if(!file_exists($uploadFolder.$filename)) { + if(!file_exists($uploadFolder.$filename) || $_POST['edited'] == 1) { //echo "Upload de ".$fileinfo."\t".$filename."..."; if(move_uploaded_file($_FILES[$fileinfo]['tmp_name'], $uploadFolder.$filename)) { - copy($uploadFolder.$filename, $uploadFolder.'original_'.$filename); - $metasAdded = addFileToProject($uploadFolder.$filename, $metas, $tcIn, $tcOut); - $key = $metasAdded["key"]; - unset($metasAdded["key"]); - $retour .= '"code":1, "tcIn":'.$tcIn.', "tcOut":'.$tcOut.', "key":"'.$key.'", "status":"OK ('.(filesize($uploadFolder.$filename)/1000.).' kB)", "metas":'.json_encode($metasAdded); + if (!file_exists($uploadFolder.'original_'.$filename) && $_POST['edited'] != 1) { + copy($uploadFolder.$filename, $uploadFolder.'original_'.$filename); + $metasAdded = addFileToProject($uploadFolder.$filename, $metas, $tcIn, $tcOut); + $key = $metasAdded["key"]; + unset($metasAdded["key"]); + $retour .= '"code":1, "tcIn":'.$tcIn.', "tcOut":'.$tcOut.', "key":"'.$key.'", "status":"OK ('.(filesize($uploadFolder.$filename)/1000.).' kB)", "metas":'.json_encode($metasAdded); + } $status |= true; } else