mirror of
http://git.whoc.org.uk/git/password-manager.git
synced 2024-11-14 18:29:02 +01:00
Download all records data for export together, to avoid request-toll issues
This commit is contained in:
parent
7eb82d391e
commit
337743964c
@ -461,10 +461,11 @@ div.overlay {
|
||||
-o-animation-delay: -0.0833s;
|
||||
animation-delay: -0.0833s; }
|
||||
div.overlay .progressBar {
|
||||
width: 100%;
|
||||
background-color: #222;
|
||||
height: 4px;
|
||||
margin-top: 86px;
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
-webkit-border-radius: 2px;
|
||||
-moz-border-radius: 2px;
|
||||
border-radius: 2px; }
|
||||
|
File diff suppressed because one or more lines are too long
@ -164,10 +164,19 @@ Clipperz.PM.DataModel.EncryptedRemoteObject.prototype = MochiKit.Base.update(nul
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'hasLoadedRemoteData': function () {
|
||||
//console.log("EncryptedRemoteObject.hasLoadedRemoteData", this._remoteData);
|
||||
return (this._remoteData != null);
|
||||
},
|
||||
|
||||
'setRemoteData': function (someData) {
|
||||
return Clipperz.Async.callbacks("EncryptedRemoteObject.setRemoteData", [
|
||||
MochiKit.Base.method(this, 'unpackRemoteData', someData),
|
||||
MochiKit.Base.bind(function (unpackedData) {
|
||||
this._remoteData = unpackedData;
|
||||
return this._remoteData;
|
||||
}, this)
|
||||
], {trace:false});
|
||||
},
|
||||
|
||||
'getRemoteData': function () {
|
||||
var deferredResult;
|
||||
var deferredLock;
|
||||
@ -184,17 +193,12 @@ Clipperz.PM.DataModel.EncryptedRemoteObject.prototype = MochiKit.Base.update(nul
|
||||
} else {
|
||||
innerDeferredResult = Clipperz.Async.callbacks("EncryptedRemoteObjects.getRemoteData <inner deferred>", [
|
||||
MochiKit.Base.partial(this.retrieveRemoteDataFunction(), this.reference()),
|
||||
MochiKit.Base.method(this, 'unpackRemoteData'),
|
||||
MochiKit.Base.bind(function (someData) {
|
||||
this._remoteData = someData;
|
||||
return this._remoteData;
|
||||
}, this)
|
||||
MochiKit.Base.method(this, 'setRemoteData'),
|
||||
], {trace:false});
|
||||
}
|
||||
|
||||
return innerDeferredResult;
|
||||
}, this))
|
||||
deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress');
|
||||
deferredResult.releaseLock(deferredLock);
|
||||
|
||||
deferredResult.callback();
|
||||
@ -259,7 +263,6 @@ Clipperz.PM.DataModel.EncryptedRemoteObject.prototype = MochiKit.Base.update(nul
|
||||
innerDeferredResult = new Clipperz.Async.Deferred("EncryptedRemoteObject.getDecryptedData <inner deferred>", {trace:false});
|
||||
|
||||
innerDeferredResult.addMethod(this, 'getRemoteData');
|
||||
innerDeferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress');
|
||||
innerDeferredResult.collectResults({
|
||||
'key': MochiKit.Base.method(this, 'getKey'),
|
||||
'value': MochiKit.Base.itemgetter(this._encryptedDataKeypath),
|
||||
@ -267,14 +270,12 @@ Clipperz.PM.DataModel.EncryptedRemoteObject.prototype = MochiKit.Base.update(nul
|
||||
});
|
||||
|
||||
innerDeferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt);
|
||||
innerDeferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress');
|
||||
innerDeferredResult.addMethod(this, 'unpackData');
|
||||
innerDeferredResult.callback();
|
||||
|
||||
return innerDeferredResult;
|
||||
}, this)));
|
||||
deferredResult.releaseLock(deferredLock);
|
||||
deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress');
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
@ -534,10 +535,6 @@ Clipperz.PM.DataModel.EncryptedRemoteObject.prototype = MochiKit.Base.update(nul
|
||||
},
|
||||
MochiKit.Base.method(this, 'packRemoteData'),
|
||||
MochiKit.Base.method(this.transientState(), 'setValue', 'packedRemoteData'),
|
||||
function (someData) {
|
||||
MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'advanceProgress');
|
||||
return someData;
|
||||
}
|
||||
], {trace:false});
|
||||
},
|
||||
|
||||
|
@ -630,6 +630,19 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, {
|
||||
|
||||
//=========================================================================
|
||||
|
||||
'recordWithData': function (recordData) {
|
||||
//console.log("recordWithData", recordData)
|
||||
return Clipperz.Async.callbacks("User.recordWithData", [
|
||||
MochiKit.Base.method(this, 'getHeaderIndex', 'recordsIndex'),
|
||||
MochiKit.Base.methodcaller('records'),
|
||||
MochiKit.Base.itemgetter(recordData['reference']),
|
||||
MochiKit.Base.methodcaller('setRemoteData', recordData),
|
||||
], {trace:false});
|
||||
|
||||
},
|
||||
|
||||
//=========================================================================
|
||||
|
||||
'getRecords': function () {
|
||||
return Clipperz.Async.callbacks("User.getRecords", [
|
||||
MochiKit.Base.method(this, 'getHeaderIndex', 'recordsIndex'),
|
||||
@ -638,49 +651,22 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, {
|
||||
], {trace:false});
|
||||
},
|
||||
|
||||
'getRecordsInfo': function (someInfo /*, shouldIncludeArchivedCards */) {
|
||||
'getRecordsLoadingAllData': function () {
|
||||
return Clipperz.Async.callbacks("User.getRecordsLoadingAllData", [
|
||||
MochiKit.Base.method(this.connection(), 'message', 'getAllRecordDetails'),
|
||||
MochiKit.Base.values,
|
||||
MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'recordWithData')),
|
||||
MochiKit.Base.method(this, 'getRecords'),
|
||||
], {trace:false});
|
||||
},
|
||||
|
||||
'getRecordsInfo': function (someInfo) {
|
||||
return Clipperz.Async.callbacks("User.getRecordsInfo", [
|
||||
MochiKit.Base.method(this, 'getRecords'),
|
||||
MochiKit.Base.partial(MochiKit.Base.map, Clipperz.Async.collectResults("collectResults", someInfo, {trace:false})),
|
||||
Clipperz.Async.collectAll,
|
||||
/*
|
||||
function (aResult) {
|
||||
var result;
|
||||
|
||||
if (shouldIncludeArchivedCards == false) {
|
||||
result = MochiKit.Base.filter(function (aRecordInfo) { return !aRecordInfo['_isArchived']; }, aResult);
|
||||
} else {
|
||||
result = aResult;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
], {trace:false});
|
||||
},
|
||||
/*
|
||||
'filterRecordsInfo': function (someArgs) {
|
||||
var info = (someArgs.info ? someArgs.info : Clipperz.PM.DataModel.Record.defaultCardInfo);
|
||||
var searchField = (someArgs.searchField ? someArgs.searchField : Clipperz.PM.DataModel.Record.defaultSearchField);
|
||||
var includeArchived = (someArgs.includeArchived ? someArgs.includeArchived : false);
|
||||
var regExp = (someArgs.regExp ? someArgs.regExp : Clipperz.PM.DataModel.Record.regExpForSearch(''));
|
||||
|
||||
if (someArgs.regExp) {
|
||||
regExp = regExp;
|
||||
} else if (someArgs.search) {
|
||||
regExp = Clipperz.PM.DataModel.Record.regExpForSearch(someArgs.search);
|
||||
} else if (someArgs.tag) {
|
||||
regExp = Clipperz.PM.DataModel.Record.regExpForTag(someArgs.tag);
|
||||
} else {
|
||||
regExp = Clipperz.PM.DataModel.Record.regExpForSearch('');
|
||||
};
|
||||
|
||||
return Clipperz.Async.callbacks("User.filterRecordsInfo", [
|
||||
MochiKit.Base.method(this, 'getRecordsInfo', info, includeArchived),
|
||||
MochiKit.Base.partial(MochiKit.Base.filter, function (aCardInfo) { regExp.lastIndex = 0; return regExp.test(aCardInfo[searchField]);})
|
||||
], {trace:false});
|
||||
},
|
||||
*/
|
||||
|
||||
'recordWithLabel': function (aLabel) {
|
||||
return Clipperz.Async.callbacks("User.recordWithLabel", [
|
||||
|
@ -482,37 +482,11 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, {
|
||||
|
||||
//=====================================================================
|
||||
} else if (someParameters.message == 'getRecordDetail') {
|
||||
/*
|
||||
var recordData;
|
||||
var currentVersionData;
|
||||
|
||||
recordData = this.userData()['records'][someParameters['parameters']['reference']];
|
||||
result['reference'] = someParameters['parameters']['reference'];
|
||||
result['data'] = recordData['data'];
|
||||
result['version'] = recordData['version'];
|
||||
result['creationData'] = recordData['creationDate'];
|
||||
result['updateDate'] = recordData['updateDate'];
|
||||
result['accessDate'] = recordData['accessDate'];
|
||||
|
||||
currentVersionData = recordData['versions'][recordData['currentVersion']];
|
||||
|
||||
result['currentVersion'] = {};
|
||||
result['currentVersion']['reference'] = recordData['currentVersion'];
|
||||
result['currentVersion']['version'] = currentVersionData['version'];
|
||||
result['currentVersion']['header'] = currentVersionData['header'];
|
||||
result['currentVersion']['data'] = currentVersionData['data'];
|
||||
result['currentVersion']['creationData'] = currentVersionData['creationDate'];
|
||||
result['currentVersion']['updateDate'] = currentVersionData['updateDate'];
|
||||
result['currentVersion']['accessDate'] = currentVersionData['accessDate'];
|
||||
if (typeof(currentVersionData['previousVersion']) != 'undefined') {
|
||||
result['currentVersion']['previousVersionKey'] = currentVersionData['previousVersionKey'];
|
||||
result['currentVersion']['previousVersion'] = currentVersionData['previousVersion'];
|
||||
}
|
||||
*/
|
||||
MochiKit.Base.update(result, aConnection['userData']['records'][someParameters['parameters']['reference']]);
|
||||
result['reference'] = someParameters['parameters']['reference'];
|
||||
|
||||
} else if (someParameters.message == 'getOneTimePasswordsDetails') {
|
||||
} else if (someParameters.message == 'getAllRecordDetails') {
|
||||
MochiKit.Base.update(result, aConnection['userData']['records']);
|
||||
} else if (someParameters.message == 'getOneTimePasswordsDetails') {
|
||||
var result = MochiKit.Iter.reduce(function(prev, cur){
|
||||
prev[cur.reference] = {
|
||||
'status': cur.status,
|
||||
|
@ -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;
|
||||
},
|
||||
|
@ -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();
|
||||
|
@ -129,10 +129,12 @@ div.overlay {
|
||||
|
||||
.progressBar {
|
||||
// display: block;
|
||||
width: 100%;
|
||||
// width: 100%;
|
||||
background-color: #222;
|
||||
height: 4px;
|
||||
margin-top: 86px;
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
@include border-radius(2px);
|
||||
|
||||
.progress {
|
||||
|
Loading…
Reference in New Issue
Block a user