summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Mueller <thomas.mueller@tmit.eu>2013-01-11 16:47:28 +0100
committerThomas Mueller <thomas.mueller@tmit.eu>2013-01-11 16:47:28 +0100
commite560cba76beb918a2c127b931b6d409abd9f03ab (patch)
tree87cc9214ae6bb2a5c19c3f7230d704cd3e48b817 /apps
parent938254a1c015c447b24fe1f3e64d8026f4dda8c3 (diff)
downloadnextcloud-server-e560cba76beb918a2c127b931b6d409abd9f03ab.tar.gz
nextcloud-server-e560cba76beb918a2c127b931b6d409abd9f03ab.zip
adding a ajax call to get the current file storage stats like free space
logic to call it every 5 minutes make use of visibility API/jquery-visibility to perform the ajax call only if the browser is visible/in use
Diffstat (limited to 'apps')
-rw-r--r--apps/files/ajax/getstoragestats.php16
-rw-r--r--apps/files/js/files.js26
2 files changed, 42 insertions, 0 deletions
diff --git a/apps/files/ajax/getstoragestats.php b/apps/files/ajax/getstoragestats.php
new file mode 100644
index 00000000000..e55e346ed67
--- /dev/null
+++ b/apps/files/ajax/getstoragestats.php
@@ -0,0 +1,16 @@
+<?php
+
+// only need filesystem apps
+$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
+)));
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 96b3cc5b627..440aeeaf6a6 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -732,6 +732,32 @@ $(document).ready(function() {
});
resizeBreadcrumbs(true);
+
+ // file space size sync
+ function update_storage_statistics() {
+ $.getJSON(OC.filePath('files','ajax','getstoragestats.php'),function(response) {
+ Files.updateMaxUploadFilesize(response);
+ });
+ }
+
+ // start on load - we ask the server every 5 minutes
+ var update_storage_statistics_interval = 5*60*1000;
+ var update_storage_statistics_interval_id = setInterval(update_storage_statistics, update_storage_statistics_interval);
+
+ // Use jquery-visibility to de-/re-activate file stats sync
+ if ($.support.pageVisibility) {
+ $(document).on({
+ 'show.visibility': function() {
+ if (!update_storage_statistics_interval_id) {
+ update_storage_statistics_interval_id = setInterval(update_storage_statistics, update_storage_statistics_interval);
+ }
+ },
+ 'hide.visibility': function() {
+ clearInterval(update_storage_statistics_interval_id);
+ update_storage_statistics_interval_id = 0;
+ }
+ });
+ }
});
function scanFiles(force,dir){