From 66485be81a3f100b0672a3193823cd8a4bbc177e Mon Sep 17 00:00:00 2001 From: Tyr Johanson Date: Fri, 24 Jul 2015 16:34:57 -0600 Subject: [PATCH] Auto-collect app/ instead of only app/core/ Angular code for openstack_dashboard is almost finished migrating to openstack_dashboard/static/app/. Previously, the root module of app (app.module.js) was explicitly included from _conf.html so that environment variables from Django could be captured in the 'horizon.app.conf' constant. This prevented auto-collection at the static/app/ level because app.module.js will be included twice (once from _conf.html, and again during auto-collection) It turns out that 'horizon.app.conf' is unnecessary as an Angular constant. It's only use is to initialize the 'horizon.conf' global provided by horizon.js. This patch refactors _conf.html to directly initialize horizon.conf. This removes the need for app.module.js to be included from _conf.html, which allows us to change the auto-collection directory to 'app/'. Now all files in horizon/static and openstack_dashboard/static/app are auto-collected, without including app.module.js twice. All new angular files are expected to live in one of these two locations, minimizing changes to static_settings.py to include new files for auto-collection Change-Id: I95b6f13c85eb08c875885812a7db054a5aa6e7c2 Partial-Bug: #1458697 Closes-Bug: #1477825 --- horizon/static/horizon/js/horizon.js | 5 +++ openstack_dashboard/static/app/app.module.js | 14 +------- openstack_dashboard/static_settings.py | 2 +- .../templates/horizon/_conf.html | 32 ++++++++----------- 4 files changed, 21 insertions(+), 32 deletions(-) diff --git a/horizon/static/horizon/js/horizon.js b/horizon/static/horizon/js/horizon.js index 3caf127ee1..8edd37c078 100644 --- a/horizon/static/horizon/js/horizon.js +++ b/horizon/static/horizon/js/horizon.js @@ -38,6 +38,11 @@ var Horizon = function () { .replace(/\//g, '/'); }; + /* Storage for backend configuration variables which the frontend + * should be aware of. + */ + horizon.conf = {}; + return horizon; }; diff --git a/openstack_dashboard/static/app/app.module.js b/openstack_dashboard/static/app/app.module.js index da5ef6dc1a..35f1acd0cc 100644 --- a/openstack_dashboard/static/app/app.module.js +++ b/openstack_dashboard/static/app/app.module.js @@ -59,20 +59,11 @@ .concat(horizonPlugInModules) ) - .constant('horizon.app.conf', { - // Placeholders; updated by Django. - static_url: null, - ajax: { - queue_limit: null - } - }) - .run(updateHorizon); updateHorizon.$inject = [ 'gettextCatalog', 'horizon.framework.conf.spinner_options', - 'horizon.app.conf', 'horizon.framework.util.tech-debt.helper-functions', '$cookieStore', '$http', @@ -82,7 +73,6 @@ function updateHorizon( gettextCatalog, spinnerOptions, - hzConfig, hzUtils, $cookieStore, $http, @@ -93,9 +83,7 @@ //expose the configuration for horizon legacy variable horizon.utils = hzUtils; - horizon.conf = angular.extend({ - spinner_options: spinnerOptions - }, hzConfig); + horizon.conf.spinner_options = spinnerOptions; horizon.cookies = angular.extend({}, $cookieStore, { put: put, diff --git a/openstack_dashboard/static_settings.py b/openstack_dashboard/static_settings.py index 9e847227c3..fe6f5dc1b4 100644 --- a/openstack_dashboard/static_settings.py +++ b/openstack_dashboard/static_settings.py @@ -153,5 +153,5 @@ def find_static_files(ROOT_PATH, HORIZON_CONFIG): file_discovery.populate_horizon_config( HORIZON_CONFIG, os.path.join(ROOT_PATH, 'static/'), - sub_path='app/core/' + sub_path='app/' ) diff --git a/openstack_dashboard/templates/horizon/_conf.html b/openstack_dashboard/templates/horizon/_conf.html index 3d42af67dd..65fb8840b5 100644 --- a/openstack_dashboard/templates/horizon/_conf.html +++ b/openstack_dashboard/templates/horizon/_conf.html @@ -13,36 +13,32 @@ {% endcompress %} + global.horizonPlugInModules = {{ HORIZON_CONFIG.angular_modules|default:"[]"|safe }}; -{% compress js %} - -{% endcompress %} - -