summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2016-06-09 21:44:54 +0200
committerLukas Reschke <lukas@owncloud.com>2016-06-09 21:44:54 +0200
commitc49402d26640df2adfdf3201cfc9c4c1456b7a66 (patch)
treecd3ad293efa5b267b75401ec6257a9490d1e4909 /apps
parentc268ad15972e728dea0465f7332067a63c5bd678 (diff)
downloadnextcloud-server-c49402d26640df2adfdf3201cfc9c4c1456b7a66.tar.gz
nextcloud-server-c49402d26640df2adfdf3201cfc9c4c1456b7a66.zip
Add some error handling
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/js/files_drop.js24
-rw-r--r--apps/files_sharing/templates/public.php7
2 files changed, 27 insertions, 4 deletions
diff --git a/apps/files_sharing/js/files_drop.js b/apps/files_sharing/js/files_drop.js
index 3c1ccd63da5..c9dafb0564f 100644
--- a/apps/files_sharing/js/files_drop.js
+++ b/apps/files_sharing/js/files_drop.js
@@ -23,14 +23,30 @@
dirToken: $('#sharingToken').val()
},
add: function(e, data) {
+ var errors = [];
+ if(data.files[0]['size'] && data.files[0]['size'] > $('#maxFilesizeUpload').val()) {
+ errors.push('File is too big');
+ }
+
_.each(data['files'], function(file) {
- $('#public-upload ul').append('<li data-name="'+escapeHTML(file.name)+'"><span class="icon-loading-small"></span> '+escapeHTML(file.name)+'</li>');
+ if(errors.length === 0) {
+ $('#public-upload ul').append('<li data-toggle="tooltip" title="'+escapeHTML(file.name)+'" data-name="'+escapeHTML(file.name)+'"><span class="icon-loading-small"></span> '+escapeHTML(file.name)+'</li>');
+ $('[data-toggle="tooltip"]').tooltip();
+ data.submit();
+ } else {
+ OC.Notification.showTemporary(OC.L10N.translate('files_sharing', 'Could not upload "{filename}"', {filename: file.name}));
+ $('#public-upload ul').append('<li data-toggle="tooltip" title="'+escapeHTML(file.name)+'" data-name="'+escapeHTML(file.name)+'"><img src="'+OC.imagePath('core', 'actions/error.svg')+'"/> '+escapeHTML(file.name)+'</li>');
+ $('[data-toggle="tooltip"]').tooltip();
+
+ }
});
- data.submit();
},
success: function (response) {
- var mimeTypeUrl = OC.MimeType.getIconUrl(response['mimetype']);
- $('#public-upload ul li[data-name="'+escapeHTML(response['filename'])+'"]').html('<img src="'+escapeHTML(mimeTypeUrl)+'"/> '+escapeHTML(response['filename']));
+ if(response.status !== 'error') {
+ var mimeTypeUrl = OC.MimeType.getIconUrl(response['mimetype']);
+ $('#public-upload ul li[data-name="' + escapeHTML(response['filename']) + '"]').html('<img src="' + escapeHTML(mimeTypeUrl) + '"/> ' + escapeHTML(response['filename']));
+ $('[data-toggle="tooltip"]').tooltip();
+ }
}
});
$('#public-upload .button.icon-upload').click(function(e) {
diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php
index ef9e4bfa574..35adb240022 100644
--- a/apps/files_sharing/templates/public.php
+++ b/apps/files_sharing/templates/public.php
@@ -41,6 +41,13 @@ OCP\Util::addscript('files', 'keyboardshortcuts');
<input type="hidden" name="mimetype" value="<?php p($_['mimetype']) ?>" id="mimetype">
<input type="hidden" name="previewSupported" value="<?php p($_['previewSupported'] ? 'true' : 'false'); ?>" id="previewSupported">
<input type="hidden" name="mimetypeIcon" value="<?php p(\OC::$server->getMimeTypeDetector()->mimeTypeIcon($_['mimetype'])); ?>" id="mimetypeIcon">
+<?php
+$upload_max_filesize = OC::$server->getIniWrapper()->getBytes('upload_max_filesize');
+$post_max_size = OC::$server->getIniWrapper()->getBytes('post_max_size');
+$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
+?>
+<input type="hidden" name="maxFilesizeUpload" value="<?php p($maxUploadFilesize); ?>" id="maxFilesizeUpload">
+
<?php if (!isset($_['hideFileList']) || (isset($_['hideFileList']) && $_['hideFileList'] === false)): ?>
<input type="hidden" name="filesize" value="<?php p($_['nonHumanFileSize']); ?>" id="filesize">
<?php endif; ?>