import/export

This commit is contained in:
Mo Bitar
2016-12-11 23:43:06 -06:00
parent 358fd89989
commit 8ad3776819
13 changed files with 219 additions and 180 deletions

View File

@@ -17,4 +17,12 @@ angular.module('app.frontend')
apiController.setGk(new_keys.gk);
}
// var note = new Note();
// note.content = {title: "hello", text: "world"};
// console.log("note content", note.content);
// console.log("note title", note.title);
// console.log("note json", JSON.stringify(note));
//
// console.log("Copy", _.cloneDeep(note));
});

View File

@@ -102,7 +102,7 @@ angular.module('app.frontend')
this.setNote = function(note, oldNote) {
this.editorMode = 'edit';
if(note.text.length == 0) {
if(note.content.text.length == 0) {
this.focusTitle(100);
}
@@ -138,7 +138,7 @@ angular.module('app.frontend')
}
this.renderedContent = function() {
return markdownRenderer.renderHtml(markdownRenderer.renderedContentForText(this.note.text));
return markdownRenderer.renderHtml(markdownRenderer.renderedContentForText(this.note.content.text));
}
var statusTimeout;

View File

@@ -18,6 +18,7 @@ angular.module('app.frontend')
// });
scope.$on('auth:validation-success', function(ev) {
// TODO
setTimeout(function(){
ctrl.onValidationSuccess();
})
@@ -64,7 +65,6 @@ angular.module('app.frontend')
})
}.bind(this))
}
this.hasLocalData = function() {
@@ -119,11 +119,9 @@ angular.module('app.frontend')
}
this.onValidationSuccess = function() {
if(this.user.local_encryption_enabled) {
apiController.verifyEncryptionStatusOfAllNotes(this.user, function(success){
});
}
}
this.encryptionStatusForNotes = function() {
@@ -138,31 +136,6 @@ angular.module('app.frontend')
return countEncrypted + "/" + allNotes.length + " notes encrypted";
}
this.toggleEncryptionStatus = function() {
this.encryptionConfirmation = true;
}
this.cancelEncryptionChange = function() {
this.encryptionConfirmation = false;
}
this.confirmEncryptionChange = function() {
var callback = function(success, enabled) {
if(success) {
this.encryptionConfirmation = false;
this.user.local_encryption_enabled = enabled;
}
}.bind(this)
if(this.user.local_encryption_enabled) {
apiController.disableEncryptionForUser(this.user, callback);
} else {
apiController.enableEncryptionForUser(this.user, callback);
}
}
this.downloadDataArchive = function() {
var link = document.createElement('a');
link.setAttribute('download', 'neeto.json');
@@ -170,6 +143,22 @@ angular.module('app.frontend')
link.click();
}
this.importFileSelected = function(files) {
var file = files[0];
var reader = new FileReader();
reader.onload = function(e) {
apiController.importJSONData(e.target.result, function(success, response){
console.log("import response", success, response);
if(success) {
// window.location.reload();
} else {
alert("There was an error importing your data. Please try again.");
}
})
}
reader.readAsText(file);
}
this.onAuthSuccess = function(user) {
this.user.id = user.id;

View File

@@ -164,8 +164,6 @@ angular.module('app.frontend')
$scope.selectedNote = null;
}
note.onDelete();
if(note.dummy) {
return;
}

View File

@@ -76,18 +76,12 @@ angular.module('app.frontend')
return;
}
if(this.user.local_encryption_enabled) {
if(!confirm("Sharing this group will disable local encryption on all group notes.")) {
return;
}
}
var callback = function(username) {
apiController.shareGroup(this.user, this.group, function(response){
})
}.bind(this);
if(!this.user.getUsername()) {
if(!this.user.username) {
ngDialog.open({
template: 'frontend/modals/username.html',
controller: 'UsernameModalCtrl',
@@ -99,7 +93,7 @@ angular.module('app.frontend')
disableAnimation: true
});
} else {
callback(this.user.getUsername());
callback(this.user.username);
}
}
@@ -138,15 +132,12 @@ angular.module('app.frontend')
this.selectNote = function(note) {
this.selectedNote = note;
this.selectionMade()(note);
note.onDelete = function() {
this.setNotes(this.group.notes, false);
}.bind(this);
}
this.createNewNote = function() {
var title = "New Note" + (this.notes ? (" " + (this.notes.length + 1)) : "");
this.newNote = new Note({title: title, content: '', dummy: true});
this.newNote = new Note({dummy: true});
this.newNote.content.title = title;
this.newNote.shared_via_group = this.group.presentation && this.group.presentation.enabled;
this.selectNote(this.newNote);
this.addNew()(this.newNote);