summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-01-26 04:15:40 -0800
committerThomas Müller <thomas.mueller@tmit.eu>2013-01-26 04:15:40 -0800
commit276d98b9ddd18c216956b2c9916583e8098186d0 (patch)
treeeafc40da091c41e8e40d5ce9948c85b0dbe976dc
parent3b547895ec0c8b076bf31abdb53079ba8fa983db (diff)
parent5d6c1d52bdb5aa3addc26d1e105749a8eda35301 (diff)
downloadnextcloud-server-276d98b9ddd18c216956b2c9916583e8098186d0.tar.gz
nextcloud-server-276d98b9ddd18c216956b2c9916583e8098186d0.zip
Merge pull request #1059 from owncloud/fixing-998-master
Fixing 998 master
-rw-r--r--apps/files/ajax/delete.php23
-rw-r--r--apps/files/ajax/getstoragestats.php9
-rw-r--r--apps/files/ajax/upload.php87
-rw-r--r--apps/files/index.php4
-rw-r--r--apps/files/js/filelist.js33
-rw-r--r--apps/files/js/files.js75
-rw-r--r--apps/files/lib/helper.php20
-rw-r--r--apps/files/templates/index.php2
-rw-r--r--core/css/styles.css3
-rw-r--r--core/js/js.js53
-rw-r--r--core/templates/layout.user.php5
-rw-r--r--lib/helper.php19
-rw-r--r--settings/js/users.js15
-rw-r--r--settings/personal.php16
-rw-r--r--settings/templates/users.php2
15 files changed, 205 insertions, 161 deletions
diff --git a/apps/files/ajax/delete.php b/apps/files/ajax/delete.php
index 293543c547f..575b8c8d9ea 100644
--- a/apps/files/ajax/delete.php
+++ b/apps/files/ajax/delete.php
@@ -14,27 +14,18 @@ $files = json_decode($files);
$filesWithError = '';
$success = true;
//Now delete
-foreach($files as $file) {
- if( !OC_Files::delete( $dir, $file )) {
+foreach ($files as $file) {
+ if (!OC_Files::delete($dir, $file)) {
$filesWithError .= $file . "\n";
$success = false;
}
}
-// updated max file size after upload
-$l=new OC_L10N('files');
-$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
-$maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize);
-$maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize;
+// get array with updated storage stats (e.g. max file size) after upload
+$storageStats = \OCA\files\lib\Helper::buildFileStorageStatistics($dir);
-if($success) {
- OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $files,
- 'uploadMaxFilesize'=>$maxUploadFilesize,
- 'maxHumanFilesize'=>$maxHumanFilesize
- )));
+if ($success) {
+ OCP\JSON::success(array("data" => array_merge(array("dir" => $dir, "files" => $files), $storageStats)));
} else {
- OCP\JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError,
- 'uploadMaxFilesize'=>$maxUploadFilesize,
- 'maxHumanFilesize'=>$maxHumanFilesize
- )));
+ OCP\JSON::error(array("data" => array_merge(array("message" => "Could not delete:\n" . $filesWithError), $storageStats)));
}
diff --git a/apps/files/ajax/getstoragestats.php b/apps/files/ajax/getstoragestats.php
index e55e346ed67..7a2b642a9bd 100644
--- a/apps/files/ajax/getstoragestats.php
+++ b/apps/files/ajax/getstoragestats.php
@@ -5,12 +5,5 @@ $RUNTIME_APPTYPES = array('filesystem');
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
-OCP\JSON::success(array('data' => array('uploadMaxFilesize' => $maxUploadFilesize,
- 'maxHumanFilesize' => $maxHumanFilesize
-)));
+OCP\JSON::success(array('data' => \OCA\files\lib\Helper::buildFileStorageStatistics('/')));
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index 93398019608..415524be629 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -8,90 +8,73 @@ OCP\JSON::setContentTypeHeader('text/plain');
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
-$l=OC_L10N::get('files');
+$l = OC_L10N::get('files');
-// current max upload size
-$l=new OC_L10N('files');
-$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
-$maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize);
-$maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize;
+// get array with current storage stats (e.g. max file size)
+$storageStats = \OCA\files\lib\Helper::buildFileStorageStatistics($dir);
if (!isset($_FILES['files'])) {
- OCP\JSON::error(array('data' => array( 'message' => $l->t( 'No file was uploaded. Unknown error' ),
- 'uploadMaxFilesize'=>$maxUploadFilesize,
- 'maxHumanFilesize'=>$maxHumanFilesize
- )));
+ OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('No file was uploaded. Unknown error')), $storageStats)));
exit();
}
foreach ($_FILES['files']['error'] as $error) {
if ($error != 0) {
$errors = array(
- UPLOAD_ERR_OK=>$l->t('There is no error, the file uploaded with success'),
- UPLOAD_ERR_INI_SIZE=>$l->t('The uploaded file exceeds the upload_max_filesize directive in php.ini: ')
- .ini_get('upload_max_filesize'),
- UPLOAD_ERR_FORM_SIZE=>$l->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified'
- .' in the HTML form'),
- UPLOAD_ERR_PARTIAL=>$l->t('The uploaded file was only partially uploaded'),
- UPLOAD_ERR_NO_FILE=>$l->t('No file was uploaded'),
- UPLOAD_ERR_NO_TMP_DIR=>$l->t('Missing a temporary folder'),
- UPLOAD_ERR_CANT_WRITE=>$l->t('Failed to write to disk'),
+ UPLOAD_ERR_OK => $l->t('There is no error, the file uploaded with success'),
+ UPLOAD_ERR_INI_SIZE => $l->t('The uploaded file exceeds the upload_max_filesize directive in php.ini: ')
+ . ini_get('upload_max_filesize'),
+ UPLOAD_ERR_FORM_SIZE => $l->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified'
+ . ' in the HTML form'),
+ UPLOAD_ERR_PARTIAL => $l->t('The uploaded file was only partially uploaded'),
+ UPLOAD_ERR_NO_FILE => $l->t('No file was uploaded'),
+ UPLOAD_ERR_NO_TMP_DIR => $l->t('Missing a temporary folder'),
+ UPLOAD_ERR_CANT_WRITE => $l->t('Failed to write to disk'),
);
- OCP\JSON::error(array('data' => array( 'message' => $errors[$error],
- 'uploadMaxFilesize'=>$maxUploadFilesize,
- 'maxHumanFilesize'=>$maxHumanFilesize
- )));
+ OCP\JSON::error(array('data' => array_merge(array('message' => $errors[$error]), $storageStats)));
exit();
}
}
-$files=$_FILES['files'];
+$files = $_FILES['files'];
$dir = $_POST['dir'];
-$error='';
+$error = '';
-$totalSize=0;
-foreach($files['size'] as $size) {
- $totalSize+=$size;
+$totalSize = 0;
+foreach ($files['size'] as $size) {
+ $totalSize += $size;
}
-if($totalSize>OC_Filesystem::free_space($dir)) {
- OCP\JSON::error(array('data' => array( 'message' => $l->t( 'Not enough space available' ),
- 'uploadMaxFilesize'=>$maxUploadFilesize,
- 'maxHumanFilesize'=>$maxHumanFilesize)));
+if ($totalSize > OC_Filesystem::free_space($dir)) {
+ OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Not enough storage available')), $storageStats)));
exit();
}
-$result=array();
-if(strpos($dir, '..') === false) {
- $fileCount=count($files['name']);
- for($i=0;$i<$fileCount;$i++) {
+$result = array();
+if (strpos($dir, '..') === false) {
+ $fileCount = count($files['name']);
+ for ($i = 0; $i < $fileCount; $i++) {
$target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
// $path needs to be normalized - this failed within drag'n'drop upload to a sub-folder
$target = OC_Filesystem::normalizePath($target);
- 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);
$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;
+ $storageStats = \OCA\files\lib\Helper::buildFileStorageStatistics($dir);
- $result[]=array( 'status' => 'success',
- 'mime'=>$meta['mimetype'],
- 'size'=>$meta['size'],
- 'id'=>$id,
- 'name'=>basename($target),
- 'uploadMaxFilesize'=>$maxUploadFilesize,
- 'maxHumanFilesize'=>$maxHumanFilesize
+ $result[] = array_merge(array('status' => 'success',
+ 'mime' => $meta['mimetype'],
+ 'size' => $meta['size'],
+ 'id' => $id,
+ 'name' => basename($target)), $storageStats
);
}
}
OCP\JSON::encodedPrint($result);
exit();
} else {
- $error=$l->t( 'Invalid directory.' );
+ $error = $l->t('Invalid directory.');
}
-OCP\JSON::error(array('data' => array('message' => $error,
- 'uploadMaxFilesize'=>$maxUploadFilesize,
- 'maxHumanFilesize'=>$maxHumanFilesize
-)));
+OCP\JSON::error(array('data' => array_merge(array('message' => $error), $storageStats)));
diff --git a/apps/files/index.php b/apps/files/index.php
index 1c4b7fbd497..2c6b689b0c9 100644
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -93,6 +93,9 @@ if (OC_Filesystem::isSharable($dir . '/')) {
$permissions |= OCP\PERMISSION_SHARE;
}
+// information about storage capacities
+$storageInfo=OC_Helper::getStorageInfo();
+
$tmpl = new OCP\Template('files', 'index', 'user');
$tmpl->assign('fileList', $list->fetchPage(), false);
$tmpl->assign('breadcrumb', $breadcrumbNav->fetchPage(), false);
@@ -103,4 +106,5 @@ $tmpl->assign('files', $files);
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
$tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
+$tmpl->assign('usedSpacePercent', (int)$storageInfo['relative']);
$tmpl->printPage();
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 66697bbbf56..04b7d92e2c3 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -201,15 +201,14 @@ var FileList={
},
checkName:function(oldName, newName, isNewFile) {
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('newName', newName);
$('#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;
} else {
return false;
@@ -251,11 +250,10 @@ var FileList={
FileList.finishReplace();
};
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 {
- $('#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() {
if (!FileList.replaceCanceled && FileList.replaceOldName && FileList.replaceNewName) {
@@ -285,11 +283,10 @@ var FileList={
} else {
// NOTE: Temporary fix to change the text to unshared for files in root of Shared folder
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 {
- $('#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){
@@ -302,7 +299,7 @@ var FileList={
data: {dir:$('#dir').val(),files:fileNames},
complete: function(data){
boolOperationFinished(data, function(){
- $('#notification').fadeOut('400');
+ OC.Notification.hide();
$.each(FileList.deleteFiles,function(index,file){
FileList.remove(file);
});
@@ -362,16 +359,16 @@ $(document).ready(function(){
FileList.replaceIsNewFile = null;
}
FileList.lastAction = null;
- $('#notification').fadeOut('400');
+ OC.Notification.hide();
});
$('#notification .replace').live('click', function() {
- $('#notification').fadeOut('400', function() {
- FileList.replace($('#notification').data('oldName'), $('#notification').data('newName'), $('#notification').data('isNewFile'));
- });
+ OC.Notification.hide(function() {
+ FileList.replace($('#notification').data('oldName'), $('#notification').data('newName'), $('#notification').data('isNewFile'));
+ });
});
$('#notification .suggest').live('click', function() {
$('tr').filterAttr('data-file', $('#notification').data('oldName')).show();
- $('#notification').fadeOut('400');
+ OC.Notification.hide();
});
$('#notification .cancel').live('click', function() {
if ($('#notification').data('isNewFile')) {
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index c1abe205151..6486468eafd 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -32,26 +32,28 @@ Files={
}
if(response.data !== undefined && response.data.uploadMaxFilesize !== undefined) {
$('#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) {
return;
}
if(response[0].uploadMaxFilesize !== undefined) {
$('#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) {
if (name === '.') {
- $('#notification').text(t('files', '\'.\' is an invalid file name.'));
- $('#notification').fadeIn();
+ OC.Notification.show(t('files', '\'.\' is an invalid file name.'));
return false;
}
if (name.length == 0) {
- $('#notification').text(t('files', 'File name cannot be empty.'));
- $('#notification').fadeIn();
+ OC.Notification.show(t('files', 'File name cannot be empty.'));
return false;
}
@@ -59,13 +61,26 @@ Files={
var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*'];
for (var i = 0; i < invalid_characters.length; i++) {
if (name.indexOf(invalid_characters[i]) != -1) {
- $('#notification').text(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed."));
- $('#notification').fadeIn();
+ OC.Notification.show(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed."));
return false;
}
}
- $('#notification').fadeOut();
+ OC.Notification.hide();
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() {
@@ -201,8 +216,7 @@ $(document).ready(function() {
$('.download').click('click',function(event) {
var files=getSelectedFiles('name').join(';');
var dir=$('#dir').val()||'/';
- $('#notification').text(t('files','Your download is being prepared. This might take some time if the files are big.'));
- $('#notification').fadeIn();
+ OC.Notification.show(t('files','Your download is being prepared. This might take some time if the files are big.'));
// use special download URL if provided, e.g. for public shared files
if ( (downloadURL = document.getElementById("downloadURL")) ) {
window.location=downloadURL.value+"&download&files="+files;
@@ -331,8 +345,7 @@ $(document).ready(function() {
var response;
response=jQuery.parseJSON(result);
if(response[0] == undefined || response[0].status != 'success') {
- $('#notification').text(t('files', response.data.message));
- $('#notification').fadeIn();
+ OC.Notification.show(t('files', response.data.message));
}
Files.updateMaxUploadFilesize(response);
var file=response[0];
@@ -372,9 +385,7 @@ $(document).ready(function() {
uploadtext.text(t('files', '{count} files uploading', {count: currentUploads}));
}
delete uploadingFiles[dirName][fileName];
- $('#notification').hide();
- $('#notification').text(t('files', 'Upload cancelled.'));
- $('#notification').fadeIn();
+ OC.Notification.show(t('files', 'Upload cancelled.'));
}
});
//TODO test with filenames containing slashes
@@ -401,20 +412,17 @@ $(document).ready(function() {
FileList.loadingDone(file.name, file.id);
} else {
Files.cancelUpload(this.files[0].name);
- $('#notification').text(t('files', response.data.message));
- $('#notification').fadeIn();
+ OC.Notification.show(t('files', response.data.message));
$('#fileList > tr').not('[data-mime]').fadeOut();
$('#fileList > tr').not('[data-mime]').remove();
}
- })
- .error(function(jqXHR, textStatus, errorThrown) {
- if(errorThrown === 'abort') {
- Files.cancelUpload(this.files[0].name);
- $('#notification').hide();
- $('#notification').text(t('files', 'Upload cancelled.'));
- $('#notification').fadeIn();
- }
- });
+ })
+ .error(function(jqXHR, textStatus, errorThrown) {
+ if(errorThrown === 'abort') {
+ Files.cancelUpload(this.files[0].name);
+ OC.Notification.show(t('files', 'Upload cancelled.'));
+ }
+ });
uploadingFiles[uniqueName] = jqXHR;
}
}
@@ -435,8 +443,7 @@ $(document).ready(function() {
FileList.loadingDone(file.name, file.id);
} else {
//TODO Files.cancelUpload(/*where do we get the filename*/);
- $('#notification').text(t('files', response.data.message));
- $('#notification').fadeIn();
+ OC.Notification.show(t('files', response.data.message));
$('#fileList > tr').not('[data-mime]').fadeOut();
$('#fileList > tr').not('[data-mime]').remove();
}
@@ -556,14 +563,12 @@ $(document).ready(function() {
event.preventDefault();
var newname=input.val();
if(type == 'web' && newname.length == 0) {
- $('#notification').text(t('files', 'URL cannot be empty.'));
- $('#notification').fadeIn();
+ OC.Notification.show(t('files', 'URL cannot be empty.'));
return false;
} else if (type != 'web' && !Files.isFileNameValid(newname)) {
return false;
} else if( type == 'folder' && $('#dir').val() == '/' && newname == 'Shared') {
- $('#notification').text(t('files','Invalid folder name. Usage of \'Shared\' is reserved by Owncloud'));
- $('#notification').fadeIn();
+ OC.Notification.show(t('files','Invalid folder name. Usage of \'Shared\' is reserved by Owncloud'));
return false;
}
if (FileList.lastAction) {
@@ -734,6 +739,10 @@ $(document).ready(function() {
resizeBreadcrumbs(true);
+ // display storage warnings
+ setTimeout ( "Files.displayStorageWarnings()", 100 );
+ OC.Notification.setDefault(Files.displayStorageWarnings);
+
// file space size sync
function update_storage_statistics() {
$.getJSON(OC.filePath('files','ajax','getstoragestats.php'),function(response) {
diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php
new file mode 100644
index 00000000000..f2b1f142e9b
--- /dev/null
+++ b/apps/files/lib/helper.php
@@ -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']);
+ }
+}
diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php
index 2e0772443f2..b66b523ae38 100644
--- a/apps/files/templates/index.php
+++ b/apps/files/templates/index.php
@@ -50,7 +50,6 @@
<?php endif;?>
<input type="hidden" name="permissions" value="<?php echo $_['permissions']; ?>" id="permissions">
</div>
-<div id='notification'></div>
<?php if (isset($_['files']) and $_['isCreatable'] and count($_['files'])==0):?>
<div id="emptyfolder"><?php echo $l->t('Nothing in here. Upload something!')?></div>
@@ -115,3 +114,4 @@
<!-- config hints for javascript -->
<input type="hidden" name="allowZipDownload" id="allowZipDownload" value="<?php echo $_['allowZipDownload']; ?>" />
+<input type="hidden" name="usedSpacePercent" id="usedSpacePercent" value="<?php echo $_['usedSpacePercent']; ?>" />
diff --git a/core/css/styles.css b/core/css/styles.css
index 3c172d11df8..022acab4d8a 100644
--- a/core/css/styles.css
+++ b/core/css/styles.css
@@ -191,7 +191,8 @@ fieldset.warning legend { color:#b94a48 !important; }
.bold { font-weight:bold; }
.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; }
tr .action, .selectedActions a { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter:alpha(opacity=0); opacity:0; }
diff --git a/core/js/js.js b/core/js/js.js
index 6e0a405114b..01e47edf268 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -37,14 +37,14 @@ function t(app,text, vars){
t.cache[app] = [];
}
}
- var _build = function(text, vars) {
- return text.replace(/{([^{}]*)}/g,
- function (a, b) {
- var r = vars[b];
- return typeof r === 'string' || typeof r === 'number' ? r : a;
- }
- );
- }
+ var _build = function (text, vars) {
+ return text.replace(/{([^{}]*)}/g,
+ function (a, b) {
+ var r = vars[b];
+ return typeof r === 'string' || typeof r === 'number' ? r : a;
+ }
+ );
+ };
if( typeof( t.cache[app][text] ) !== 'undefined' ){
if(typeof vars === 'object') {
return _build(t.cache[app][text], vars);
@@ -268,7 +268,7 @@ var OC={
var popup = $('#appsettings_popup');
if(popup.length == 0) {
$('body').prepend('<div class="popup hidden" id="appsettings_popup"></div>');
- popup = $('#appsettings_popup');
+ popup = $('#appsettings_popup');
popup.addClass(settings.hasClass('topright') ? 'topright' : 'bottomleft');
}
if(popup.is(':visible')) {
@@ -310,6 +310,41 @@ OC.search.lastResults={};
OC.addStyle.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={
container:null,
crumbs:[],
diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php
index c6e928ca33c..18291e0f84e 100644
--- a/core/templates/layout.user.php
+++ b/core/templates/layout.user.php
@@ -24,7 +24,10 @@
</head>
<body id="<?php echo $_['bodyid'];?>">
- <header><div id="header">
+ <div id="notification-container">
+ <div id="notification"></div>
+ </div>
+ <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 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>
<form class="searchbox header-right" action="#" method="post">
diff --git a/lib/helper.php b/lib/helper.php
index a7b2a429952..d2c6b1695bd 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -785,4 +785,23 @@ class OC_Helper {
}
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);
+ }
}
diff --git a/settings/js/users.js b/settings/js/users.js
index fa6f058d923..9f0c1ffd111 100644
--- a/settings/js/users.js
+++ b/settings/js/users.js
@@ -26,9 +26,8 @@ var UserList = {
UserList.deleteCanceled = false;
// Provide user with option to undo
- $('#notification').html(t('users', 'deleted') + ' ' + uid + '<span class="undo">' + t('users', 'undo') + '</span>');
$('#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) {
if (result.status == 'success') {
// Remove undo option, & remove user from table
- $('#notification').fadeOut();
+ OC.Notification.hide();
$('tr').filterAttr('data-uid', UserList.deleteUid).remove();
UserList.deleteCanceled = true;
if (ready) {
@@ -197,7 +196,7 @@ var UserList = {
checked:checked,
oncheck:checkHandeler,
onuncheck:checkHandeler,
- minWidth:100,
+ minWidth:100
});
}
if ($(element).attr('class') == 'subadminsselect') {
@@ -232,7 +231,7 @@ var UserList = {
checked:checked,
oncheck:checkHandeler,
onuncheck:checkHandeler,
- minWidth:100,
+ minWidth:100
});
}
}
@@ -389,7 +388,7 @@ $(document).ready(function () {
{
username:username,
password:password,
- groups:groups,
+ groups:groups
},
function (result) {
if (result.status != 'success') {
@@ -402,13 +401,13 @@ $(document).ready(function () {
);
});
// Handle undo notifications
- $('#notification').hide();
+ OC.Notification.hide();
$('#notification .undo').live('click', function () {
if ($('#notification').data('deleteuser')) {
$('tbody tr').filterAttr('data-uid', UserList.deleteUid).show();
UserList.deleteCanceled = true;
}
- $('#notification').fadeOut();
+ OC.Notification.hide();
});
UserList.useUndo = ('onbeforeunload' in window)
$(window).bind('beforeunload', function () {
diff --git a/settings/personal.php b/settings/personal.php
index 47dbcc53ebc..4624bda8397 100644
--- a/settings/personal.php
+++ b/settings/personal.php
@@ -15,15 +15,7 @@ OC_Util::addScript( '3rdparty', 'chosen/chosen.jquery.min' );
OC_Util::addStyle( '3rdparty', 'chosen' );
OC_App::setActiveNavigationEntry( 'personal' );
-// calculate the disc space
-$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;
+$storageInfo=OC_Helper::getStorageInfo();
$email=OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', '');
@@ -50,9 +42,9 @@ foreach($languageCodes as $lang) {
// Return template
$tmpl = new OC_Template( 'settings', 'personal', 'user');
-$tmpl->assign('usage', OC_Helper::humanFileSize($used));
-$tmpl->assign('total_space', OC_Helper::humanFileSize($total));
-$tmpl->assign('usage_relative', $relative);
+$tmpl->assign('usage', OC_Helper::humanFileSize($storageInfo['used']));
+$tmpl->assign('total_space', OC_Helper::humanFileSize($storageInfo['total']));
+$tmpl->assign('usage_relative', $storageInfo['relative']);
$tmpl->assign('email', $email);
$tmpl->assign('languages', $languages);
diff --git a/settings/templates/users.php b/settings/templates/users.php
index 5e588f9ead7..c88966f7137 100644
--- a/settings/templates/users.php
+++ b/settings/templates/users.php
@@ -73,8 +73,6 @@ $_['subadmingroups'] = array_flip($items);
</div>
</div>
-<div id='notification'></div>
-
<table data-groups="<?php echo implode(', ', $allGroups);?>">
<thead>
<tr>