encryption updates

This commit is contained in:
Mo Bitar
2016-12-12 20:00:21 -06:00
parent 8ad3776819
commit d200df0b85
12 changed files with 136 additions and 144 deletions

View File

@@ -235,11 +235,13 @@ angular.module('app.frontend')
this.saveUrl = function($event) {
$event.target.blur();
var original = this.note.presentation.root_path;
this.note.presentation.root_path = this.url.token;
apiController.saveNote(this.user, this.note, function(note){
if(!note) {
this.note.token = original;
var original = this.note.presentation.relative_path;
this.note.presentation.relative_path = this.url.token;
apiController.updatePresentation(this.note, this.note.presentation, function(response){
if(!response) {
this.note.presentation.relative_path = original;
this.url.token = original;
alert("This URL is not available.");
} else {

View File

@@ -53,7 +53,7 @@ angular.module('app.frontend')
return;
}
this.newGroup = {notes : []};
this.newGroup = new Group({notes : []});
if(!this.user.id) {
this.newGroup.id = Neeto.crypto.generateRandomKey()
}
@@ -92,7 +92,7 @@ angular.module('app.frontend')
}
this.noteCount = function(group) {
var validNotes = apiController.filterDummyNotes(group.notes);
var validNotes = Note.filterDummyNotes(group.notes);
return validNotes.length;
}

View File

@@ -13,17 +13,7 @@ angular.module('app.frontend')
bindToController: true,
link:function(scope, elem, attrs, ctrl) {
// scope.$on('auth:login-success', function(event, user) {
// ctrl.onAuthSuccess(user);
// });
scope.$on('auth:validation-success', function(ev) {
// TODO
setTimeout(function(){
ctrl.onValidationSuccess();
})
});
}
}
})
@@ -118,17 +108,11 @@ angular.module('app.frontend')
}.bind(this));
}
this.onValidationSuccess = function() {
apiController.verifyEncryptionStatusOfAllNotes(this.user, function(success){
});
}
this.encryptionStatusForNotes = function() {
var allNotes = this.user.filteredNotes();
var countEncrypted = 0;
allNotes.forEach(function(note){
if(note.isEncrypted()) {
if(note.encryptionEnabled()) {
countEncrypted++;
}
}.bind(this))

View File

@@ -6,21 +6,12 @@ angular.module('app.frontend')
var onUserSet = function() {
$scope.defaultUser.notes = _.map($scope.defaultUser.notes, function(json_obj) {
return new Note(json_obj);
});
$scope.allGroup = new Group({name: "All", all: true});
$scope.groups = $scope.defaultUser.groups;
$scope.defaultUser.filteredNotes = function() {
return apiController.filterDummyNotes($scope.defaultUser.notes);
}
var groups = $scope.defaultUser.groups;
var allNotes = $scope.defaultUser.notes;
groups.forEach(function(group){
var notes = allNotes.filter(function(note){return note.group_id && note.group_id == group.id});
group.notes = notes;
})
$scope.allGroup = {name: "All", all: true};
$scope.groups = groups;
apiController.verifyEncryptionStatusOfAllNotes($scope.defaultUser, function(success){
});
}
apiController.getCurrentUser(function(response){
@@ -39,7 +30,7 @@ angular.module('app.frontend')
*/
$scope.updateAllGroup = function() {
var allNotes = apiController.filterDummyNotes($scope.defaultUser.notes);
var allNotes = Note.filterDummyNotes($scope.defaultUser.notes);
$scope.defaultUser.notes = allNotes;
$scope.allGroup.notes = allNotes;
}
@@ -78,6 +69,8 @@ angular.module('app.frontend')
originalNote.group_id = null;
} else {
originalNote.group_id = newGroup.id
originalNote.group = newGroup;
newGroup.notes.unshift(originalNote);
newGroup.notes.sort(function(a,b){
//subtract to get a value that is either negative, positive, or zero.
@@ -85,8 +78,6 @@ angular.module('app.frontend')
});
}
originalNote.shared_via_group = newGroup.presentation && newGroup.presentation.enabled;
apiController.saveNote($scope.defaultUser, originalNote, function(note){
_.merge(originalNote, note);
});
@@ -97,7 +88,7 @@ angular.module('app.frontend')
*/
$scope.notesRemoveGroup = function(group) {
var validNotes = apiController.filterDummyNotes(group.notes);
var validNotes = Note.filterDummyNotes(group.notes);
if(validNotes == 0) {
// if no more notes, delete group
apiController.deleteGroup($scope.defaultUser, group, function(){

View File

@@ -138,7 +138,7 @@ angular.module('app.frontend')
var title = "New Note" + (this.notes ? (" " + (this.notes.length + 1)) : "");
this.newNote = new Note({dummy: true});
this.newNote.content.title = title;
this.newNote.shared_via_group = this.group.presentation && this.group.presentation.enabled;
this.newNote.group = this.group;
this.selectNote(this.newNote);
this.addNew()(this.newNote);
}