mirror of https://github.com/xwiki-labs/cryptpad
Add progress when creating a pad from a file
This commit is contained in:
parent
1ac6b84c6d
commit
3f88e29f30
|
@ -279,7 +279,7 @@ button:not(.btn).primary:hover{
|
|||
var built = false;
|
||||
|
||||
var types = ['less', 'drive', 'migrate', 'sf', 'team', 'pad', 'end'];
|
||||
var current;
|
||||
var current, progress;
|
||||
var makeList = function (data) {
|
||||
var c = types.indexOf(data.type);
|
||||
current = c;
|
||||
|
@ -295,7 +295,7 @@ button:not(.btn).primary:hover{
|
|||
};
|
||||
var list = '<ul>';
|
||||
types.forEach(function (el, i) {
|
||||
if (i >= 6) { return; }
|
||||
if (el === "end") { return; }
|
||||
list += getLi(i);
|
||||
});
|
||||
list += '</ul>';
|
||||
|
@ -303,7 +303,7 @@ button:not(.btn).primary:hover{
|
|||
};
|
||||
var makeBar = function (data) {
|
||||
var c = types.indexOf(data.type);
|
||||
var l = types.length;
|
||||
var l = types.length - 1; // don't count "end" as a type
|
||||
var progress = Math.min(data.progress, 100);
|
||||
var p = (progress / l) + (100 * c / l);
|
||||
var bar = '<div class="cp-loading-progress-bar">'+
|
||||
|
@ -315,8 +315,13 @@ button:not(.btn).primary:hover{
|
|||
var hasErrored = false;
|
||||
var updateLoadingProgress = function (data) {
|
||||
if (!built || !data) { return; }
|
||||
|
||||
// Make sure progress doesn't go backward
|
||||
var c = types.indexOf(data.type);
|
||||
if (c < current) { return console.error(data); }
|
||||
if (c === current && progress > data.progress) { return console.error(data); }
|
||||
progress = data.progress;
|
||||
|
||||
try {
|
||||
document.querySelector('.cp-loading-spinner-container').style.display = 'none';
|
||||
document.querySelector('.cp-loading-progress-list').innerHTML = makeList(data);
|
||||
|
|
|
@ -701,7 +701,7 @@ define([
|
|||
});
|
||||
};
|
||||
|
||||
common.useFile = function (Crypt, cb, optsPut) {
|
||||
common.useFile = function (Crypt, cb, optsPut, onProgress) {
|
||||
var fileHost = Config.fileHost || window.location.origin;
|
||||
var data = common.fromFileData;
|
||||
var parsed = Hash.parsePadUrl(data.href);
|
||||
|
@ -758,7 +758,9 @@ define([
|
|||
return void cb(err);
|
||||
}
|
||||
u8 = _u8;
|
||||
}));
|
||||
}), function (progress) {
|
||||
onProgress(progress * 50);
|
||||
});
|
||||
}).nThen(function (waitFor) {
|
||||
require(["/file/file-crypto.js"], waitFor(function (FileCrypto) {
|
||||
FileCrypto.decrypt(u8, key, waitFor(function (err, _res) {
|
||||
|
@ -767,7 +769,9 @@ define([
|
|||
return void cb(err);
|
||||
}
|
||||
res = _res;
|
||||
}));
|
||||
}), function (progress) {
|
||||
onProgress(50 + progress * 50);
|
||||
});
|
||||
}));
|
||||
}).nThen(function (waitFor) {
|
||||
var ext = Util.parseFilename(data.title).ext;
|
||||
|
|
|
@ -1802,7 +1802,12 @@ define([
|
|||
}
|
||||
startRealtime();
|
||||
cb();
|
||||
}, cryptputCfg);
|
||||
}, cryptputCfg, function (progress) {
|
||||
sframeChan.event('EV_LOADING_INFO', {
|
||||
type: 'pad',
|
||||
progress: progress
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
// Start realtime outside the iframe and callback
|
||||
|
|
Loading…
Reference in New Issue