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
This commit is contained in:
parent
55d88786fd
commit
66485be81a
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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/'
|
||||
)
|
||||
|
@ -13,36 +13,32 @@
|
||||
{% endcompress %}
|
||||
|
||||
<script type='text/javascript' charset='utf-8'>
|
||||
(function (global) {
|
||||
'use strict';
|
||||
|
||||
// make translation info available on client
|
||||
horizon.languageCode = '{{ LANGUAGE_CODE }}';
|
||||
horizon.languageBidi = '{{ LANGUAGE_BIDI }}';
|
||||
horizon.datepickerLocale = '{{ DATEPICKER_LOCALE }}';
|
||||
|
||||
/* Load angular modules extensions list before we include angular/horizon.js */
|
||||
var horizonPlugInModules = {{ HORIZON_CONFIG.angular_modules|default:"[]"|safe }};
|
||||
</script>
|
||||
global.horizonPlugInModules = {{ HORIZON_CONFIG.angular_modules|default:"[]"|safe }};
|
||||
|
||||
{% compress js %}
|
||||
<script src="{{ STATIC_URL }}app/app.module.js"></script>
|
||||
{% endcompress %}
|
||||
|
||||
<script type='text/javascript' charset='utf-8'>
|
||||
/* Storage for backend configuration variables which the frontend
|
||||
* should be aware of.
|
||||
*/
|
||||
|
||||
angular.module('horizon.app')
|
||||
.config(['horizon.app.conf', function (hzConfig) {
|
||||
hzConfig.static_url = "{{ STATIC_URL }}";
|
||||
hzConfig.ajax = {
|
||||
/* Storage for backend configuration variables which the frontend
|
||||
* should be aware of.
|
||||
*/
|
||||
var conf = horizon.conf;
|
||||
conf.static_url = "{{ STATIC_URL }}";
|
||||
conf.ajax = {
|
||||
queue_limit: {{ HORIZON_CONFIG.ajax_queue_limit|default:"null" }}
|
||||
};
|
||||
hzConfig.auto_fade_alerts = {
|
||||
conf.auto_fade_alerts = {
|
||||
delay: {{ HORIZON_CONFIG.auto_fade_alerts.delay|default:"3000" }},
|
||||
fade_duration: {{ HORIZON_CONFIG.auto_fade_alerts.fade_duration|default:"1500" }},
|
||||
types: {{ HORIZON_CONFIG.auto_fade_alerts.types|default:"[]"|safe }}
|
||||
};
|
||||
hzConfig.disable_password_reveal = {{ HORIZON_CONFIG.disable_password_reveal|yesno:"true,false" }};
|
||||
}]);
|
||||
conf.disable_password_reveal =
|
||||
{{ HORIZON_CONFIG.disable_password_reveal|yesno:"true,false" }};
|
||||
|
||||
})(this);
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user