mirror of
https://github.com/misterunknown/ifm.git
synced 2025-08-15 12:33:59 +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();
|
e.preventDefault();
|
||||||
var newfilename = form.elements.newfilename.value;
|
var newfilename = form.elements.newfilename.value;
|
||||||
var files = Array.prototype.slice.call( form.elements.files.files );
|
var files = Array.prototype.slice.call( form.elements.files.files );
|
||||||
var existing_files = [];
|
var existing_files;
|
||||||
if (files.length > 1)
|
if (files.length > 1)
|
||||||
existing_files = files.map(x => x.name).filter(item => self.fileCache.map(x => x.name).includes(item));
|
existing_files = files.map(x => x.name).filter(item => self.fileCache.map(x => x.name).includes(item));
|
||||||
else
|
else
|
||||||
existing_files = self.fileCache.map(x => x.name).includes(newfilename);
|
existing_files = self.fileCache.map(x => x.name).indexOf(newfilename) ? [newfilename] : [];
|
||||||
if (existing_files.length > 0)
|
if (existing_files.length > 0 && self.config.confirmoverwrite)
|
||||||
self.showUploadConfirmOverwrite(files, existing_files, newfilename);
|
self.showUploadConfirmOverwrite(files, existing_files, newfilename);
|
||||||
else {
|
else {
|
||||||
if (files.length == 1)
|
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}));
|
self.showModal(Mustache.render(self.templates.uploadconfirmoverwrite, {files: existing_files, i18n: self.i18n}));
|
||||||
var form = document.forms.formUploadConfirmOverwrite;
|
var form = document.forms.formUploadConfirmOverwrite;
|
||||||
form.addEventListener('click', function(e) {
|
form.addEventListener('click', function(e) {
|
||||||
if (e.target.id == "buttonConfirm") {
|
if (e.target.id == "buttonConfirm") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (files.length == 1)
|
if (files.length == 1 && newfilename)
|
||||||
self.uploadFile(files[0], newfilename);
|
self.uploadFile(files[0], newfilename);
|
||||||
else
|
else
|
||||||
files.forEach(function(file) {
|
files.forEach(function(file) {
|
||||||
@@ -1889,10 +1889,14 @@ function IFM(params) {
|
|||||||
div.ondrop = function( e ) {
|
div.ondrop = function( e ) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
var files = e.dataTransfer.files;
|
var files = Array.from(e.dataTransfer.files);
|
||||||
for( var i = 0; i < files.length; i++ ) {
|
var existing_files = files.map(x => x.name).filter(item => self.fileCache.map(x => x.name).includes(item));
|
||||||
self.uploadFile( files[i] );
|
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' )
|
if( e.target.id == 'filedropoverlay' )
|
||||||
e.target.style.display = 'none';
|
e.target.style.display = 'none';
|
||||||
else if( e.target.parentElement.id == 'filedropoverlay' ) {
|
else if( e.target.parentElement.id == 'filedropoverlay' ) {
|
||||||
|
@@ -56,7 +56,8 @@ class IFM {
|
|||||||
"contextmenu" => 1,
|
"contextmenu" => 1,
|
||||||
"disable_mime_detection" => 0,
|
"disable_mime_detection" => 0,
|
||||||
"showrefresh" => 1,
|
"showrefresh" => 1,
|
||||||
"forceproxy" => 0
|
"forceproxy" => 0,
|
||||||
|
"confirmoverwrite" => 1
|
||||||
);
|
);
|
||||||
|
|
||||||
private $config = array();
|
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['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['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['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
|
// optional settings
|
||||||
if( getenv('IFM_SESSION_LIFETIME') !== false )
|
if( getenv('IFM_SESSION_LIFETIME') !== false )
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
body {
|
body {
|
||||||
padding-top: 70px;
|
padding-top: 70px;
|
||||||
overflow-y: scroll !important;
|
overflow-y: scroll !important;
|
||||||
|
padding-right: 0px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
@@ -188,9 +189,6 @@ table.dataTable thead th.sorting_desc:after {
|
|||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-open {
|
|
||||||
padding-right: 0px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 576px) {
|
@media (min-width: 576px) {
|
||||||
.modal-dialog {
|
.modal-dialog {
|
||||||
|
Reference in New Issue
Block a user