Move the file manager into /drive and add a toolbar
parent
6106f7d6ca
commit
d5561910d4
|
@ -4,7 +4,7 @@ define([
|
|||
'/bower_components/chainpad-listmap/chainpad-listmap.js',
|
||||
'/bower_components/chainpad-crypto/crypto.js',
|
||||
'/bower_components/textpatcher/TextPatcher.amd.js',
|
||||
'/file/fileObject.js'
|
||||
'/common/fileObject.js'
|
||||
], function (Config, Messages, Listmap, Crypto, TextPatcher, FO) {
|
||||
/*
|
||||
This module uses localStorage, which is synchronous, but exposes an
|
||||
|
|
|
@ -170,7 +170,7 @@ define(function () {
|
|||
|
||||
// File manager
|
||||
|
||||
out.fm_rootName = "Mes documents";
|
||||
out.fm_rootName = "Documents";
|
||||
out.fm_trashName = "Corbeille";
|
||||
out.fm_unsortedName = "Fichiers non triés";
|
||||
out.fm_filesDataName = "Tous les fichiers";
|
||||
|
@ -185,6 +185,7 @@ define(function () {
|
|||
out.fm_creation = "Création";
|
||||
out.fm_forbidden = "Action interdite";
|
||||
out.fm_originalPath = "Chemin d'origine";
|
||||
out.fm_noname = "Document sans titre";
|
||||
out.fm_emptyTrashDialog = "Êtes-vous sûr de vouloir vider la corbeille ?";
|
||||
out.fm_removeSeveralPermanentlyDialog = "Êtes-vous sûr de vouloir supprimer ces {0} éléments de manière permanente ?";
|
||||
out.fm_removePermanentlyDialog = "Êtes-vous sûr de vouloir supprimer {0} de manière permanente ?";
|
||||
|
@ -195,9 +196,9 @@ define(function () {
|
|||
out.fm_contextMenuError = "Impossible d'ouvrir le menu contextuel pour cet élément. Si le problème persiste, essayez de rechercher la page.";
|
||||
out.fm_selectError = "Impossible de sélectionner l'élément ciblé. Si le problème persiste, essayez de recharger la page.";
|
||||
out.fm_info_root = "Créez ici autant de dossiers que vous le souhaitez pour trier vos fichiers.";
|
||||
out.fm_info_unsorted = 'Contient tous les documents que vous avez ouvert et qui ne sont pas triés dans "Mes documents" ou déplacés vers la "Corbeille".'; // "My Documents" should match with the "out.fm_rootName" key, and "Trash" with "out.fm_trashName"
|
||||
out.fm_info_unsorted = 'Contient tous les documents que vous avez ouvert et qui ne sont pas triés dans "Documents" ou déplacés vers la "Corbeille".'; // "My Documents" should match with the "out.fm_rootName" key, and "Trash" with "out.fm_trashName"
|
||||
out.fm_info_trash = 'Les fichiers supprimés dans la corbeille sont également enlevés de "Tous les fichiers" et il est impossible de les récupérer depuis l\'explorateur de fichiers.'; // Same here for "All files" and "out.fm_filesDataName"
|
||||
out.fm_info_allFiles = 'Contient tous les fichiers de "Mes documents", "Fichiers non triés" et "Corbeille". Vous ne pouvez pas supprimer ou déplacer des fichiers d\'ici.'; // Same here
|
||||
out.fm_info_allFiles = 'Contient tous les fichiers de "Documents", "Fichiers non triés" et "Corbeille". Vous ne pouvez pas supprimer ou déplacer des fichiers d\'ici.'; // Same here
|
||||
// File - Context menu
|
||||
out.fc_newfolder = "Nouveau dossier";
|
||||
out.fc_rename = "Renommer";
|
||||
|
@ -234,10 +235,10 @@ define(function () {
|
|||
out.table_created = 'Créé le';
|
||||
out.table_last = 'Dernier accès';
|
||||
|
||||
out.button_newpad = 'CRÉER UN PAD WYSIWYG';
|
||||
out.button_newcode = 'CRÉER UN PAD DE CODE';
|
||||
out.button_newpoll = 'CRÉER UN SONDAGE';
|
||||
out.button_newslide = 'CRÉER UNE PRÉSENTATION';
|
||||
out.button_newpad = 'NOUVEAU DOCUMENT TEXTE';
|
||||
out.button_newcode = 'NOUVELLE PAGE DE CODE';
|
||||
out.button_newpoll = 'NOUVEAU SONDAGE';
|
||||
out.button_newslide = 'NOUVELLE PRÉSENTATION';
|
||||
|
||||
// privacy.html
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ define(function () {
|
|||
out.main_slogan = "Unity is Strength - Collaboration is Key";
|
||||
|
||||
out.type = {};
|
||||
out.type.pad = 'Pad';
|
||||
out.type.pad = 'Rich text';
|
||||
out.type.code = 'Code';
|
||||
out.type.poll = 'Poll';
|
||||
out.type.slide = 'Presentation';
|
||||
|
@ -171,7 +171,7 @@ define(function () {
|
|||
|
||||
// File manager
|
||||
|
||||
out.fm_rootName = "My documents";
|
||||
out.fm_rootName = "Documents";
|
||||
out.fm_trashName = "Trash";
|
||||
out.fm_unsortedName = "Unsorted files";
|
||||
out.fm_filesDataName = "All files";
|
||||
|
@ -187,6 +187,7 @@ define(function () {
|
|||
out.fm_creation = "Creation";
|
||||
out.fm_forbidden = "Forbidden action";
|
||||
out.fm_originalPath = "Original path";
|
||||
out.fm_noname = "Untitled Document";
|
||||
out.fm_emptyTrashDialog = "Are you sure you want to empty the trash?";
|
||||
out.fm_removeSeveralPermanentlyDialog = "Are you sure you want to remove these {0} elements from the trash permanently?";
|
||||
out.fm_removePermanentlyDialog = "Are you sure you want to remove {0} permanently?";
|
||||
|
@ -197,9 +198,9 @@ define(function () {
|
|||
out.fm_contextMenuError = "Unable to open the context menu for that element. If the problem persist, try to reload the page.";
|
||||
out.fm_selectError = "Unable to select the targetted element. If the problem persist, try to reload the page.";
|
||||
out.fm_info_root = "Create as many nested folders here as you want to sort your files.";
|
||||
out.fm_info_unsorted = 'Contains all the files you\'ve visited that are not yet sorted in "My Documents" or moved to the "Trash".'; // "My Documents" should match with the "out.fm_rootName" key, and "Trash" with "out.fm_trashName"
|
||||
out.fm_info_unsorted = 'Contains all the files you\'ve visited that are not yet sorted in "Documents" or moved to the "Trash".'; // "My Documents" should match with the "out.fm_rootName" key, and "Trash" with "out.fm_trashName"
|
||||
out.fm_info_trash = 'Files deleted from the trash are also removed from "All files" and it is impossible to recover them from the file manager.'; // Same here for "All files" and "out.fm_filesDataName"
|
||||
out.fm_info_allFiles = 'Contains all the files from "My Documents", "Unsorted" and "Trash". You can\'t move or remove files from here.'; // Same here
|
||||
out.fm_info_allFiles = 'Contains all the files from "Documents", "Unsorted" and "Trash". You can\'t move or remove files from here.'; // Same here
|
||||
// File - Context menu
|
||||
out.fc_newfolder = "New folder";
|
||||
out.fc_rename = "Rename";
|
||||
|
|
|
@ -264,6 +264,14 @@ define([
|
|||
if (idx !== -1) {
|
||||
debug("Removing", f, "from filesData");
|
||||
files[FILES_DATA].splice(idx, 1);
|
||||
Object.keys(files).forEach(function (key) {
|
||||
var hash = f.href.indexOf('#') !== -1 ? f.href.slice(f.href.indexOf('#') + 1) : null;
|
||||
if (hash && key.indexOf(hash) === 0) {
|
||||
debug("Deleting pad attribute in the realtime object");
|
||||
files[key] = undefined;
|
||||
delete files[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
|
@ -184,6 +184,7 @@ li {
|
|||
|
||||
#content h1 {
|
||||
padding-left: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#content .info-box {
|
||||
|
@ -325,3 +326,31 @@ li {
|
|||
display: inline;
|
||||
}
|
||||
}
|
||||
|
||||
/* Toolbar */
|
||||
|
||||
#driveToolbar {
|
||||
background: #ccc;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.newPadContainer {
|
||||
display: inline-block;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
button.newElement {
|
||||
border-radius: 0px;
|
||||
height: 30px;
|
||||
margin: 5px 5px;
|
||||
background: #888;
|
||||
color: #eee;
|
||||
font-size: 15px;
|
||||
border: none;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
button.newElement:hover {
|
||||
box-shadow: 0px 0px 2px #000;
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="cp">
|
||||
<head>
|
||||
<title>CryptFiles</title>
|
||||
<title>CryptDrive</title>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
||||
<link rel="icon" type="image/png"
|
||||
href="/customize/main-favicon.png"
|
|
@ -7,9 +7,10 @@ define([
|
|||
'/customize/messages.js?app=file',
|
||||
'json.sortify',
|
||||
'/common/cryptpad-common.js',
|
||||
'/file/fileObject.js',
|
||||
'/common/fileObject.js',
|
||||
'/common/toolbar.js',
|
||||
], function (Config, Listmap, Crypto, TextPatcher, Messages, JSONSortify, Cryptpad, FO, Toolbar) {
|
||||
'/customize/application_config.js'
|
||||
], function (Config, Listmap, Crypto, TextPatcher, Messages, JSONSortify, Cryptpad, FO, Toolbar, AppConfig) {
|
||||
var module = window.MODULE = {};
|
||||
|
||||
var $ = window.jQuery;
|
||||
|
@ -144,10 +145,13 @@ define([
|
|||
};
|
||||
|
||||
var init = function (files) {
|
||||
var ownFileManager = function () {
|
||||
var isOwnDrive = function () {
|
||||
return Cryptpad.getUserHash() === APP.hash || localStorage.FS_hash === APP.hash;
|
||||
};
|
||||
config.workgroup = !ownFileManager();
|
||||
var isWorkgroup = function () {
|
||||
return files.workgroup == 1;
|
||||
};
|
||||
config.workgroup = isWorkgroup();
|
||||
|
||||
var filesOp = FO.init(files, config);
|
||||
filesOp.fixFiles();
|
||||
|
@ -195,7 +199,8 @@ define([
|
|||
});
|
||||
|
||||
// FILE MANAGER
|
||||
var currentPath = module.currentPath = getLastOpenedFolder();
|
||||
// _WORKGROUP_ and other people drive : display Documents as main page
|
||||
var currentPath = module.currentPath = isOwnDrive() ? getLastOpenedFolder() : [ROOT];
|
||||
var lastSelectTime;
|
||||
var selectedElement;
|
||||
|
||||
|
@ -371,7 +376,7 @@ define([
|
|||
if (!APP.editable) {
|
||||
$menu.find('a.editable').parent('li').hide();
|
||||
}
|
||||
if (!ownFileManager()) {
|
||||
if (!isOwnDrive()) {
|
||||
$menu.find('a.own').parent('li').hide();
|
||||
}
|
||||
|
||||
|
@ -439,7 +444,7 @@ define([
|
|||
if (!APP.editable) {
|
||||
$menu.find('a.editable').parent('li').hide();
|
||||
}
|
||||
if (!ownFileManager()) {
|
||||
if (!isOwnDrive()) {
|
||||
$menu.find('a.own').parent('li').hide();
|
||||
}
|
||||
|
||||
|
@ -613,6 +618,7 @@ define([
|
|||
};
|
||||
|
||||
// In list mode, display metadata from the filesData object
|
||||
// _WORKGROUP_ : Do not display title, atime and ctime columns since we don't have files data
|
||||
var addFileData = function (element, key, $span, displayTitle) {
|
||||
if (!filesOp.isFile(element)) { return; }
|
||||
|
||||
|
@ -631,11 +637,11 @@ define([
|
|||
var $type = $('<span>', {'class': 'type listElement', title: type}).text(type);
|
||||
var $adate = $('<span>', {'class': 'atime listElement', title: getDate(data.atime)}).text(getDate(data.atime));
|
||||
var $cdate = $('<span>', {'class': 'ctime listElement', title: getDate(data.ctime)}).text(getDate(data.ctime));
|
||||
if (displayTitle && ownFileManager()) {
|
||||
if (displayTitle && !isWorkgroup()) {
|
||||
$span.append($title);
|
||||
}
|
||||
$span.append($type);
|
||||
if (ownFileManager()) {
|
||||
if (!isWorkgroup()) {
|
||||
$span.append($adate).append($cdate);
|
||||
}
|
||||
};
|
||||
|
@ -833,12 +839,8 @@ define([
|
|||
};
|
||||
|
||||
var createNewFolderButton = function () {
|
||||
var $block = $('<div>', {
|
||||
'class': 'btn-group topButtonContainer newFolderButtonContainer'
|
||||
});
|
||||
|
||||
var $listButton = $('<button>', {
|
||||
'class': 'btn'
|
||||
'class': 'newElement'
|
||||
}).text(Messages.fm_newFolderButton);
|
||||
|
||||
$listButton.click(function () {
|
||||
|
@ -849,7 +851,23 @@ define([
|
|||
filesOp.createNewFolder(currentPath, null, onCreated);
|
||||
});
|
||||
|
||||
$block.append($listButton);
|
||||
|
||||
return $listButton;
|
||||
};
|
||||
|
||||
var createNewPadButtons = function () {
|
||||
var $block = $('<div>', { 'class': 'newPadContainer'});
|
||||
AppConfig.availablePadTypes.forEach(function (type) {
|
||||
var $button = $('<button>', {
|
||||
'class': 'newElement'
|
||||
}).text(Messages['button_new' + type]);
|
||||
|
||||
$button.click(function () {
|
||||
//TODO
|
||||
});
|
||||
|
||||
$block.append($button);
|
||||
});
|
||||
return $block;
|
||||
};
|
||||
|
||||
|
@ -932,6 +950,7 @@ define([
|
|||
$list.find('.' + classSorted).prepend($icon);
|
||||
}
|
||||
};
|
||||
// _WORKGROUP_ : do not display title, atime and ctime in workgroups since we don't have files data
|
||||
var getFileListHeader = function (displayTitle) {
|
||||
var $fileHeader = $('<li>', {'class': 'file-header header listElement'});
|
||||
var $fihElement = $('<span>', {'class': 'element'}).appendTo($fileHeader);
|
||||
|
@ -941,11 +960,11 @@ define([
|
|||
var $fhAdate = $('<span>', {'class': 'atime'}).text(Messages.fm_lastAccess).click(onSortByClick);
|
||||
var $fhCdate = $('<span>', {'class': 'ctime'}).text(Messages.fm_creation).click(onSortByClick);
|
||||
$fihElement.append($fhName);
|
||||
if (displayTitle && ownFileManager()) {
|
||||
if (displayTitle && !isWorkgroup()) {
|
||||
$fihElement.append($fhTitle);
|
||||
}
|
||||
$fihElement.append($fhType);
|
||||
if (ownFileManager()) {
|
||||
if (!isWorkgroup()) {
|
||||
$fihElement.append($fhAdate).append($fhCdate);
|
||||
}
|
||||
addFileSortIcon($fihElement);
|
||||
|
@ -971,14 +990,21 @@ define([
|
|||
if (prop) {
|
||||
var element = useHref || useData ? el : root[el];
|
||||
var e = useData ? element : filesOp.getFileData(element);
|
||||
if (!e) {
|
||||
e = {
|
||||
title : Messages.fm_noname,
|
||||
atime : 0,
|
||||
ctime : 0
|
||||
}
|
||||
}
|
||||
if (prop === 'type') {
|
||||
var hrefData = Cryptpad.parsePadUrl(e.href);
|
||||
var hrefData = Cryptpad.parsePadUrl(el);
|
||||
return hrefData.type;
|
||||
}
|
||||
if (prop === 'atime' || prop === 'ctime') {
|
||||
return new Date(e[prop]);
|
||||
}
|
||||
return e.title.toLowerCase();
|
||||
return e && e.title ? e.title.toLowerCase() : '';
|
||||
}
|
||||
return useData ? el.title.toLowerCase() : el.toLowerCase();
|
||||
};
|
||||
|
@ -1015,6 +1041,15 @@ define([
|
|||
});
|
||||
return keys;
|
||||
};
|
||||
|
||||
// Drive content toolbar
|
||||
var createToolbar = function (path) {
|
||||
var $toolbar = $('<div>', {
|
||||
id: 'driveToolbar'
|
||||
});
|
||||
return $toolbar;
|
||||
};
|
||||
|
||||
// Unsorted element are represented by "href" in an array: they don't have a filename
|
||||
// and they don't hav a hierarchical structure (folder/subfolders)
|
||||
var displayHrefArray = function ($container, rootName) {
|
||||
|
@ -1029,8 +1064,9 @@ define([
|
|||
sortedFiles.forEach(function (href) {
|
||||
var file = filesOp.getFileData(href);
|
||||
if (!file) {
|
||||
debug("Unsorted or template returns an element not present in filesData: ", href);
|
||||
return;
|
||||
//debug("Unsorted or template returns an element not present in filesData: ", href);
|
||||
file = { title: Messages.fm_noname };
|
||||
//return;
|
||||
}
|
||||
var idx = files[rootName].indexOf(href);
|
||||
var $icon = $fileIcon.clone();
|
||||
|
@ -1118,7 +1154,7 @@ define([
|
|||
var displayDirectory = module.displayDirectory = function (path, force) {
|
||||
if (!appStatus.isReady && !force) { return; }
|
||||
// Only Trash and Root are available in not-owned files manager
|
||||
if (!ownFileManager() && !filesOp.isPathInTrash(path) && !filesOp.isPathInRoot(path)) {
|
||||
if (isWorkgroup() && !filesOp.isPathInTrash(path) && !filesOp.isPathInRoot(path)) {
|
||||
log("TRANSLATE or REMOVE: Unable to open the selected category, displaying root"); //TODO translate
|
||||
currentPath = [ROOT];
|
||||
displayDirectory(currentPath);
|
||||
|
@ -1149,6 +1185,7 @@ define([
|
|||
|
||||
setLastOpenedFolder(path);
|
||||
|
||||
var $toolbar = createToolbar(path);
|
||||
var $title = createTitle(path);
|
||||
var $info = createInfoBox(path);
|
||||
|
||||
|
@ -1166,7 +1203,8 @@ define([
|
|||
return;
|
||||
}*/
|
||||
|
||||
var $modeButton = createViewModeButton().appendTo($title);
|
||||
var $modeButton = createViewModeButton().appendTo($toolbar);
|
||||
// createNewPadButtons().appendTo($toolbar);
|
||||
|
||||
var $folderHeader = getFolderListHeader();
|
||||
var $fileHeader = getFileListHeader(true);
|
||||
|
@ -1179,7 +1217,7 @@ define([
|
|||
displayTrashRoot($list, $folderHeader, $fileHeader);
|
||||
} else {
|
||||
$dirContent.contextmenu(openContentContextMenu);
|
||||
var $newFolderButton = createNewFolderButton().appendTo($title);
|
||||
var $newFolderButton = createNewFolderButton().appendTo($toolbar);
|
||||
if (filesOp.hasSubfolder(root)) { $list.append($folderHeader); }
|
||||
// display sub directories
|
||||
var keys = Object.keys(root);
|
||||
|
@ -1198,7 +1236,7 @@ define([
|
|||
$element.appendTo($list);
|
||||
});
|
||||
}
|
||||
$content.append($title).append($info).append($dirContent);
|
||||
$content.append($toolbar).append($title).append($info).append($dirContent);
|
||||
appStatus.ready(true);
|
||||
};
|
||||
|
||||
|
@ -1349,7 +1387,7 @@ define([
|
|||
var resetTree = module.resetTree = function () {
|
||||
$tree.html('');
|
||||
createTree($tree, [ROOT]);
|
||||
if (ownFileManager()) {
|
||||
if (!isWorkgroup()) {
|
||||
createUnsorted($tree, [UNSORTED]);
|
||||
createTemplate($tree, [TEMPLATE]);
|
||||
createAllFiles($tree, [FILES_DATA]);
|
||||
|
@ -1533,7 +1571,7 @@ define([
|
|||
}
|
||||
// If we are already in the trash, delete the elements permanently
|
||||
var msg = Messages._getKey("fm_removeSeveralPermanentlyDialog", [paths.length]);
|
||||
if (paths.length === 1) {
|
||||
if (paths.length === 1) { // If we delete only one element, display its name in the popup
|
||||
var path = paths[0];
|
||||
var element = filesOp.findElement(files, path);
|
||||
var name = filesOp.isInTrashRoot(path) ? path[1] : (filesOp.isPathInHrefArray(path) ? filesOp.getTitle(element) : path[path.length - 1]);
|
Loading…
Reference in New Issue