diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index ebce33322b..c00298e977 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -39,7 +39,7 @@ import {JobTemplatesList, JobTemplatesAdd, JobTemplatesEdit} from 'tower/control import {ScheduleEditController} from 'tower/controllers/Schedules'; import {ProjectsList, ProjectsAdd, ProjectsEdit} from 'tower/controllers/Projects'; import {OrganizationsList, OrganizationsAdd, OrganizationsEdit} from 'tower/controllers/Organizations'; -import {InventoriesList, InventoriesAdd, InventoriesEdit} from 'tower/controllers/Inventories'; +import {InventoriesList, InventoriesAdd, InventoriesEdit, InventoriesManage} from 'tower/controllers/Inventories'; import {AdminsList} from 'tower/controllers/Admins'; import {UsersList, UsersAdd, UsersEdit} from 'tower/controllers/Users'; import {TeamsList, TeamsAdd, TeamsEdit} from 'tower/controllers/Teams'; @@ -257,10 +257,15 @@ var tower = angular.module('Tower', [ }). when('/inventories/:inventory_id', { - templateUrl: urlPrefix + 'partials/inventory-edit.html', + templateUrl: urlPrefix + 'partials/inventories.html', controller: InventoriesEdit }). + when('/inventories/:inventory_id/manage', { + templateUrl: urlPrefix + 'partials/inventory-manage.html', + controller: InventoriesManage + }). + when('/organizations', { templateUrl: urlPrefix + 'partials/organizations.html', controller: OrganizationsList diff --git a/awx/ui/static/js/controllers/Inventories.js b/awx/ui/static/js/controllers/Inventories.js index ba30c6c33d..7d90a8001e 100644 --- a/awx/ui/static/js/controllers/Inventories.js +++ b/awx/ui/static/js/controllers/Inventories.js @@ -318,6 +318,10 @@ export function InventoriesList($scope, $rootScope, $location, $log, $routeParam $location.path($location.path() + '/' + id); }; + $scope.manageInventory = function(id){ + $location.path($location.path() + '/' + id + '/manage'); + } + $scope.deleteInventory = function (id, name) { var action = function () { @@ -476,9 +480,175 @@ InventoriesAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log 'PaginateInit', 'LookUpInit', 'GetBasePath', 'ParseTypeChange', 'Wait', 'ToJSON' ]; +export function InventoriesEdit($scope, $rootScope, $compile, $location, $log, $routeParams, InventoryForm, GenerateForm, Rest, + Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, GenerateList, OrganizationList, SearchInit, PaginateInit, + LookUpInit, GetBasePath, ParseTypeChange, Wait, ToJSON, ParseVariableString, Stream) { + + ClearScope(); + + // Inject dynamic view + var defaultUrl = GetBasePath('inventory'), + form = InventoryForm, + generator = GenerateForm, + inventory_id = $routeParams.inventory_id, + master = {}, + fld, json_data, data; + + form.well = true; + form.formLabelSize = null; + form.formFieldSize = null; + + generator.inject(form, { mode: 'edit', related: false, scope: $scope }); + + generator.reset(); + LoadBreadCrumbs(); + + // $scope.parseType = 'yaml'; + // ParseTypeChange({ + // scope: $scope, + // variable: 'variables', + // parse_variable: 'parseType', + // field_id: 'inventory_variables' + // }); + + // LookUpInit({ + // scope: $scope, + // form: form, + // current_item: ($routeParams.organization_id) ? $routeParams.organization_id : null, + // list: OrganizationList, + // field: 'organization', + // input_type: 'radio' + // }); + Wait('start'); + Rest.setUrl(GetBasePath('inventory') + inventory_id + '/'); + Rest.get() + .success(function (data) { + var fld; + for (fld in form.fields) { + if (fld === 'variables') { + $scope.variables = ParseVariableString(data.variables); + master.variables = $scope.variables; + } else if (fld === 'inventory_name') { + $scope[fld] = data.name; + master[fld] = $scope[fld]; + } else if (fld === 'inventory_description') { + $scope[fld] = data.description; + master[fld] = $scope[fld]; + } else if (data[fld]) { + $scope[fld] = data[fld]; + master[fld] = $scope[fld]; + } + if (form.fields[fld].sourceModel && data.summary_fields && + data.summary_fields[form.fields[fld].sourceModel]) { + $scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] = + data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField]; + master[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] = + data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField]; + } + } + Wait('stop'); + $scope.parseType = 'yaml'; + ParseTypeChange({ + scope: $scope, + variable: 'variables', + parse_variable: 'parseType', + field_id: 'inventory_variables' + }); + LookUpInit({ + scope: $scope, + form: form, + current_item: $scope.organization, + list: OrganizationList, + field: 'organization', + input_type: 'radio' + }); + }) + .error(function (data, status) { + ProcessErrors($scope, data, status, null, { hdr: 'Error!', + msg: 'Failed to get inventory: ' + inventory_id + '. GET returned: ' + status }); + }); + // Save + $scope.formSave = function () { + Wait('start'); + + // Make sure we have valid variable data + json_data = ToJSON($scope.parseType, $scope.variables); + + data = {}; + for (fld in form.fields) { + if (fld !== 'variables') { + if (form.fields[fld].realName) { + data[form.fields[fld].realName] = $scope[fld]; + } else { + data[fld] = $scope[fld]; + } + } + } + + if ($scope.removeUpdateInventoryVariables) { + $scope.removeUpdateInventoryVariables(); + } + $scope.removeUpdateInventoryVariables = $scope.$on('UpdateInventoryVariables', function(e, data) { + Rest.setUrl(data.related.variable_data); + Rest.put(json_data) + .success(function () { + Wait('stop'); + $location.path('/inventories/'); + }) + .error(function (data, status) { + ProcessErrors($scope, data, status, form, { hdr: 'Error!', + msg: 'Failed to update inventory varaibles. PUT returned status: ' + status + }); + }); + }); + + Rest.setUrl(defaultUrl + inventory_id + '/'); + Rest.put(data) + .success(function (data) { + if ($scope.variables) { + $scope.$emit('UpdateInventoryVariables', data); + } else { + $location.path('/inventories/'); + } + }) + .error(function (data, status) { + ProcessErrors($scope, data, status, form, { hdr: 'Error!', + msg: 'Failed to update inventory. PUT returned status: ' + status }); + }); + }; + + $scope.manageInventory = function(){ + $location.path($location.path() + '/manage'); + } + + $scope.showActivity = function () { + Stream({ scope: $scope }); + }; + + // Reset + $scope.formReset = function () { + generator.reset(); + for (var fld in master) { + $scope[fld] = master[fld]; + } + $scope.parseType = 'yaml'; + ParseTypeChange({ + scope: $scope, + variable: 'variables', + parse_variable: 'parseType', + field_id: 'inventory_variables' + }); + }; +} + +InventoriesEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'InventoryForm', 'GenerateForm', + 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GenerateList', 'OrganizationList', 'SearchInit', + 'PaginateInit', 'LookUpInit', 'GetBasePath', 'ParseTypeChange', 'Wait', 'ToJSON', 'ParseVariableString', 'Stream' +]; -export function InventoriesEdit ($log, $scope, $location, $routeParams, $compile, GenerateList, ClearScope, Empty, Wait, Rest, Alert, LoadBreadCrumbs, GetBasePath, ProcessErrors, + +export function InventoriesManage ($log, $scope, $location, $routeParams, $compile, GenerateList, ClearScope, Empty, Wait, Rest, Alert, LoadBreadCrumbs, GetBasePath, ProcessErrors, Breadcrumbs, InventoryGroups, InjectHosts, Find, HostsReload, SearchInit, PaginateInit, GetSyncStatusMsg, GetHostsStatusMsg, GroupsEdit, InventoryUpdate, GroupsCancelUpdate, ViewUpdateStatus, GroupsDelete, Store, HostsEdit, HostsDelete, EditInventoryProperties, ToggleHostEnabled, Stream, ShowJobSummary, InventoryGroupsHelp, HelpDialog, ViewJob, WatchInventoryWindowResize, GetHostContainerRows, GetGroupContainerRows, GetGroupContainerHeight, @@ -860,7 +1030,8 @@ export function InventoriesEdit ($log, $scope, $location, $routeParams, $compile }; $scope.editInventoryProperties = function () { - EditInventoryProperties({ scope: $scope, inventory_id: $scope.inventory.id }); + // EditInventoryProperties({ scope: $scope, inventory_id: $scope.inventory.id }); + $location.path('/inventories/' + $scope.inventory.id + '/'); }; hostScope.createHost = function () { @@ -1019,7 +1190,8 @@ export function InventoriesEdit ($log, $scope, $location, $routeParams, $compile }); } -InventoriesEdit.$inject = ['$log', '$scope', '$location', '$routeParams', '$compile', 'generateList', 'ClearScope', 'Empty', 'Wait', 'Rest', 'Alert', 'LoadBreadCrumbs', + +InventoriesManage.$inject = ['$log', '$scope', '$location', '$routeParams', '$compile', 'GenerateList', 'ClearScope', 'Empty', 'Wait', 'Rest', 'Alert', 'LoadBreadCrumbs', 'GetBasePath', 'ProcessErrors', 'Breadcrumbs', 'InventoryGroups', 'InjectHosts', 'Find', 'HostsReload', 'SearchInit', 'PaginateInit', 'GetSyncStatusMsg', 'GetHostsStatusMsg', 'GroupsEdit', 'InventoryUpdate', 'GroupsCancelUpdate', 'ViewUpdateStatus', 'GroupsDelete', 'Store', 'HostsEdit', 'HostsDelete', 'EditInventoryProperties', 'ToggleHostEnabled', 'Stream', 'ShowJobSummary', 'InventoryGroupsHelp', 'HelpDialog', 'ViewJob', 'WatchInventoryWindowResize', diff --git a/awx/ui/static/js/helpers/inventory.js b/awx/ui/static/js/helpers/inventory.js index ba90eccb51..3860c93929 100644 --- a/awx/ui/static/js/helpers/inventory.js +++ b/awx/ui/static/js/helpers/inventory.js @@ -46,8 +46,8 @@ export default return function() { var height, rows; height = $('#hosts-container .list-well').height() - $('#hosts-constainer .list-well .row').height() - $('#hosts_table thead').height(); - rows = Math.floor(height / 30) - 2; - rows = (rows < 20) ? 20 : rows; + rows = Math.floor(height / 44) - 2; + // rows = (rows < 20) ? 20 : rows; return rows; }; }]) @@ -56,8 +56,8 @@ export default return function() { var height, rows; height = $('#groups-container .list-table-container').height(); - rows = Math.floor(height / 31) - 2; - rows = (rows < 20) ? 20 : rows; + rows = Math.floor(height / 44) - 2; + // rows = (rows < 20) ? 20 : rows; return rows; }; }]) diff --git a/awx/ui/static/js/lists/Inventories.js b/awx/ui/static/js/lists/Inventories.js index 602f7007b4..6fc95a4b50 100644 --- a/awx/ui/static/js/lists/Inventories.js +++ b/awx/ui/static/js/lists/Inventories.js @@ -48,7 +48,8 @@ export default key: true, label: 'Name', columnClass: 'col-md-4 col-sm-6 col-xs-6', - modalColumnClass: 'col-md-8' + modalColumnClass: 'col-md-8', + linkTo: '/#/inventories/{{inventory.id}}/manage' }, organization: { label: 'Organization', @@ -96,16 +97,9 @@ export default }, fieldActions: { - failed_hosts: { - //label: 'Failures', - ngHref: "{{ inventory.failed_hosts_link }}", - iconClass: "{{ 'fa icon-failures-' + inventory.failed_hosts_class }}", - awToolTip: "{{ inventory.failed_hosts_tip }}", - dataPlacement: "top" - }, edit: { label: 'Edit', - ngClick: 'editInventoryProperties(inventory.id)', + ngClick: 'editInventory(inventory.id)', //'editInventoryProperties(inventory.id)', awToolTip: 'Edit inventory', dataPlacement: 'top' }, diff --git a/awx/ui/static/js/lists/InventoryGroups.js b/awx/ui/static/js/lists/InventoryGroups.js index 2e3483d6fa..ef88713e4d 100644 --- a/awx/ui/static/js/lists/InventoryGroups.js +++ b/awx/ui/static/js/lists/InventoryGroups.js @@ -23,7 +23,7 @@ export default key: true, ngClick: "groupSelect(group.id)", columnClick: "groupSelect(group.id)", - columnClass: 'col-lg-8 col-md-8 col-sm-8 col-xs-6' + columnClass: 'col-lg-6 col-md-6 col-sm-6 col-xs-6' }, source: { label: 'Source', @@ -109,7 +109,7 @@ export default fieldActions: { - columnClass: 'col-lg-4 col-md-4 col-sm-4 col-xs-6 text-right', + columnClass: 'col-lg-6 col-md-6 col-sm-6 col-xs-6 text-right', label: false, sync_status: { @@ -169,4 +169,4 @@ export default dataPlacement: "top" } } - }); \ No newline at end of file + }); diff --git a/awx/ui/static/js/lists/InventoryHosts.js b/awx/ui/static/js/lists/InventoryHosts.js index d1bbfa3520..513fc0c6e4 100644 --- a/awx/ui/static/js/lists/InventoryHosts.js +++ b/awx/ui/static/js/lists/InventoryHosts.js @@ -29,8 +29,7 @@ export default key: true, label: 'Hosts', ngClick: "editHost(host.id)", - ngClass: "{ 'host-disabled-label': !host.enabled }", - columnClass: 'col-lg-8 col-md-9 col-sm-9 col-xs-7', + columnClass: 'col-lg-6 col-md-9 col-sm-9 col-xs-7',git dataHostId: "{{ host.id }}", dataType: "host" }, @@ -52,7 +51,7 @@ export default fieldActions: { - columnClass: 'col-lg-4 col-md-3 col-sm-3 col-xs-5 text-right', + columnClass: 'col-lg-6 col-md-3 col-sm-3 col-xs-5 text-right', label: false, active_failures: { diff --git a/awx/ui/static/js/shared/generator-helpers.js b/awx/ui/static/js/shared/generator-helpers.js index 4f9d9166cf..061503300b 100644 --- a/awx/ui/static/js/shared/generator-helpers.js +++ b/awx/ui/static/js/shared/generator-helpers.js @@ -141,7 +141,7 @@ angular.module('GeneratorHelpers', [systemStatus.name]) icon = 'fa-check-square-o'; break; case 'properties': - icon = "fa-wrench"; + icon = "fa-pencil"; break; case 'reset': icon = "fa-undo"; diff --git a/awx/ui/static/partials/inventory-edit.html b/awx/ui/static/partials/inventory-manage.html similarity index 98% rename from awx/ui/static/partials/inventory-edit.html rename to awx/ui/static/partials/inventory-manage.html index 3116445ec1..0ec23f3107 100644 --- a/awx/ui/static/partials/inventory-edit.html +++ b/awx/ui/static/partials/inventory-manage.html @@ -3,7 +3,7 @@
@@ -156,4 +156,4 @@ - \ No newline at end of file +