confirm delete, extension load actions

This commit is contained in:
Mo Bitar
2017-01-29 16:59:06 -06:00
parent 2274e6835d
commit 72afcd7da4
8 changed files with 36 additions and 22 deletions

View File

@@ -236,8 +236,10 @@ angular.module('app.frontend')
}
this.deleteNote = function() {
this.remove()(this.note);
this.showMenu = false;
if(confirm("Are you sure you want to delete this note?")) {
this.remove()(this.note);
this.showMenu = false;
}
}
this.clickedEditNote = function() {

View File

@@ -1,18 +1,20 @@
class Action {
constructor(json) {
_.merge(this, json);
this.running = false; // in case running=true was synced with server since model is uploaded nondiscriminatory
this.error = false;
if(this.lastExecuted) {
// is string
this.lastExecuted = new Date(this.lastExecuted);
}
_.merge(this, json);
this.running = false; // in case running=true was synced with server since model is uploaded nondiscriminatory
this.error = false;
if(this.lastExecuted) {
// is string
this.lastExecuted = new Date(this.lastExecuted);
}
}
get permissionsString() {
permissionsString() {
console.log("permissions", this.permissions);
if(!this.permissions) {
return "";
}
var permission = this.permissions.charAt(0).toUpperCase() + this.permissions.slice(1); // capitalize first letter
permission += ": ";
for(var contentType of this.content_types) {
@@ -28,7 +30,7 @@ class Action {
return permission;
}
get encryptionModeString() {
encryptionModeString() {
if(this.verb != "post") {
return null;
}
@@ -54,6 +56,12 @@ class Extension extends Item {
this.encrypted = true;
this.content_type = "Extension";
if(json.actions) {
this.actions = json.actions.map(function(action){
return new Action(action);
})
}
}
actionsInGlobalContext() {

View File

@@ -39,8 +39,8 @@ angular.module('app.frontend')
callback(response.plain());
})
.catch(function(response){
console.log("Error getting current user", response);
callback(response.data);
console.log("Error getting auth params", response);
callback(null);
})
}
@@ -59,7 +59,7 @@ angular.module('app.frontend')
this.login = function(url, email, password, callback) {
this.getAuthParamsForEmail(url, email, function(authParams){
if(!authParams) {
callback({error: "Unable to get authentication parameters."});
callback({error : {message: "Unable to get authentication parameters."}});
return;
}
@@ -72,6 +72,8 @@ angular.module('app.frontend')
return;
}
console.log("compute encryption keys", password, authParams);
Neeto.crypto.computeEncryptionKeysForUser(_.merge({password: password}, authParams), function(keys){
var mk = keys.mk;
var requestUrl = url + "/auth/sign_in";
@@ -112,7 +114,7 @@ angular.module('app.frontend')
}.bind(this))
.catch(function(response){
console.log("Registration error", response);
callback(response.data);
callback(null);
})
}.bind(this));
}

View File

@@ -103,7 +103,9 @@ class DBManager {
var request = db.transaction("items", "readwrite").objectStore("items").delete(item.uuid);
request.onsuccess = function(event) {
console.log("Successfully deleted item", item.uuid);
callback(true);
if(callback) {
callback(true);
}
};
}, null)
}

View File

@@ -10,7 +10,7 @@ class SyncManager {
}
get serverURL() {
return localStorage.getItem("server") || "http://localhost:3000";
return localStorage.getItem("server") || "https://n3.standardnotes.org";
}
get masterKey() {