summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-04-26 18:08:49 +0200
committerGeorg Ehrke <dev@georgswebsite.de>2012-04-26 18:08:49 +0200
commit2b10371bdeb2c8a3d5cc2617ada5cf8195c264c9 (patch)
treef25b463c90992764887416c3082098fed6ecac65 /apps/files
parent40f95ffdf3edf9ab45c15bd5b9018d7f4d92baa9 (diff)
parent127796218314c6b1f19ba86f74caa913375aac8d (diff)
downloadnextcloud-server-2b10371bdeb2c8a3d5cc2617ada5cf8195c264c9.tar.gz
nextcloud-server-2b10371bdeb2c8a3d5cc2617ada5cf8195c264c9.zip
fix merge conflicts
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/ajax/scan.php3
-rw-r--r--apps/files/css/files.css8
-rw-r--r--apps/files/index.php2
-rw-r--r--apps/files/js/fileactions.js15
-rw-r--r--apps/files/js/filelist.js1
-rw-r--r--apps/files/js/files.js286
-rw-r--r--apps/files/templates/index.php5
-rw-r--r--apps/files/templates/part.list.php4
8 files changed, 254 insertions, 70 deletions
diff --git a/apps/files/ajax/scan.php b/apps/files/ajax/scan.php
index 488f68e6b3c..a227dcc3ffc 100644
--- a/apps/files/ajax/scan.php
+++ b/apps/files/ajax/scan.php
@@ -3,6 +3,7 @@
set_time_limit(0);//scanning can take ages
$force=isset($_GET['force']) and $_GET['force']=='true';
+$dir=isset($_GET['dir'])?$_GET['dir']:'';
$checkOnly=isset($_GET['checkonly']) and $_GET['checkonly']=='true';
if(!$checkOnly){
@@ -14,7 +15,7 @@ if(!$checkOnly){
if($force or !OC_FileCache::inCache('')){
if(!$checkOnly){
OC_DB::beginTransaction();
- OC_FileCache::scan('',$eventSource);
+ OC_FileCache::scan($dir,$eventSource);
OC_FileCache::clean();
OC_DB::commit();
$eventSource->send('success',true);
diff --git a/apps/files/css/files.css b/apps/files/css/files.css
index 99623b6355e..a135f7ded5b 100644
--- a/apps/files/css/files.css
+++ b/apps/files/css/files.css
@@ -30,6 +30,8 @@
.file_upload_filename { position: relative; z-index:100; padding-left: 0.8em; padding-right: 0.8em; cursor:pointer; border-top-left-radius:0; border-bottom-left-radius:0; }
.file_upload_filename img { position: absolute; top: 0.4em; left: 0.4em; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; filter:alpha(opacity=100); opacity:1; }
+#upload { position:absolute; right:13.5em; top:0em; }
+#upload #uploadprogressbar { position:relative; display:inline-block; width:10em; height:1.5em; top:.4em; }
.file_upload_form, .file_upload_wrapper, .file_upload_start, .file_upload_filename, #file_upload_submit { cursor:pointer; }
@@ -41,7 +43,7 @@ tbody tr { background-color:#fff; height:2.5em; }
tbody tr:hover, tbody tr:active, tbody tr.selected { background-color:#f8f8f8; }
tbody tr.selected { background-color:#eee; }
tbody a { color:#000; }
-span.extension, td.date { color:#999; }
+span.extension, span.uploading, td.date { color:#999; }
span.extension { text-transform:lowercase; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=70)"; filter:alpha(opacity=70); opacity:.7; -webkit-transition:opacity 300ms; -moz-transition:opacity 300ms; -o-transition:opacity 300ms; transition:opacity 300ms; }
tr:hover span.extension { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; filter:alpha(opacity=100); opacity:1; color:#777; }
div.crumb { float:left; display:block; background:no-repeat right 0; padding:.75em 1.5em 0 1em; height:2.9em; }
@@ -60,8 +62,10 @@ table td.filename a.name { display:block; height:1.5em; vertical-align:middle; m
table tr[data-type="dir"] td.filename a.name span.nametext {font-weight:bold; }
table td.filename a.name input, table td.filename a.name form { width:100%; cursor:text; }
table td.filename a, table td.login, table td.logout, table td.download, table td.upload, table td.create, table td.delete { padding:.2em .5em .5em 0; }
-table td.filename .nametext, .modified { float:left; padding:.3em 0; }
+table td.filename .nametext, .uploadtext, .modified { float:left; padding:.3em 0; }
+// TODO fix usability bug (accidental file/folder selection)
table td.filename .nametext { width:70%; overflow:hidden; }
+table td.filename .uploadtext { font-weight:normal; margin-left:.5em; }
table td.filename form { float:left; font-size:.85em; }
table thead.fixed tr{ position:fixed; top:6.5em; z-index:49; -moz-box-shadow:0 -3px 7px #ddd; -webkit-box-shadow:0 -3px 7px #ddd; box-shadow:0 -3px 7px #ddd; }
table thead.fixed { height:2em; }
diff --git a/apps/files/index.php b/apps/files/index.php
index 46b511d66eb..8464db30f01 100644
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -26,6 +26,8 @@ OC_Util::checkLoggedIn();
// Load the files we need
OC_Util::addStyle( "files", "files" );
+OC_Util::addScript( "files", "jquery.iframe-transport" );
+OC_Util::addScript( "files", "jquery.fileupload" );
OC_Util::addScript( "files", "files" );
OC_Util::addScript( 'files', 'filelist' );
OC_Util::addScript( 'files', 'fileactions' );
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index 481802e0d63..68268a7d3a9 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -140,7 +140,20 @@ $(document).ready(function(){
});
FileActions.register('all','Delete',function(){return OC.imagePath('core','actions/delete')},function(filename){
- FileList.do_delete(filename);
+ if(Files.cancelUpload(filename)) {
+ if(filename.substr){
+ filename=[filename];
+ }
+ $.each(filename,function(index,file){
+ var filename = $('tr').filterAttr('data-file',file);
+ filename.hide();
+ filename.find('input[type="checkbox"]').removeAttr('checked');
+ filename.removeClass('selected');
+ });
+ procesSelection();
+ }else{
+ FileList.do_delete(filename);
+ }
});
FileActions.register('all','Rename',function(){return OC.imagePath('core','actions/rename')},function(filename){
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 5bd85fc29ef..febdfc473b1 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -43,6 +43,7 @@ FileList={
td.append('<input type="checkbox" />');
var link_elem = $('<a></a>').attr({ "class": "name", "href": "index.php?dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/') });
link_elem.append($('<span></span>').addClass('nametext').text(name));
+ link_elem.append($('<span></span>').attr({'class': 'uploadtext', 'currentUploads': 0}));
td.append(link_elem);
html.append(td);
if(size!='Pending'){
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 9d83e5e6d26..2dce00035e1 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -1,3 +1,32 @@
+var uploadingFiles = {};
+Files={
+ cancelUpload:function(filename) {
+ if(uploadingFiles[filename]) {
+ uploadingFiles[filename].abort();
+ delete uploadingFiles[filename];
+ return true;
+ }
+ return false;
+ },
+ cancelUploads:function() {
+ $.each(uploadingFiles,function(index,file) {
+ if(typeof file['abort'] === 'function') {
+ file.abort();
+ var filename = $('tr').filterAttr('data-file',index);
+ filename.hide();
+ filename.find('input[type="checkbox"]').removeAttr('checked');
+ filename.removeClass('selected');
+ } else {
+ $.each(file,function(i,f) {
+ f.abort();
+ delete file[i];
+ });
+ }
+ delete uploadingFiles[index];
+ });
+ procesSelection();
+ }
+}
$(document).ready(function() {
$('#fileList tr').each(function(){
//little hack to set unescape filenames in attribute
@@ -151,83 +180,205 @@ $(document).ready(function() {
return false;
});
- $('.file_upload_start').live('change',function(){
- var form=$(this).closest('form');
- var that=this;
- var uploadId=form.attr('data-upload-id');
- var files=this.files;
- var target=form.children('iframe');
- var totalSize=0;
- if(files){
- for(var i=0;i<files.length;i++){
- totalSize+=files[i].size;
- if(FileList.deleteFiles && FileList.deleteFiles.indexOf(files[i].name)!=-1){//finish delete if we are uploading a deleted file
- FileList.finishDelete(function(){
- $(that).change();
- });
- return;
- }
- }
- }
- if(totalSize>$('#max_upload').val()){
- $( "#uploadsize-message" ).dialog({
- modal: true,
- buttons: {
- Close: function() {
- $( this ).dialog( "close" );
+ // drag&drop support using jquery.fileupload
+ // TODO use OC.dialogs
+ $(document).bind('drop dragover', function (e) {
+ e.preventDefault(); // prevent browser from doing anything, if file isn't dropped in dropZone
+ });
+
+ $(function() {
+ $('.file_upload_start').fileupload({
+ dropZone: $('#content'), // restrict dropZone to content div
+ add: function(e, data) {
+ var files = data.files;
+ var totalSize=0;
+ if(files){
+ for(var i=0;i<files.length;i++){
+ totalSize+=files[i].size;
+ if(FileList.deleteFiles && FileList.deleteFiles.indexOf(files[i].name)!=-1){//finish delete if we are uploading a deleted file
+ FileList.finishDelete(function(){
+ $('.file_upload_start').change();
+ });
+ return;
+ }
}
}
- });
- }else{
- target.load(function(){
- var response=jQuery.parseJSON(target.contents().find('body').text());
- //set mimetype and if needed filesize
- if(response){
- if(response[0] != undefined && response[0].status == 'success'){
- for(var i=0;i<response.length;i++){
- var file=response[i];
+ if(totalSize>$('#max_upload').val()){
+ $( '#uploadsize-message' ).dialog({
+ modal: true,
+ buttons: {
+ Close: function() {
+ $( this ).dialog( 'close' );
+ }
+ }
+ });
+ }else{
+ if($.support.xhrFileUpload) {
+ for(var i=0;i<files.length;i++){
+ var fileName = files[i].name
+ var dropTarget = $(e.originalEvent.target).closest('tr');
+ if(dropTarget && dropTarget.attr('data-type') === 'dir') { // drag&drop upload to folder
+ var dirName = dropTarget.attr('data-file')
+ var jqXHR = $('.file_upload_start').fileupload('send', {files: files[i],
+ formData: function(form) {
+ var formArray = form.serializeArray();
+ formArray[1]['value'] = dirName;
+ return formArray;
+ }}).success(function(result, textStatus, jqXHR) {
+ var response;
+ response=jQuery.parseJSON(result);
+ if(response[0] == undefined || response[0].status != 'success') {
+ $('#notification').text(t('files', response.data.message));
+ $('#notification').fadeIn();
+ }
+ var file=response[0];
+ delete uploadingFiles[dirName][file.name];
+ var currentUploads = parseInt(uploadtext.attr('currentUploads'));
+ currentUploads -= 1;
+ uploadtext.attr('currentUploads', currentUploads);
+ if(currentUploads === 0) {
+ var img = OC.imagePath('core', 'filetypes/folder.png');
+ var tr=$('tr').filterAttr('data-file',dirName);
+ tr.find('td.filename').attr('style','background-image:url('+img+')');
+ uploadtext.text('');
+ uploadtext.hide();
+ } else {
+ uploadtext.text(currentUploads + ' files uploading')
+ }
+ })
+ .error(function(jqXHR, textStatus, errorThrown) {
+ if(errorThrown === 'abort') {
+ var currentUploads = parseInt(uploadtext.attr('currentUploads'));
+ currentUploads -= 1;
+ uploadtext.attr('currentUploads', currentUploads);
+ if(currentUploads === 0) {
+ var img = OC.imagePath('core', 'filetypes/folder.png');
+ var tr=$('tr').filterAttr('data-file',dirName);
+ tr.find('td.filename').attr('style','background-image:url('+img+')');
+ uploadtext.text('');
+ uploadtext.hide();
+ } else {
+ uploadtext.text(currentUploads + ' files uploading')
+ }
+ $('#notification').hide();
+ $('#notification').text(t('files', 'Upload cancelled.'));
+ $('#notification').fadeIn();
+ }
+ });
+ //TODO test with filenames containing slashes
+ if(uploadingFiles[dirName] === undefined) {
+ uploadingFiles[dirName] = {};
+ }
+ uploadingFiles[dirName][fileName] = jqXHR;
+ } else {
+ var jqXHR = $('.file_upload_start').fileupload('send', {files: files[i]})
+ .success(function(result, textStatus, jqXHR) {
+ var response;
+ response=jQuery.parseJSON(result);
+ if(response[0] != undefined && response[0].status == 'success') {
+ var file=response[0];
+ delete uploadingFiles[file.name];
+ $('tr').filterAttr('data-file',file.name).data('mime',file.mime);
+ var size = $('tr').filterAttr('data-file',file.name).find('td.filesize').text();
+ if(size==t('files','Pending')){
+ $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size);
+ }
+ FileList.loadingDone(file.name);
+ } else {
+ $('#notification').text(t('files', response.data.message));
+ $('#notification').fadeIn();
+ $('#fileList > tr').not('[data-mime]').fadeOut();
+ $('#fileList > tr').not('[data-mime]').remove();
+ }
+ })
+ .error(function(jqXHR, textStatus, errorThrown) {
+ if(errorThrown === 'abort') {
+ $('#notification').hide();
+ $('#notification').text(t('files', 'Upload cancelled.'));
+ $('#notification').fadeIn();
+ }
+ });
+ uploadingFiles[files[i].name] = jqXHR;
+ }
+ }
+ }else{
+ data.submit().success(function(data, status) {
+ response = jQuery.parseJSON(data[0].body.innerText);
+ if(response[0] != undefined && response[0].status == 'success') {
+ var file=response[0];
+ delete uploadingFiles[file.name];
$('tr').filterAttr('data-file',file.name).data('mime',file.mime);
- if(size=='Pending'){
+ var size = $('tr').filterAttr('data-file',file.name).find('td.filesize').text();
+ if(size==t('files','Pending')){
$('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size);
}
FileList.loadingDone(file.name);
+ } else {
+ $('#notification').text(t('files', response.data.message));
+ $('#notification').fadeIn();
+ $('#fileList > tr').not('[data-mime]').fadeOut();
+ $('#fileList > tr').not('[data-mime]').remove();
}
- }
- else{
- $('#notification').text(t('files',response.data.message));
- $('#notification').fadeIn();
- $('#fileList > tr').not('[data-mime]').fadeOut();
- $('#fileList > tr').not('[data-mime]').remove();
- }
+ });
}
- });
- form.submit();
- var date=new Date();
- if(files){
- for(var i=0;i<files.length;i++){
- if(files[i].size>0){
- var size=files[i].size;
- }else{
- var size=t('files','Pending');
- }
+
+ var date=new Date();
if(files){
+ for(var i=0;i<files.length;i++){
+ if(files[i].size>0){
+ var size=files[i].size;
+ }else{
+ var size=t('files','Pending');
+ }
+ if(files && !dirName){
FileList.addFile(getUniqueName(files[i].name),size,date,true);
+ } else if(dirName) {
+ var uploadtext = $('tr').filterAttr('data-type', 'dir').filterAttr('data-file', dirName).find('.uploadtext')
+ var currentUploads = parseInt(uploadtext.attr('currentUploads'));
+ currentUploads += 1;
+ uploadtext.attr('currentUploads', currentUploads);
+ if(currentUploads === 1) {
+ var img = OC.imagePath('core', 'loading.gif');
+ var tr=$('tr').filterAttr('data-file',dirName);
+ tr.find('td.filename').attr('style','background-image:url('+img+')');
+ uploadtext.text('1 file uploading');
+ uploadtext.show();
+ } else {
+ uploadtext.text(currentUploads + ' files uploading')
+ }
+ }
+ }
+ }else{
+ var filename=this.value.split('\\').pop(); //ie prepends C:\fakepath\ in front of the filename
+ FileList.addFile(getUniqueName(filename),'Pending',date,true);
}
}
- }else{
- var filename=this.value.split('\\').pop(); //ie prepends C:\fakepath\ in front of the filename
- FileList.addFile(getUniqueName(filename),'Pending',date,true);
+ },
+ fail: function(e, data) {
+ // TODO: cancel upload & display error notification
+ },
+ progress: function(e, data) {
+ // TODO: show nice progress bar in file row
+ },
+ progressall: function(e, data) {
+ var progress = (data.loaded/data.total)*100;
+ $('#uploadprogressbar').progressbar('value',progress);
+ },
+ start: function(e, data) {
+ $('#uploadprogressbar').progressbar({value:0});
+ $('#uploadprogressbar').fadeIn();
+ if(data.dataType != 'iframe ') {
+ $('#upload input.stop').show();
+ }
+ },
+ stop: function(e, data) {
+ if(data.dataType != 'iframe ') {
+ $('#upload input.stop').hide();
+ }
+ $('#uploadprogressbar').progressbar('value',100);
+ $('#uploadprogressbar').fadeOut();
}
-
- //clone the upload form and hide the new one to allow users to start a new upload while the old one is still uploading
- var clone=form.clone();
- uploadId++;
- clone.attr('data-upload-id',uploadId);
- clone.attr('target','file_upload_target_'+uploadId);
- clone.children('iframe').attr('name','file_upload_target_'+uploadId)
- clone.insertBefore(form);
- form.hide();
- }
+ })
});
//add multiply file upload attribute to all browsers except konqueror (which crashes when it's used)
@@ -370,12 +521,15 @@ $(document).ready(function() {
}, "json");
});
-function scanFiles(force){
+function scanFiles(force,dir){
+ if(!dir){
+ dir='';
+ }
force=!!force; //cast to bool
scanFiles.scanning=true;
$('#scanning-message').show();
$('#fileList').remove();
- var scannerEventSource=new OC.EventSource(OC.filePath('files','ajax','scan.php'),{force:force});
+ var scannerEventSource=new OC.EventSource(OC.filePath('files','ajax','scan.php'),{force:force,dir:dir});
scanFiles.cancel=scannerEventSource.close.bind(scannerEventSource);
scannerEventSource.listen('scanning',function(data){
$('#scan-count').text(data.count+' files scanned');
diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php
index 3571950467e..fc385e1ed3a 100644
--- a/apps/files/templates/index.php
+++ b/apps/files/templates/index.php
@@ -22,6 +22,11 @@
<iframe name="file_upload_target_1" class='file_upload_target' src=""></iframe>
</form>
</div>
+ <div id="upload">
+ <div id="uploadprogressbar"></div>
+ <input type="button" class="stop" style="display:none" value="<?php echo $l->t('Cancel upload');?>" onclick="javascript:Files.cancelUploads();" />
+ </div>
+
</div>
<div id="file_action_panel"></div>
<?php else:?>
diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php
index 5a5941fc7ae..b2db4cbb8df 100644
--- a/apps/files/templates/part.list.php
+++ b/apps/files/templates/part.list.php
@@ -21,6 +21,10 @@
<?php echo htmlspecialchars($file['basename']);?><span class='extension'><?php echo $file['extension'];?></span>
<?php endif;?>
</span>
+ <?php if($file['type'] == 'dir'):?>
+ <span class="uploadtext" currentUploads="0">
+ </span>
+ <?php endif;?>
</a>
</td>
<td class="filesize" title="<?php echo human_file_size($file['size']); ?>" style="color:rgb(<?php echo $simple_size_color.','.$simple_size_color.','.$simple_size_color ?>)"><?php echo $simple_file_size; ?></td>