diff options
Diffstat (limited to 'apps/files/js/files.js')
-rw-r--r-- | apps/files/js/files.js | 69 |
1 files changed, 52 insertions, 17 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 68e9315954f..55fdb96ebda 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -61,8 +61,10 @@ if (response.data !== undefined && response.data.uploadMaxFilesize !== undefined) { $('#max_upload').val(response.data.uploadMaxFilesize); $('#free_space').val(response.data.freeSpace); - $('#upload.button').attr('original-title', response.data.maxHumanFilesize); + $('#upload.button').attr('data-original-title', response.data.maxHumanFilesize); $('#usedSpacePercent').val(response.data.usedSpacePercent); + $('#owner').val(response.data.owner); + $('#ownerDisplayName').val(response.data.ownerDisplayName); Files.displayStorageWarnings(); } if (response[0] === undefined) { @@ -70,7 +72,7 @@ } if (response[0].uploadMaxFilesize !== undefined) { $('#max_upload').val(response[0].uploadMaxFilesize); - $('#upload.button').attr('original-title', response[0].maxHumanFilesize); + $('#upload.button').attr('data-original-title', response[0].maxHumanFilesize); $('#usedSpacePercent').val(response[0].usedSpacePercent); Files.displayStorageWarnings(); } @@ -109,12 +111,24 @@ return; } - var usedSpacePercent = $('#usedSpacePercent').val(); + var usedSpacePercent = $('#usedSpacePercent').val(), + owner = $('#owner').val(), + ownerDisplayName = $('#ownerDisplayName').val(); if (usedSpacePercent > 98) { + if (owner !== oc_current_user) { + OC.Notification.showTemporary(t('files', 'Storage of {owner} is full, files can not be updated or synced anymore!', + { owner: ownerDisplayName })); + return; + } OC.Notification.show(t('files', 'Your storage is full, files can not be updated or synced anymore!')); return; } if (usedSpacePercent > 90) { + if (owner !== oc_current_user) { + OC.Notification.showTemporary(t('files', 'Storage of {owner} is almost full ({usedSpacePercent}%)', + { usedSpacePercent: usedSpacePercent, owner: ownerDisplayName })); + return; + } OC.Notification.show(t('files', 'Your storage is almost full ({usedSpacePercent}%)', {usedSpacePercent: usedSpacePercent})); } @@ -149,18 +163,14 @@ return OC.filePath('files', 'ajax', action + '.php') + q; }, + /** + * Fetch the icon url for the mimetype + * @param {string} mime The mimetype + * @param {Files~mimeicon} ready Function to call when mimetype is retrieved + * @deprecated use OC.MimeType.getIconUrl(mime) + */ getMimeIcon: function(mime, ready) { - if (Files.getMimeIcon.cache[mime]) { - ready(Files.getMimeIcon.cache[mime]); - } else { - $.get( OC.filePath('files','ajax','mimeicon.php'), {mime: mime}, function(path) { - if(OC.Util.hasSVGSupport()){ - path = path.substr(0, path.length-4) + '.svg'; - } - Files.getMimeIcon.cache[mime]=path; - ready(Files.getMimeIcon.cache[mime]); - }); - } + ready(OC.MimeType.getIconUrl(mime)); }, /** @@ -197,7 +207,6 @@ * Initialize the files view */ initialize: function() { - Files.getMimeIcon.cache = {}; Files.bindKeyboardShortcuts(document, $); // TODO: move file list related code (upload) to OCA.Files.FileList @@ -225,7 +234,6 @@ // display storage warnings setTimeout(Files.displayStorageWarnings, 100); - OC.Notification.setDefault(Files.displayStorageWarnings); // only possible at the moment if user is logged in or the files app is loaded if (OC.currentUser && OCA.Files.App) { @@ -256,14 +264,41 @@ $('#webdavurl').select(); }); + $('#upload').tooltip({placement:'right'}); + //FIXME scroll to and highlight preselected file /* if (getURLParameter('scrollto')) { FileList.scrollTo(getURLParameter('scrollto')); } */ + }, + + /** + * Handles the download and calls the callback function once the download has started + * - browser sends download request and adds parameter with a token + * - server notices this token and adds a set cookie to the download response + * - browser now adds this cookie for the domain + * - JS periodically checks for this cookie and then knows when the download has started to call the callback + * + * @param {string} url download URL + * @param {function} callback function to call once the download has started + */ + handleDownload: function(url, callback) { + var randomToken = Math.random().toString(36).substring(2), + checkForDownloadCookie = function() { + if (!OC.Util.isCookieSetToValue('ocDownloadStarted', randomToken)){ + return false; + } else { + callback(); + return true; + } + }; + + OC.redirect(url + '&downloadStartSecret=' + randomToken); + OC.Util.waitFor(checkForDownloadCookie, 500); } - } + }; Files._updateStorageStatisticsDebounced = _.debounce(Files._updateStorageStatistics, 250); OCA.Files.Files = Files; |