Add the storage limit warning in the toolbar

This commit is contained in:
yflory
2017-04-27 18:46:46 +02:00
parent 197b366712
commit bf7c7c45d0
7 changed files with 67 additions and 1 deletions

View File

@@ -16,6 +16,8 @@ define([
/** Id of the div containing the lag info. */
var LAG_ELEM_CLS = Bar.constants.lag = 'cryptpad-lag';
var LIMIT_ELEM_CLS = Bar.constants.lag = 'cryptpad-limit';
/** The toolbar class which contains the user list, debug link and lag. */
var TOOLBAR_CLS = Bar.constants.toolbar = 'cryptpad-toolbar';
@@ -488,6 +490,28 @@ define([
$userContainer.append($lag);
}
if (config.displayed.indexOf('limit') !== -1 && Config.enablePinning) {
var usage;
var $limitIcon = $('<span>', {'class': 'fa fa-exclamation-triangle'});
var $limit = $('<span>', {
'class': LIMIT_ELEM_CLS,
'title': Messages.pinLimitReached
}).append($limitIcon).hide().appendTo($userContainer);
var andThen = function (e, limit) {
if (usage > limit) {
$limit.show().click(function () {
Cryptpad.alert(Messages.pinLimitReachedAlert, null, true);
});
}
};
var todo = function (e, used) {
usage = Cryptpad.bytesToMegabytes(used);
if (e) { console.error("Unable tog et the pinned usage"); return; }
Cryptpad.getPinLimit(andThen);
};
Cryptpad.getPinnedUsage(todo);
}
if (config.displayed.indexOf('newpad') !== -1) {
var pads_options = [];
Config.availablePadTypes.forEach(function (p) {