ngReorg - move dashboard-app to dashboard
Move the angular app module from the framework to openstack_dashboard at the top level as "horizon.app". This edit also removes the old hzUtils.log function: it exists in the framework, but is configured in the application, thus causing dependency issues. It is only used in one place (hz.tables.js), and for debugging. I contend that if debugging is needed then $log can be asked for as needed. The hzConfig.debug flag was only used by that one function, so it is also removed in this edit. Change-Id: Ie538940cd8d1b0eabe677790bad979cc146bfbd1 Closes-Bug: #1458697 Closes-Bug: #1465885
This commit is contained in:
parent
e44d95fa21
commit
2270e9139b
@ -66,9 +66,6 @@ module.exports = function(config) {
|
|||||||
|
|
||||||
// from jasmine_tests.py; only those that are deps for others
|
// from jasmine_tests.py; only those that are deps for others
|
||||||
'horizon/js/horizon.js',
|
'horizon/js/horizon.js',
|
||||||
'../../openstack_dashboard/static/openstack-service-api/openstack-service-api.module.js',
|
|
||||||
'dashboard-app/dashboard-app.module.js',
|
|
||||||
'dashboard-app/**/*.js',
|
|
||||||
'auth/auth.module.js',
|
'auth/auth.module.js',
|
||||||
'auth/login/login.module.js',
|
'auth/login/login.module.js',
|
||||||
'framework/framework.module.js',
|
'framework/framework.module.js',
|
||||||
|
@ -3,26 +3,14 @@
|
|||||||
|
|
||||||
angular
|
angular
|
||||||
.module('horizon.framework.util.tech-debt')
|
.module('horizon.framework.util.tech-debt')
|
||||||
.service('horizon.framework.util.tech-debt.helper-functions', utils);
|
.factory('horizon.framework.util.tech-debt.helper-functions', utils);
|
||||||
|
|
||||||
// An example of using the John Papa recommended $inject instead of in-line array syntax
|
// An example of using the John Papa recommended $inject instead of in-line
|
||||||
utils.$inject = [
|
// array syntax
|
||||||
'horizon.dashboard-app.conf',
|
utils.$inject = ['$rootScope', '$compile'];
|
||||||
'$log',
|
|
||||||
'$rootScope',
|
|
||||||
'$compile'];
|
|
||||||
|
|
||||||
function utils(hzConfig, $log, $rootScope, $compile) {
|
function utils($rootScope, $compile) {
|
||||||
return {
|
return {
|
||||||
/*
|
|
||||||
Use the log levels of http://docs.angularjs.org/api/ng.$log
|
|
||||||
default to log level.
|
|
||||||
*/
|
|
||||||
log: function (msg, lvl) {
|
|
||||||
if (hzConfig.debug) {
|
|
||||||
($log[lvl] || $log.log)(msg);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
capitalize: function (string) {
|
capitalize: function (string) {
|
||||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||||
},
|
},
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe('horizon.framework.util.tech-debt', function () {
|
|
||||||
|
|
||||||
describe('horizon.framework.util.tech-debt.helper-functions', function () {
|
describe('horizon.framework.util.tech-debt.helper-functions', function () {
|
||||||
|
|
||||||
beforeEach(module('horizon.dashboard-app'));
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
angular.mock.module('horizon.framework.util.tech-debt');
|
angular.mock.module('horizon.framework.util.tech-debt');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('horizon.framework.util.tech-debt.helper-functions', function () {
|
|
||||||
var hzUtils;
|
var hzUtils;
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
angular.mock.inject(function ($injector) {
|
angular.mock.inject(function ($injector) {
|
||||||
@ -18,43 +13,6 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('log', function () {
|
|
||||||
var hzConfig, $log, log;
|
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
log = 'display a log';
|
|
||||||
angular.mock.inject(function ($injector) {
|
|
||||||
$log = $injector.get('$log');
|
|
||||||
hzConfig = $injector.get('horizon.dashboard-app.conf');
|
|
||||||
//jasmine cannot mock properties
|
|
||||||
hzConfig.debug = true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should display a log at default log level', function () {
|
|
||||||
hzUtils.log(log);
|
|
||||||
expect($log.log.logs.length).toBe(1);
|
|
||||||
expect($log.log.logs[0][0]).toBe(log);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should have a configurable log level', function () {
|
|
||||||
hzUtils.log(log, 'debug');
|
|
||||||
expect($log.debug.logs.length).toBe(1);
|
|
||||||
|
|
||||||
hzUtils.log(log, 'error');
|
|
||||||
expect($log.error.logs.length).toBe(1);
|
|
||||||
|
|
||||||
hzUtils.log(log, 'info');
|
|
||||||
expect($log.info.logs.length).toBe(1);
|
|
||||||
|
|
||||||
hzUtils.log(log, 'log');
|
|
||||||
expect($log.log.logs.length).toBe(1);
|
|
||||||
|
|
||||||
hzUtils.log(log, 'warn');
|
|
||||||
expect($log.warn.logs.length).toBe(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('capitalize', function () {
|
describe('capitalize', function () {
|
||||||
it('should capitalize the first letter of a string', function () {
|
it('should capitalize the first letter of a string', function () {
|
||||||
expect(hzUtils.capitalize('string to test')).toBe('String to test');
|
expect(hzUtils.capitalize('string to test')).toBe('String to test');
|
||||||
@ -92,7 +50,7 @@
|
|||||||
toBe(string);
|
toBe(string);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add an ellipsis if needed', function () {
|
it('should add an ellipsis if needed ', function () {
|
||||||
expect(hzUtils.truncate(string, 15, true)).
|
expect(hzUtils.truncate(string, 15, true)).
|
||||||
toBe(string.slice(0, 12) + ellipsis);
|
toBe(string.slice(0, 12) + ellipsis);
|
||||||
|
|
||||||
@ -116,7 +74,7 @@
|
|||||||
spyOn(rootScope, '$apply');
|
spyOn(rootScope, '$apply');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call a compile and apply', function () {
|
it('should call a compile and apply ', function () {
|
||||||
hzUtils.loadAngular(element);
|
hzUtils.loadAngular(element);
|
||||||
//checks the use of apply function
|
//checks the use of apply function
|
||||||
expect(rootScope.$apply).toHaveBeenCalled();
|
expect(rootScope.$apply).toHaveBeenCalled();
|
||||||
@ -125,7 +83,4 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* global STATIC_URL */
|
/* global STATIC_URL, console */
|
||||||
/* Namespace for core functionality related to DataTables. */
|
/* Namespace for core functionality related to DataTables. */
|
||||||
horizon.datatables = {
|
horizon.datatables = {
|
||||||
update: function () {
|
update: function () {
|
||||||
@ -56,7 +56,7 @@ horizon.datatables = {
|
|||||||
horizon.datatables.update_actions();
|
horizon.datatables.update_actions();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
horizon.utils.log(gettext("An error occurred while updating."));
|
console.log(gettext("An error occurred while updating."));
|
||||||
$row.removeClass("ajax-update");
|
$row.removeClass("ajax-update");
|
||||||
$row.find("i.ajax-updating").remove();
|
$row.find("i.ajax-updating").remove();
|
||||||
break;
|
break;
|
||||||
@ -127,7 +127,7 @@ horizon.datatables = {
|
|||||||
horizon.ajax.queue({
|
horizon.ajax.queue({
|
||||||
url: $action.attr('data-update-url'),
|
url: $action.attr('data-update-url'),
|
||||||
error: function () {
|
error: function () {
|
||||||
horizon.utils.log(gettext("An error occurred while updating."));
|
console.log(gettext("An error occurred while updating."));
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
var $new_action = $(data);
|
var $new_action = $(data);
|
||||||
|
@ -32,8 +32,6 @@ class ServicesTests(test.JasmineTests):
|
|||||||
'auth/login/login.controller.js',
|
'auth/login/login.controller.js',
|
||||||
'auth/login/login-finder.directive.js',
|
'auth/login/login-finder.directive.js',
|
||||||
|
|
||||||
'dashboard-app/dashboard-app.module.js',
|
|
||||||
|
|
||||||
'framework/framework.module.js',
|
'framework/framework.module.js',
|
||||||
|
|
||||||
'framework/conf/conf.js',
|
'framework/conf/conf.js',
|
||||||
|
@ -71,7 +71,8 @@ module.exports = function(config) {
|
|||||||
'openstack-service-api/openstack-service-api.module.js',
|
'openstack-service-api/openstack-service-api.module.js',
|
||||||
'openstack-service-api/**/*.js',
|
'openstack-service-api/**/*.js',
|
||||||
|
|
||||||
// This one seems to have to come first.
|
// first load dependencies in order that matters
|
||||||
|
"app/app.module.js",
|
||||||
"dashboard/dashboard.module.js",
|
"dashboard/dashboard.module.js",
|
||||||
"dashboard/workflow/workflow.js",
|
"dashboard/workflow/workflow.js",
|
||||||
"dashboard/launch-instance/launch-instance.js",
|
"dashboard/launch-instance/launch-instance.js",
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('horizon.dashboard-app', [
|
angular.module('horizon.app', [
|
||||||
'horizon.framework',
|
|
||||||
'horizon.auth',
|
'horizon.auth',
|
||||||
'horizon.openstack-service-api',
|
'horizon.openstack-service-api',
|
||||||
|
'horizon.framework',
|
||||||
|
'hz.dashboard',
|
||||||
'ngCookies'].concat(angularModuleExtension))
|
'ngCookies'].concat(angularModuleExtension))
|
||||||
|
|
||||||
.constant('horizon.dashboard-app.conf', {
|
.constant('horizon.app.conf', {
|
||||||
// Placeholders; updated by Django.
|
// Placeholders; updated by Django.
|
||||||
debug: null, //
|
|
||||||
static_url: null,
|
static_url: null,
|
||||||
ajax: {
|
ajax: {
|
||||||
queue_limit: null
|
queue_limit: null
|
||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
.run([
|
.run([
|
||||||
'horizon.framework.conf.spinner_options',
|
'horizon.framework.conf.spinner_options',
|
||||||
'horizon.dashboard-app.conf',
|
'horizon.app.conf',
|
||||||
'horizon.framework.util.tech-debt.helper-functions',
|
'horizon.framework.util.tech-debt.helper-functions',
|
||||||
'$cookieStore',
|
'$cookieStore',
|
||||||
'$http',
|
'$http',
|
@ -14,7 +14,7 @@
|
|||||||
{% include "horizon/client_side/_script_loader.html" %}
|
{% include "horizon/client_side/_script_loader.html" %}
|
||||||
{% include "horizon/_custom_head_js.html" %}
|
{% include "horizon/_custom_head_js.html" %}
|
||||||
</head>
|
</head>
|
||||||
<body id="{% block body_id %}{% endblock %}" ng-app='horizon.dashboard-app'>
|
<body id="{% block body_id %}{% endblock %}" ng-app='horizon.app'>
|
||||||
<noscript>
|
<noscript>
|
||||||
<div class="javascript_disabled_alert">
|
<div class="javascript_disabled_alert">
|
||||||
{% trans "This application requires JavaScript to be enabled in your web browser." %}
|
{% trans "This application requires JavaScript to be enabled in your web browser." %}
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{% compress js %}
|
{% compress js %}
|
||||||
<script src='{{ STATIC_URL }}dashboard-app/dashboard-app.module.js' type='text/javascript' charset='utf-8'></script>
|
<script src="{{ STATIC_URL }}app/app.module.js"></script>
|
||||||
{% endcompress %}
|
{% endcompress %}
|
||||||
|
|
||||||
<script type='text/javascript' charset='utf-8'>
|
<script type='text/javascript' charset='utf-8'>
|
||||||
@ -31,9 +31,8 @@
|
|||||||
* should be aware of.
|
* should be aware of.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
angular.module('horizon.dashboard-app')
|
angular.module('horizon.app')
|
||||||
.config(['horizon.dashboard-app.conf', function (hzConfig) {
|
.config(['horizon.app.conf', function (hzConfig) {
|
||||||
hzConfig.debug = {{ debug|yesno:"true,false" }};
|
|
||||||
hzConfig.static_url = "{{ STATIC_URL }}";
|
hzConfig.static_url = "{{ STATIC_URL }}";
|
||||||
hzConfig.ajax = {
|
hzConfig.ajax = {
|
||||||
queue_limit: {{ HORIZON_CONFIG.ajax_queue_limit|default:"null" }}
|
queue_limit: {{ HORIZON_CONFIG.ajax_queue_limit|default:"null" }}
|
||||||
|
Loading…
Reference in New Issue
Block a user