diff --git a/horizon/karma.conf.js b/horizon/karma.conf.js
index 7986adb3cf..50f6742a19 100644
--- a/horizon/karma.conf.js
+++ b/horizon/karma.conf.js
@@ -66,9 +66,6 @@ module.exports = function(config) {
// from jasmine_tests.py; only those that are deps for others
'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/login/login.module.js',
'framework/framework.module.js',
diff --git a/horizon/static/framework/util/tech-debt/helper-functions.js b/horizon/static/framework/util/tech-debt/helper-functions.js
index ee8589da64..0dc3c73301 100644
--- a/horizon/static/framework/util/tech-debt/helper-functions.js
+++ b/horizon/static/framework/util/tech-debt/helper-functions.js
@@ -3,26 +3,14 @@
angular
.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
- utils.$inject = [
- 'horizon.dashboard-app.conf',
- '$log',
- '$rootScope',
- '$compile'];
+ // An example of using the John Papa recommended $inject instead of in-line
+ // array syntax
+ utils.$inject = ['$rootScope', '$compile'];
- function utils(hzConfig, $log, $rootScope, $compile) {
+ function utils($rootScope, $compile) {
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) {
return string.charAt(0).toUpperCase() + string.slice(1);
},
diff --git a/horizon/static/framework/util/tech-debt/helper-functions.spec.js b/horizon/static/framework/util/tech-debt/helper-functions.spec.js
index 0c6b1f333d..7614fc3be3 100644
--- a/horizon/static/framework/util/tech-debt/helper-functions.spec.js
+++ b/horizon/static/framework/util/tech-debt/helper-functions.spec.js
@@ -1,131 +1,86 @@
(function() {
'use strict';
- describe('horizon.framework.util.tech-debt', function () {
+ describe('horizon.framework.util.tech-debt.helper-functions', function () {
+ beforeEach(function () {
+ angular.mock.module('horizon.framework.util.tech-debt');
+ });
- describe('horizon.framework.util.tech-debt.helper-functions', function () {
+ var hzUtils;
+ beforeEach(function () {
+ angular.mock.inject(function ($injector) {
+ hzUtils = $injector.get('horizon.framework.util.tech-debt.helper-functions');
+ });
+ });
- beforeEach(module('horizon.dashboard-app'));
- beforeEach(function () {
- angular.mock.module('horizon.framework.util.tech-debt');
+ describe('capitalize', function () {
+ it('should capitalize the first letter of a string', function () {
+ expect(hzUtils.capitalize('string to test')).toBe('String to test');
+ });
+ });
+
+ describe('humanizeNumbers', function () {
+ it('should add a comma every three number', function () {
+ expect(hzUtils.humanizeNumbers('1234')).toBe('1,234');
+ expect(hzUtils.humanizeNumbers('1234567')).toBe('1,234,567');
});
- describe('horizon.framework.util.tech-debt.helper-functions', function () {
- var hzUtils;
- beforeEach(function () {
- angular.mock.inject(function ($injector) {
- hzUtils = $injector.get('horizon.framework.util.tech-debt.helper-functions');
- });
+ it('should work with string or numbers', function () {
+ expect(hzUtils.humanizeNumbers('1234')).toBe('1,234');
+ expect(hzUtils.humanizeNumbers(1234)).toBe('1,234');
+ });
+
+ it('should work with multiple values through a string', function () {
+ expect(hzUtils.humanizeNumbers('My Total: 1234')).
+ toBe('My Total: 1,234');
+
+ expect(hzUtils.humanizeNumbers('My Total: 1234, His Total: 1234567')).
+ toBe('My Total: 1,234, His Total: 1,234,567');
+ });
+ });
+
+ describe('truncate', function () {
+ var string = 'This will be cut';
+ var ellipsis = '…';
+
+ it('should truncate a string at a given length', function () {
+ expect(hzUtils.truncate(string, 15)).
+ toBe(string.slice(0, 15));
+ expect(hzUtils.truncate(string, 20)).
+ toBe(string);
+ });
+
+ it('should add an ellipsis if needed ', function () {
+ expect(hzUtils.truncate(string, 15, true)).
+ toBe(string.slice(0, 12) + ellipsis);
+
+ expect(hzUtils.truncate(string, 20, true)).
+ toBe(string);
+
+ expect(hzUtils.truncate(string, 2, true)).
+ toBe(ellipsis);
+ });
+ });
+
+ describe('loadAngular', function () {
+ var rootScope, element;
+
+ beforeEach(function () {
+ element = angular.element('
');
+
+ angular.mock.inject(function ($injector) {
+ rootScope = $injector.get('$rootScope');
});
+ spyOn(rootScope, '$apply');
+ });
- 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 () {
- it('should capitalize the first letter of a string', function () {
- expect(hzUtils.capitalize('string to test')).toBe('String to test');
- });
- });
-
- describe('humanizeNumbers', function () {
- it('should add a comma every three number', function () {
- expect(hzUtils.humanizeNumbers('1234')).toBe('1,234');
- expect(hzUtils.humanizeNumbers('1234567')).toBe('1,234,567');
- });
-
- it('should work with string or numbers', function () {
- expect(hzUtils.humanizeNumbers('1234')).toBe('1,234');
- expect(hzUtils.humanizeNumbers(1234)).toBe('1,234');
- });
-
- it('should work with multiple values through a string', function () {
- expect(hzUtils.humanizeNumbers('My Total: 1234')).
- toBe('My Total: 1,234');
-
- expect(hzUtils.humanizeNumbers('My Total: 1234, His Total: 1234567')).
- toBe('My Total: 1,234, His Total: 1,234,567');
- });
- });
-
- describe('truncate', function () {
- var string = 'This will be cut';
- var ellipsis = '…';
-
- it('should truncate a string at a given length', function () {
- expect(hzUtils.truncate(string, 15)).
- toBe(string.slice(0, 15));
- expect(hzUtils.truncate(string, 20)).
- toBe(string);
- });
-
- it('should add an ellipsis if needed', function () {
- expect(hzUtils.truncate(string, 15, true)).
- toBe(string.slice(0, 12) + ellipsis);
-
- expect(hzUtils.truncate(string, 20, true)).
- toBe(string);
-
- expect(hzUtils.truncate(string, 2, true)).
- toBe(ellipsis);
- });
- });
-
- describe('loadAngular', function () {
- var rootScope, element;
-
- beforeEach(function () {
- element = angular.element('
');
-
- angular.mock.inject(function ($injector) {
- rootScope = $injector.get('$rootScope');
- });
- spyOn(rootScope, '$apply');
- });
-
- it('should call a compile and apply', function () {
- hzUtils.loadAngular(element);
- //checks the use of apply function
- expect(rootScope.$apply).toHaveBeenCalled();
- //checks the use of compile function
- expect(element.hasClass('ng-scope')).toBeTruthy();
- });
- });
+ it('should call a compile and apply ', function () {
+ hzUtils.loadAngular(element);
+ //checks the use of apply function
+ expect(rootScope.$apply).toHaveBeenCalled();
+ //checks the use of compile function
+ expect(element.hasClass('ng-scope')).toBeTruthy();
});
});
});
-
})();
diff --git a/horizon/static/horizon/js/horizon.tables.js b/horizon/static/horizon/js/horizon.tables.js
index d699f788f9..2e4b05aa4e 100644
--- a/horizon/static/horizon/js/horizon.tables.js
+++ b/horizon/static/horizon/js/horizon.tables.js
@@ -1,4 +1,4 @@
-/* global STATIC_URL */
+/* global STATIC_URL, console */
/* Namespace for core functionality related to DataTables. */
horizon.datatables = {
update: function () {
@@ -56,7 +56,7 @@ horizon.datatables = {
horizon.datatables.update_actions();
break;
default:
- horizon.utils.log(gettext("An error occurred while updating."));
+ console.log(gettext("An error occurred while updating."));
$row.removeClass("ajax-update");
$row.find("i.ajax-updating").remove();
break;
@@ -127,7 +127,7 @@ horizon.datatables = {
horizon.ajax.queue({
url: $action.attr('data-update-url'),
error: function () {
- horizon.utils.log(gettext("An error occurred while updating."));
+ console.log(gettext("An error occurred while updating."));
},
success: function (data) {
var $new_action = $(data);
diff --git a/horizon/test/jasmine/jasmine_tests.py b/horizon/test/jasmine/jasmine_tests.py
index 4ca529e479..d5dc35e7b2 100644
--- a/horizon/test/jasmine/jasmine_tests.py
+++ b/horizon/test/jasmine/jasmine_tests.py
@@ -32,8 +32,6 @@ class ServicesTests(test.JasmineTests):
'auth/login/login.controller.js',
'auth/login/login-finder.directive.js',
- 'dashboard-app/dashboard-app.module.js',
-
'framework/framework.module.js',
'framework/conf/conf.js',
diff --git a/openstack_dashboard/karma.conf.js b/openstack_dashboard/karma.conf.js
index bcb2b27063..5a7de8a18e 100644
--- a/openstack_dashboard/karma.conf.js
+++ b/openstack_dashboard/karma.conf.js
@@ -71,7 +71,8 @@ module.exports = function(config) {
'openstack-service-api/openstack-service-api.module.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/workflow/workflow.js",
"dashboard/launch-instance/launch-instance.js",
diff --git a/horizon/static/dashboard-app/dashboard-app.module.js b/openstack_dashboard/static/app/app.module.js
similarity index 89%
rename from horizon/static/dashboard-app/dashboard-app.module.js
rename to openstack_dashboard/static/app/app.module.js
index 1aef3f5cb9..b783c09497 100644
--- a/horizon/static/dashboard-app/dashboard-app.module.js
+++ b/openstack_dashboard/static/app/app.module.js
@@ -2,15 +2,15 @@
(function () {
'use strict';
- angular.module('horizon.dashboard-app', [
- 'horizon.framework',
+ angular.module('horizon.app', [
'horizon.auth',
'horizon.openstack-service-api',
+ 'horizon.framework',
+ 'hz.dashboard',
'ngCookies'].concat(angularModuleExtension))
- .constant('horizon.dashboard-app.conf', {
+ .constant('horizon.app.conf', {
// Placeholders; updated by Django.
- debug: null, //
static_url: null,
ajax: {
queue_limit: null
@@ -19,7 +19,7 @@
.run([
'horizon.framework.conf.spinner_options',
- 'horizon.dashboard-app.conf',
+ 'horizon.app.conf',
'horizon.framework.util.tech-debt.helper-functions',
'$cookieStore',
'$http',
diff --git a/openstack_dashboard/templates/base.html b/openstack_dashboard/templates/base.html
index 8fc4697d04..c4fd2e9ca3 100644
--- a/openstack_dashboard/templates/base.html
+++ b/openstack_dashboard/templates/base.html
@@ -14,7 +14,7 @@
{% include "horizon/client_side/_script_loader.html" %}
{% include "horizon/_custom_head_js.html" %}
-
+