1
0
mirror of http://git.whoc.org.uk/git/password-manager.git synced 2025-10-29 18:37:35 +01:00

Download all records data for export together, to avoid request-toll issues

This commit is contained in:
Giulio Cesare Solaroli
2015-08-21 11:42:05 +02:00
parent 7eb82d391e
commit 337743964c
8 changed files with 56 additions and 107 deletions

View File

@@ -28,8 +28,8 @@ Clipperz.Base.module('Clipperz.PM.UI');
// https://github.com/eligrey/Blob.js
Clipperz.PM.UI.ExportController = function(args) {
this._recordsInfo = args['recordsInfo'] || Clipperz.Base.exception.raise('MandatoryParameter');
this._processedRecords = 0;
this._totalCardsToExport = 0;
this._style =
"body {" +
@@ -157,24 +157,13 @@ MochiKit.Base.update(Clipperz.PM.UI.ExportController.prototype, {
return "Clipperz.PM.UI.ExportController";
},
//-----------------------------------------------------------------------------
'recordsInfo': function () {
return this._recordsInfo;
},
//=============================================================================
'reportRecordExport': function (aRecordData) {
var percentage;
var exportedCardsCount;
var totalCardsToExport;
this._processedRecords = this._processedRecords + 1;
exportedCardsCount = this._processedRecords;
totalCardsToExport = this.recordsInfo().length;
percentage = Math.round(100 * exportedCardsCount / totalCardsToExport);
percentage = Math.round(100 * this._processedRecords / this._totalCardsToExport);
//console.log("PROCESSING " + exportedCardsCount + "/" + totalCardsToExport + " - " + percentage + "%");
MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'updateProgress', percentage);
@@ -285,16 +274,17 @@ MochiKit.Base.update(Clipperz.PM.UI.ExportController.prototype, {
//=============================================================================
'run': function () {
'run': function (records) {
var deferredResult;
var self = this;
this._totalCardsToExport = records.length;
deferredResult = new Clipperz.Async.Deferred("ExportController.run", {trace:false});
deferredResult.addCallback(MochiKit.Base.map, function(recordIn) {
deferredResult.addCallback(MochiKit.Base.map, function(aRecord) {
var innerDeferredResult;
innerDeferredResult = new Clipperz.Async.Deferred("ExportController.run__exportRecord", {trace:false});
innerDeferredResult.addMethod(recordIn._rowObject, 'export');
innerDeferredResult.addMethod(aRecord, 'export');
innerDeferredResult.addMethod(self, 'reportRecordExport');
innerDeferredResult.callback();
@@ -302,7 +292,7 @@ MochiKit.Base.update(Clipperz.PM.UI.ExportController.prototype, {
});
deferredResult.addCallback(Clipperz.Async.collectAll);
deferredResult.addMethod(this, 'saveResult');
deferredResult.callback(this.recordsInfo());
deferredResult.callback(records);
return deferredResult;
},

View File

@@ -99,6 +99,8 @@ Clipperz.PM.UI.MainController = function() {
Mousetrap.bind(['?'], MochiKit.Base.method(this, 'showHelp_handler'));
// Mousetrap.bind(['t e s t'], MochiKit.Base.method(this, 'downloadExport_handler'));
return this;
}
@@ -1288,19 +1290,16 @@ console.log("THE BROWSER IS OFFLINE");
//----------------------------------------------------------------------------
// export_handler: function(exportType) {
// return Clipperz.PM.UI.ExportController.exportJSON( this.recordsInfo(), exportType );
// },
downloadExport_handler: function () {
var exportController;
var deferredResult;
exportController = new Clipperz.PM.UI.ExportController({'recordsInfo': this.recordsInfo()});
exportController = new Clipperz.PM.UI.ExportController();
deferredResult = new Clipperz.Async.Deferred("MainController.downloadExport_handler", {trace: false});
deferredResult.addMethod(this.overlay(), 'show', "exporting …", true, true);
// deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'toggleSettingsPanel');
deferredResult.addMethod(this.overlay(), 'show', "loading …", true, true);
deferredResult.addMethod(this.user(), 'getRecordsLoadingAllData');
deferredResult.addCallbackPass(MochiKit.Base.method(this.overlay(), 'show', "exporting …", true, true));
deferredResult.addMethod(exportController, 'run');
deferredResult.addMethod(this.overlay(), 'done', "", 1);
deferredResult.callback();