functional minimalism

This commit is contained in:
Mo Bitar
2017-01-27 19:39:10 -06:00
parent ce053226a5
commit f296b0e49e
36 changed files with 444 additions and 960 deletions

View File

@@ -0,0 +1,66 @@
class GlobalExtensionsMenu {
constructor() {
this.restrict = "E";
this.templateUrl = "frontend/directives/global-extensions-menu.html";
this.scope = {
};
}
controller($scope, extensionManager, syncManager) {
'ngInject';
$scope.extensionManager = extensionManager;
$scope.toggleExtensionForm = function() {
$scope.newExtensionData = {};
$scope.showNewExtensionForm = !$scope.showNewExtensionForm;
}
$scope.submitNewExtensionForm = function() {
if($scope.newExtensionData.url) {
extensionManager.addExtension($scope.newExtensionData.url, function(response){
if(!response) {
alert("Unable to register this extension. Make sure the link is valid and try again.");
} else {
$scope.newExtensionData.url = "";
$scope.showNewExtensionForm = false;
}
})
}
}
$scope.selectedAction = function(action, extension) {
action.running = true;
extensionManager.executeAction(action, extension, null, function(response){
action.running = false;
if(response && response.error) {
action.error = true;
alert("There was an error performing this action. Please try again.");
} else {
action.error = false;
syncManager.sync(null);
}
})
}
$scope.changeExtensionEncryptionFormat = function(encrypted, extension) {
extensionManager.changeExtensionEncryptionFormat(encrypted, extension);
}
$scope.deleteExtension = function(extension) {
if(confirm("Are you sure you want to delete this extension?")) {
extensionManager.deleteExtension(extension);
}
}
$scope.reloadExtensionsPressed = function() {
if(confirm("For your security, reloading extensions will disable any currently enabled repeat actions.")) {
extensionManager.refreshExtensionsFromServer();
}
}
}
}
angular.module('app.frontend').directive('globalExtensionsMenu', () => new GlobalExtensionsMenu);