extension css and logic updates
This commit is contained in:
@@ -210,7 +210,7 @@ angular.module('app.frontend')
|
||||
this.note.setDirty(true);
|
||||
|
||||
apiController.sync(function(response){
|
||||
if(!response) {
|
||||
if(response && response.error) {
|
||||
this.note.presentation_name = original;
|
||||
this.url.token = original;
|
||||
alert("This URL is not available.");
|
||||
|
||||
@@ -32,9 +32,11 @@ angular.module('app.frontend')
|
||||
this.showAccountMenu = !this.showAccountMenu;
|
||||
this.showFaq = false;
|
||||
this.showNewPasswordForm = false;
|
||||
this.showExtensionsMenu = false;
|
||||
}
|
||||
|
||||
this.toggleExtensions = function() {
|
||||
this.showAccountMenu = false;
|
||||
this.showExtensionsMenu = !this.showExtensionsMenu;
|
||||
}
|
||||
|
||||
@@ -57,7 +59,13 @@ angular.module('app.frontend')
|
||||
action.running = true;
|
||||
extensionManager.executeAction(action, extension, null, function(response){
|
||||
action.running = false;
|
||||
apiController.sync(null);
|
||||
if(response && response.error) {
|
||||
action.error = true;
|
||||
alert("There was an error performing this action. Please try again.");
|
||||
} else {
|
||||
action.error = false;
|
||||
apiController.sync(null);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -118,7 +126,7 @@ angular.module('app.frontend')
|
||||
$timeout(function(){
|
||||
this.isRefreshing = false;
|
||||
}.bind(this), 200)
|
||||
if(!response) {
|
||||
if(response && response.error) {
|
||||
alert("There was an error syncing. Please try again. If all else fails, log out and log back in.");
|
||||
} else {
|
||||
this.syncUpdated();
|
||||
|
||||
@@ -113,11 +113,15 @@ angular.module('app.frontend')
|
||||
$scope.saveNote = function(note, callback) {
|
||||
note.setDirty(true);
|
||||
|
||||
apiController.sync(function(){
|
||||
note.hasChanges = false;
|
||||
|
||||
if(callback) {
|
||||
callback(true);
|
||||
apiController.sync(function(response){
|
||||
if(response && response.error) {
|
||||
alert("There was an error saving your note. Please try again.");
|
||||
callback(false);
|
||||
} else {
|
||||
note.hasChanges = false;
|
||||
if(callback) {
|
||||
callback(true);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,6 +2,11 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
get permissionsString() {
|
||||
@@ -47,6 +52,7 @@ class Extension extends Item {
|
||||
super(json);
|
||||
_.merge(this, json);
|
||||
|
||||
this.encrypted = true;
|
||||
this.content_type = "Extension";
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,10 @@ angular.module('app.frontend')
|
||||
Auth
|
||||
*/
|
||||
|
||||
this.isUserSignedIn = function() {
|
||||
return this.user.email && this.retrieveMk();
|
||||
}
|
||||
|
||||
this.getAuthParamsForEmail = function(email, callback) {
|
||||
var request = Restangular.one("auth", "params");
|
||||
request.get({email: email}).then(function(response){
|
||||
@@ -219,7 +223,6 @@ angular.module('app.frontend')
|
||||
this.syncWithOptions = function(callback, options = {}) {
|
||||
if(!this.user.uuid) {
|
||||
this.writeItemsToLocalStorage(function(responseItems){
|
||||
this.handleItemsResponse(responseItems);
|
||||
modelManager.clearDirtyItems();
|
||||
if(callback) {
|
||||
callback();
|
||||
@@ -256,7 +259,7 @@ angular.module('app.frontend')
|
||||
}.bind(this))
|
||||
.catch(function(response){
|
||||
console.log("Sync error: ", response);
|
||||
callback(null);
|
||||
callback({error: "Sync error"});
|
||||
})
|
||||
}
|
||||
|
||||
@@ -361,7 +364,7 @@ angular.module('app.frontend')
|
||||
console.log("importing data", data);
|
||||
this.decryptItems(data.items);
|
||||
modelManager.mapResponseItemsToLocalModels(data.items);
|
||||
modelManager.items.forEach(function(item){
|
||||
modelManager.allItems.forEach(function(item){
|
||||
item.setDirty(true);
|
||||
})
|
||||
this.syncWithOptions(callback, {additionalFields: ["created_at", "updated_at"]});
|
||||
@@ -430,10 +433,10 @@ angular.module('app.frontend')
|
||||
}
|
||||
|
||||
this.writeItemsToLocalStorage = function(callback) {
|
||||
var items = _.map(modelManager.items, function(item){
|
||||
var items = _.map(modelManager.allItems, function(item){
|
||||
return this.paramsForItem(item, false, ["created_at", "updated_at"], false)
|
||||
}.bind(this));
|
||||
console.log("writing items to local", items);
|
||||
console.log("Writing items to local", items);
|
||||
this.writeToLocalStorage('items', items);
|
||||
callback(items);
|
||||
}
|
||||
@@ -445,7 +448,7 @@ angular.module('app.frontend')
|
||||
this.loadLocalItemsAndUser = function() {
|
||||
var user = {};
|
||||
var items = JSON.parse(localStorage.getItem('items')) || [];
|
||||
items = this.handleItemsResponse(items);
|
||||
items = this.handleItemsResponse(items, null);
|
||||
Item.sortItemsByDate(items);
|
||||
user.items = items;
|
||||
user.shouldMerge = true;
|
||||
|
||||
@@ -62,7 +62,7 @@ class ExtensionManager {
|
||||
deleteExtension(extension) {
|
||||
for(var action of extension.actions) {
|
||||
_.pull(this.decryptedExtensions, extension);
|
||||
if(action.repeat_type) {
|
||||
if(action.repeat_mode) {
|
||||
if(this.isRepeatActionEnabled(action)) {
|
||||
this.disableRepeatAction(action);
|
||||
}
|
||||
@@ -105,7 +105,9 @@ class ExtensionManager {
|
||||
refreshExtensionsFromServer() {
|
||||
for (var url of this.enabledRepeatActionUrls) {
|
||||
var action = this.actionWithURL(url);
|
||||
this.disableRepeatAction(action);
|
||||
if(action) {
|
||||
this.disableRepeatAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
for(var ext of this.extensions) {
|
||||
@@ -117,14 +119,24 @@ class ExtensionManager {
|
||||
|
||||
executeAction(action, extension, item, callback) {
|
||||
|
||||
if(this.extensionUsesEncryptedData(extension) && !this.apiController.isUserSignedIn()) {
|
||||
alert("To send data encrypted, you must have an encryption key, and must therefore be signed in.");
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (action.verb) {
|
||||
case "get": {
|
||||
this.Restangular.oneUrl(action.url, action.url).get().then(function(response){
|
||||
console.log("Execute action response", response);
|
||||
action.error = false;
|
||||
var items = response.items;
|
||||
this.modelManager.mapResponseItemsToLocalModels(items);
|
||||
callback(items);
|
||||
}.bind(this))
|
||||
.catch(function(response){
|
||||
action.error = true;
|
||||
})
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -133,6 +145,7 @@ class ExtensionManager {
|
||||
var win = window.open(action.url, '_blank');
|
||||
win.focus();
|
||||
callback();
|
||||
break;
|
||||
}
|
||||
|
||||
case "post": {
|
||||
@@ -149,9 +162,11 @@ class ExtensionManager {
|
||||
params.item = this.outgoingParamsForItem(item, extension);
|
||||
}
|
||||
|
||||
this.performPost(action, extension, params, function(items){
|
||||
callback(items);
|
||||
this.performPost(action, extension, params, function(response){
|
||||
callback(response);
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
@@ -170,6 +185,7 @@ class ExtensionManager {
|
||||
console.log("Disabling action", action);
|
||||
|
||||
_.pull(this.enabledRepeatActionUrls, action.url);
|
||||
localStorage.setItem("enabledRepeatActionUrls", JSON.stringify(this.enabledRepeatActionUrls));
|
||||
this.modelManager.removeItemChangeObserver(action.url);
|
||||
|
||||
console.assert(this.isRepeatActionEnabled(action) == false);
|
||||
@@ -220,16 +236,15 @@ class ExtensionManager {
|
||||
var diffInSeconds = (new Date() - lastExecuted)/1000;
|
||||
if(diffInSeconds < action.repeat_timeout) {
|
||||
var delay = action.repeat_timeout - diffInSeconds;
|
||||
console.log("Delaying action by", delay);
|
||||
this.queueAction(action, extension, delay, changedItems);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Performing action immediately", action);
|
||||
|
||||
action.lastExecuted = new Date();
|
||||
|
||||
console.log("Performing action immediately", action);
|
||||
|
||||
if(action.verb == "post") {
|
||||
var params = {};
|
||||
params.items = changedItems.map(function(item){
|
||||
@@ -251,11 +266,18 @@ class ExtensionManager {
|
||||
_.merge(request, params);
|
||||
|
||||
request.post().then(function(response){
|
||||
// console.log("watch action response", response);
|
||||
action.error = false;
|
||||
if(callback) {
|
||||
callback(response.plain());
|
||||
}
|
||||
})
|
||||
.catch(function(response){
|
||||
action.error = true;
|
||||
console.log("Action error response:", response);
|
||||
if(callback) {
|
||||
callback({error: "Request error"});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,19 @@ class ModelManager {
|
||||
this.itemSyncObservers = [];
|
||||
this.itemChangeObservers = [];
|
||||
this.items = [];
|
||||
this.extensions = [];
|
||||
this._extensions = [];
|
||||
}
|
||||
|
||||
get allItems() {
|
||||
return this.items.filter(function(item){
|
||||
return !item.dummy;
|
||||
})
|
||||
}
|
||||
|
||||
get extensions() {
|
||||
return this._extensions.filter(function(ext){
|
||||
return !ext.deleted;
|
||||
})
|
||||
}
|
||||
|
||||
allItemsMatchingTypes(contentTypes) {
|
||||
@@ -111,8 +123,8 @@ class ModelManager {
|
||||
this.notes.unshift(item);
|
||||
}
|
||||
} else if(item.content_type == "Extension") {
|
||||
if(!_.find(this.extensions, {uuid: item.uuid})) {
|
||||
this.extensions.unshift(item);
|
||||
if(!_.find(this._extensions, {uuid: item.uuid})) {
|
||||
this._extensions.unshift(item);
|
||||
}
|
||||
}
|
||||
}.bind(this))
|
||||
@@ -199,7 +211,7 @@ class ModelManager {
|
||||
} else if(item.content_type == "Note") {
|
||||
_.pull(this.notes, item);
|
||||
} else if(item.content_type == "Extension") {
|
||||
_.pull(this.extensions, item);
|
||||
_.pull(this._extensions, item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,6 +114,10 @@
|
||||
.email {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.server {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
@@ -286,8 +290,10 @@ Extensions
|
||||
|
||||
.extension {
|
||||
margin-bottom: 18px;
|
||||
background-color: #ededed;
|
||||
padding: 10px;
|
||||
background-color: #f6f6f6;
|
||||
border: 1px solid #f2f2f2;
|
||||
padding: 14px 6px;
|
||||
padding-bottom: 8px;
|
||||
color: black;
|
||||
|
||||
a {
|
||||
@@ -299,16 +305,18 @@ Extensions
|
||||
> .name {
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
margin-bottom: 2px;
|
||||
margin-bottom: 6px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.encryption-format {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
|
||||
> .title {
|
||||
font-size: 13px;
|
||||
font-weight: bold;
|
||||
// font-weight: bold;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
}
|
||||
@@ -323,16 +331,44 @@ Extensions
|
||||
font-size: 12px;
|
||||
|
||||
.action {
|
||||
padding: 13px;
|
||||
margin-bottom: 10px;
|
||||
background-color: rgba(white, 0.9);
|
||||
border: 1px solid rgba(gray, 0.15);
|
||||
|
||||
> .name {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
> .permissions {
|
||||
margin-top: 2px;
|
||||
a {
|
||||
font-weight: normal !important;
|
||||
}
|
||||
}
|
||||
|
||||
> .execute {
|
||||
font-weight: bold;
|
||||
margin-bottom: 0px;
|
||||
font-size: 12px;
|
||||
height: 30px;
|
||||
padding-top: 7px;
|
||||
text-align: center;
|
||||
margin-top: 6px;
|
||||
border: 1px solid rgba(gray, 0.15);
|
||||
cursor: pointer;
|
||||
color: $blue-color;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(gray, 0.10);
|
||||
}
|
||||
|
||||
.execution-spinner {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
text-align: center;
|
||||
margin-top: 3px;
|
||||
}
|
||||
}
|
||||
|
||||
> .execute-type {
|
||||
@@ -340,9 +376,15 @@ Extensions
|
||||
margin-bottom: 1px;
|
||||
}
|
||||
|
||||
> .error {
|
||||
color: red;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
> .last-run {
|
||||
opacity: 0.5;
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
|
||||
.account-item{"ng-if" => "ctrl.user.email"}
|
||||
.email {{ctrl.user.email}}
|
||||
.server {{ctrl.serverData.url}}
|
||||
.links{"ng-if" => "ctrl.user.email"}
|
||||
.link-item
|
||||
%a{"ng-click" => "ctrl.changePasswordPressed()"} Change Password
|
||||
@@ -98,7 +99,7 @@
|
||||
.extension{"ng-repeat" => "extension in ctrl.extensionManager.extensions"}
|
||||
.name {{extension.name}}
|
||||
.encryption-format
|
||||
.title Send data
|
||||
.title Send data:
|
||||
%label
|
||||
%input{"type" => "radio", "ng-model" => "extension.encrypted", "ng-value" => "true", "ng-change" => "ctrl.extensionManager.changeExtensionEncryptionFormat(true, extension)"}
|
||||
Encrypted
|
||||
@@ -120,16 +121,18 @@
|
||||
.encryption-type
|
||||
%span {{action.encryptionModeString}}
|
||||
.execute
|
||||
%a{"ng-if" => "action.repeat_mode"}
|
||||
%span{"ng-if" => "ctrl.extensionManager.isRepeatActionEnabled(action)", "ng-click" => "ctrl.extensionManager.disableRepeatAction(action, extension)"} Disable
|
||||
%span{"ng-if" => "!ctrl.extensionManager.isRepeatActionEnabled(action)", "ng-click" => "ctrl.extensionManager.enableRepeatAction(action, extension)"} Enable
|
||||
%a{"ng-if" => "!action.repeat_mode", "ng-click" => "ctrl.selectedAction(action, extension)"}
|
||||
%span{"ng-if" => "!action.running"}
|
||||
Run
|
||||
%span{"ng-if" => "action.running"}
|
||||
.spinner{"style" => "margin-top: 3px;"}
|
||||
.last-run{"ng-if" => "action.lastExecuted && !action.running"}
|
||||
Last executed {{action.lastExecuted | appDateTime}}
|
||||
%div{"ng-if" => "action.repeat_mode"}
|
||||
%div{"ng-if" => "ctrl.extensionManager.isRepeatActionEnabled(action)", "ng-click" => "ctrl.extensionManager.disableRepeatAction(action, extension)"} Disable
|
||||
%div{"ng-if" => "!ctrl.extensionManager.isRepeatActionEnabled(action)", "ng-click" => "ctrl.extensionManager.enableRepeatAction(action, extension)"} Enable
|
||||
%div{"ng-if" => "!action.repeat_mode", "ng-click" => "ctrl.selectedAction(action, extension)"}
|
||||
%div{"ng-if" => "!action.running"}
|
||||
Perform Action
|
||||
%div{"ng-if" => "action.running"}
|
||||
.spinner.execution-spinner
|
||||
.last-run{"ng-if" => "!action.error && action.lastExecuted && !action.running"}
|
||||
Last run {{action.lastExecuted | appDateTime}}
|
||||
.error{"ng-if" => "action.error"}
|
||||
Error performing action.
|
||||
%a{"ng-click" => "ctrl.deleteExtension(extension)", "style" => "margin-top: 22px; display: block;"} Remove extension
|
||||
|
||||
.extension-link
|
||||
|
||||
109
vendor/assets/javascripts/transpiled.js
vendored
109
vendor/assets/javascripts/transpiled.js
vendored
@@ -659,7 +659,7 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
||||
this.note.setDirty(true);
|
||||
|
||||
apiController.sync(function (response) {
|
||||
if (!response) {
|
||||
if (response && response.error) {
|
||||
this.note.presentation_name = original;
|
||||
this.url.token = original;
|
||||
alert("This URL is not available.");
|
||||
@@ -744,9 +744,11 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
||||
this.showAccountMenu = !this.showAccountMenu;
|
||||
this.showFaq = false;
|
||||
this.showNewPasswordForm = false;
|
||||
this.showExtensionsMenu = false;
|
||||
};
|
||||
|
||||
this.toggleExtensions = function () {
|
||||
this.showAccountMenu = false;
|
||||
this.showExtensionsMenu = !this.showExtensionsMenu;
|
||||
};
|
||||
|
||||
@@ -769,7 +771,13 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
||||
action.running = true;
|
||||
extensionManager.executeAction(action, extension, null, function (response) {
|
||||
action.running = false;
|
||||
apiController.sync(null);
|
||||
if (response && response.error) {
|
||||
action.error = true;
|
||||
alert("There was an error performing this action. Please try again.");
|
||||
} else {
|
||||
action.error = false;
|
||||
apiController.sync(null);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -827,7 +835,7 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
||||
$timeout(function () {
|
||||
this.isRefreshing = false;
|
||||
}.bind(this), 200);
|
||||
if (!response) {
|
||||
if (response && response.error) {
|
||||
alert("There was an error syncing. Please try again. If all else fails, log out and log back in.");
|
||||
} else {
|
||||
this.syncUpdated();
|
||||
@@ -1036,11 +1044,15 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
||||
$scope.saveNote = function (note, callback) {
|
||||
note.setDirty(true);
|
||||
|
||||
apiController.sync(function () {
|
||||
note.hasChanges = false;
|
||||
|
||||
if (callback) {
|
||||
callback(true);
|
||||
apiController.sync(function (response) {
|
||||
if (response && response.error) {
|
||||
alert("There was an error saving your note. Please try again.");
|
||||
callback(false);
|
||||
} else {
|
||||
note.hasChanges = false;
|
||||
if (callback) {
|
||||
callback(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -1498,6 +1510,11 @@ var Action = function () {
|
||||
|
||||
_.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);
|
||||
}
|
||||
}
|
||||
|
||||
_createClass(Action, [{
|
||||
@@ -1574,6 +1591,7 @@ var Extension = function (_Item) {
|
||||
|
||||
_.merge(_this3, json);
|
||||
|
||||
_this3.encrypted = true;
|
||||
_this3.content_type = "Extension";
|
||||
return _this3;
|
||||
}
|
||||
@@ -1927,6 +1945,10 @@ var User = function User(json_obj) {
|
||||
Auth
|
||||
*/
|
||||
|
||||
this.isUserSignedIn = function () {
|
||||
return this.user.email && this.retrieveMk();
|
||||
};
|
||||
|
||||
this.getAuthParamsForEmail = function (email, callback) {
|
||||
var request = Restangular.one("auth", "params");
|
||||
request.get({ email: email }).then(function (response) {
|
||||
@@ -2084,7 +2106,6 @@ var User = function User(json_obj) {
|
||||
|
||||
if (!this.user.uuid) {
|
||||
this.writeItemsToLocalStorage(function (responseItems) {
|
||||
this.handleItemsResponse(responseItems);
|
||||
modelManager.clearDirtyItems();
|
||||
if (callback) {
|
||||
callback();
|
||||
@@ -2120,7 +2141,7 @@ var User = function User(json_obj) {
|
||||
}
|
||||
}.bind(this)).catch(function (response) {
|
||||
console.log("Sync error: ", response);
|
||||
callback(null);
|
||||
callback({ error: "Sync error" });
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2226,7 +2247,7 @@ var User = function User(json_obj) {
|
||||
console.log("importing data", data);
|
||||
this.decryptItems(data.items);
|
||||
modelManager.mapResponseItemsToLocalModels(data.items);
|
||||
modelManager.items.forEach(function (item) {
|
||||
modelManager.allItems.forEach(function (item) {
|
||||
item.setDirty(true);
|
||||
});
|
||||
this.syncWithOptions(callback, { additionalFields: ["created_at", "updated_at"] });
|
||||
@@ -2290,10 +2311,10 @@ var User = function User(json_obj) {
|
||||
};
|
||||
|
||||
this.writeItemsToLocalStorage = function (callback) {
|
||||
var items = _.map(modelManager.items, function (item) {
|
||||
var items = _.map(modelManager.allItems, function (item) {
|
||||
return this.paramsForItem(item, false, ["created_at", "updated_at"], false);
|
||||
}.bind(this));
|
||||
console.log("writing items to local", items);
|
||||
console.log("Writing items to local", items);
|
||||
this.writeToLocalStorage('items', items);
|
||||
callback(items);
|
||||
};
|
||||
@@ -2305,7 +2326,7 @@ var User = function User(json_obj) {
|
||||
this.loadLocalItemsAndUser = function () {
|
||||
var user = {};
|
||||
var items = JSON.parse(localStorage.getItem('items')) || [];
|
||||
items = this.handleItemsResponse(items);
|
||||
items = this.handleItemsResponse(items, null);
|
||||
Item.sortItemsByDate(items);
|
||||
user.items = items;
|
||||
user.shouldMerge = true;
|
||||
@@ -2960,7 +2981,7 @@ var ExtensionManager = function () {
|
||||
var action = _step8.value;
|
||||
|
||||
_.pull(this.decryptedExtensions, extension);
|
||||
if (action.repeat_type) {
|
||||
if (action.repeat_mode) {
|
||||
if (this.isRepeatActionEnabled(action)) {
|
||||
this.disableRepeatAction(action);
|
||||
}
|
||||
@@ -3026,7 +3047,9 @@ var ExtensionManager = function () {
|
||||
var url = _step9.value;
|
||||
|
||||
var action = this.actionWithURL(url);
|
||||
this.disableRepeatAction(action);
|
||||
if (action) {
|
||||
this.disableRepeatAction(action);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError9 = true;
|
||||
@@ -3074,15 +3097,24 @@ var ExtensionManager = function () {
|
||||
key: 'executeAction',
|
||||
value: function executeAction(action, extension, item, callback) {
|
||||
|
||||
if (this.extensionUsesEncryptedData(extension) && !this.apiController.isUserSignedIn()) {
|
||||
alert("To send data encrypted, you must have an encryption key, and must therefore be signed in.");
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (action.verb) {
|
||||
case "get":
|
||||
{
|
||||
this.Restangular.oneUrl(action.url, action.url).get().then(function (response) {
|
||||
console.log("Execute action response", response);
|
||||
action.error = false;
|
||||
var items = response.items;
|
||||
this.modelManager.mapResponseItemsToLocalModels(items);
|
||||
callback(items);
|
||||
}.bind(this));
|
||||
}.bind(this)).catch(function (response) {
|
||||
action.error = true;
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -3092,6 +3124,7 @@ var ExtensionManager = function () {
|
||||
var win = window.open(action.url, '_blank');
|
||||
win.focus();
|
||||
callback();
|
||||
break;
|
||||
}
|
||||
|
||||
case "post":
|
||||
@@ -3108,9 +3141,11 @@ var ExtensionManager = function () {
|
||||
params.item = this.outgoingParamsForItem(item, extension);
|
||||
}
|
||||
|
||||
this.performPost(action, extension, params, function (items) {
|
||||
callback(items);
|
||||
this.performPost(action, extension, params, function (response) {
|
||||
callback(response);
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
@@ -3130,6 +3165,7 @@ var ExtensionManager = function () {
|
||||
console.log("Disabling action", action);
|
||||
|
||||
_.pull(this.enabledRepeatActionUrls, action.url);
|
||||
localStorage.setItem("enabledRepeatActionUrls", JSON.stringify(this.enabledRepeatActionUrls));
|
||||
this.modelManager.removeItemChangeObserver(action.url);
|
||||
|
||||
console.assert(this.isRepeatActionEnabled(action) == false);
|
||||
@@ -3182,16 +3218,15 @@ var ExtensionManager = function () {
|
||||
var diffInSeconds = (new Date() - lastExecuted) / 1000;
|
||||
if (diffInSeconds < action.repeat_timeout) {
|
||||
var delay = action.repeat_timeout - diffInSeconds;
|
||||
console.log("Delaying action by", delay);
|
||||
this.queueAction(action, extension, delay, changedItems);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Performing action immediately", action);
|
||||
|
||||
action.lastExecuted = new Date();
|
||||
|
||||
console.log("Performing action immediately", action);
|
||||
|
||||
if (action.verb == "post") {
|
||||
var params = {};
|
||||
params.items = changedItems.map(function (item) {
|
||||
@@ -3215,10 +3250,16 @@ var ExtensionManager = function () {
|
||||
_.merge(request, params);
|
||||
|
||||
request.post().then(function (response) {
|
||||
// console.log("watch action response", response);
|
||||
action.error = false;
|
||||
if (callback) {
|
||||
callback(response.plain());
|
||||
}
|
||||
}).catch(function (response) {
|
||||
action.error = true;
|
||||
console.log("Action error response:", response);
|
||||
if (callback) {
|
||||
callback({ error: "Request error" });
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
@@ -3269,7 +3310,7 @@ var ModelManager = function () {
|
||||
this.itemSyncObservers = [];
|
||||
this.itemChangeObservers = [];
|
||||
this.items = [];
|
||||
this.extensions = [];
|
||||
this._extensions = [];
|
||||
}
|
||||
|
||||
_createClass(ModelManager, [{
|
||||
@@ -3448,8 +3489,8 @@ var ModelManager = function () {
|
||||
this.notes.unshift(item);
|
||||
}
|
||||
} else if (item.content_type == "Extension") {
|
||||
if (!_.find(this.extensions, { uuid: item.uuid })) {
|
||||
this.extensions.unshift(item);
|
||||
if (!_.find(this._extensions, { uuid: item.uuid })) {
|
||||
this._extensions.unshift(item);
|
||||
}
|
||||
}
|
||||
}.bind(this));
|
||||
@@ -3567,7 +3608,7 @@ var ModelManager = function () {
|
||||
} else if (item.content_type == "Note") {
|
||||
_.pull(this.notes, item);
|
||||
} else if (item.content_type == "Extension") {
|
||||
_.pull(this.extensions, item);
|
||||
_.pull(this._extensions, item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3593,6 +3634,20 @@ var ModelManager = function () {
|
||||
itemOne.setDirty(true);
|
||||
itemTwo.setDirty(true);
|
||||
}
|
||||
}, {
|
||||
key: 'allItems',
|
||||
get: function get() {
|
||||
return this.items.filter(function (item) {
|
||||
return !item.dummy;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'extensions',
|
||||
get: function get() {
|
||||
return this._extensions.filter(function (ext) {
|
||||
return !ext.deleted;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'filteredNotes',
|
||||
get: function get() {
|
||||
|
||||
2
vendor/assets/javascripts/transpiled.js.map
vendored
2
vendor/assets/javascripts/transpiled.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user