functional minimalism
This commit is contained in:
@@ -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);
|
||||
Reference in New Issue
Block a user