1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

updates to jshint and groups language to inventory_source

This commit is contained in:
John Mitchell 2017-05-26 11:56:14 -04:00
parent 6789abbdeb
commit 4fcfac3137
6 changed files with 48 additions and 49 deletions

View File

@ -5,13 +5,12 @@
*************************************************/
export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition',
'ParseTypeChange', 'GenerateForm', 'inventoryData', 'GroupManageService',
'GetChoices', 'GetBasePath', 'CreateSelect2', 'GetSourceTypeOptions', 'Empty',
'rbacUiControlService', 'ToJSON', 'SourcesService', 'Wait', 'Rest',
'ParseTypeChange', 'GenerateForm', 'inventoryData', 'GetChoices', 'GetBasePath', 'CreateSelect2', 'GetSourceTypeOptions', 'Empty',
'rbacUiControlService', 'ToJSON', 'SourcesService', 'Wait', 'Rest', 'Alert', 'ProcessErrors',
function($state, $stateParams, $scope, SourcesFormDefinition, ParseTypeChange,
GenerateForm, inventoryData, GroupManageService, GetChoices,
GenerateForm, inventoryData, GetChoices,
GetBasePath, CreateSelect2, GetSourceTypeOptions, Empty, rbacUiControlService,
ToJSON, SourcesService, Wait, Rest) {
ToJSON, SourcesService, Wait, Rest, Alert, ProcessErrors) {
let form = SourcesFormDefinition;
init();
@ -42,7 +41,7 @@ export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition',
sync_inventory_file_select2();
Wait('stop');
})
.error(function (ret,status_code) {
.error(function () {
Alert('Cannot get inventory files', 'Unable to retrieve the list of inventory files for this project.', 'alert-info');
Wait('stop');
});

View File

@ -5,13 +5,11 @@
*************************************************/
export default ['$state', '$stateParams', '$scope', 'ParseVariableString',
'rbacUiControlService', 'ToJSON', 'ParseTypeChange', 'GroupManageService',
'GetChoices', 'GetBasePath', 'CreateSelect2', 'GetSourceTypeOptions',
'inventorySourceData', 'SourcesService', 'inventoryData', 'Empty', 'Wait', 'Rest',
'rbacUiControlService', 'ToJSON', 'ParseTypeChange', 'GetChoices', 'GetBasePath', 'CreateSelect2', 'GetSourceTypeOptions',
'inventorySourceData', 'SourcesService', 'inventoryData', 'Empty', 'Wait', 'Rest', 'Alert', 'ProcessErrors',
function($state, $stateParams, $scope, ParseVariableString,
rbacUiControlService, ToJSON,ParseTypeChange, GroupManageService,
GetChoices, GetBasePath, CreateSelect2, GetSourceTypeOptions,
inventorySourceData, SourcesService, inventoryData, Empty, Wait, Rest) {
rbacUiControlService, ToJSON,ParseTypeChange, GetChoices, GetBasePath, CreateSelect2, GetSourceTypeOptions,
inventorySourceData, SourcesService, inventoryData, Empty, Wait, Rest, Alert, ProcessErrors) {
init();
@ -31,6 +29,8 @@ export default ['$state', '$stateParams', '$scope', 'ParseVariableString',
{instance_filters: inventorySourceData.instance_filters},
{inventory_script: inventorySourceData.source_script},
{verbosity: inventorySourceData.verbosity});
$scope.inventory_source_obj = inventorySourceData;
if (inventorySourceData.credential) {
$scope.credential_name = inventorySourceData.summary_fields.credential.name;
}
@ -73,7 +73,7 @@ export default ['$state', '$stateParams', '$scope', 'ParseVariableString',
sync_inventory_file_select2();
Wait('stop');
})
.error(function (ret,status_code) {
.error(function () {
Alert('Cannot get inventory files', 'Unable to retrieve the list of inventory files for this project.', 'alert-info');
Wait('stop');
});
@ -104,7 +104,7 @@ export default ['$state', '$stateParams', '$scope', 'ParseVariableString',
}
})
.error(function (data, status) {
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
ProcessErrors($scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to get project ' + $scope.project + '. GET returned status: ' + status });
});
}

View File

@ -5,17 +5,18 @@
*************************************************/
export default
['$scope', '$rootScope', '$state', '$stateParams', 'SourcesListDefinition',
'InventoryUpdate', 'GroupManageService', 'CancelSourceUpdate',
'InventoryUpdate', 'CancelSourceUpdate',
'ViewUpdateStatus', 'rbacUiControlService', 'GetBasePath',
'GetSyncStatusMsg', 'Dataset', 'Find', 'QuerySet',
'inventoryData', '$filter', 'Prompt', 'Wait', 'SourcesService',
function($scope, $rootScope, $state, $stateParams, SourcesListDefinition,
InventoryUpdate, GroupManageService, CancelSourceUpdate,
InventoryUpdate, CancelSourceUpdate,
ViewUpdateStatus, rbacUiControlService, GetBasePath, GetSyncStatusMsg,
Dataset, Find, qs, inventoryData, $filter, Prompt,
Wait, SourcesService){
let list = SourcesListDefinition;
var inventory_source;
init();
@ -24,7 +25,7 @@
$scope.canAdhoc = inventoryData.summary_fields.user_capabilities.adhoc;
$scope.canAdd = false;
rbacUiControlService.canAdd(GetBasePath('inventory') + $scope.inventory_id + "/groups")
rbacUiControlService.canAdd(GetBasePath('inventory') + $scope.inventory_id + "/inventory_sources")
.then(function(canAdd) {
$scope.canAdd = canAdd;
});
@ -38,7 +39,7 @@
_.forEach($scope[list.name], buildStatusIndicators);
$scope.$on(`ws-jobs`, function(e, data){
var inventory_source = Find({ list: $scope.inventory_sources, key: 'id', val: data.inventory_source_id });
inventory_source = Find({ list: $scope.inventory_sources, key: 'id', val: data.inventory_source_id });
if (inventory_source === undefined || inventory_source === null) {
inventory_source = {};
@ -101,7 +102,7 @@
Wait('start');
SourcesService.delete(inventory_source.id).then(() => {
$('#prompt-modal').modal('hide');
if (parseInt($state.params.source_id) === invnetory_source) {
if (parseInt($state.params.source_id) === inventory_source) {
$state.go("sources", null, {reload: true});
} else {
$state.go($state.current.name, null, {reload: true});
@ -136,7 +137,7 @@
});
};
$scope.scheduleSource = function(id) {
// Add this group's id to the array of group id's so that it gets
// Add this inv source's id to the array of inv source id's so that it gets
// added to the breadcrumb trail
$state.go('inventories.edit.inventory_sources.edit.schedules', {inventory_source_id: id}, {reload: true});
};

View File

@ -5,7 +5,7 @@
<div class="Modal-title ng-binding">
Delete Group
<a href="" id="awp-promote" href=""
aw-pop-over="<dl><dt>Delete</dt><dd>Deletes groups and hosts associated with the group being deleted. If a group or host is associated with other groups, it will still exist within those groups. Otherwise, the associated groups and hosts will no longer appear in the inventory.</dd>\n<dt style='margin-top: 5px;'>Promote</dt><dd>Groups and hosts associated with the group being removed will be promoted root level. Note: groups already associated with other groups cannot be promoted.</dd></dl>\n" aw-tool-tip="Click for help"
aw-pop-over="<dl><dt>Delete</dt><dd>Deletes groups and hosts associated with the inventory source being deleted. If a group or host is associated with other inventory sources, it will still exist within those inventory sources. Otherwise, the associated groups and hosts will no longer appear in the inventory.</dd>\n<dt style='margin-top: 5px;'>Promote</dt><dd>Groups and hosts associated with the inventory source being removed will be promoted root level. Note: groups already associated with other inventory sources cannot be promoted.</dd></dl>\n" aw-tool-tip="Click for help"
data-placement="right"
data-container="body"
data-title="Delete Group"
@ -66,7 +66,7 @@
</div>
<div ng-show="toDelete.total_groups == 0 && toDelete.total_hosts == 0">
<div class="Prompt-bodyQuery">Are you sure you want to permanently delete the group below from the inventory?</div>
<div class="Prompt-bodyQuery">Are you sure you want to permanently delete the inventory source below from the inventory?</div>
<div class="Prompt-bodyTarget">{{ toDelete.name }}</div>
</div>
<div class="Modal-footer">

View File

@ -47,14 +47,14 @@ return {
name: {
label: 'Name',
type: 'text',
ngDisabled: '!(group_obj.summary_fields.user_capabilities.edit || canAdd)',
ngDisabled: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)',
required: true,
tab: 'properties'
},
description: {
label: 'Description',
type: 'text',
ngDisabled: '!(group_obj.summary_fields.user_capabilities.edit || canAdd)',
ngDisabled: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)',
tab: 'properties'
},
source: {
@ -62,7 +62,7 @@ return {
type: 'select',
ngOptions: 'source.label for source in source_type_options track by source.value',
ngChange: 'sourceChange(source)',
ngDisabled: '!(group_obj.summary_fields.user_capabilities.edit || canAdd)',
ngDisabled: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)',
ngModel: 'source'
},
credential: {
@ -78,7 +78,7 @@ return {
reqExpression: "cloudCredentialRequired",
init: "false"
},
ngDisabled: '!(group_obj.summary_fields.user_capabilities.edit || canAdd)',
ngDisabled: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)',
watchBasePath: "credentialBasePath"
},
project: {
@ -96,7 +96,7 @@ return {
reqExpression: "projectRequired",
init: "false"
},
ngDisabled: '!(group_obj.summary_fields.user_capabilities.edit || canAdd)',
ngDisabled: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)',
watchBasePath: "projectBasePath"
},
inventory_file: {
@ -104,7 +104,7 @@ return {
type:'select',
ngOptions: 'file for file in inventory_files track by file',
ngShow: "source && source.value === 'scm'",
ngDisabled: "!(group_obj.summary_fields.user_capabilities.edit || canAdd) || disableInventoryFileBecausePermissionDenied",
ngDisabled: "!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd) || disableInventoryFileBecausePermissionDenied",
id: 'inventory-file-select',
awRequiredWhen: {
reqExpression: "inventoryfilerequired",
@ -131,7 +131,7 @@ return {
"or choose <em>All</em> to include all regions. Tower will only be updated with Hosts associated with the selected regions." +
"</p>",
dataContainer: 'body',
ngDisabled: '!(group_obj.summary_fields.user_capabilities.edit || canAdd)'
ngDisabled: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)'
},
instance_filters: {
label: 'Instance Filters',
@ -150,7 +150,7 @@ return {
"<p>View the <a href=\"http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstances.html\" target=\"_blank\">Describe Instances documentation</a> " +
"for a complete list of supported filters.</p>",
dataContainer: 'body',
ngDisabled: '!(group_obj.summary_fields.user_capabilities.edit || canAdd)'
ngDisabled: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)'
},
group_by: {
label: 'Only Group By',
@ -174,7 +174,7 @@ return {
"<li>Tag None: <strong>tags &raquo; tag_none</strong></li>" +
"</ul><p>If blank, all groups above are created except <em>Instance ID</em>.</p>",
dataContainer: 'body',
ngDisabled: '!(group_obj.summary_fields.user_capabilities.edit || canAdd)'
ngDisabled: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)'
},
inventory_script: {
label : "Custom Inventory Script",
@ -188,7 +188,7 @@ return {
reqExpression: "source && source.value === 'custom'",
init: "false"
},
ngDisabled: '!(group_obj.summary_fields.user_capabilities.edit || canAdd)',
ngDisabled: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)',
},
custom_variables: {
id: 'custom_variables',
@ -292,7 +292,7 @@ return {
dataTitle: i18n._('Verbosity'),
dataPlacement: 'right',
dataContainer: "body",
ngDisabled: '!(group_obj.summary_fields.user_capabilities.edit || canAdd)',
ngDisabled: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)',
},
checkbox_group: {
label: 'Update Options',
@ -313,7 +313,7 @@ return {
dataContainer: 'body',
dataPlacement: 'right',
labelClass: 'checkbox-options',
ngDisabled: "(!(group_obj.summary_fields.user_capabilities.edit || canAdd))"
ngDisabled: "(!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd))"
}, {
name: 'overwrite_vars',
label: 'Overwrite Variables',
@ -328,7 +328,7 @@ return {
dataContainer: 'body',
dataPlacement: 'right',
labelClass: 'checkbox-options',
ngDisabled: "(!(group_obj.summary_fields.user_capabilities.edit || canAdd) || source.value === 'scm')"
ngDisabled: "(!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd) || source.value === 'scm')"
}, {
name: 'update_on_launch',
label: 'Update on Launch',
@ -340,7 +340,7 @@ return {
dataContainer: 'body',
dataPlacement: 'right',
labelClass: 'checkbox-options',
ngDisabled: '!(group_obj.summary_fields.user_capabilities.edit || canAdd)'
ngDisabled: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)'
}, {
name: 'update_on_project_update',
label: 'Update on Project Update',
@ -351,14 +351,14 @@ return {
dataContainer: 'body',
dataPlacement: 'right',
labelClass: 'checkbox-options',
ngDisabled: '!(group_obj.summary_fields.user_capabilities.edit || canAdd)'
ngDisabled: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)'
}]
},
update_cache_timeout: {
label: "Cache Timeout <span class=\"small-text\"> (seconds)</span>",
id: 'source-cache-timeout',
type: 'number',
ngDisabled: '!(group_obj.summary_fields.user_capabilities.edit || canAdd)',
ngDisabled: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)',
integer: true,
min: 0,
ngShow: "source && source.value !== '' && update_on_launch",
@ -376,16 +376,16 @@ return {
buttons: {
cancel: {
ngClick: 'formCancel()',
ngShow: '(group_obj.summary_fields.user_capabilities.edit || canAdd)'
ngShow: '(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)'
},
close: {
ngClick: 'formCancel()',
ngShow: '!(group_obj.summary_fields.user_capabilities.edit || canAdd)'
ngShow: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)'
},
save: {
ngClick: 'formSave()',
ngDisabled: true,
ngShow: '(group_obj.summary_fields.user_capabilities.edit || canAdd)'
ngShow: '(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)'
}
},

View File

@ -618,17 +618,16 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
var element = params.element,
options = params.opts,
multiple = (params.multiple !== undefined) ? params.multiple : true,
createNew = (params.createNew !== undefined) ? params.createNew : false,
placeholder = params.placeholder,
customDropdownAdapter = (params.customDropdownAdapter !== undefined) ? params.customDropdownAdapter : true,
addNew = params.addNew,
scope = params.scope,
options = params.options,
selectOptions = params.options,
model = params.model,
original_options;
if (scope && options) {
original_options = _.cloneDeep(scope[options]);
if (scope && selectOptions) {
original_options = _.cloneDeep(scope[selectOptions]);
}
$.fn.select2.amd.require([
@ -690,15 +689,15 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
}
}).on('select2:unselecting', (e) => {
$(e.target).data('select2-unselecting', true);
})
});
}
if (addNew && !multiple) {
$(element).on('select2:select', (e) => {
scope[model] = e.params.data.text;
scope[options] = _.cloneDeep(original_options);
if (scope[options].indexOf(e.params.data.text) === -1) {
scope[options].push(e.params.data.text);
scope[selectOptions] = _.cloneDeep(original_options);
if (scope[selectOptions].indexOf(e.params.data.text) === -1) {
scope[selectOptions].push(e.params.data.text);
}
$(element).select2(config);
});