Merge "Allow extensions to add Angular modules"
This commit is contained in:
commit
90474517de
@ -156,6 +156,24 @@ when associating one with an instance.
|
||||
can be associated with each VIF and we need to check whether there is only
|
||||
one VIF for an instance to enable simple association support.
|
||||
|
||||
``angular_modules``
|
||||
-------------------------
|
||||
|
||||
Default: ``[]``
|
||||
|
||||
A list of AngularJS modules to be loaded when Angular bootstraps. These modules
|
||||
are added as dependencies on the root Horizon application ``hz``.
|
||||
|
||||
``js_files``
|
||||
-------------------------
|
||||
|
||||
Default: ``[]``
|
||||
|
||||
A list of javascript files to be included in the compressed set of files that are
|
||||
loaded on every page. This is needed for AngularJS modules that are referenced in
|
||||
``angular_modules`` and therefore need to be include in every page.
|
||||
|
||||
|
||||
OpenStack Settings (Partial)
|
||||
============================
|
||||
|
||||
@ -526,6 +544,19 @@ A dictionary of exception classes to be added to ``HORIZON['exceptions']``.
|
||||
A list of applications to be prepended to ``INSTALLED_APPS``.
|
||||
This is needed to expose static files from a plugin.
|
||||
|
||||
``ADD_ANGULAR_MODULES``
|
||||
----------------------
|
||||
|
||||
A list of AngularJS modules to be loaded when Angular bootstraps. These modules
|
||||
are added as dependencies on the root Horizon application ``hz``.
|
||||
|
||||
``ADD_JS_FILES``
|
||||
----------------------
|
||||
|
||||
A list of javascript files to be included in the compressed set of files that are
|
||||
loaded on every page. This is needed for AngularJS modules that are referenced in
|
||||
``ADD_ANGULAR_MODULES`` and therefore need to be included in every page.
|
||||
|
||||
``DISABLED``
|
||||
------------
|
||||
|
||||
@ -632,6 +663,19 @@ If set to ``True``, the PANEL will be removed from PANEL_DASHBOARD/PANEL_GROUP.
|
||||
A list of applications to be prepended to ``INSTALLED_APPS``.
|
||||
This is needed to expose static files from a plugin.
|
||||
|
||||
``ADD_ANGULAR_MODULES``
|
||||
----------------------
|
||||
|
||||
A list of AngularJS modules to be loaded when Angular bootstraps. These modules
|
||||
are added as dependencies on the root Horizon application ``hz``.
|
||||
|
||||
``ADD_JS_FILES``
|
||||
----------------------
|
||||
|
||||
A list of javascript files to be included in the compressed set of files that are
|
||||
loaded on every page. This is needed for AngularJS modules that are referenced in
|
||||
``ADD_ANGULAR_MODULES`` and therefore need to be included in every page.
|
||||
|
||||
``DISABLED``
|
||||
------------
|
||||
|
||||
|
4
horizon/static/horizon/js/angular/horizon.js
vendored
4
horizon/static/horizon/js/angular/horizon.js
vendored
@ -1,4 +1,6 @@
|
||||
var horizonApp = angular.module('hz', ['hz.conf', 'hz.utils', 'ngCookies'])
|
||||
var horizon_dependencies = ['hz.conf', 'hz.utils', 'ngCookies'];
|
||||
dependencies = horizon_dependencies.concat(angularModuleExtension);
|
||||
var horizonApp = angular.module('hz', dependencies)
|
||||
.config(['$interpolateProvider', '$httpProvider',
|
||||
function ($interpolateProvider, $httpProvider) {
|
||||
$interpolateProvider.startSymbol('{$');
|
||||
|
@ -1,12 +1,13 @@
|
||||
{% load compress %}
|
||||
|
||||
{% compress js %}
|
||||
|
||||
<script src='{{ STATIC_URL }}horizon/lib/jquery/jquery.js' type='text/javascript' charset="utf-8"></script>
|
||||
<script src="{{ STATIC_URL }}horizon/lib/angular/angular.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
|
||||
<script src='{{ STATIC_URL }}horizon/js/horizon.js' type='text/javascript' charset='utf-8'></script>
|
||||
<script type='text/javascript' charset='utf-8'>
|
||||
/* Load angular modules extensions list before we include angular/horizon.js */
|
||||
var angularModuleExtension = {{ HORIZON_CONFIG.angular_modules|default:"[]"|safe }};
|
||||
</script>
|
||||
<script src='{{ STATIC_URL }}horizon/js/angular/horizon.js' type='text/javascript' charset='utf-8'></script>
|
||||
<script type='text/javascript' charset='utf-8'>
|
||||
/* Storage for backend configuration variables which the frontend
|
||||
|
@ -6,6 +6,9 @@
|
||||
|
||||
{% comment %} Compress jQuery, Angular, Plugins, Bootstrap, Hogan.js and Horizon-specific JS. {% endcomment %}
|
||||
{% compress js %}
|
||||
{% for file in HORIZON_CONFIG.js_files %}
|
||||
<script src='{{ STATIC_URL }}{{ file }}' type='text/javascript' charset='utf-8'></script>
|
||||
{% endfor %}
|
||||
<script src='{{ STATIC_URL }}horizon/lib/angular/angular-cookies.js' type='text/javascript' charset='utf-8'></script>
|
||||
|
||||
<script src='{{ STATIC_URL }}horizon/js/angular/controllers/dummy.js' type='text/javascript' charset='utf-8'></script>
|
||||
|
@ -121,7 +121,7 @@ HORIZON_CONFIG = {
|
||||
"help_text": "Password must be between 8 and 18 characters."
|
||||
},
|
||||
'user_home': None,
|
||||
'help_url': "http://example.com"
|
||||
'help_url': "http://example.com",
|
||||
}
|
||||
|
||||
COMPRESS_ENABLED = True
|
||||
|
@ -63,6 +63,8 @@ HORIZON_CONFIG = {
|
||||
'exceptions': {'recoverable': exceptions.RECOVERABLE,
|
||||
'not_found': exceptions.NOT_FOUND,
|
||||
'unauthorized': exceptions.UNAUTHORIZED},
|
||||
'angular_modules': [],
|
||||
'js_files': [],
|
||||
}
|
||||
|
||||
# Specify a regular expression to validate user passwords.
|
||||
|
@ -67,6 +67,8 @@ HORIZON_CONFIG = {
|
||||
'exceptions': {'recoverable': exceptions.RECOVERABLE,
|
||||
'not_found': exceptions.NOT_FOUND,
|
||||
'unauthorized': exceptions.UNAUTHORIZED},
|
||||
'angular_modules': [],
|
||||
'js_files': [],
|
||||
}
|
||||
|
||||
# Set to True to allow users to upload images to glance via Horizon server.
|
||||
|
@ -79,6 +79,8 @@ HORIZON_CONFIG = {
|
||||
'exceptions': {'recoverable': exceptions.RECOVERABLE,
|
||||
'not_found': exceptions.NOT_FOUND,
|
||||
'unauthorized': exceptions.UNAUTHORIZED},
|
||||
'angular_modules': [],
|
||||
'js_files': [],
|
||||
}
|
||||
|
||||
# Set to True to allow users to upload images to glance via Horizon server.
|
||||
|
@ -0,0 +1 @@
|
||||
angular.module('testAngularModule', []);
|
@ -8,3 +8,12 @@ PANEL_GROUP = 'admin'
|
||||
# Python panel class of the PANEL to be added.
|
||||
ADD_PANEL = \
|
||||
'openstack_dashboard.test.test_panels.plugin_panel.panel.PluginPanel'
|
||||
|
||||
# A list of Django applications to be prepended to ``INSTALLED_APPS``
|
||||
ADD_INSTALLED_APPS = ['openstack_dashboard.test.test_panels.plugin_panel']
|
||||
|
||||
# A list of AngularJS modules to be loaded when Angular bootstraps.
|
||||
ADD_ANGULAR_MODULES = ['testAngularModule']
|
||||
|
||||
# A list of javascript files to be included in the compressed set of files
|
||||
ADD_JS_FILES = ['plugin_panel/plugin_module.js']
|
||||
|
@ -86,12 +86,16 @@ def update_dashboards(modules, horizon_config, installed_apps):
|
||||
dashboards = []
|
||||
exceptions = {}
|
||||
apps = []
|
||||
angular_modules = []
|
||||
js_files = set()
|
||||
panel_customization = []
|
||||
update_horizon_config = {}
|
||||
for key, config in import_dashboard_config(modules):
|
||||
if config.get('DISABLED', False):
|
||||
continue
|
||||
apps.extend(config.get('ADD_INSTALLED_APPS', []))
|
||||
angular_modules.extend(config.get('ADD_ANGULAR_MODULES', []))
|
||||
js_files.update(config.get('ADD_JS_FILES', []))
|
||||
if config.get('DASHBOARD'):
|
||||
dashboard = key
|
||||
dashboards.append(dashboard)
|
||||
@ -107,4 +111,6 @@ def update_dashboards(modules, horizon_config, installed_apps):
|
||||
horizon_config['dashboards'] = tuple(dashboards)
|
||||
horizon_config['exceptions'].update(exceptions)
|
||||
horizon_config.update(update_horizon_config)
|
||||
horizon_config.setdefault('angular_modules', []).extend(angular_modules)
|
||||
horizon_config.setdefault('js_files', []).extend(js_files)
|
||||
installed_apps[:] = apps + installed_apps
|
||||
|
2
tox.ini
2
tox.ini
@ -53,7 +53,7 @@ downloadcache = ~/cache/pip
|
||||
|
||||
[flake8]
|
||||
builtins = _
|
||||
exclude = .venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*
|
||||
exclude = .venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*
|
||||
# E127 continuation line over-indented for visual indent
|
||||
# E128 continuation line under-indented for visual indent
|
||||
# H701 empty localization string
|
||||
|
Loading…
x
Reference in New Issue
Block a user