Merge pull request #1059 from owncloud/fixing-998-master
Fixing 998 master
This commit is contained in:
commit
276d98b9dd
|
@ -21,20 +21,11 @@ foreach($files as $file) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// updated max file size after upload
|
// get array with updated storage stats (e.g. max file size) after upload
|
||||||
$l=new OC_L10N('files');
|
$storageStats = \OCA\files\lib\Helper::buildFileStorageStatistics($dir);
|
||||||
$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
|
|
||||||
$maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize);
|
|
||||||
$maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize;
|
|
||||||
|
|
||||||
if ($success) {
|
if ($success) {
|
||||||
OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $files,
|
OCP\JSON::success(array("data" => array_merge(array("dir" => $dir, "files" => $files), $storageStats)));
|
||||||
'uploadMaxFilesize'=>$maxUploadFilesize,
|
|
||||||
'maxHumanFilesize'=>$maxHumanFilesize
|
|
||||||
)));
|
|
||||||
} else {
|
} else {
|
||||||
OCP\JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError,
|
OCP\JSON::error(array("data" => array_merge(array("message" => "Could not delete:\n" . $filesWithError), $storageStats)));
|
||||||
'uploadMaxFilesize'=>$maxUploadFilesize,
|
|
||||||
'maxHumanFilesize'=>$maxHumanFilesize
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,5 @@ $RUNTIME_APPTYPES = array('filesystem');
|
||||||
|
|
||||||
OCP\JSON::checkLoggedIn();
|
OCP\JSON::checkLoggedIn();
|
||||||
|
|
||||||
$l=new OC_L10N('files');
|
|
||||||
$maxUploadFilesize = OCP\Util::maxUploadFilesize($dir);
|
|
||||||
$maxHumanFilesize = OCP\Util::humanFileSize($maxUploadFilesize);
|
|
||||||
$maxHumanFilesize = $l->t('Upload') . ' max. ' . $maxHumanFilesize;
|
|
||||||
|
|
||||||
// send back json
|
// send back json
|
||||||
OCP\JSON::success(array('data' => array('uploadMaxFilesize' => $maxUploadFilesize,
|
OCP\JSON::success(array('data' => \OCA\files\lib\Helper::buildFileStorageStatistics('/')));
|
||||||
'maxHumanFilesize' => $maxHumanFilesize
|
|
||||||
)));
|
|
||||||
|
|
|
@ -10,17 +10,11 @@ OCP\JSON::checkLoggedIn();
|
||||||
OCP\JSON::callCheck();
|
OCP\JSON::callCheck();
|
||||||
$l = OC_L10N::get('files');
|
$l = OC_L10N::get('files');
|
||||||
|
|
||||||
// current max upload size
|
// get array with current storage stats (e.g. max file size)
|
||||||
$l=new OC_L10N('files');
|
$storageStats = \OCA\files\lib\Helper::buildFileStorageStatistics($dir);
|
||||||
$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
|
|
||||||
$maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize);
|
|
||||||
$maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize;
|
|
||||||
|
|
||||||
if (!isset($_FILES['files'])) {
|
if (!isset($_FILES['files'])) {
|
||||||
OCP\JSON::error(array('data' => array( 'message' => $l->t( 'No file was uploaded. Unknown error' ),
|
OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('No file was uploaded. Unknown error')), $storageStats)));
|
||||||
'uploadMaxFilesize'=>$maxUploadFilesize,
|
|
||||||
'maxHumanFilesize'=>$maxHumanFilesize
|
|
||||||
)));
|
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,10 +31,7 @@ foreach ($_FILES['files']['error'] as $error) {
|
||||||
UPLOAD_ERR_NO_TMP_DIR => $l->t('Missing a temporary folder'),
|
UPLOAD_ERR_NO_TMP_DIR => $l->t('Missing a temporary folder'),
|
||||||
UPLOAD_ERR_CANT_WRITE => $l->t('Failed to write to disk'),
|
UPLOAD_ERR_CANT_WRITE => $l->t('Failed to write to disk'),
|
||||||
);
|
);
|
||||||
OCP\JSON::error(array('data' => array( 'message' => $errors[$error],
|
OCP\JSON::error(array('data' => array_merge(array('message' => $errors[$error]), $storageStats)));
|
||||||
'uploadMaxFilesize'=>$maxUploadFilesize,
|
|
||||||
'maxHumanFilesize'=>$maxHumanFilesize
|
|
||||||
)));
|
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,9 +45,7 @@ foreach($files['size'] as $size) {
|
||||||
$totalSize += $size;
|
$totalSize += $size;
|
||||||
}
|
}
|
||||||
if ($totalSize > OC_Filesystem::free_space($dir)) {
|
if ($totalSize > OC_Filesystem::free_space($dir)) {
|
||||||
OCP\JSON::error(array('data' => array( 'message' => $l->t( 'Not enough space available' ),
|
OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Not enough storage available')), $storageStats)));
|
||||||
'uploadMaxFilesize'=>$maxUploadFilesize,
|
|
||||||
'maxHumanFilesize'=>$maxHumanFilesize)));
|
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,18 +59,15 @@ if(strpos($dir, '..') === false) {
|
||||||
if (is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
|
if (is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
|
||||||
$meta = OC_FileCache::get($target);
|
$meta = OC_FileCache::get($target);
|
||||||
$id = OC_FileCache::getId($target);
|
$id = OC_FileCache::getId($target);
|
||||||
// updated max file size after upload
|
|
||||||
$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
|
|
||||||
$maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize);
|
|
||||||
$maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize;
|
|
||||||
|
|
||||||
$result[]=array( 'status' => 'success',
|
// updated max file size after upload
|
||||||
|
$storageStats = \OCA\files\lib\Helper::buildFileStorageStatistics($dir);
|
||||||
|
|
||||||
|
$result[] = array_merge(array('status' => 'success',
|
||||||
'mime' => $meta['mimetype'],
|
'mime' => $meta['mimetype'],
|
||||||
'size' => $meta['size'],
|
'size' => $meta['size'],
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'name'=>basename($target),
|
'name' => basename($target)), $storageStats
|
||||||
'uploadMaxFilesize'=>$maxUploadFilesize,
|
|
||||||
'maxHumanFilesize'=>$maxHumanFilesize
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +77,4 @@ if(strpos($dir, '..') === false) {
|
||||||
$error = $l->t('Invalid directory.');
|
$error = $l->t('Invalid directory.');
|
||||||
}
|
}
|
||||||
|
|
||||||
OCP\JSON::error(array('data' => array('message' => $error,
|
OCP\JSON::error(array('data' => array_merge(array('message' => $error), $storageStats)));
|
||||||
'uploadMaxFilesize'=>$maxUploadFilesize,
|
|
||||||
'maxHumanFilesize'=>$maxHumanFilesize
|
|
||||||
)));
|
|
||||||
|
|
|
@ -93,6 +93,9 @@ if (OC_Filesystem::isSharable($dir . '/')) {
|
||||||
$permissions |= OCP\PERMISSION_SHARE;
|
$permissions |= OCP\PERMISSION_SHARE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// information about storage capacities
|
||||||
|
$storageInfo=OC_Helper::getStorageInfo();
|
||||||
|
|
||||||
$tmpl = new OCP\Template('files', 'index', 'user');
|
$tmpl = new OCP\Template('files', 'index', 'user');
|
||||||
$tmpl->assign('fileList', $list->fetchPage(), false);
|
$tmpl->assign('fileList', $list->fetchPage(), false);
|
||||||
$tmpl->assign('breadcrumb', $breadcrumbNav->fetchPage(), false);
|
$tmpl->assign('breadcrumb', $breadcrumbNav->fetchPage(), false);
|
||||||
|
@ -103,4 +106,5 @@ $tmpl->assign('files', $files);
|
||||||
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
|
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
|
||||||
$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
|
$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
|
||||||
$tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
|
$tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
|
||||||
|
$tmpl->assign('usedSpacePercent', (int)$storageInfo['relative']);
|
||||||
$tmpl->printPage();
|
$tmpl->printPage();
|
||||||
|
|
|
@ -201,15 +201,14 @@ var FileList={
|
||||||
},
|
},
|
||||||
checkName:function(oldName, newName, isNewFile) {
|
checkName:function(oldName, newName, isNewFile) {
|
||||||
if (isNewFile || $('tr').filterAttr('data-file', newName).length > 0) {
|
if (isNewFile || $('tr').filterAttr('data-file', newName).length > 0) {
|
||||||
if (isNewFile) {
|
|
||||||
$('#notification').html(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+'<span class="replace">'+t('files', 'replace')+'</span><span class="suggest">'+t('files', 'suggest name')+'</span><span class="cancel">'+t('files', 'cancel')+'</span>');
|
|
||||||
} else {
|
|
||||||
$('#notification').html(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+'<span class="replace">'+t('files', 'replace')+'</span><span class="cancel">'+t('files', 'cancel')+'</span>');
|
|
||||||
}
|
|
||||||
$('#notification').data('oldName', oldName);
|
$('#notification').data('oldName', oldName);
|
||||||
$('#notification').data('newName', newName);
|
$('#notification').data('newName', newName);
|
||||||
$('#notification').data('isNewFile', isNewFile);
|
$('#notification').data('isNewFile', isNewFile);
|
||||||
$('#notification').fadeIn();
|
if (isNewFile) {
|
||||||
|
OC.Notification.showHtml(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+'<span class="replace">'+t('files', 'replace')+'</span><span class="suggest">'+t('files', 'suggest name')+'</span><span class="cancel">'+t('files', 'cancel')+'</span>');
|
||||||
|
} else {
|
||||||
|
OC.Notification.showHtml(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+'<span class="replace">'+t('files', 'replace')+'</span><span class="cancel">'+t('files', 'cancel')+'</span>');
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -251,11 +250,10 @@ var FileList={
|
||||||
FileList.finishReplace();
|
FileList.finishReplace();
|
||||||
};
|
};
|
||||||
if (isNewFile) {
|
if (isNewFile) {
|
||||||
$('#notification').html(t('files', 'replaced {new_name}', {new_name: newName})+'<span class="undo">'+t('files', 'undo')+'</span>');
|
OC.Notification.showHtml(t('files', 'replaced {new_name}', {new_name: newName})+'<span class="undo">'+t('files', 'undo')+'</span>');
|
||||||
} else {
|
} else {
|
||||||
$('#notification').html(t('files', 'replaced {new_name} with {old_name}', {new_name: newName}, {old_name: oldName})+'<span class="undo">'+t('files', 'undo')+'</span>');
|
OC.Notification.showHtml(t('files', 'replaced {new_name} with {old_name}', {new_name: newName}, {old_name: oldName})+'<span class="undo">'+t('files', 'undo')+'</span>');
|
||||||
}
|
}
|
||||||
$('#notification').fadeIn();
|
|
||||||
},
|
},
|
||||||
finishReplace:function() {
|
finishReplace:function() {
|
||||||
if (!FileList.replaceCanceled && FileList.replaceOldName && FileList.replaceNewName) {
|
if (!FileList.replaceCanceled && FileList.replaceOldName && FileList.replaceNewName) {
|
||||||
|
@ -285,11 +283,10 @@ var FileList={
|
||||||
} else {
|
} else {
|
||||||
// NOTE: Temporary fix to change the text to unshared for files in root of Shared folder
|
// NOTE: Temporary fix to change the text to unshared for files in root of Shared folder
|
||||||
if ($('#dir').val() == '/Shared') {
|
if ($('#dir').val() == '/Shared') {
|
||||||
$('#notification').html(t('files', 'unshared {files}', {'files': escapeHTML(files)})+'<span class="undo">'+t('files', 'undo')+'</span>');
|
OC.Notification.showHtml(t('files', 'unshared {files}', {'files': escapeHTML(files)})+'<span class="undo">'+t('files', 'undo')+'</span>');
|
||||||
} else {
|
} else {
|
||||||
$('#notification').html(t('files', 'deleted {files}', {'files': escapeHTML(files)})+'<span class="undo">'+t('files', 'undo')+'</span>');
|
OC.Notification.showHtml(t('files', 'deleted {files}', {'files': escapeHTML(files)})+'<span class="undo">'+t('files', 'undo')+'</span>');
|
||||||
}
|
}
|
||||||
$('#notification').fadeIn();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
finishDelete:function(ready,sync){
|
finishDelete:function(ready,sync){
|
||||||
|
@ -302,7 +299,7 @@ var FileList={
|
||||||
data: {dir:$('#dir').val(),files:fileNames},
|
data: {dir:$('#dir').val(),files:fileNames},
|
||||||
complete: function(data){
|
complete: function(data){
|
||||||
boolOperationFinished(data, function(){
|
boolOperationFinished(data, function(){
|
||||||
$('#notification').fadeOut('400');
|
OC.Notification.hide();
|
||||||
$.each(FileList.deleteFiles,function(index,file){
|
$.each(FileList.deleteFiles,function(index,file){
|
||||||
FileList.remove(file);
|
FileList.remove(file);
|
||||||
});
|
});
|
||||||
|
@ -362,16 +359,16 @@ $(document).ready(function(){
|
||||||
FileList.replaceIsNewFile = null;
|
FileList.replaceIsNewFile = null;
|
||||||
}
|
}
|
||||||
FileList.lastAction = null;
|
FileList.lastAction = null;
|
||||||
$('#notification').fadeOut('400');
|
OC.Notification.hide();
|
||||||
});
|
});
|
||||||
$('#notification .replace').live('click', function() {
|
$('#notification .replace').live('click', function() {
|
||||||
$('#notification').fadeOut('400', function() {
|
OC.Notification.hide(function() {
|
||||||
FileList.replace($('#notification').data('oldName'), $('#notification').data('newName'), $('#notification').data('isNewFile'));
|
FileList.replace($('#notification').data('oldName'), $('#notification').data('newName'), $('#notification').data('isNewFile'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$('#notification .suggest').live('click', function() {
|
$('#notification .suggest').live('click', function() {
|
||||||
$('tr').filterAttr('data-file', $('#notification').data('oldName')).show();
|
$('tr').filterAttr('data-file', $('#notification').data('oldName')).show();
|
||||||
$('#notification').fadeOut('400');
|
OC.Notification.hide();
|
||||||
});
|
});
|
||||||
$('#notification .cancel').live('click', function() {
|
$('#notification .cancel').live('click', function() {
|
||||||
if ($('#notification').data('isNewFile')) {
|
if ($('#notification').data('isNewFile')) {
|
||||||
|
|
|
@ -32,26 +32,28 @@ Files={
|
||||||
}
|
}
|
||||||
if(response.data !== undefined && response.data.uploadMaxFilesize !== undefined) {
|
if(response.data !== undefined && response.data.uploadMaxFilesize !== undefined) {
|
||||||
$('#max_upload').val(response.data.uploadMaxFilesize);
|
$('#max_upload').val(response.data.uploadMaxFilesize);
|
||||||
$('#data-upload-form a').attr('original-title', response.data.maxHumanFilesize);
|
$('#upload.button').attr('original-title', response.data.maxHumanFilesize);
|
||||||
|
$('#usedSpacePercent').val(response.data.usedSpacePercent);
|
||||||
|
Files.displayStorageWarnings();
|
||||||
}
|
}
|
||||||
if(response[0] == undefined) {
|
if(response[0] == undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(response[0].uploadMaxFilesize !== undefined) {
|
if(response[0].uploadMaxFilesize !== undefined) {
|
||||||
$('#max_upload').val(response[0].uploadMaxFilesize);
|
$('#max_upload').val(response[0].uploadMaxFilesize);
|
||||||
$('#data-upload-form a').attr('original-title', response[0].maxHumanFilesize);
|
$('#upload.button').attr('original-title', response[0].maxHumanFilesize);
|
||||||
|
$('#usedSpacePercent').val(response[0].usedSpacePercent);
|
||||||
|
Files.displayStorageWarnings();
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
isFileNameValid:function (name) {
|
isFileNameValid:function (name) {
|
||||||
if (name === '.') {
|
if (name === '.') {
|
||||||
$('#notification').text(t('files', '\'.\' is an invalid file name.'));
|
OC.Notification.show(t('files', '\'.\' is an invalid file name.'));
|
||||||
$('#notification').fadeIn();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (name.length == 0) {
|
if (name.length == 0) {
|
||||||
$('#notification').text(t('files', 'File name cannot be empty.'));
|
OC.Notification.show(t('files', 'File name cannot be empty.'));
|
||||||
$('#notification').fadeIn();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,13 +61,26 @@ Files={
|
||||||
var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*'];
|
var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*'];
|
||||||
for (var i = 0; i < invalid_characters.length; i++) {
|
for (var i = 0; i < invalid_characters.length; i++) {
|
||||||
if (name.indexOf(invalid_characters[i]) != -1) {
|
if (name.indexOf(invalid_characters[i]) != -1) {
|
||||||
$('#notification').text(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed."));
|
OC.Notification.show(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed."));
|
||||||
$('#notification').fadeIn();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$('#notification').fadeOut();
|
OC.Notification.hide();
|
||||||
return true;
|
return true;
|
||||||
|
},
|
||||||
|
displayStorageWarnings: function() {
|
||||||
|
if (!OC.Notification.isHidden()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var usedSpacePercent = $('#usedSpacePercent').val();
|
||||||
|
if (usedSpacePercent > 98) {
|
||||||
|
OC.Notification.show(t('files', 'Your storage is full, files can not be updated or synced anymore!'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (usedSpacePercent > 90) {
|
||||||
|
OC.Notification.show(t('files', 'Your storage is almost full ({usedSpacePercent}%)', {usedSpacePercent: usedSpacePercent}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
@ -201,8 +216,7 @@ $(document).ready(function() {
|
||||||
$('.download').click('click',function(event) {
|
$('.download').click('click',function(event) {
|
||||||
var files=getSelectedFiles('name').join(';');
|
var files=getSelectedFiles('name').join(';');
|
||||||
var dir=$('#dir').val()||'/';
|
var dir=$('#dir').val()||'/';
|
||||||
$('#notification').text(t('files','Your download is being prepared. This might take some time if the files are big.'));
|
OC.Notification.show(t('files','Your download is being prepared. This might take some time if the files are big.'));
|
||||||
$('#notification').fadeIn();
|
|
||||||
// use special download URL if provided, e.g. for public shared files
|
// use special download URL if provided, e.g. for public shared files
|
||||||
if ( (downloadURL = document.getElementById("downloadURL")) ) {
|
if ( (downloadURL = document.getElementById("downloadURL")) ) {
|
||||||
window.location=downloadURL.value+"&download&files="+files;
|
window.location=downloadURL.value+"&download&files="+files;
|
||||||
|
@ -331,8 +345,7 @@ $(document).ready(function() {
|
||||||
var response;
|
var response;
|
||||||
response=jQuery.parseJSON(result);
|
response=jQuery.parseJSON(result);
|
||||||
if(response[0] == undefined || response[0].status != 'success') {
|
if(response[0] == undefined || response[0].status != 'success') {
|
||||||
$('#notification').text(t('files', response.data.message));
|
OC.Notification.show(t('files', response.data.message));
|
||||||
$('#notification').fadeIn();
|
|
||||||
}
|
}
|
||||||
Files.updateMaxUploadFilesize(response);
|
Files.updateMaxUploadFilesize(response);
|
||||||
var file=response[0];
|
var file=response[0];
|
||||||
|
@ -372,9 +385,7 @@ $(document).ready(function() {
|
||||||
uploadtext.text(t('files', '{count} files uploading', {count: currentUploads}));
|
uploadtext.text(t('files', '{count} files uploading', {count: currentUploads}));
|
||||||
}
|
}
|
||||||
delete uploadingFiles[dirName][fileName];
|
delete uploadingFiles[dirName][fileName];
|
||||||
$('#notification').hide();
|
OC.Notification.show(t('files', 'Upload cancelled.'));
|
||||||
$('#notification').text(t('files', 'Upload cancelled.'));
|
|
||||||
$('#notification').fadeIn();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//TODO test with filenames containing slashes
|
//TODO test with filenames containing slashes
|
||||||
|
@ -401,8 +412,7 @@ $(document).ready(function() {
|
||||||
FileList.loadingDone(file.name, file.id);
|
FileList.loadingDone(file.name, file.id);
|
||||||
} else {
|
} else {
|
||||||
Files.cancelUpload(this.files[0].name);
|
Files.cancelUpload(this.files[0].name);
|
||||||
$('#notification').text(t('files', response.data.message));
|
OC.Notification.show(t('files', response.data.message));
|
||||||
$('#notification').fadeIn();
|
|
||||||
$('#fileList > tr').not('[data-mime]').fadeOut();
|
$('#fileList > tr').not('[data-mime]').fadeOut();
|
||||||
$('#fileList > tr').not('[data-mime]').remove();
|
$('#fileList > tr').not('[data-mime]').remove();
|
||||||
}
|
}
|
||||||
|
@ -410,9 +420,7 @@ $(document).ready(function() {
|
||||||
.error(function(jqXHR, textStatus, errorThrown) {
|
.error(function(jqXHR, textStatus, errorThrown) {
|
||||||
if(errorThrown === 'abort') {
|
if(errorThrown === 'abort') {
|
||||||
Files.cancelUpload(this.files[0].name);
|
Files.cancelUpload(this.files[0].name);
|
||||||
$('#notification').hide();
|
OC.Notification.show(t('files', 'Upload cancelled.'));
|
||||||
$('#notification').text(t('files', 'Upload cancelled.'));
|
|
||||||
$('#notification').fadeIn();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
uploadingFiles[uniqueName] = jqXHR;
|
uploadingFiles[uniqueName] = jqXHR;
|
||||||
|
@ -435,8 +443,7 @@ $(document).ready(function() {
|
||||||
FileList.loadingDone(file.name, file.id);
|
FileList.loadingDone(file.name, file.id);
|
||||||
} else {
|
} else {
|
||||||
//TODO Files.cancelUpload(/*where do we get the filename*/);
|
//TODO Files.cancelUpload(/*where do we get the filename*/);
|
||||||
$('#notification').text(t('files', response.data.message));
|
OC.Notification.show(t('files', response.data.message));
|
||||||
$('#notification').fadeIn();
|
|
||||||
$('#fileList > tr').not('[data-mime]').fadeOut();
|
$('#fileList > tr').not('[data-mime]').fadeOut();
|
||||||
$('#fileList > tr').not('[data-mime]').remove();
|
$('#fileList > tr').not('[data-mime]').remove();
|
||||||
}
|
}
|
||||||
|
@ -556,14 +563,12 @@ $(document).ready(function() {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var newname=input.val();
|
var newname=input.val();
|
||||||
if(type == 'web' && newname.length == 0) {
|
if(type == 'web' && newname.length == 0) {
|
||||||
$('#notification').text(t('files', 'URL cannot be empty.'));
|
OC.Notification.show(t('files', 'URL cannot be empty.'));
|
||||||
$('#notification').fadeIn();
|
|
||||||
return false;
|
return false;
|
||||||
} else if (type != 'web' && !Files.isFileNameValid(newname)) {
|
} else if (type != 'web' && !Files.isFileNameValid(newname)) {
|
||||||
return false;
|
return false;
|
||||||
} else if( type == 'folder' && $('#dir').val() == '/' && newname == 'Shared') {
|
} else if( type == 'folder' && $('#dir').val() == '/' && newname == 'Shared') {
|
||||||
$('#notification').text(t('files','Invalid folder name. Usage of \'Shared\' is reserved by Owncloud'));
|
OC.Notification.show(t('files','Invalid folder name. Usage of \'Shared\' is reserved by Owncloud'));
|
||||||
$('#notification').fadeIn();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (FileList.lastAction) {
|
if (FileList.lastAction) {
|
||||||
|
@ -734,6 +739,10 @@ $(document).ready(function() {
|
||||||
|
|
||||||
resizeBreadcrumbs(true);
|
resizeBreadcrumbs(true);
|
||||||
|
|
||||||
|
// display storage warnings
|
||||||
|
setTimeout ( "Files.displayStorageWarnings()", 100 );
|
||||||
|
OC.Notification.setDefault(Files.displayStorageWarnings);
|
||||||
|
|
||||||
// file space size sync
|
// file space size sync
|
||||||
function update_storage_statistics() {
|
function update_storage_statistics() {
|
||||||
$.getJSON(OC.filePath('files','ajax','getstoragestats.php'),function(response) {
|
$.getJSON(OC.filePath('files','ajax','getstoragestats.php'),function(response) {
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace OCA\files\lib;
|
||||||
|
|
||||||
|
class Helper
|
||||||
|
{
|
||||||
|
public static function buildFileStorageStatistics($dir) {
|
||||||
|
$l = new \OC_L10N('files');
|
||||||
|
$maxUploadFilesize = \OCP\Util::maxUploadFilesize($dir);
|
||||||
|
$maxHumanFilesize = \OCP\Util::humanFileSize($maxUploadFilesize);
|
||||||
|
$maxHumanFilesize = $l->t('Upload') . ' max. ' . $maxHumanFilesize;
|
||||||
|
|
||||||
|
// information about storage capacities
|
||||||
|
$storageInfo = \OC_Helper::getStorageInfo();
|
||||||
|
|
||||||
|
return array('uploadMaxFilesize' => $maxUploadFilesize,
|
||||||
|
'maxHumanFilesize' => $maxHumanFilesize,
|
||||||
|
'usedSpacePercent' => (int)$storageInfo['relative']);
|
||||||
|
}
|
||||||
|
}
|
|
@ -50,7 +50,6 @@
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
<input type="hidden" name="permissions" value="<?php echo $_['permissions']; ?>" id="permissions">
|
<input type="hidden" name="permissions" value="<?php echo $_['permissions']; ?>" id="permissions">
|
||||||
</div>
|
</div>
|
||||||
<div id='notification'></div>
|
|
||||||
|
|
||||||
<?php if (isset($_['files']) and $_['isCreatable'] and count($_['files'])==0):?>
|
<?php if (isset($_['files']) and $_['isCreatable'] and count($_['files'])==0):?>
|
||||||
<div id="emptyfolder"><?php echo $l->t('Nothing in here. Upload something!')?></div>
|
<div id="emptyfolder"><?php echo $l->t('Nothing in here. Upload something!')?></div>
|
||||||
|
@ -115,3 +114,4 @@
|
||||||
|
|
||||||
<!-- config hints for javascript -->
|
<!-- config hints for javascript -->
|
||||||
<input type="hidden" name="allowZipDownload" id="allowZipDownload" value="<?php echo $_['allowZipDownload']; ?>" />
|
<input type="hidden" name="allowZipDownload" id="allowZipDownload" value="<?php echo $_['allowZipDownload']; ?>" />
|
||||||
|
<input type="hidden" name="usedSpacePercent" id="usedSpacePercent" value="<?php echo $_['usedSpacePercent']; ?>" />
|
||||||
|
|
|
@ -191,7 +191,8 @@ fieldset.warning legend { color:#b94a48 !important; }
|
||||||
.bold { font-weight:bold; }
|
.bold { font-weight:bold; }
|
||||||
.center { text-align:center; }
|
.center { text-align:center; }
|
||||||
|
|
||||||
#notification { z-index:101; background-color:#fc4; border:0; padding:0 .7em .3em; display:none; position:fixed; left:50%; top:0; -moz-border-radius-bottomleft:1em; -webkit-border-bottom-left-radius:1em; border-bottom-left-radius:1em; -moz-border-radius-bottomright:1em; -webkit-border-bottom-right-radius:1em; border-bottom-right-radius:1em; }
|
#notification-container { position: fixed; top: 0px; width: 100%; text-align: center; z-index: 101; line-height: 1.2;}
|
||||||
|
#notification { z-index:101; background-color:#fc4; border:0; padding:0 .7em .3em; display:none; position: relative; top:0; -moz-border-radius-bottomleft:1em; -webkit-border-bottom-left-radius:1em; border-bottom-left-radius:1em; -moz-border-radius-bottomright:1em; -webkit-border-bottom-right-radius:1em; border-bottom-right-radius:1em; }
|
||||||
#notification span { cursor:pointer; font-weight:bold; margin-left:1em; }
|
#notification span { cursor:pointer; font-weight:bold; margin-left:1em; }
|
||||||
|
|
||||||
tr .action, .selectedActions a { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter:alpha(opacity=0); opacity:0; }
|
tr .action, .selectedActions a { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter:alpha(opacity=0); opacity:0; }
|
||||||
|
|
|
@ -44,7 +44,7 @@ function t(app,text, vars){
|
||||||
return typeof r === 'string' || typeof r === 'number' ? r : a;
|
return typeof r === 'string' || typeof r === 'number' ? r : a;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
if( typeof( t.cache[app][text] ) !== 'undefined' ){
|
if( typeof( t.cache[app][text] ) !== 'undefined' ){
|
||||||
if(typeof vars === 'object') {
|
if(typeof vars === 'object') {
|
||||||
return _build(t.cache[app][text], vars);
|
return _build(t.cache[app][text], vars);
|
||||||
|
@ -310,6 +310,41 @@ OC.search.lastResults={};
|
||||||
OC.addStyle.loaded=[];
|
OC.addStyle.loaded=[];
|
||||||
OC.addScript.loaded=[];
|
OC.addScript.loaded=[];
|
||||||
|
|
||||||
|
OC.Notification={
|
||||||
|
getDefaultNotificationFunction: null,
|
||||||
|
setDefault: function(callback) {
|
||||||
|
OC.Notification.getDefaultNotificationFunction = callback;
|
||||||
|
},
|
||||||
|
hide: function(callback) {
|
||||||
|
$("#notification").text('');
|
||||||
|
$('#notification').fadeOut('400', function(){
|
||||||
|
if (OC.Notification.isHidden()) {
|
||||||
|
if (OC.Notification.getDefaultNotificationFunction) {
|
||||||
|
OC.Notification.getDefaultNotificationFunction.call();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (callback) {
|
||||||
|
callback.call();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
showHtml: function(html) {
|
||||||
|
var notification = $('#notification');
|
||||||
|
notification.hide();
|
||||||
|
notification.html(html);
|
||||||
|
notification.fadeIn().css("display","inline");
|
||||||
|
},
|
||||||
|
show: function(text) {
|
||||||
|
var notification = $('#notification');
|
||||||
|
notification.hide();
|
||||||
|
notification.text(text);
|
||||||
|
notification.fadeIn().css("display","inline");
|
||||||
|
},
|
||||||
|
isHidden: function() {
|
||||||
|
return ($("#notification").text() === '');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
OC.Breadcrumb={
|
OC.Breadcrumb={
|
||||||
container:null,
|
container:null,
|
||||||
crumbs:[],
|
crumbs:[],
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body id="<?php echo $_['bodyid'];?>">
|
<body id="<?php echo $_['bodyid'];?>">
|
||||||
|
<div id="notification-container">
|
||||||
|
<div id="notification"></div>
|
||||||
|
</div>
|
||||||
<header><div id="header">
|
<header><div id="header">
|
||||||
<a href="<?php echo link_to('', 'index.php'); ?>" title="" id="owncloud"><img class="svg" src="<?php echo image_path('', 'logo-wide.svg'); ?>" alt="ownCloud" /></a>
|
<a href="<?php echo link_to('', 'index.php'); ?>" title="" id="owncloud"><img class="svg" src="<?php echo image_path('', 'logo-wide.svg'); ?>" alt="ownCloud" /></a>
|
||||||
<a class="header-right header-action" id="logout" href="<?php echo link_to('', 'index.php'); ?>?logout=true"><img class="svg" alt="<?php echo $l->t('Log out');?>" title="<?php echo $l->t('Log out'); echo OC_User::getUser()?' ('.OC_User::getUser().') ':'' ?>" src="<?php echo image_path('', 'actions/logout.svg'); ?>" /></a>
|
<a class="header-right header-action" id="logout" href="<?php echo link_to('', 'index.php'); ?>?logout=true"><img class="svg" alt="<?php echo $l->t('Log out');?>" title="<?php echo $l->t('Log out'); echo OC_User::getUser()?' ('.OC_User::getUser().') ':'' ?>" src="<?php echo image_path('', 'actions/logout.svg'); ?>" /></a>
|
||||||
|
|
|
@ -785,4 +785,23 @@ class OC_Helper {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the disc space
|
||||||
|
*/
|
||||||
|
public static function getStorageInfo() {
|
||||||
|
$rootInfo = OC_FileCache::get('');
|
||||||
|
$used = $rootInfo['size'];
|
||||||
|
if ($used < 0) {
|
||||||
|
$used = 0;
|
||||||
|
}
|
||||||
|
$free = OC_Filesystem::free_space();
|
||||||
|
$total = $free + $used;
|
||||||
|
if ($total == 0) {
|
||||||
|
$total = 1; // prevent division by zero
|
||||||
|
}
|
||||||
|
$relative = round(($used / $total) * 10000) / 100;
|
||||||
|
|
||||||
|
return array('free' => $free, 'used' => $used, 'total' => $total, 'relative' => $relative);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,8 @@ var UserList = {
|
||||||
UserList.deleteCanceled = false;
|
UserList.deleteCanceled = false;
|
||||||
|
|
||||||
// Provide user with option to undo
|
// Provide user with option to undo
|
||||||
$('#notification').html(t('users', 'deleted') + ' ' + uid + '<span class="undo">' + t('users', 'undo') + '</span>');
|
|
||||||
$('#notification').data('deleteuser', true);
|
$('#notification').data('deleteuser', true);
|
||||||
$('#notification').fadeIn();
|
OC.Notification.showHtml(t('users', 'deleted') + ' ' + uid + '<span class="undo">' + t('users', 'undo') + '</span>');
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +52,7 @@ var UserList = {
|
||||||
success:function (result) {
|
success:function (result) {
|
||||||
if (result.status == 'success') {
|
if (result.status == 'success') {
|
||||||
// Remove undo option, & remove user from table
|
// Remove undo option, & remove user from table
|
||||||
$('#notification').fadeOut();
|
OC.Notification.hide();
|
||||||
$('tr').filterAttr('data-uid', UserList.deleteUid).remove();
|
$('tr').filterAttr('data-uid', UserList.deleteUid).remove();
|
||||||
UserList.deleteCanceled = true;
|
UserList.deleteCanceled = true;
|
||||||
if (ready) {
|
if (ready) {
|
||||||
|
@ -197,7 +196,7 @@ var UserList = {
|
||||||
checked:checked,
|
checked:checked,
|
||||||
oncheck:checkHandeler,
|
oncheck:checkHandeler,
|
||||||
onuncheck:checkHandeler,
|
onuncheck:checkHandeler,
|
||||||
minWidth:100,
|
minWidth:100
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ($(element).attr('class') == 'subadminsselect') {
|
if ($(element).attr('class') == 'subadminsselect') {
|
||||||
|
@ -232,7 +231,7 @@ var UserList = {
|
||||||
checked:checked,
|
checked:checked,
|
||||||
oncheck:checkHandeler,
|
oncheck:checkHandeler,
|
||||||
onuncheck:checkHandeler,
|
onuncheck:checkHandeler,
|
||||||
minWidth:100,
|
minWidth:100
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -389,7 +388,7 @@ $(document).ready(function () {
|
||||||
{
|
{
|
||||||
username:username,
|
username:username,
|
||||||
password:password,
|
password:password,
|
||||||
groups:groups,
|
groups:groups
|
||||||
},
|
},
|
||||||
function (result) {
|
function (result) {
|
||||||
if (result.status != 'success') {
|
if (result.status != 'success') {
|
||||||
|
@ -402,13 +401,13 @@ $(document).ready(function () {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
// Handle undo notifications
|
// Handle undo notifications
|
||||||
$('#notification').hide();
|
OC.Notification.hide();
|
||||||
$('#notification .undo').live('click', function () {
|
$('#notification .undo').live('click', function () {
|
||||||
if ($('#notification').data('deleteuser')) {
|
if ($('#notification').data('deleteuser')) {
|
||||||
$('tbody tr').filterAttr('data-uid', UserList.deleteUid).show();
|
$('tbody tr').filterAttr('data-uid', UserList.deleteUid).show();
|
||||||
UserList.deleteCanceled = true;
|
UserList.deleteCanceled = true;
|
||||||
}
|
}
|
||||||
$('#notification').fadeOut();
|
OC.Notification.hide();
|
||||||
});
|
});
|
||||||
UserList.useUndo = ('onbeforeunload' in window)
|
UserList.useUndo = ('onbeforeunload' in window)
|
||||||
$(window).bind('beforeunload', function () {
|
$(window).bind('beforeunload', function () {
|
||||||
|
|
|
@ -15,15 +15,7 @@ OC_Util::addScript( '3rdparty', 'chosen/chosen.jquery.min' );
|
||||||
OC_Util::addStyle( '3rdparty', 'chosen' );
|
OC_Util::addStyle( '3rdparty', 'chosen' );
|
||||||
OC_App::setActiveNavigationEntry( 'personal' );
|
OC_App::setActiveNavigationEntry( 'personal' );
|
||||||
|
|
||||||
// calculate the disc space
|
$storageInfo=OC_Helper::getStorageInfo();
|
||||||
$rootInfo=OC_FileCache::get('');
|
|
||||||
$sharedInfo=OC_FileCache::get('/Shared');
|
|
||||||
$used=$rootInfo['size'];
|
|
||||||
if($used<0) $used=0;
|
|
||||||
$free=OC_Filesystem::free_space();
|
|
||||||
$total=$free+$used;
|
|
||||||
if($total==0) $total=1; // prevent division by zero
|
|
||||||
$relative=round(($used/$total)*10000)/100;
|
|
||||||
|
|
||||||
$email=OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', '');
|
$email=OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', '');
|
||||||
|
|
||||||
|
@ -50,9 +42,9 @@ foreach($languageCodes as $lang) {
|
||||||
|
|
||||||
// Return template
|
// Return template
|
||||||
$tmpl = new OC_Template( 'settings', 'personal', 'user');
|
$tmpl = new OC_Template( 'settings', 'personal', 'user');
|
||||||
$tmpl->assign('usage', OC_Helper::humanFileSize($used));
|
$tmpl->assign('usage', OC_Helper::humanFileSize($storageInfo['used']));
|
||||||
$tmpl->assign('total_space', OC_Helper::humanFileSize($total));
|
$tmpl->assign('total_space', OC_Helper::humanFileSize($storageInfo['total']));
|
||||||
$tmpl->assign('usage_relative', $relative);
|
$tmpl->assign('usage_relative', $storageInfo['relative']);
|
||||||
$tmpl->assign('email', $email);
|
$tmpl->assign('email', $email);
|
||||||
$tmpl->assign('languages', $languages);
|
$tmpl->assign('languages', $languages);
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,6 @@ $_['subadmingroups'] = array_flip($items);
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id='notification'></div>
|
|
||||||
|
|
||||||
<table data-groups="<?php echo implode(', ', $allGroups);?>">
|
<table data-groups="<?php echo implode(', ', $allGroups);?>">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in New Issue