JSCS Cleanup - tech-debt and auth
JSCS cleanup for files in: - horizon/static/auth - horizon/static/framework/util/tech-debt/ - openstack_dashboard/static/dashboard/tech-debt/ NOTE: These files were previously in horizon/static/dashboard-app, but were moved between patches, causing the seemingly random selection of cleanups Change-Id: I63c3c641bf42152d8ff99702078d06df22812555 Partially-Implements: blueprint jscs-cleanup
This commit is contained in:
parent
729c36c381
commit
c6677c229a
@ -16,7 +16,8 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
angular.module('horizon.auth.login')
|
||||
angular
|
||||
.module('horizon.auth.login')
|
||||
/**
|
||||
* @ngdoc hzLoginFinder
|
||||
* @description
|
||||
@ -31,27 +32,31 @@
|
||||
restrict: 'A',
|
||||
link: function(scope, element) {
|
||||
|
||||
// test code does not have access to document
|
||||
// so we are restricted to search through the element
|
||||
/**
|
||||
* Test code does not have access to document,
|
||||
* so we are restricted to search through the element
|
||||
*/
|
||||
var authType = element.find('#id_auth_type');
|
||||
var userInput = element.find("#id_username").parents('.form-group');
|
||||
var passwordInput = element.find("#id_password").parents('.form-group');
|
||||
var domainInput = element.find('#id_domain').parents('form-group');
|
||||
var regionInput = element.find('#id_region').parents('form-group');
|
||||
|
||||
// helptext exists outside of element
|
||||
// we have to traverse one node up
|
||||
/**
|
||||
* `helpText` exists outside of element,
|
||||
* so we have to traverse one node up
|
||||
*/
|
||||
var helpText = element.parent().find('#help_text');
|
||||
helpText.hide();
|
||||
|
||||
// update the visuals
|
||||
// when user selects item from dropdown
|
||||
// Update the visuals when user selects item from dropdown
|
||||
function onChange() {
|
||||
$timeout(function() {
|
||||
|
||||
// if type is credential
|
||||
// show the username and password fields
|
||||
// and domain and region if applicable
|
||||
/**
|
||||
* If auth_type is 'credential', show the username and password fields,
|
||||
* and domain and region if applicable
|
||||
*/
|
||||
scope.auth_type = authType.val();
|
||||
switch (scope.auth_type) {
|
||||
case 'credentials':
|
||||
@ -66,26 +71,24 @@
|
||||
domainInput.hide();
|
||||
regionInput.hide();
|
||||
}
|
||||
|
||||
}); // end of timeout
|
||||
} // end of onChange
|
||||
|
||||
// if authType field exists
|
||||
// then websso was enabled
|
||||
// If authType field exists then websso was enabled
|
||||
if (authType.length > 0) {
|
||||
|
||||
// programmatically insert help text after dropdown
|
||||
// this is the only way to do it since template is
|
||||
// generated server side via form_fields
|
||||
/**
|
||||
* Programmatically insert help text after dropdown.
|
||||
* This is the only way to do it since template is generated server side,
|
||||
* via form_fields
|
||||
*/
|
||||
authType.after(helpText);
|
||||
helpText.show();
|
||||
|
||||
// trigger the onChange on first load
|
||||
// so that initial choice is auto-selected
|
||||
// Trigger the onChange on first load so that initial choice is auto-selected
|
||||
onChange();
|
||||
authType.change(onChange);
|
||||
}
|
||||
|
||||
} // end of link
|
||||
}; // end of return
|
||||
}); // end of directive
|
||||
|
@ -18,7 +18,6 @@
|
||||
'use strict';
|
||||
|
||||
describe('hzLoginCtrl', function() {
|
||||
|
||||
var $controller;
|
||||
beforeEach(module('horizon.auth.login'));
|
||||
beforeEach(inject(function(_$controller_) {
|
||||
@ -32,14 +31,13 @@
|
||||
expect(scope.auth_type).toEqual('credentials');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('hzLoginFinder', function() {
|
||||
|
||||
var $compile, $rootScope, $timeout;
|
||||
|
||||
var websso_markup =
|
||||
var webssoMarkup =
|
||||
'<form>' +
|
||||
'<p id="help_text">Some help text.</p>' +
|
||||
'<fieldset hz-login-finder>' +
|
||||
@ -54,7 +52,7 @@
|
||||
'</fieldset>' +
|
||||
'</form>';
|
||||
|
||||
var regular_markup =
|
||||
var regularMarkup =
|
||||
'<form>' +
|
||||
'<p id="help_text">Some help text.</p>' +
|
||||
'<fieldset hz-login-finder>' +
|
||||
@ -91,13 +89,12 @@
|
||||
}));
|
||||
|
||||
describe('when websso is not enabled', function() {
|
||||
|
||||
var element,
|
||||
helpText, authType,
|
||||
userInput, passwordInput;
|
||||
|
||||
beforeEach(function() {
|
||||
element = $compile(regular_markup)($rootScope);
|
||||
element = $compile(regularMarkup)($rootScope);
|
||||
authType = element.find('#id_auth_type');
|
||||
userInput = element.find("#id_username").parents('.form-group');
|
||||
passwordInput = element.find("#id_password").parents('.form-group');
|
||||
@ -117,7 +114,6 @@
|
||||
expect(userInput).toBeVisible();
|
||||
expect(passwordInput).toBeVisible();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('when websso is enabled', function() {
|
||||
@ -127,7 +123,7 @@
|
||||
userInput, passwordInput;
|
||||
|
||||
beforeEach(function() {
|
||||
element = $compile(websso_markup)($rootScope);
|
||||
element = $compile(webssoMarkup)($rootScope);
|
||||
authType = element.find('#id_auth_type');
|
||||
userInput = element.find("#id_username").parents('.form-group');
|
||||
passwordInput = element.find("#id_password").parents('.form-group');
|
||||
@ -159,8 +155,6 @@
|
||||
expect(userInput).not.toBeVisible();
|
||||
expect(passwordInput).not.toBeVisible();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
})();
|
@ -1,11 +1,11 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular.module('horizon.framework.util.tech-debt')
|
||||
angular
|
||||
.module('horizon.framework.util.tech-debt')
|
||||
.service('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 array syntax
|
||||
utils.$inject = [
|
||||
'horizon.dashboard-app.conf',
|
||||
'$log',
|
||||
@ -65,9 +65,7 @@
|
||||
Compilation fails when it could not find a directive,
|
||||
fails silently on this, it is an angular behaviour.
|
||||
*/
|
||||
|
||||
},
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}());
|
@ -1,6 +1,8 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
angular.module('horizon.framework.util.tech-debt')
|
||||
|
||||
angular
|
||||
.module('horizon.framework.util.tech-debt')
|
||||
|
||||
.directive('imageFileOnChange', function () {
|
||||
return {
|
||||
@ -8,7 +10,8 @@
|
||||
restrict: 'A',
|
||||
link: function ($scope, element, attrs, ngModel) {
|
||||
element.bind('change', function (event) {
|
||||
var files = event.target.files, file = files[0];
|
||||
var files = event.target.files;
|
||||
var file = files[0];
|
||||
ngModel.$setViewValue(file);
|
||||
$scope.$apply();
|
||||
});
|
||||
|
@ -1,6 +1,8 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
angular.module('horizon.framework.util.tech-debt')
|
||||
|
||||
angular
|
||||
.module('horizon.framework.util.tech-debt')
|
||||
.controller('hzModalFormUpdateMetadataCtrl', [
|
||||
'$scope', '$window',
|
||||
function ($scope, $window) {
|
||||
|
@ -41,7 +41,7 @@ ADD_JS_FILES = [
|
||||
LAUNCH_INST + 'configuration/load-edit.js',
|
||||
|
||||
'dashboard/tech-debt/tech-debt.module.js',
|
||||
'dashboard/tech-debt/image-form-controller.js',
|
||||
'dashboard/tech-debt/image-form-ctrl.js',
|
||||
]
|
||||
|
||||
ADD_JS_SPEC_FILES = [
|
||||
|
@ -22,6 +22,6 @@ ADD_INSTALLED_APPS = [
|
||||
|
||||
ADD_JS_FILES = [
|
||||
'dashboard/tech-debt/tech-debt.module.js',
|
||||
'dashboard/tech-debt/namespace-controller.js',
|
||||
'dashboard/tech-debt/image-form-controller.js',
|
||||
'dashboard/tech-debt/namespace-ctrl.js',
|
||||
'dashboard/tech-debt/image-form-ctrl.js',
|
||||
]
|
||||
|
@ -1,18 +0,0 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular.module('hz.dashboard.tech-debt')
|
||||
.controller('ImageFormCtrl', ['$scope', function ($scope) {
|
||||
$scope.selectImageFormat = function (path) {
|
||||
if (!path) { return; }
|
||||
var format = path.substr(path.lastIndexOf(".") + 1)
|
||||
.toLowerCase().replace(/[^a-z0-9]+/gi, "");
|
||||
if ($('#id_disk_format').find('[value=' + format + ']').length !== 0) {
|
||||
$scope.diskFormat = format;
|
||||
} else {
|
||||
$scope.diskFormat = "";
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
}());
|
@ -0,0 +1,17 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
angular
|
||||
.module('hz.dashboard.tech-debt')
|
||||
.controller('ImageFormCtrl', ['$scope', function ($scope) {
|
||||
$scope.selectImageFormat = function (path) {
|
||||
if (!path) { return; }
|
||||
var format = path.substr(path.lastIndexOf(".") + 1)
|
||||
.toLowerCase().replace(/[^a-z0-9]+/gi, "");
|
||||
if ($('#id_disk_format').find('[value=' + format + ']').length !== 0) {
|
||||
$scope.diskFormat = format;
|
||||
} else {
|
||||
$scope.diskFormat = "";
|
||||
}
|
||||
};
|
||||
}]);
|
||||
}());
|
@ -1,6 +1,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
angular.module('hz.dashboard.tech-debt')
|
||||
angular
|
||||
.module('hz.dashboard.tech-debt')
|
||||
.controller('hzNamespaceResourceTypeFormController', function($scope, $window) {
|
||||
$scope.resource_types = $window.resource_types;
|
||||
|
Loading…
Reference in New Issue
Block a user