mirror of
https://github.com/misterunknown/ifm.git
synced 2025-08-10 10:04:01 +02:00
Add overwrite hint when uploading via drag&drop, make it configurable
Signed-off-by: Marco Dickert <marco@misterunknown.de>
This commit is contained in:
22
src/ifm.js
22
src/ifm.js
@@ -947,12 +947,12 @@ function IFM(params) {
|
||||
e.preventDefault();
|
||||
var newfilename = form.elements.newfilename.value;
|
||||
var files = Array.prototype.slice.call( form.elements.files.files );
|
||||
var existing_files = [];
|
||||
var existing_files;
|
||||
if (files.length > 1)
|
||||
existing_files = files.map(x => x.name).filter(item => self.fileCache.map(x => x.name).includes(item));
|
||||
else
|
||||
existing_files = self.fileCache.map(x => x.name).includes(newfilename);
|
||||
if (existing_files.length > 0)
|
||||
existing_files = self.fileCache.map(x => x.name).indexOf(newfilename) ? [newfilename] : [];
|
||||
if (existing_files.length > 0 && self.config.confirmoverwrite)
|
||||
self.showUploadConfirmOverwrite(files, existing_files, newfilename);
|
||||
else {
|
||||
if (files.length == 1)
|
||||
@@ -970,13 +970,13 @@ function IFM(params) {
|
||||
});
|
||||
};
|
||||
|
||||
this.showUploadConfirmOverwrite = function(files, existing_files, newfilename="") {
|
||||
this.showUploadConfirmOverwrite = function(files, existing_files, newfilename=undefined) {
|
||||
self.showModal(Mustache.render(self.templates.uploadconfirmoverwrite, {files: existing_files, i18n: self.i18n}));
|
||||
var form = document.forms.formUploadConfirmOverwrite;
|
||||
form.addEventListener('click', function(e) {
|
||||
if (e.target.id == "buttonConfirm") {
|
||||
e.preventDefault();
|
||||
if (files.length == 1)
|
||||
if (files.length == 1 && newfilename)
|
||||
self.uploadFile(files[0], newfilename);
|
||||
else
|
||||
files.forEach(function(file) {
|
||||
@@ -1889,10 +1889,14 @@ function IFM(params) {
|
||||
div.ondrop = function( e ) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var files = e.dataTransfer.files;
|
||||
for( var i = 0; i < files.length; i++ ) {
|
||||
self.uploadFile( files[i] );
|
||||
}
|
||||
var files = Array.from(e.dataTransfer.files);
|
||||
var existing_files = files.map(x => x.name).filter(item => self.fileCache.map(x => x.name).includes(item));
|
||||
if (existing_files.length > 0 && self.config.confirmoverwrite)
|
||||
self.showUploadConfirmOverwrite(files, existing_files);
|
||||
else
|
||||
files.forEach(function(file) {
|
||||
self.uploadFile(file);
|
||||
});
|
||||
if( e.target.id == 'filedropoverlay' )
|
||||
e.target.style.display = 'none';
|
||||
else if( e.target.parentElement.id == 'filedropoverlay' ) {
|
||||
|
@@ -56,7 +56,8 @@ class IFM {
|
||||
"contextmenu" => 1,
|
||||
"disable_mime_detection" => 0,
|
||||
"showrefresh" => 1,
|
||||
"forceproxy" => 0
|
||||
"forceproxy" => 0,
|
||||
"confirmoverwrite" => 1
|
||||
);
|
||||
|
||||
private $config = array();
|
||||
@@ -106,6 +107,7 @@ class IFM {
|
||||
$this->config['search'] = getenv('IFM_API_SEARCH') !== false ? intval( getenv('IFM_API_SEARCH') ) : $this->config['search'] ;
|
||||
$this->config['showrefresh'] = getenv('IFM_GUI_REFRESH') !== false ? intval( getenv('IFM_GUI_REFRESH') ) : $this->config['showrefresh'] ;
|
||||
$this->config['forceproxy'] = getenv('IFM_GUI_FORCEPROXY') !== false ? intval( getenv('IFM_GUI_FORCEPROXY') ) : $this->config['forceproxy'] ;
|
||||
$this->config['confirmoverwrite'] = getenv('IFM_GUI_CONFIRMOVERWRITE') !== false ? intval( getenv('IFM_GUI_CONFIRMOVERWRITE') ) : $this->config['confirmoverwrite'] ;
|
||||
|
||||
// optional settings
|
||||
if( getenv('IFM_SESSION_LIFETIME') !== false )
|
||||
|
@@ -1,6 +1,7 @@
|
||||
body {
|
||||
padding-top: 70px;
|
||||
overflow-y: scroll !important;
|
||||
padding-right: 0px !important;
|
||||
}
|
||||
|
||||
main {
|
||||
@@ -188,9 +189,6 @@ table.dataTable thead th.sorting_desc:after {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.modal-open {
|
||||
padding-right: 0px !important;
|
||||
}
|
||||
|
||||
@media (min-width: 576px) {
|
||||
.modal-dialog {
|
||||
|
Reference in New Issue
Block a user