Enable drag & upload in code2 and prepare filepicker

This commit is contained in:
yflory
2017-08-31 16:32:26 +02:00
parent 885282ddea
commit 89b7b644f3
13 changed files with 797 additions and 118 deletions

View File

@@ -723,7 +723,7 @@ define([
var proxy = store.getProxy();
var fo = proxy.fo;
var hashes = [];
var list = fo.getFiles().filter(function (id) {
var list = fo.getFiles([fo.ROOT]).filter(function (id) {
var href = fo.getFileData(id).href;
var parsed = parsePadUrl(href);
if ((parsed.type === 'file' || parsed.type === 'media')
@@ -734,6 +734,26 @@ define([
});
return list;
};
// Needed for the secure filepicker app
common.getSecureFilesList = function (cb) {
var store = common.getStore();
if (!store) { return void cb("Store is not ready"); }
var proxy = store.getProxy();
var fo = proxy.fo;
var list = {};
var hashes = [];
fo.getFiles([fo.ROOT]).forEach(function (id) {
var data = fo.getFileData(id);
var parsed = parsePadUrl(data.href);
if ((parsed.type === 'file' || parsed.type === 'media')
&& hashes.indexOf(parsed.hash) === -1) {
hashes.push(parsed.hash);
list[id] = data;
}
});
console.log(list);
cb (null, list);
};
var getUserChannelList = common.getUserChannelList = function () {
var store = common.getStore();
@@ -953,6 +973,9 @@ define([
rpc.uploadCancel(cb);
};
common.uploadFileSecure = Files.upload;
/* Create a usage bar which keeps track of how much storage space is used
by your CryptDrive. The getPinnedUsage RPC is one of the heavier calls,
so we throttle its usage. Clients will not update more than once per
@@ -1414,7 +1437,7 @@ define([
};
// This is duplicated in drive/main.js, it should be unified
var getFileIcon = function (data) {
var getFileIcon = common.getFileIcon = function (data) {
var $icon = common.getIcon();
if (!data) { return $icon; }