New anonymous drive

pull/1/head
yflory 8 years ago
parent ed95bbb08f
commit 601226115b

@ -32,6 +32,7 @@ define(function () {
out.error = "Erreur"; out.error = "Erreur";
out.saved = "Enregistré"; out.saved = "Enregistré";
out.synced = "Tout est enregistré"; out.synced = "Tout est enregistré";
out.deleted = "Pad supprimé de votre CryptDrive";
out.disconnected = 'Déconnecté'; out.disconnected = 'Déconnecté';
out.synchronizing = 'Synchronisation'; out.synchronizing = 'Synchronisation';

@ -34,6 +34,7 @@ define(function () {
out.error = "Error"; out.error = "Error";
out.saved = "Saved"; out.saved = "Saved";
out.synced = "Everything is saved"; out.synced = "Everything is saved";
out.deleted = "Pad deleted from your CryptDrive";
out.disconnected = 'Disconnected'; out.disconnected = 'Disconnected';
out.synchronizing = 'Synchronizing'; out.synchronizing = 'Synchronizing';

@ -149,9 +149,7 @@ define([
left: true, // Open to the left of the button left: true, // Open to the left of the button
isSelect: true, isSelect: true,
}; };
console.log('here');
var $block = exp.$language = Cryptpad.createDropdown(dropdownConfig); var $block = exp.$language = Cryptpad.createDropdown(dropdownConfig);
console.log(exp);
$block.find('a').click(function () { $block.find('a').click(function () {
setMode($(this).attr('data-value'), $block); setMode($(this).attr('data-value'), $block);
onLocal(); onLocal();

@ -743,13 +743,13 @@ define([
common.updatePinLimit = function (cb) { common.updatePinLimit = function (cb) {
if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); } if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); }
rpc.getFileListSize(cb); rpc.updatePinLimits(cb);
}; };
common.getPinLimit = function (cb) { common.getPinLimit = function (cb) {
if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); } if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); }
rpc.getFileListSize(cb); cb(void 0, typeof(AppConfig.pinLimit) === 'number'? AppConfig.pinLimit: 1000);
//cb(void 0, typeof(AppConfig.pinLimit) === 'number'? AppConfig.pinLimit: 1000); //rpc.getLimit(cb); TODO
}; };
common.isOverPinLimit = function (cb) { common.isOverPinLimit = function (cb) {
@ -858,7 +858,8 @@ define([
if (callback) { if (callback) {
button.click(function() { button.click(function() {
var href = window.location.href; var href = window.location.href;
common.confirm(Messages.forgetPrompt, function (yes) { var msg = isLoggedIn() ? Messages.forgetPrompt : Messages.fm_removePermanentlyDialog;
common.confirm(msg, function (yes) {
if (!yes) { return; } if (!yes) { return; }
common.forgetPad(href, function (err) { common.forgetPad(href, function (err) {
if (err) { if (err) {
@ -877,7 +878,8 @@ define([
} else { } else {
callback(); callback();
} }
common.alert(Messages.movedToTrash, undefined, true); var cMsg = isLoggedIn() ? Messages.movedToTrash : Messages.deleted;
common.alert(cMsg, undefined, true);
return; return;
}); });
}); });

@ -539,6 +539,7 @@ define([
// ADD // ADD
var add = exp.add = function (data, path) { var add = exp.add = function (data, path) {
if (!Cryptpad.isLoggedIn()) { return; }
if (!data || typeof(data) !== "object") { return; } if (!data || typeof(data) !== "object") { return; }
var href = data.href; var href = data.href;
var name = data.title; var name = data.title;
@ -596,6 +597,18 @@ define([
// FORGET (move with href not path) // FORGET (move with href not path)
exp.forget = function (href) { exp.forget = function (href) {
if (!Cryptpad.isLoggedIn()) {
// delete permanently
var data = getFileData(href);
if (data) {
var i = find([FILES_DATA]).indexOf(data);
if (i !== -1) {
exp.removePadAttribute(href);
spliceFileData(i);
}
}
return;
}
var paths = findFile(href); var paths = findFile(href);
move(paths, [TRASH]); move(paths, [TRASH]);
}; };
@ -603,7 +616,7 @@ define([
// DELETE // DELETE
// Permanently delete multiple files at once using a list of paths // Permanently delete multiple files at once using a list of paths
// NOTE: We have to be careful when removing elements from arrays (trash root, unsorted or template) // NOTE: We have to be careful when removing elements from arrays (trash root, unsorted or template)
var removePadAttribute = function (f) { var removePadAttribute = exp.removePadAttribute = function (f) {
if (typeof(f) !== 'string') { if (typeof(f) !== 'string') {
console.error("Can't find pad attribute for an undefined pad"); console.error("Can't find pad attribute for an undefined pad");
return; return;
@ -619,7 +632,7 @@ define([
}; };
var checkDeletedFiles = function () { var checkDeletedFiles = function () {
// Nothing in FILES_DATA for workgroups // Nothing in FILES_DATA for workgroups
if (workgroup) { return; } if (workgroup || !Cryptpad.isLoggedIn()) { return; }
var filesList = getFiles([ROOT, 'hrefArray', TRASH]); var filesList = getFiles([ROOT, 'hrefArray', TRASH]);
var toRemove = []; var toRemove = [];
@ -654,6 +667,23 @@ define([
var hrefPaths = paths.filter(function(x) { return isPathIn(x, ['hrefArray']); }); var hrefPaths = paths.filter(function(x) { return isPathIn(x, ['hrefArray']); });
var rootPaths = paths.filter(function(x) { return isPathIn(x, [ROOT]); }); var rootPaths = paths.filter(function(x) { return isPathIn(x, [ROOT]); });
var trashPaths = paths.filter(function(x) { return isPathIn(x, [TRASH]); }); var trashPaths = paths.filter(function(x) { return isPathIn(x, [TRASH]); });
var allFilesPaths = paths.filter(function(x) { return isPathIn(x, [FILES_DATA]); });
if (!Cryptpad.isLoggedIn()) {
var toSplice = [];
allFilesPaths.forEach(function (path) {
var el = find(path);
toSplice.push(el);
});
toSplice.forEach(function (el) {
var i = find([FILES_DATA]).indexOf(el);
if (i === -1) { return; }
removePadAttribute(el.href);
console.log(el.href);
spliceFileData(i);
});
return;
}
var hrefs = []; var hrefs = [];
hrefPaths.forEach(function (path) { hrefPaths.forEach(function (path) {
@ -882,7 +912,7 @@ define([
toClean.push(el); toClean.push(el);
return; return;
} }
if (rootFiles.indexOf(el.href) === -1) { if (Cryptpad.isLoggedIn() && rootFiles.indexOf(el.href) === -1) {
debug("An element in filesData was not in ROOT, TEMPLATE or TRASH.", el); debug("An element in filesData was not in ROOT, TEMPLATE or TRASH.", el);
var name = el.title || NEW_FILE_NAME; var name = el.title || NEW_FILE_NAME;
var newName = getAvailableName(root, name); var newName = getAvailableName(root, name);

@ -154,6 +154,9 @@ span.fa-folder-open {
min-width: 30px; min-width: 30px;
cursor: pointer; cursor: pointer;
} }
#tree #allfilesTree {
margin-top: 0;
}
#tree #searchContainer { #tree #searchContainer {
text-align: center; text-align: center;
padding: 5px 0; padding: 5px 0;

@ -194,6 +194,9 @@ span {
} }
} }
} }
#allfilesTree {
margin-top: 0;
}
#searchContainer { #searchContainer {
text-align: center; text-align: center;
padding: 5px 0; padding: 5px 0;

@ -205,7 +205,6 @@ define([
var $trashTreeContextMenu = $iframe.find("#trashTreeContextMenu"); var $trashTreeContextMenu = $iframe.find("#trashTreeContextMenu");
var $trashContextMenu = $iframe.find("#trashContextMenu"); var $trashContextMenu = $iframe.find("#trashContextMenu");
// TOOLBAR // TOOLBAR
/* add a "change username" button */ /* add a "change username" button */
@ -227,10 +226,14 @@ define([
if (AppConfig.enableTemplates) { displayedCategories.push(TEMPLATE); } if (AppConfig.enableTemplates) { displayedCategories.push(TEMPLATE); }
if (isWorkgroup()) { displayedCategories = [ROOT, TRASH, SEARCH]; } if (isWorkgroup()) { displayedCategories = [ROOT, TRASH, SEARCH]; }
if (!Cryptpad.isLoggedIn()) {
displayedCategories = [FILES_DATA];
currentPath = [FILES_DATA];
}
if (!APP.readOnly) { if (!APP.readOnly) {
setEditable(true); setEditable(true);
} }
var appStatus = { var appStatus = {
isReady: true, isReady: true,
_onReady: [], _onReady: [],
@ -1811,6 +1814,7 @@ define([
module.resetTree(); module.resetTree();
if (displayedCategories.indexOf(SEARCH) !== -1) {
// in history mode we want to focus the version number input // in history mode we want to focus the version number input
if (!history.isHistoryMode && !APP.mobile()) { if (!history.isHistoryMode && !APP.mobile()) {
var st = $tree.scrollTop() || 0; var st = $tree.scrollTop() || 0;
@ -1819,6 +1823,7 @@ define([
} }
$tree.find('#searchInput')[0].selectionStart = getSearchCursor(); $tree.find('#searchInput')[0].selectionStart = getSearchCursor();
$tree.find('#searchInput')[0].selectionEnd = getSearchCursor(); $tree.find('#searchInput')[0].selectionEnd = getSearchCursor();
}
if (!isWorkgroup()) { if (!isWorkgroup()) {
setLastOpenedFolder(path); setLastOpenedFolder(path);
@ -2310,6 +2315,19 @@ define([
else if ($(this).hasClass('delete')) { else if ($(this).hasClass('delete')) {
var pathsList = []; var pathsList = [];
paths.forEach(function (p) { pathsList.push(p.path); }); paths.forEach(function (p) { pathsList.push(p.path); });
if (!Cryptpad.isLoggedIn()) {
console.log(paths);
var msg = Messages._getKey("fm_removeSeveralPermanentlyDialog", [paths.length]);
if (paths.length === 1) {
msg = Messages.fm_removePermanentlyDialog;
}
Cryptpad.confirm(msg, function(res) {
$(ifrw).focus();
if (!res) { return; }
filesOp.delete(pathsList, refresh);
});
return;
}
moveElements(pathsList, [TRASH], false, refresh); moveElements(pathsList, [TRASH], false, refresh);
} }
else if ($(this).hasClass("properties")) { else if ($(this).hasClass("properties")) {
@ -2432,7 +2450,9 @@ define([
$appContainer.on('keydown', function (e) { $appContainer.on('keydown', function (e) {
// "Del" // "Del"
if (e.which === 46) { if (e.which === 46) {
if (filesOp.isPathIn(currentPath, [FILES_DATA])) { return; } // We can't remove elements directly from filesData if (filesOp.isPathIn(currentPath, [FILES_DATA]) && Cryptpad.isLoggedIn()) {
return; // We can't remove elements directly from filesData
}
var $selected = $iframe.find('.selected'); var $selected = $iframe.find('.selected');
if (!$selected.length) { return; } if (!$selected.length) { return; }
var paths = []; var paths = [];
@ -2442,7 +2462,7 @@ define([
paths.push($(elmt).data('path')); paths.push($(elmt).data('path'));
}); });
// If we are in the trash or anon pad or if we are holding the "shift" key, delete permanently, // If we are in the trash or anon pad or if we are holding the "shift" key, delete permanently,
if (isTrash || e.shiftKey) { if (!Cryptpad.isLoggedIn() || isTrash || e.shiftKey) {
var msg = Messages._getKey("fm_removeSeveralPermanentlyDialog", [paths.length]); var msg = Messages._getKey("fm_removeSeveralPermanentlyDialog", [paths.length]);
if (paths.length === 1) { if (paths.length === 1) {
msg = Messages.fm_removePermanentlyDialog; msg = Messages.fm_removePermanentlyDialog;

Loading…
Cancel
Save