diff --git a/awx/ui/client/components/input/select.directive.js b/awx/ui/client/components/input/select.directive.js deleted file mode 100644 index d1ef291dc4..0000000000 --- a/awx/ui/client/components/input/select.directive.js +++ /dev/null @@ -1,45 +0,0 @@ -let eventService; -let pathService; - -function link (scope, el, attrs, form) { - form.use('input', scope, el); - - let apply = eventService.listenWith(scope); - - let input = el.find('input')[0]; - let select = el.find('select')[0]; - - input.addEventListener('focus', apply(select.focus)); - select.addEventListener('mousedown', apply(() => scope.open = !scope.open)); - select.addEventListener('change', apply(() => scope.open = false)); - select.addEventListener('focus', apply(() => input.classList.add('at-Input--focus'))); - select.addEventListener('blur', apply(() => { - input.classList.remove('at-Input--focus'); - scope.open = scope.open && false; - })); -} - -function atInputSelect (_eventService_, _pathService_) { - eventService = _eventService_; - pathService = _pathService_; - - return { - restrict: 'E', - transclude: true, - replace: true, - require: '^^at-form', - templateUrl: pathService.getPartialPath('components/input/select'), - link, - scope: { - config: '=', - col: '@' - } - }; -} - -atInputSelect.$inject = [ - 'EventService', - 'PathService' -]; - -export default atInputSelect; diff --git a/awx/ui/client/features/_index.less b/awx/ui/client/features/_index.less new file mode 100644 index 0000000000..5046881522 --- /dev/null +++ b/awx/ui/client/features/_index.less @@ -0,0 +1 @@ +@import 'credentials/_index'; diff --git a/awx/ui/client/components/list/list-item.directive.js b/awx/ui/client/features/credentials/_index.less similarity index 100% rename from awx/ui/client/components/list/list-item.directive.js rename to awx/ui/client/features/credentials/_index.less diff --git a/awx/ui/client/src/credentials/add-credentials.controller.js b/awx/ui/client/features/credentials/add-credentials.controller.js similarity index 100% rename from awx/ui/client/src/credentials/add-credentials.controller.js rename to awx/ui/client/features/credentials/add-credentials.controller.js diff --git a/awx/ui/client/src/credentials/add-credentials.view.html b/awx/ui/client/features/credentials/add-credentials.view.html similarity index 100% rename from awx/ui/client/src/credentials/add-credentials.view.html rename to awx/ui/client/features/credentials/add-credentials.view.html diff --git a/awx/ui/client/src/credentials/credentials.list.js b/awx/ui/client/features/credentials/credentials.list.js similarity index 100% rename from awx/ui/client/src/credentials/credentials.list.js rename to awx/ui/client/features/credentials/credentials.list.js diff --git a/awx/ui/client/src/credentials/factories/become-method-change.factory.js b/awx/ui/client/features/credentials/factories/become-method-change.factory.js similarity index 100% rename from awx/ui/client/src/credentials/factories/become-method-change.factory.js rename to awx/ui/client/features/credentials/factories/become-method-change.factory.js diff --git a/awx/ui/client/src/credentials/factories/credential-form-save.factory.js b/awx/ui/client/features/credentials/factories/credential-form-save.factory.js similarity index 100% rename from awx/ui/client/src/credentials/factories/credential-form-save.factory.js rename to awx/ui/client/features/credentials/factories/credential-form-save.factory.js diff --git a/awx/ui/client/src/credentials/factories/kind-change.factory.js b/awx/ui/client/features/credentials/factories/kind-change.factory.js similarity index 100% rename from awx/ui/client/src/credentials/factories/kind-change.factory.js rename to awx/ui/client/features/credentials/factories/kind-change.factory.js diff --git a/awx/ui/client/src/credentials/factories/owner-change.factory.js b/awx/ui/client/features/credentials/factories/owner-change.factory.js similarity index 100% rename from awx/ui/client/src/credentials/factories/owner-change.factory.js rename to awx/ui/client/features/credentials/factories/owner-change.factory.js diff --git a/awx/ui/client/src/credentials/index.js b/awx/ui/client/features/credentials/index.js similarity index 98% rename from awx/ui/client/src/credentials/index.js rename to awx/ui/client/features/credentials/index.js index 51ad39b57a..761bd1e6dc 100644 --- a/awx/ui/client/src/credentials/index.js +++ b/awx/ui/client/features/credentials/index.js @@ -1,7 +1,7 @@ import CredentialList from './credentials.list.js'; import ListController from './list/credentials-list.controller'; import AddController from './add-credentials.controller.js'; -import { N_ } from '../i18n'; +import { N_ } from '../../src/i18n'; function config ($stateExtenderProvider, pathServiceProvider) { let pathService = pathServiceProvider.$get(); diff --git a/awx/ui/client/src/credentials/index.view.html b/awx/ui/client/features/credentials/index.view.html similarity index 100% rename from awx/ui/client/src/credentials/index.view.html rename to awx/ui/client/features/credentials/index.view.html diff --git a/awx/ui/client/src/credentials/list/credentials-list.controller.js b/awx/ui/client/features/credentials/list/credentials-list.controller.js similarity index 100% rename from awx/ui/client/src/credentials/list/credentials-list.controller.js rename to awx/ui/client/features/credentials/list/credentials-list.controller.js diff --git a/awx/ui/client/src/credentials/ownerList.block.less b/awx/ui/client/features/credentials/ownerList.block.less similarity index 100% rename from awx/ui/client/src/credentials/ownerList.block.less rename to awx/ui/client/features/credentials/ownerList.block.less diff --git a/awx/ui/client/src/credentials/ownerList.directive.js b/awx/ui/client/features/credentials/ownerList.directive.js similarity index 100% rename from awx/ui/client/src/credentials/ownerList.directive.js rename to awx/ui/client/features/credentials/ownerList.directive.js diff --git a/awx/ui/client/src/credentials/ownerList.partial.html b/awx/ui/client/features/credentials/ownerList.partial.html similarity index 100% rename from awx/ui/client/src/credentials/ownerList.partial.html rename to awx/ui/client/features/credentials/ownerList.partial.html diff --git a/awx/ui/client/features/index.js b/awx/ui/client/features/index.js new file mode 100644 index 0000000000..30ce87123d --- /dev/null +++ b/awx/ui/client/features/index.js @@ -0,0 +1,5 @@ +import './credentials'; + +angular.module('at.features', [ + 'at.features.credentials' +]); diff --git a/awx/ui/client/components/_index.less b/awx/ui/client/lib/components/_index.less similarity index 100% rename from awx/ui/client/components/_index.less rename to awx/ui/client/lib/components/_index.less diff --git a/awx/ui/client/components/action/_index.less b/awx/ui/client/lib/components/action/_index.less similarity index 100% rename from awx/ui/client/components/action/_index.less rename to awx/ui/client/lib/components/action/_index.less diff --git a/awx/ui/client/components/action/action-group.directive.js b/awx/ui/client/lib/components/action/action-group.directive.js similarity index 100% rename from awx/ui/client/components/action/action-group.directive.js rename to awx/ui/client/lib/components/action/action-group.directive.js diff --git a/awx/ui/client/components/action/action-group.partial.html b/awx/ui/client/lib/components/action/action-group.partial.html similarity index 100% rename from awx/ui/client/components/action/action-group.partial.html rename to awx/ui/client/lib/components/action/action-group.partial.html diff --git a/awx/ui/client/components/action/action.directive.js b/awx/ui/client/lib/components/action/action.directive.js similarity index 100% rename from awx/ui/client/components/action/action.directive.js rename to awx/ui/client/lib/components/action/action.directive.js diff --git a/awx/ui/client/components/action/action.partial.html b/awx/ui/client/lib/components/action/action.partial.html similarity index 100% rename from awx/ui/client/components/action/action.partial.html rename to awx/ui/client/lib/components/action/action.partial.html diff --git a/awx/ui/client/components/badge/_index.less b/awx/ui/client/lib/components/badge/_index.less similarity index 100% rename from awx/ui/client/components/badge/_index.less rename to awx/ui/client/lib/components/badge/_index.less diff --git a/awx/ui/client/components/badge/badge.directive.js b/awx/ui/client/lib/components/badge/badge.directive.js similarity index 100% rename from awx/ui/client/components/badge/badge.directive.js rename to awx/ui/client/lib/components/badge/badge.directive.js diff --git a/awx/ui/client/components/badge/badge.partial.html b/awx/ui/client/lib/components/badge/badge.partial.html similarity index 100% rename from awx/ui/client/components/badge/badge.partial.html rename to awx/ui/client/lib/components/badge/badge.partial.html diff --git a/awx/ui/client/components/form/_index.less b/awx/ui/client/lib/components/form/_index.less similarity index 100% rename from awx/ui/client/components/form/_index.less rename to awx/ui/client/lib/components/form/_index.less diff --git a/awx/ui/client/components/form/form.directive.js b/awx/ui/client/lib/components/form/form.directive.js similarity index 85% rename from awx/ui/client/components/form/form.directive.js rename to awx/ui/client/lib/components/form/form.directive.js index 38f0924471..a32fe009ba 100644 --- a/awx/ui/client/components/form/form.directive.js +++ b/awx/ui/client/lib/components/form/form.directive.js @@ -30,7 +30,7 @@ function trackInput (componentElement) { componentElement.find('input').focus(); } - vm.inputs.push(input); + vm.inputs.push(input) return input; } @@ -47,6 +47,18 @@ function trackAction (componentElement) { return action; } +function update () { + let vm = this; + + vm.inputs.forEach(input => console.log(input)); +} + +function remove (id) { + let vm = this; + + delete inputs[id]; +} + function AtFormController () { let vm = this; @@ -56,6 +68,8 @@ function AtFormController () { vm.use = use; vm.trackInput = trackInput; vm.trackAction = trackAction; + vm.update = update; + vm.remove = remove; } function atForm (pathService) { diff --git a/awx/ui/client/components/form/form.partial.html b/awx/ui/client/lib/components/form/form.partial.html similarity index 100% rename from awx/ui/client/components/form/form.partial.html rename to awx/ui/client/lib/components/form/form.partial.html diff --git a/awx/ui/client/components/index.js b/awx/ui/client/lib/components/index.js similarity index 97% rename from awx/ui/client/components/index.js rename to awx/ui/client/lib/components/index.js index 2b4532e9d2..9f89a08615 100644 --- a/awx/ui/client/components/index.js +++ b/awx/ui/client/lib/components/index.js @@ -14,7 +14,7 @@ import toggleButton from './toggle/button.directive'; import toggleContent from './toggle/content.directive'; angular - .module('at.components', []) + .module('at.lib.components', []) .directive('atAction', action) .directive('atActionGroup', actionGroup) .directive('atBadge', badge) diff --git a/awx/ui/client/components/input/_index.less b/awx/ui/client/lib/components/input/_index.less similarity index 100% rename from awx/ui/client/components/input/_index.less rename to awx/ui/client/lib/components/input/_index.less diff --git a/awx/ui/client/components/input/label.directive.js b/awx/ui/client/lib/components/input/label.directive.js similarity index 100% rename from awx/ui/client/components/input/label.directive.js rename to awx/ui/client/lib/components/input/label.directive.js diff --git a/awx/ui/client/components/input/label.partial.html b/awx/ui/client/lib/components/input/label.partial.html similarity index 100% rename from awx/ui/client/components/input/label.partial.html rename to awx/ui/client/lib/components/input/label.partial.html diff --git a/awx/ui/client/components/input/search.directive.js b/awx/ui/client/lib/components/input/search.directive.js similarity index 100% rename from awx/ui/client/components/input/search.directive.js rename to awx/ui/client/lib/components/input/search.directive.js diff --git a/awx/ui/client/components/input/search.partial.html b/awx/ui/client/lib/components/input/search.partial.html similarity index 100% rename from awx/ui/client/components/input/search.partial.html rename to awx/ui/client/lib/components/input/search.partial.html diff --git a/awx/ui/client/lib/components/input/select.directive.js b/awx/ui/client/lib/components/input/select.directive.js new file mode 100644 index 0000000000..a8c8c5ce4b --- /dev/null +++ b/awx/ui/client/lib/components/input/select.directive.js @@ -0,0 +1,55 @@ +let eventService; +let pathService; + +function link (scope, el, attrs, form) { + form.use('input', scope, el); // avoid passing scope? assign to scope.meta instead or reference form properties in view + + let input = el.find('input')[0]; + let select = el.find('select')[0]; + + let listeners = eventService.addListeners(scope, [ + [input, 'focus', () => select.focus()], + [select, 'mousedown', () => scope.open = !scope.open], + [select, 'focus', () => input.classList.add('at-Input--focus')], + [select, 'change', () => scope.open = false], + [select, 'blur', () => { + input.classList.remove('at-Input--focus'); + scope.open = scope.open && false; + }] + ]); + + scope.$on('$destroy', () => eventService.remove(listeners)); + + /* + * Should notify form on: + * - valid (required, passes validation) state change + * + * Should get from form: + * - display as disabled + */ +} + +function atInputSelect (_eventService_, _pathService_) { + eventService = _eventService_; + pathService = _pathService_; + + return { + restrict: 'E', + transclude: true, + replace: true, + require: '^^at-form', + templateUrl: pathService.getPartialPath('components/input/select'), + link, + scope: { + config: '=', + col: '@' + } + }; +} + +atInputSelect.$inject = [ + 'EventService', + 'PathService' +]; + +export default atInputSelect; diff --git a/awx/ui/client/components/input/select.partial.html b/awx/ui/client/lib/components/input/select.partial.html similarity index 100% rename from awx/ui/client/components/input/select.partial.html rename to awx/ui/client/lib/components/input/select.partial.html diff --git a/awx/ui/client/components/input/text.directive.js b/awx/ui/client/lib/components/input/text.directive.js similarity index 100% rename from awx/ui/client/components/input/text.directive.js rename to awx/ui/client/lib/components/input/text.directive.js diff --git a/awx/ui/client/components/input/text.partial.html b/awx/ui/client/lib/components/input/text.partial.html similarity index 100% rename from awx/ui/client/components/input/text.partial.html rename to awx/ui/client/lib/components/input/text.partial.html diff --git a/awx/ui/client/components/list/list.directive.js b/awx/ui/client/lib/components/list/list-item.directive.js similarity index 100% rename from awx/ui/client/components/list/list.directive.js rename to awx/ui/client/lib/components/list/list-item.directive.js diff --git a/awx/ui/client/components/pagination/pagination.directive.js b/awx/ui/client/lib/components/list/list.directive.js similarity index 100% rename from awx/ui/client/components/pagination/pagination.directive.js rename to awx/ui/client/lib/components/list/list.directive.js diff --git a/awx/ui/client/components/prompt/prompt.directive.js b/awx/ui/client/lib/components/pagination/pagination.directive.js similarity index 100% rename from awx/ui/client/components/prompt/prompt.directive.js rename to awx/ui/client/lib/components/pagination/pagination.directive.js diff --git a/awx/ui/client/components/panel/_index.less b/awx/ui/client/lib/components/panel/_index.less similarity index 100% rename from awx/ui/client/components/panel/_index.less rename to awx/ui/client/lib/components/panel/_index.less diff --git a/awx/ui/client/components/panel/body.directive.js b/awx/ui/client/lib/components/panel/body.directive.js similarity index 100% rename from awx/ui/client/components/panel/body.directive.js rename to awx/ui/client/lib/components/panel/body.directive.js diff --git a/awx/ui/client/components/panel/body.partial.html b/awx/ui/client/lib/components/panel/body.partial.html similarity index 100% rename from awx/ui/client/components/panel/body.partial.html rename to awx/ui/client/lib/components/panel/body.partial.html diff --git a/awx/ui/client/components/panel/heading.directive.js b/awx/ui/client/lib/components/panel/heading.directive.js similarity index 100% rename from awx/ui/client/components/panel/heading.directive.js rename to awx/ui/client/lib/components/panel/heading.directive.js diff --git a/awx/ui/client/components/panel/heading.partial.html b/awx/ui/client/lib/components/panel/heading.partial.html similarity index 100% rename from awx/ui/client/components/panel/heading.partial.html rename to awx/ui/client/lib/components/panel/heading.partial.html diff --git a/awx/ui/client/components/panel/panel.directive.js b/awx/ui/client/lib/components/panel/panel.directive.js similarity index 100% rename from awx/ui/client/components/panel/panel.directive.js rename to awx/ui/client/lib/components/panel/panel.directive.js diff --git a/awx/ui/client/components/panel/panel.partial.html b/awx/ui/client/lib/components/panel/panel.partial.html similarity index 100% rename from awx/ui/client/components/panel/panel.partial.html rename to awx/ui/client/lib/components/panel/panel.partial.html diff --git a/awx/ui/client/components/popover/_index.less b/awx/ui/client/lib/components/popover/_index.less similarity index 100% rename from awx/ui/client/components/popover/_index.less rename to awx/ui/client/lib/components/popover/_index.less diff --git a/awx/ui/client/components/popover/popover.directive.js b/awx/ui/client/lib/components/popover/popover.directive.js similarity index 100% rename from awx/ui/client/components/popover/popover.directive.js rename to awx/ui/client/lib/components/popover/popover.directive.js diff --git a/awx/ui/client/components/popover/popover.partial.html b/awx/ui/client/lib/components/popover/popover.partial.html similarity index 100% rename from awx/ui/client/components/popover/popover.partial.html rename to awx/ui/client/lib/components/popover/popover.partial.html diff --git a/awx/ui/client/components/table/table.directive.js b/awx/ui/client/lib/components/prompt/prompt.directive.js similarity index 100% rename from awx/ui/client/components/table/table.directive.js rename to awx/ui/client/lib/components/prompt/prompt.directive.js diff --git a/awx/ui/client/components/tabs/tab-navigation.directive.js b/awx/ui/client/lib/components/table/table.directive.js similarity index 100% rename from awx/ui/client/components/tabs/tab-navigation.directive.js rename to awx/ui/client/lib/components/table/table.directive.js diff --git a/awx/ui/client/components/tabs/tab.directive.js b/awx/ui/client/lib/components/tabs/tab-navigation.directive.js similarity index 100% rename from awx/ui/client/components/tabs/tab.directive.js rename to awx/ui/client/lib/components/tabs/tab-navigation.directive.js diff --git a/awx/ui/client/models/Credential.js b/awx/ui/client/lib/components/tabs/tab.directive.js similarity index 100% rename from awx/ui/client/models/Credential.js rename to awx/ui/client/lib/components/tabs/tab.directive.js diff --git a/awx/ui/client/components/toggle/_index.less b/awx/ui/client/lib/components/toggle/_index.less similarity index 100% rename from awx/ui/client/components/toggle/_index.less rename to awx/ui/client/lib/components/toggle/_index.less diff --git a/awx/ui/client/components/toggle/button.directive.js b/awx/ui/client/lib/components/toggle/button.directive.js similarity index 100% rename from awx/ui/client/components/toggle/button.directive.js rename to awx/ui/client/lib/components/toggle/button.directive.js diff --git a/awx/ui/client/components/toggle/button.partial.html b/awx/ui/client/lib/components/toggle/button.partial.html similarity index 100% rename from awx/ui/client/components/toggle/button.partial.html rename to awx/ui/client/lib/components/toggle/button.partial.html diff --git a/awx/ui/client/components/toggle/content.directive.js b/awx/ui/client/lib/components/toggle/content.directive.js similarity index 100% rename from awx/ui/client/components/toggle/content.directive.js rename to awx/ui/client/lib/components/toggle/content.directive.js diff --git a/awx/ui/client/components/toggle/content.partial.html b/awx/ui/client/lib/components/toggle/content.partial.html similarity index 100% rename from awx/ui/client/components/toggle/content.partial.html rename to awx/ui/client/lib/components/toggle/content.partial.html diff --git a/awx/ui/client/lib/event.service.js b/awx/ui/client/lib/event.service.js deleted file mode 100644 index 391fc7d26d..0000000000 --- a/awx/ui/client/lib/event.service.js +++ /dev/null @@ -1,16 +0,0 @@ -function listenWith (scope) { - return fn => apply(scope, fn); -} - -function apply (scope, fn) { - return () => scope.$apply(fn); -} - -function EventService () { - return { - listenWith, - apply - }; -} - -export default EventService; diff --git a/awx/ui/client/models/Base.js b/awx/ui/client/lib/models/Base.js similarity index 100% rename from awx/ui/client/models/Base.js rename to awx/ui/client/lib/models/Base.js diff --git a/awx/ui/client/lib/models/Credential.js b/awx/ui/client/lib/models/Credential.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/awx/ui/client/models/CredentialType.js b/awx/ui/client/lib/models/CredentialType.js similarity index 100% rename from awx/ui/client/models/CredentialType.js rename to awx/ui/client/lib/models/CredentialType.js diff --git a/awx/ui/client/models/index.js b/awx/ui/client/lib/models/index.js similarity index 90% rename from awx/ui/client/models/index.js rename to awx/ui/client/lib/models/index.js index 845b2bb628..505bf80558 100644 --- a/awx/ui/client/models/index.js +++ b/awx/ui/client/lib/models/index.js @@ -8,7 +8,7 @@ function config ($resourceProvider) { config.$inject = ['$resourceProvider']; angular - .module('at.models', []) + .module('at.lib.models', []) .config(config) .factory('Base', Base) .factory('CredentialType', CredentialType); diff --git a/awx/ui/client/lib/services/event.service.js b/awx/ui/client/lib/services/event.service.js new file mode 100644 index 0000000000..7473b65aa0 --- /dev/null +++ b/awx/ui/client/lib/services/event.service.js @@ -0,0 +1,38 @@ +function addListeners (scope, list) { + let listeners = []; + + list.forEach(args => { + listeners.push(addListener.call(null, scope, ...args)); + }); + + return listeners; +} + +function addListener (scope, el, name, fn, type) { + type = type || '$apply'; + + let listener = { + fn: () => scope[type](fn), + name, + el + }; + + listener.el.addEventListener(listener.name, listener.fn); + + return listener; +} + +function remove (listeners) { + listeners.forEach(listener => { + listener.el.removeEventListener(listener.name, listener.fn); + }); +} + +function EventService () { + return { + addListeners, + remove + }; +} + +export default EventService; diff --git a/awx/ui/client/lib/index.js b/awx/ui/client/lib/services/index.js similarity index 83% rename from awx/ui/client/lib/index.js rename to awx/ui/client/lib/services/index.js index 58c2e928dc..d4c3462542 100644 --- a/awx/ui/client/lib/index.js +++ b/awx/ui/client/lib/services/index.js @@ -2,6 +2,6 @@ import EventService from './event.service'; import PathService from './path.service'; angular - .module('at.lib', []) + .module('at.lib.services', []) .factory('EventService', EventService) .factory('PathService', PathService); diff --git a/awx/ui/client/lib/path.service.js b/awx/ui/client/lib/services/path.service.js similarity index 100% rename from awx/ui/client/lib/path.service.js rename to awx/ui/client/lib/services/path.service.js diff --git a/awx/ui/client/theme/_common.less b/awx/ui/client/lib/theme/_common.less similarity index 100% rename from awx/ui/client/theme/_common.less rename to awx/ui/client/lib/theme/_common.less diff --git a/awx/ui/client/theme/_mixins.less b/awx/ui/client/lib/theme/_mixins.less similarity index 100% rename from awx/ui/client/theme/_mixins.less rename to awx/ui/client/lib/theme/_mixins.less diff --git a/awx/ui/client/theme/_temporary-overrides.less b/awx/ui/client/lib/theme/_temporary-overrides.less similarity index 100% rename from awx/ui/client/theme/_temporary-overrides.less rename to awx/ui/client/lib/theme/_temporary-overrides.less diff --git a/awx/ui/client/theme/_utility.less b/awx/ui/client/lib/theme/_utility.less similarity index 100% rename from awx/ui/client/theme/_utility.less rename to awx/ui/client/lib/theme/_utility.less diff --git a/awx/ui/client/theme/_variables.less b/awx/ui/client/lib/theme/_variables.less similarity index 100% rename from awx/ui/client/theme/_variables.less rename to awx/ui/client/lib/theme/_variables.less diff --git a/awx/ui/client/theme/index.less b/awx/ui/client/lib/theme/index.less similarity index 78% rename from awx/ui/client/theme/index.less rename to awx/ui/client/lib/theme/index.less index 5a8441bb5c..a7aeddaaca 100644 --- a/awx/ui/client/theme/index.less +++ b/awx/ui/client/lib/theme/index.less @@ -4,8 +4,9 @@ @import '_utility'; @import '_common'; -// Component and feature specific aggregated styles +// Aggregated component and feature specific styles @import '../components/_index'; +@import '../../features/_index'; /* * Temporary overrides used only during the transition away from old style diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index edc04c82f4..c608606503 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -72,10 +72,10 @@ import footer from './footer/main'; import scheduler from './scheduler/main'; import instanceGroups from './instance-groups/main'; -import '../components'; -import '../models'; -import '../lib'; -import './credentials'; +import '../lib/components'; +import '../lib/models'; +import '../lib/services'; +import '../features'; var tower = angular.module('Tower', [ // how to add CommonJS / AMD third-party dependencies: @@ -137,10 +137,10 @@ var tower = angular.module('Tower', [ 'features', 'ngResource', - 'at.components', - 'at.models', - 'at.lib', - 'at.features.credentials' + 'at.lib.components', + 'at.lib.models', + 'at.lib.services', + 'at.features', ]) .constant('AngularScheduler.partials', urlPrefix + 'lib/angular-scheduler/lib/') diff --git a/awx/ui/client/src/credentials/add/credentials-add.controller.js b/awx/ui/client/src/credentials/add/credentials-add.controller.js deleted file mode 100644 index bb5a708acf..0000000000 --- a/awx/ui/client/src/credentials/add/credentials-add.controller.js +++ /dev/null @@ -1,178 +0,0 @@ -/************************************************* - * Copyright (c) 2016 Ansible, Inc. - * - * All Rights Reserved - *************************************************/ - -export default ['$scope', '$rootScope', - '$log', '$stateParams', 'CredentialForm', 'GenerateForm', 'Rest', - 'ProcessErrors', 'ClearScope', 'GetBasePath', 'GetChoices', 'Empty', 'KindChange', 'BecomeMethodChange', - 'OwnerChange', 'CredentialFormSave', '$state', 'CreateSelect2', 'i18n', - function($scope, $rootScope, $log, - $stateParams, CredentialForm, GenerateForm, Rest, ProcessErrors, - ClearScope, GetBasePath, GetChoices, Empty, KindChange, BecomeMethodChange, - OwnerChange, CredentialFormSave, $state, CreateSelect2, i18n) { - - ClearScope(); - - // Inject dynamic view - var form = CredentialForm, - defaultUrl = GetBasePath('credentials'), - url; - - init(); - - function init() { - $scope.canEditOrg = true; - // Load the list of options for Kind - GetChoices({ - scope: $scope, - url: defaultUrl, - field: 'kind', - variable: 'credential_kind_options' - }); - - GetChoices({ - scope: $scope, - url: defaultUrl, - field: 'become_method', - variable: 'become_options' - }); - - CreateSelect2({ - element: '#credential_become_method', - multiple: false - }); - - CreateSelect2({ - element: '#credential_kind', - multiple: false - }); - - // apply form definition's default field values - GenerateForm.applyDefaults(form, $scope); - - $scope.keyEntered = false; - $scope.permissionsTooltip = i18n._('Please save before assigning permissions'); - - // determine if the currently logged-in user may share this credential - // previous commentary said: "$rootScope.current_user isn't available because a call to the config endpoint hasn't finished resolving yet" - // I'm 99% sure this state's will never resolve block will be rejected if setup surrounding config endpoint hasn't completed - if ($rootScope.current_user && $rootScope.current_user.is_superuser) { - $scope.canShareCredential = true; - } else { - Rest.setUrl(GetBasePath('users') + `${$rootScope.current_user.id}/admin_of_organizations`); - Rest.get() - .success(function(data) { - $scope.canShareCredential = (data.count) ? true : false; - }).error(function(data, status) { - ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to find if users is admin of org' + status }); - }); - } - } - - if (!Empty($stateParams.user_id)) { - // Get the username based on incoming route - $scope.owner = 'user'; - $scope.user = $stateParams.user_id; - OwnerChange({ scope: $scope }); - url = GetBasePath('users') + $stateParams.user_id + '/'; - Rest.setUrl(url); - Rest.get() - .success(function(data) { - $scope.user_username = data.username; - }) - .error(function(data, status) { - ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to retrieve user. GET status: ' + status }); - }); - } else if (!Empty($stateParams.team_id)) { - // Get the username based on incoming route - $scope.owner = 'team'; - $scope.team = $stateParams.team_id; - OwnerChange({ scope: $scope }); - url = GetBasePath('teams') + $stateParams.team_id + '/'; - Rest.setUrl(url); - Rest.get() - .success(function(data) { - $scope.team_name = data.name; - }) - .error(function(data, status) { - ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to retrieve team. GET status: ' + status }); - }); - } else { - // default type of owner to a user - $scope.owner = 'user'; - OwnerChange({ scope: $scope }); - } - - $scope.$watch("ssh_key_data", function(val) { - if (val === "" || val === null || val === undefined) { - $scope.keyEntered = false; - $scope.ssh_key_unlock_ask = false; - $scope.ssh_key_unlock = ""; - } else { - $scope.keyEntered = true; - } - }); - - // Handle Kind change - $scope.kindChange = function() { - KindChange({ scope: $scope, form: form, reset: true }); - }; - - $scope.becomeMethodChange = function() { - BecomeMethodChange({ scope: $scope }); - }; - - // Save - $scope.formSave = function() { - if ($scope[form.name + '_form'].$valid) { - CredentialFormSave({ scope: $scope, mode: 'add' }); - } - }; - - $scope.formCancel = function() { - $state.go('credentials'); - }; - - // Password change - $scope.clearPWConfirm = function(fld) { - // If password value changes, make sure password_confirm must be re-entered - $scope[fld] = ''; - $scope[form.name + '_form'][fld].$setValidity('awpassmatch', false); - }; - - // Respond to 'Ask at runtime?' checkbox - $scope.ask = function(fld, associated) { - if ($scope[fld + '_ask']) { - $scope[fld] = 'ASK'; - $("#" + form.name + "_" + fld + "_input").attr("type", "text"); - $("#" + form.name + "_" + fld + "_show_input_button").html("Hide"); - if (associated !== "undefined") { - $("#" + form.name + "_" + fld + "_input").attr("type", "password"); - $("#" + form.name + "_" + fld + "_show_input_button").html("Show"); - $scope[associated] = ''; - $scope[form.name + '_form'][associated].$setValidity('awpassmatch', true); - } - } else { - $scope[fld] = ''; - $("#" + form.name + "_" + fld + "_input").attr("type", "password"); - $("#" + form.name + "_" + fld + "_show_input_button").html("Show"); - if (associated !== "undefined") { - $("#" + form.name + "_" + fld + "_input").attr("type", "text"); - $("#" + form.name + "_" + fld + "_show_input_button").html("Hide"); - $scope[associated] = ''; - $scope[form.name + '_form'][associated].$setValidity('awpassmatch', true); - } - } - }; - - // Click clear button - $scope.clear = function(fld, associated) { - $scope[fld] = ''; - $scope[associated] = ''; - $scope[form.name + '_form'][associated].$setValidity('awpassmatch', true); - $scope[form.name + '_form'].$setDirty(); - }; - } -]; diff --git a/awx/ui/client/src/credentials/credentials.form.js b/awx/ui/client/src/credentials/credentials.form.js deleted file mode 100644 index f8c0440725..0000000000 --- a/awx/ui/client/src/credentials/credentials.form.js +++ /dev/null @@ -1,475 +0,0 @@ -/************************************************* - * Copyright (c) 2015 Ansible, Inc. - * - * All Rights Reserved - *************************************************/ - - /** - * @ngdoc function - * @name forms.function:Credentials - * @description This form is for adding/editing a Credential -*/ - -export default ['i18n', function(i18n) { - return { - - addTitle: i18n._('CREATE CREDENTIAL'), //Legend in add mode - editTitle: '{{ name }}', //Legend in edit mode - name: 'credential', - // the top-most node of generated state tree - stateTree: 'credentials', - forceListeners: true, - subFormTitles: { - credentialSubForm: i18n._('Type Details'), - }, - - actions: { - - }, - - fields: { - name: { - label: i18n._('Name'), - type: 'text', - required: true, - autocomplete: false, - ngDisabled: '!(credential_obj.summary_fields.user_capabilities.edit || canAdd)' - }, - description: { - label: i18n._('Description'), - type: 'text', - ngDisabled: '!(credential_obj.summary_fields.user_capabilities.edit || canAdd)' - }, - organization: { - basePath: 'organizations', - ngShow: 'canShareCredential', - label: i18n._('Organization'), - type: 'lookup', - autopopulateLookup: false, - list: 'OrganizationList', - sourceModel: 'organization', - sourceField: 'name', - awPopOver: "
" + i18n._("If no organization is given, the credential can only be used by the user that creates the credential. Organization admins and system administrators can assign an organization so that roles for the credential can be assigned to users and teams in that organization.") + "
", - dataTitle: i18n._('Organization') + ' ', - dataPlacement: 'bottom', - dataContainer: "body", - ngDisabled: '!(credential_obj.summary_fields.user_capabilities.edit || canAdd) || !canEditOrg', - awLookupWhen: '(credential_obj.summary_fields.user_capabilities.edit || canAdd) && canEditOrg' - }, - kind: { - label: i18n._('Type'), - excludeModal: true, - type: 'select', - ngOptions: 'kind.label for kind in credential_kind_options track by kind.value', // select as label for value in array 'kind.label for kind in credential_kind_options', - ngChange: 'kindChange()', - required: true, - awPopOver: '' + i18n._('Subscription ID is an Azure construct, which is mapped to a username.') + '
', - dataTitle: i18n._('Subscription ID'), - dataPlacement: 'right', - dataContainer: "body", - subForm: 'credentialSubForm', - ngDisabled: '!(credential_obj.summary_fields.user_capabilities.edit || canAdd)' - }, - "username": { - labelBind: 'usernameLabel', - type: 'text', - ngShow: "kind.value && kind.value !== 'aws' && " + - "kind.value !== 'gce' && kind.value!=='azure'", - awRequiredWhen: { - reqExpression: 'username_required', - init: false - }, - autocomplete: false, - subForm: "credentialSubForm", - ngDisabled: '!(credential_obj.summary_fields.user_capabilities.edit || canAdd)' - }, - "email_address": { - labelBind: 'usernameLabel', - type: 'email', - ngShow: "kind.value === 'gce'", - awRequiredWhen: { - reqExpression: 'email_required', - init: false - }, - autocomplete: false, - awPopOver: '' + i18n.sprintf(i18n._('The email address assigned to the Google Compute Engine %sservice account.'), '') + '
', - dataTitle: i18n._('Email'), - dataPlacement: 'right', - dataContainer: "body", - subForm: 'credentialSubForm', - ngDisabled: '!(credential_obj.summary_fields.user_capabilities.edit || canAdd)' - }, - "api_key": { - label: i18n._('API Key'), - type: 'sensitive', - ngShow: "kind.value == 'rax'", - awRequiredWhen: { - reqExpression: "rackspace_required", - init: false - }, - autocomplete: false, - hasShowInputButton: true, - clear: false, - subForm: 'credentialSubForm', - ngDisabled: '!(credential_obj.summary_fields.user_capabilities.edit || canAdd)' - }, - "password": { - labelBind: 'passwordLabel', - type: 'sensitive', - ngShow: "kind.value == 'scm' || kind.value == 'vmware' || kind.value == 'openstack'|| kind.value == 'satellite6'|| kind.value == 'cloudforms'|| kind.value == 'net' || kind.value == 'azure_rm'", - clear: false, - autocomplete: false, - hasShowInputButton: true, - awRequiredWhen: { - reqExpression: "password_required", - init: false - }, - subForm: "credentialSubForm", - ngDisabled: '!(credential_obj.summary_fields.user_capabilities.edit || canAdd)' - }, - "ssh_password": { - label: i18n._('Password'), - type: 'sensitive', - ngShow: "kind.value == 'ssh'", - ngDisabled: "ssh_password_ask || !(credential_obj.summary_fields.user_capabilities.edit || canAdd)", - subCheckbox: { - variable: 'ssh_password_ask', - text: i18n._('Ask at runtime?'), - ngChange: 'ask(\'ssh_password\', \'undefined\')', - ngDisabled: false, - }, - hasShowInputButton: true, - autocomplete: false, - subForm: 'credentialSubForm' - }, - "ssh_key_data": { - labelBind: 'sshKeyDataLabel', - type: 'textarea', - ngShow: "kind.value == 'ssh' || kind.value == 'scm' || " + - "kind.value == 'gce' || kind.value == 'azure' || kind.value == 'net'", - awRequiredWhen: { - reqExpression: 'key_required', - init: true - }, - class: 'Form-textAreaLabel Form-formGroup--fullWidth', - elementClass: 'Form-monospace', - - - awDropFile: true, - rows: 10, - awPopOver: i18n._("SSH key description"), - awPopOverWatch: "key_description", - dataTitle: i18n._('Private Key'), - dataPlacement: 'right', - dataContainer: "body", - subForm: "credentialSubForm", - ngDisabled: '!(credential_obj.summary_fields.user_capabilities.edit || canAdd)' - }, - "ssh_key_unlock": { - label: i18n._('Private Key Passphrase'), - type: 'sensitive', - ngShow: "kind.value === 'ssh' || kind.value === 'scm' || kind.value === 'net'", - ngDisabled: "keyEntered === false || ssh_key_unlock_ask || !(credential_obj.summary_fields.user_capabilities.edit || canAdd)", - subCheckbox: { - variable: 'ssh_key_unlock_ask', - ngShow: "kind.value == 'ssh'", - text: i18n._('Ask at runtime?'), - ngChange: 'ask(\'ssh_key_unlock\', \'undefined\')', - ngDisabled: "keyEntered === false" - }, - hasShowInputButton: true, - subForm: 'credentialSubForm' - }, - "become_method": { - label: i18n._("Privilege Escalation"), - // hintText: "If your playbooks use privilege escalation (\"sudo: true\", \"su: true\", etc), you can specify the username to become, and the password to use here.", - type: 'select', - ngShow: "kind.value == 'ssh'", - dataTitle: i18n._('Privilege Escalation'), - ngOptions: 'become.label for become in become_options track by become.value', - awPopOver: "" + i18n.sprintf(i18n._("Specify a method for %s operations. " +
- "This is equivalent to specifying the %s parameter, where %s could be "+
- "%s"), "'become'", "--become-method=BECOME_METHOD", "BECOME_METHOD", "sudo | su | pbrun | pfexec | runas") + "
" + i18n.sprintf(i18n._("(defaults to %s)"), "sudo") + "
" + i18n._("OpenStack domains define administrative " + - "boundaries. It is only needed for Keystone v3 authentication URLs. " + - "Common scenarios include:") + "