Desktop manager to allow local backups

This commit is contained in:
Mo Bitar
2017-11-05 14:06:47 -06:00
parent f07a79f845
commit 9d4dea4e95
6 changed files with 93 additions and 16 deletions

View File

@@ -105,7 +105,7 @@ class ModelManager {
// first loop should add and process items
for (var json_obj of items) {
if((!json_obj.content_type || !json_obj.content) && !json_obj.deleted) {
if((!json_obj.content_type || !json_obj.content) && !json_obj.deleted && !json_obj.errorDecrypting) {
// An item that is not deleted should never have empty content
console.error("Server response item is corrupt:", json_obj);
continue;
@@ -363,6 +363,31 @@ class ModelManager {
itemOne.setDirty(true);
itemTwo.setDirty(true);
}
/*
Archives
*/
getAllItemsJSONData(keys, authParams, protocolVersion, returnNullIfEmpty) {
var items = _.map(this.allItems, (item) => {
var itemParams = new ItemParams(item, keys, protocolVersion);
return itemParams.paramsForExportFile();
});
if(returnNullIfEmpty && items.length == 0) {
return null;
}
var data = {items: items}
if(keys) {
// auth params are only needed when encrypted with a standard file key
data["auth_params"] = authParams;
}
return JSON.stringify(data, null, 2 /* pretty print */);
}
}
angular.module('app.frontend').service('modelManager', ModelManager);