From 2f3538c1329444edca8f091c97d24d789261216a 2016-11-08 15:29:53 From: Marcin Lulek Date: 2016-11-08 15:29:53 Subject: [PATCH] plugins: allow to set callables that execute after application gets run --- diff --git a/backend/src/appenlight/static/js/appenlight.js b/backend/src/appenlight/static/js/appenlight.js index e5cceb6..353d45b 100644 --- a/backend/src/appenlight/static/js/appenlight.js +++ b/backend/src/appenlight/static/js/appenlight.js @@ -2814,6 +2814,7 @@ function kickstartAE(initialUserData) { app.run(['$rootScope', '$timeout', 'stateHolder', '$state', '$location', '$transitions', '$window', 'AeConfig', function ($rootScope, $timeout, stateHolder, $state, $location, $transitions, $window, AeConfig) { + if (initialUserData){ stateHolder.AeUser.update(initialUserData); @@ -2873,8 +2874,12 @@ function kickstartAE(initialUserData) { } return true; }; - $transitions.onBefore({}, transitionApp); + for (var i=0; i < stateHolder.plugins.callables.length; i++){ + + } + + $transitions.onBefore({}, transitionApp); }]); } @@ -6894,6 +6899,11 @@ function kickstartAE(initialUserData) { ); + $templateCache.put('templates/admin/groups/parent_view.html', + "
" + ); + + $templateCache.put('templates/directives/search_type_ahead.html', "\n" + " {{match.model.tag}}\n" + @@ -11921,9 +11931,8 @@ angular.module('appenlight.directives.pluginConfig', []).directive('pluginConfig PluginConfig.$inject = ['stateHolder']; function PluginConfig(stateHolder) { - var vm = this; - vm.plugins = {}; - vm.inclusions = stateHolder.plugins.inclusions[vm.section]; + this.plugins = {}; + this.inclusions = stateHolder.plugins.inclusions[this.section]; } }); @@ -13159,6 +13168,7 @@ angular.module('appenlight.services.stateHolder', []).factory('stateHolder', var Plugins = { enabled: [], configs: {}, + callables: [], inclusions: {}, addInclusion: function (name, inclusion) { var self = this; diff --git a/frontend/src/app.js b/frontend/src/app.js index 7c29d3c..f7e7f56 100644 --- a/frontend/src/app.js +++ b/frontend/src/app.js @@ -178,6 +178,7 @@ function kickstartAE(initialUserData) { app.run(['$rootScope', '$timeout', 'stateHolder', '$state', '$location', '$transitions', '$window', 'AeConfig', function ($rootScope, $timeout, stateHolder, $state, $location, $transitions, $window, AeConfig) { + console.log('appenlight run()'); if (initialUserData){ stateHolder.AeUser.update(initialUserData); @@ -237,7 +238,12 @@ function kickstartAE(initialUserData) { } return true; }; - $transitions.onBefore({}, transitionApp); + for (var i=0; i < stateHolder.plugins.callables.length; i++){ + console.log('X', stateHolder.plugins.callables.length) + stateHolder.plugins.callables[i](); + } + + $transitions.onBefore({}, transitionApp); }]); } diff --git a/frontend/src/directives/plugin_config/plugin_config.js b/frontend/src/directives/plugin_config/plugin_config.js index 86152a5..63d2402 100644 --- a/frontend/src/directives/plugin_config/plugin_config.js +++ b/frontend/src/directives/plugin_config/plugin_config.js @@ -33,8 +33,7 @@ angular.module('appenlight.directives.pluginConfig', []).directive('pluginConfig PluginConfig.$inject = ['stateHolder']; function PluginConfig(stateHolder) { - var vm = this; - vm.plugins = {}; - vm.inclusions = stateHolder.plugins.inclusions[vm.section]; + this.plugins = {}; + this.inclusions = stateHolder.plugins.inclusions[this.section]; } }); diff --git a/frontend/src/services/state_holder.js b/frontend/src/services/state_holder.js index 4def23e..db7c3f2 100644 --- a/frontend/src/services/state_holder.js +++ b/frontend/src/services/state_holder.js @@ -139,6 +139,7 @@ angular.module('appenlight.services.stateHolder', []).factory('stateHolder', var Plugins = { enabled: [], configs: {}, + callables: [], inclusions: {}, addInclusion: function (name, inclusion) { var self = this;