Add support for max hosts on org

This commit is contained in:
mabashian 2019-02-21 16:42:46 -05:00 committed by Jeff Bradberry
parent 046385d72e
commit ce5a85a53b
8 changed files with 45 additions and 13 deletions

View File

@ -236,6 +236,17 @@ function getLicenseErrorDetails () {
return { label, value };
}
function getHostLimitErrorDetails () {
if (!resource.model.has('org_host_limit_error')) {
return null;
}
const label = strings.get('labels.HOST_LIMIT_ERROR');
const value = resource.model.get('org_host_limit_error');
return { label, value };
}
function getLaunchedByDetails () {
const createdBy = resource.model.get('summary_fields.created_by');
const jobTemplate = resource.model.get('summary_fields.job_template');
@ -804,6 +815,7 @@ function JobDetailsController (
vm.overwrite = getOverwriteDetails();
vm.overwriteVars = getOverwriteVarsDetails();
vm.licenseError = getLicenseErrorDetails();
vm.hostLimitError = getHostLimitErrorDetails();
// Relaunch and Delete Components
vm.job = angular.copy(_.get(resource.model, 'model.GET', {}));

View File

@ -81,6 +81,14 @@
</div>
</div>
<!-- HOST LIMIT ERROR DETAIL -->
<div class="JobResults-resultRow" ng-show="vm.hostLimitError">
<label class="JobResults-resultRowLabel">{{ vm.hostLimitError.label }}</label>
<div class="JobResults-resultRowText">
{{ vm.hostLimitError.value }}
</div>
</div>
<!-- START TIME DETAIL -->
<div class="JobResults-resultRow" ng-if="vm.started">
<label class="JobResults-resultRowLabel">{{ vm.started.label }}</label>

View File

@ -57,6 +57,7 @@ function OutputStrings (BaseString) {
EXTRA_VARS: t.s('Extra Variables'),
FINISHED: t.s('Finished'),
FORKS: t.s('Forks'),
HOST_LIMIT_ERROR: t.s('Host Limit Error'),
INSTANCE_GROUP: t.s('Instance Group'),
INVENTORY: t.s('Inventory'),
INVENTORY_SCM: t.s('Source Project'),

View File

@ -5,9 +5,9 @@
*************************************************/
export default ['$state', '$stateParams', '$scope', 'RelatedHostsFormDefinition', 'ParseTypeChange',
'GenerateForm', 'HostsService', 'rbacUiControlService', 'GetBasePath', 'ToJSON', 'canAdd',
'GenerateForm', 'HostsService', 'GetBasePath', 'ToJSON', 'canAdd',
function($state, $stateParams, $scope, RelatedHostsFormDefinition, ParseTypeChange,
GenerateForm, HostsService, rbacUiControlService, GetBasePath, ToJSON, canAdd) {
GenerateForm, HostsService, GetBasePath, ToJSON, canAdd) {
init();

View File

@ -17,9 +17,9 @@
url: function(){
return '';
},
error: function(data, status) {
ProcessErrors($rootScope, data.data, status, null, { hdr: 'Error!',
msg: 'Call to ' + this.url + '. GET returned: ' + status });
error: function(data) {
ProcessErrors($rootScope, data.data, data.status, null, { hdr: 'Error!',
msg: 'Call to ' + this.url + '. GET returned: ' + data.status });
},
success: function(data){
return data;

View File

@ -24,8 +24,6 @@ export default ['$scope', '$rootScope', '$location', '$stateParams',
init();
function init(){
// @issue What is this doing, why
$scope.$emit("HideOrgListHeader");
const virtualEnvs = ConfigData.custom_virtualenvs || [];
$scope.custom_virtualenvs_visible = virtualEnvs.length > 1;
$scope.custom_virtualenvs_options = virtualEnvs.filter(
@ -43,15 +41,15 @@ export default ['$scope', '$rootScope', '$location', '$stateParams',
// Save
$scope.formSave = function() {
var fld, params = {};
Wait('start');
for (fld in form.fields) {
params[fld] = $scope[fld];
}
var url = GetBasePath(base);
url += (base !== 'organizations') ? $stateParams.project_id + '/organizations/' : '';
Rest.setUrl(url);
Rest.post({
name: $scope.name,
description: $scope.description,
custom_virtualenv: $scope.custom_virtualenv
})
Rest.post(params)
.then(({data}) => {
const organization_id = data.id,
instance_group_url = data.related.instance_groups;

View File

@ -38,7 +38,6 @@ export default ['$scope', '$location', '$stateParams', 'OrgAdminLookup',
}
});
$scope.$emit("HideOrgListHeader");
$scope.instance_groups = InstanceGroupsData;
const virtualEnvs = ConfigData.custom_virtualenvs || [];
$scope.custom_virtualenvs_visible = virtualEnvs.length > 1;

View File

@ -54,6 +54,20 @@ export default ['NotificationsList', 'i18n',
dataPlacement: 'right',
ngDisabled: '!(organization_obj.summary_fields.user_capabilities.edit || canAdd)',
ngShow: 'custom_virtualenvs_visible'
},
max_hosts: {
label: i18n._('Max Hosts'),
type: 'number',
integer: true,
min: 0,
default: 0,
spinner: true,
dataTitle: i18n._('Max Hosts'),
dataPlacement: 'right',
dataContainer: 'body',
awPopOver: "<p>" + i18n._("The maximum number of hosts allowed to be managed by this organization. Value defaults to 0 which means no limit. Refer to the Ansible documentation for more details.") + "</p>",
ngDisabled: '!current_user.is_superuser',
ngShow: 'BRAND_NAME === "Tower"'
}
},