Display the storage limit in the drive
This commit is contained in:
@@ -48,6 +48,7 @@
|
|||||||
background: @toolbar-green;
|
background: @toolbar-green;
|
||||||
border-color: @toolbar-green;
|
border-color: @toolbar-green;
|
||||||
&:hover {
|
&:hover {
|
||||||
|
color: #fff;
|
||||||
background: #449d44;
|
background: #449d44;
|
||||||
border: 1px solid #419641;
|
border: 1px solid #419641;
|
||||||
}
|
}
|
||||||
@@ -64,6 +65,7 @@
|
|||||||
background: #0275d8;
|
background: #0275d8;
|
||||||
border-color: #0275d8;
|
border-color: #0275d8;
|
||||||
&:hover {
|
&:hover {
|
||||||
|
color: #fff;
|
||||||
background: #025aa5;
|
background: #025aa5;
|
||||||
border: 1px solid #01549b;
|
border: 1px solid #01549b;
|
||||||
}
|
}
|
||||||
@@ -91,6 +93,48 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button.upgrade {
|
||||||
|
font-size: 14px;
|
||||||
|
vertical-align: top;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
.cryptpad-drive-limit {
|
||||||
|
display: inline-block;
|
||||||
|
height: 26px;
|
||||||
|
width: 200px;
|
||||||
|
margin: 2px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 1px solid #999;
|
||||||
|
background: white;
|
||||||
|
position: relative;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 24px;
|
||||||
|
.usage {
|
||||||
|
height: 24px;
|
||||||
|
display: inline-block;
|
||||||
|
background: blue;
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
z-index:1;
|
||||||
|
&.normal {
|
||||||
|
background: @toolbar-green;
|
||||||
|
}
|
||||||
|
&.warning {
|
||||||
|
background: orange;
|
||||||
|
}
|
||||||
|
&.above {
|
||||||
|
background: red;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.usageText {
|
||||||
|
position: relative;
|
||||||
|
color: black;
|
||||||
|
text-shadow: 1px 0 2px white, 0 1px 2px white, -1px 0 2px white, 0 -1px 2px white;
|
||||||
|
z-index: 2;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
.cryptpad-limit {
|
.cryptpad-limit {
|
||||||
box-sizing: content-box;
|
box-sizing: content-box;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
|
|||||||
@@ -132,6 +132,7 @@
|
|||||||
}
|
}
|
||||||
.cryptpad-toolbar button#shareButton:hover,
|
.cryptpad-toolbar button#shareButton:hover,
|
||||||
.cryptpad-toolbar button.buttonSuccess:hover {
|
.cryptpad-toolbar button.buttonSuccess:hover {
|
||||||
|
color: #fff;
|
||||||
background: #449d44;
|
background: #449d44;
|
||||||
border: 1px solid #419641;
|
border: 1px solid #419641;
|
||||||
}
|
}
|
||||||
@@ -151,6 +152,7 @@
|
|||||||
}
|
}
|
||||||
.cryptpad-toolbar button#newdoc:hover,
|
.cryptpad-toolbar button#newdoc:hover,
|
||||||
.cryptpad-toolbar button.buttonPrimary:hover {
|
.cryptpad-toolbar button.buttonPrimary:hover {
|
||||||
|
color: #fff;
|
||||||
background: #025aa5;
|
background: #025aa5;
|
||||||
border: 1px solid #01549b;
|
border: 1px solid #01549b;
|
||||||
}
|
}
|
||||||
@@ -170,6 +172,48 @@
|
|||||||
background-color: #e6e6e6;
|
background-color: #e6e6e6;
|
||||||
border-color: #adadad;
|
border-color: #adadad;
|
||||||
}
|
}
|
||||||
|
.cryptpad-toolbar button.upgrade {
|
||||||
|
font-size: 14px;
|
||||||
|
vertical-align: top;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
.cryptpad-toolbar .cryptpad-drive-limit {
|
||||||
|
display: inline-block;
|
||||||
|
height: 26px;
|
||||||
|
width: 200px;
|
||||||
|
margin: 2px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 1px solid #999;
|
||||||
|
background: white;
|
||||||
|
position: relative;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 24px;
|
||||||
|
}
|
||||||
|
.cryptpad-toolbar .cryptpad-drive-limit .usage {
|
||||||
|
height: 24px;
|
||||||
|
display: inline-block;
|
||||||
|
background: blue;
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
.cryptpad-toolbar .cryptpad-drive-limit .usage.normal {
|
||||||
|
background: #5cb85c;
|
||||||
|
}
|
||||||
|
.cryptpad-toolbar .cryptpad-drive-limit .usage.warning {
|
||||||
|
background: orange;
|
||||||
|
}
|
||||||
|
.cryptpad-toolbar .cryptpad-drive-limit .usage.above {
|
||||||
|
background: red;
|
||||||
|
}
|
||||||
|
.cryptpad-toolbar .cryptpad-drive-limit .usageText {
|
||||||
|
position: relative;
|
||||||
|
color: black;
|
||||||
|
text-shadow: 1px 0 2px white, 0 1px 2px white, -1px 0 2px white, 0 -1px 2px white;
|
||||||
|
z-index: 2;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
.cryptpad-toolbar .cryptpad-limit {
|
.cryptpad-toolbar .cryptpad-limit {
|
||||||
box-sizing: content-box;
|
box-sizing: content-box;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ define(function () {
|
|||||||
|
|
||||||
out.language = "Langue";
|
out.language = "Langue";
|
||||||
|
|
||||||
|
out.upgrade = "Améliorer";
|
||||||
|
out.upgradeTitle = "Améliorer votre compte pour augmenter la limite de stockage";
|
||||||
|
out.MB = "Mo";
|
||||||
|
|
||||||
out.greenLight = "Tout fonctionne bien";
|
out.greenLight = "Tout fonctionne bien";
|
||||||
out.orangeLight = "Votre connexion est lente, ce qui réduit la qualité de l'éditeur";
|
out.orangeLight = "Votre connexion est lente, ce qui réduit la qualité de l'éditeur";
|
||||||
out.redLight = "Vous êtes déconnectés de la session";
|
out.redLight = "Vous êtes déconnectés de la session";
|
||||||
|
|||||||
@@ -53,6 +53,10 @@ define(function () {
|
|||||||
|
|
||||||
out.language = "Language";
|
out.language = "Language";
|
||||||
|
|
||||||
|
out.upgrade = "Upgrade";
|
||||||
|
out.upgradeTitle = "Upgrade your account to increase the storage limit";
|
||||||
|
out.MB = "MB";
|
||||||
|
|
||||||
out.greenLight = "Everything is working fine";
|
out.greenLight = "Everything is working fine";
|
||||||
out.orangeLight = "Your slow connection may impact your experience";
|
out.orangeLight = "Your slow connection may impact your experience";
|
||||||
out.redLight = "You are disconnected from the session";
|
out.redLight = "You are disconnected from the session";
|
||||||
@@ -62,6 +66,8 @@ define(function () {
|
|||||||
"To fix this problem, you can either remove pads from your CryptDrive (including the trash) or subscribe to a premium offer to increase your limit.";
|
"To fix this problem, you can either remove pads from your CryptDrive (including the trash) or subscribe to a premium offer to increase your limit.";
|
||||||
out.pinLimitNotPinned = "You've reached your storage limit.<br>"+
|
out.pinLimitNotPinned = "You've reached your storage limit.<br>"+
|
||||||
"This pad is not stored in your CryptDrive.";
|
"This pad is not stored in your CryptDrive.";
|
||||||
|
out.pinLimitDrive = "You've reached your storage limit.<br>" +
|
||||||
|
"You can't create new pads.";
|
||||||
|
|
||||||
out.importButtonTitle = 'Import a pad from a local file';
|
out.importButtonTitle = 'Import a pad from a local file';
|
||||||
|
|
||||||
|
|||||||
@@ -576,7 +576,7 @@ define([
|
|||||||
var data = makePad(href, name);
|
var data = makePad(href, name);
|
||||||
getStore().pushData(data, function (e) {
|
getStore().pushData(data, function (e) {
|
||||||
if (e) {
|
if (e) {
|
||||||
if (e === 'E_OVER_LIMIT') {
|
if (e === 'E_OVER_LIMIT' && AppConfig.enablePinLimit) {
|
||||||
common.alert(Messages.pinLimitNotPinned, null, true);
|
common.alert(Messages.pinLimitNotPinned, null, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -725,14 +725,15 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
var isOverPinLimit = common.isOverPinLimit = function (cb) {
|
var isOverPinLimit = common.isOverPinLimit = function (cb) {
|
||||||
if (!common.isLoggedIn()) { return void cb(null, false); }
|
if (!common.isLoggedIn() || !AppConfig.enablePinLimit) { return void cb(null, false); }
|
||||||
var usage;
|
var usage;
|
||||||
var andThen = function (e, limit) {
|
var andThen = function (e, limit) {
|
||||||
if (e) { return void cb(e); }
|
if (e) { return void cb(e); }
|
||||||
|
var data = {usage: usage, limit: limit};
|
||||||
if (usage > limit) {
|
if (usage > limit) {
|
||||||
return void cb (null, true);
|
return void cb (null, true, data);
|
||||||
}
|
}
|
||||||
return void cb (null, false);
|
return void cb (null, false, data);
|
||||||
};
|
};
|
||||||
var todo = function (e, used) {
|
var todo = function (e, used) {
|
||||||
usage = common.bytesToMegabytes(used);
|
usage = common.bytesToMegabytes(used);
|
||||||
|
|||||||
@@ -570,19 +570,20 @@ define([
|
|||||||
var parentEl = findElement(files, filePath);
|
var parentEl = findElement(files, filePath);
|
||||||
var fileName = getAvailableName(parentEl, name || NEW_FILE_NAME);
|
var fileName = getAvailableName(parentEl, name || NEW_FILE_NAME);
|
||||||
var href = '/' + type + '/#' + Cryptpad.createRandomHash();
|
var href = '/' + type + '/#' + Cryptpad.createRandomHash();
|
||||||
parentEl[fileName] = href;
|
|
||||||
|
|
||||||
pushFileData({
|
pushFileData({
|
||||||
href: href,
|
href: href,
|
||||||
title: fileName,
|
title: fileName,
|
||||||
atime: +new Date(),
|
atime: +new Date(),
|
||||||
ctime: +new Date()
|
ctime: +new Date()
|
||||||
});
|
}, function (err) {
|
||||||
|
if (err) { return void cb(err); }
|
||||||
var newPath = filePath.slice();
|
parentEl[fileName] = href;
|
||||||
newPath.push(fileName);
|
var newPath = filePath.slice();
|
||||||
cb({
|
newPath.push(fileName);
|
||||||
newPath: newPath
|
cb(void 0, {
|
||||||
|
newPath: newPath
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var addFolder = exp.addFolder = function (folderPath, name, cb) {
|
var addFolder = exp.addFolder = function (folderPath, name, cb) {
|
||||||
@@ -591,7 +592,7 @@ define([
|
|||||||
parentEl[folderName] = {};
|
parentEl[folderName] = {};
|
||||||
var newPath = folderPath.slice();
|
var newPath = folderPath.slice();
|
||||||
newPath.push(folderName);
|
newPath.push(folderName);
|
||||||
cb({
|
cb(void 0, {
|
||||||
newPath: newPath
|
newPath: newPath
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ li {
|
|||||||
.contextMenu {
|
.contextMenu {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 50;
|
z-index: 500;
|
||||||
}
|
}
|
||||||
.contextMenu li {
|
.contextMenu li {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ li {
|
|||||||
.contextMenu {
|
.contextMenu {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 50;
|
z-index: 500;
|
||||||
li {
|
li {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ define([
|
|||||||
return JSONSortify(obj);
|
return JSONSortify(obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var LIMIT_REFRESH_RATE = 30000; // milliseconds
|
||||||
|
var E_OVER_LIMIT = 'E_OVER_LIMIT';
|
||||||
|
|
||||||
var SEARCH = "search";
|
var SEARCH = "search";
|
||||||
var SEARCH_NAME = Messages.fm_searchName;
|
var SEARCH_NAME = Messages.fm_searchName;
|
||||||
var ROOT = "root";
|
var ROOT = "root";
|
||||||
@@ -650,7 +653,12 @@ define([
|
|||||||
var w = $menu.outerWidth();
|
var w = $menu.outerWidth();
|
||||||
var wH = window.innerHeight;
|
var wH = window.innerHeight;
|
||||||
var wW = window.innerWidth;
|
var wW = window.innerWidth;
|
||||||
if (e.pageY + h <= wH) {
|
if (h > wH) {
|
||||||
|
$menu.css({
|
||||||
|
top: '0px',
|
||||||
|
bottom: ''
|
||||||
|
});
|
||||||
|
} else if (e.pageY + h <= wH) {
|
||||||
$menu.css({
|
$menu.css({
|
||||||
top: e.pageY+'px',
|
top: e.pageY+'px',
|
||||||
bottom: ''
|
bottom: ''
|
||||||
@@ -661,7 +669,12 @@ define([
|
|||||||
top: ''
|
top: ''
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (e.pageX + w <= wW) {
|
if(w > wW) {
|
||||||
|
$menu.css({
|
||||||
|
left: '0px',
|
||||||
|
right: ''
|
||||||
|
});
|
||||||
|
} else if (e.pageX + w <= wW) {
|
||||||
$menu.css({
|
$menu.css({
|
||||||
left: e.pageX+'px',
|
left: e.pageX+'px',
|
||||||
right: ''
|
right: ''
|
||||||
@@ -1229,7 +1242,10 @@ define([
|
|||||||
|
|
||||||
// Handlers
|
// Handlers
|
||||||
if (isInRoot) {
|
if (isInRoot) {
|
||||||
var onCreated = function (info) {
|
var onCreated = function (err, info) {
|
||||||
|
if (err && err === E_OVER_LIMIT) {
|
||||||
|
return void Cryptpad.alert(Messages.pinLimitDrive, null, true);
|
||||||
|
}
|
||||||
module.newFolder = info.newPath;
|
module.newFolder = info.newPath;
|
||||||
refresh();
|
refresh();
|
||||||
};
|
};
|
||||||
@@ -2074,7 +2090,8 @@ define([
|
|||||||
}
|
}
|
||||||
else if ($(this).hasClass('newfolder')) {
|
else if ($(this).hasClass('newfolder')) {
|
||||||
if (paths.length !== 1) { return; }
|
if (paths.length !== 1) { return; }
|
||||||
var onCreated = function (info) {
|
var onCreated = function (err, info) {
|
||||||
|
if (err) { return void logError(err); }
|
||||||
module.newFolder = info.newPath;
|
module.newFolder = info.newPath;
|
||||||
module.displayDirectory(paths[0].path);
|
module.displayDirectory(paths[0].path);
|
||||||
};
|
};
|
||||||
@@ -2135,7 +2152,10 @@ define([
|
|||||||
$contentContextMenu.on('click', 'a', function (e) {
|
$contentContextMenu.on('click', 'a', function (e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
var path = $(this).data('path');
|
var path = $(this).data('path');
|
||||||
var onCreated = function (info) {
|
var onCreated = function (err, info) {
|
||||||
|
if (err && err === E_OVER_LIMIT) {
|
||||||
|
return void Cryptpad.alert(Messages.pinLimitDrive, null, true);
|
||||||
|
}
|
||||||
module.newFolder = info.newPath;
|
module.newFolder = info.newPath;
|
||||||
refresh();
|
refresh();
|
||||||
};
|
};
|
||||||
@@ -2310,7 +2330,6 @@ define([
|
|||||||
window.clearInterval(APP.resizeTree);
|
window.clearInterval(APP.resizeTree);
|
||||||
APP.resizeTree = undefined;
|
APP.resizeTree = undefined;
|
||||||
});
|
});
|
||||||
console.log(files);
|
|
||||||
history.onEnterHistory = function (obj) {
|
history.onEnterHistory = function (obj) {
|
||||||
var files = obj.drive;
|
var files = obj.drive;
|
||||||
filesOp = FO.init(files, config);
|
filesOp = FO.init(files, config);
|
||||||
@@ -2452,6 +2471,7 @@ console.log(files);
|
|||||||
|
|
||||||
var $bar = APP.$bar;
|
var $bar = APP.$bar;
|
||||||
var $rightside = $bar.find('.' + Toolbar.constants.rightside);
|
var $rightside = $bar.find('.' + Toolbar.constants.rightside);
|
||||||
|
var $leftside = $bar.find('.' + Toolbar.constants.leftside);
|
||||||
var $userBlock = $bar.find('.' + Toolbar.constants.userAdmin);
|
var $userBlock = $bar.find('.' + Toolbar.constants.userAdmin);
|
||||||
APP.$displayName = $bar.find('.' + Toolbar.constants.username);
|
APP.$displayName = $bar.find('.' + Toolbar.constants.username);
|
||||||
|
|
||||||
@@ -2463,6 +2483,45 @@ console.log(files);
|
|||||||
$linkToMain.off('click');
|
$linkToMain.off('click');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* add the usage */
|
||||||
|
if (AppConfig.enablePinLimit) {
|
||||||
|
var todo = function (err, state, data) {
|
||||||
|
$leftside.html('');
|
||||||
|
if (!data) {
|
||||||
|
return void window.setTimeout(function () {
|
||||||
|
Cryptpad.isOverPinLimit(todo);
|
||||||
|
}, LIMIT_REFRESH_RATE);
|
||||||
|
}
|
||||||
|
var usage = data.usage;
|
||||||
|
var limit = data.limit;
|
||||||
|
var unit = Messages.MB;
|
||||||
|
var $limit = $('<span>', {'class': 'cryptpad-drive-limit'}).appendTo($leftside);
|
||||||
|
var quota = usage/limit;
|
||||||
|
var width = Math.floor(Math.min(quota, 1)*$limit.width());
|
||||||
|
var $usage = $('<span>', {'class': 'usage'}).css('width', width+'px');
|
||||||
|
|
||||||
|
if (quota >= 0.8) {
|
||||||
|
var $upgrade = $('<button>', {
|
||||||
|
'class': 'upgrade buttonSuccess',
|
||||||
|
title: Messages.upgradeTitle
|
||||||
|
}).text(Messages.upgrade).click(function (e) {
|
||||||
|
// TODO
|
||||||
|
}).appendTo($leftside);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quota < 0.8) { $usage.addClass('normal'); }
|
||||||
|
else if (quota < 1) { $usage.addClass('warning'); }
|
||||||
|
else { $usage.addClass('above'); }
|
||||||
|
var $text = $('<span>', {'class': 'usageText'});
|
||||||
|
$text.text(usage + ' / ' + limit + ' ' + unit);
|
||||||
|
$limit.append($usage).append($text);
|
||||||
|
window.setTimeout(function () {
|
||||||
|
Cryptpad.isOverPinLimit(todo);
|
||||||
|
}, LIMIT_REFRESH_RATE);
|
||||||
|
};
|
||||||
|
Cryptpad.isOverPinLimit(todo);
|
||||||
|
}
|
||||||
|
|
||||||
/* add a history button */
|
/* add a history button */
|
||||||
var histConfig = {};
|
var histConfig = {};
|
||||||
histConfig.onRender = function (val) {
|
histConfig.onRender = function (val) {
|
||||||
|
|||||||
Reference in New Issue
Block a user