mirror of
https://github.com/ansible/awx.git
synced 2026-02-28 16:28:43 -03:30
Adding notifications panel to inventory sources
This commit is contained in:
@@ -24,7 +24,6 @@ import LogViewerStatus from "./forms/LogViewerStatus";
|
|||||||
import Organizations from "./forms/Organizations";
|
import Organizations from "./forms/Organizations";
|
||||||
import ProjectStatus from "./forms/ProjectStatus";
|
import ProjectStatus from "./forms/ProjectStatus";
|
||||||
import Projects from "./forms/Projects";
|
import Projects from "./forms/Projects";
|
||||||
import Source from "./forms/Source";
|
|
||||||
import Teams from "./forms/Teams";
|
import Teams from "./forms/Teams";
|
||||||
import Users from "./forms/Users";
|
import Users from "./forms/Users";
|
||||||
|
|
||||||
@@ -50,7 +49,6 @@ export
|
|||||||
Organizations,
|
Organizations,
|
||||||
ProjectStatus,
|
ProjectStatus,
|
||||||
Projects,
|
Projects,
|
||||||
Source,
|
|
||||||
Teams,
|
Teams,
|
||||||
Users
|
Users
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,12 +12,11 @@
|
|||||||
|
|
||||||
export default
|
export default
|
||||||
angular.module('GroupFormDefinition', [])
|
angular.module('GroupFormDefinition', [])
|
||||||
.value('GroupForm', {
|
.value('GroupFormObject', {
|
||||||
|
|
||||||
addTitle: 'Create Group',
|
addTitle: 'Create Group',
|
||||||
editTitle: 'Edit Group',
|
editTitle: '{{ name }}',
|
||||||
showTitle: true,
|
showTitle: true,
|
||||||
cancelButton: false,
|
|
||||||
name: 'group',
|
name: 'group',
|
||||||
well: false,
|
well: false,
|
||||||
|
|
||||||
@@ -57,11 +56,279 @@ export default
|
|||||||
'<p>View YAML examples at <a href="http://docs.ansible.com/YAMLSyntax.html" target="_blank">docs.ansible.com</a></p>',
|
'<p>View YAML examples at <a href="http://docs.ansible.com/YAMLSyntax.html" target="_blank">docs.ansible.com</a></p>',
|
||||||
dataContainer: 'body',
|
dataContainer: 'body',
|
||||||
tab: 'properties'
|
tab: 'properties'
|
||||||
|
},
|
||||||
|
source: {
|
||||||
|
label: 'Source',
|
||||||
|
type: 'select',
|
||||||
|
ngOptions: 'source.label for source in source_type_options track by source.value',
|
||||||
|
ngChange: 'sourceChange()',
|
||||||
|
addRequired: false,
|
||||||
|
editRequired: false
|
||||||
|
},
|
||||||
|
source_path: {
|
||||||
|
label: 'Script Path',
|
||||||
|
ngShow: "source && source.value == 'file'",
|
||||||
|
type: 'text',
|
||||||
|
awRequiredWhen: {
|
||||||
|
reqExpression: "sourcePathRequired",
|
||||||
|
init: "false"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
credential: {
|
||||||
|
label: 'Cloud Credential',
|
||||||
|
type: 'lookup',
|
||||||
|
ngShow: "source && source.value !== 'manual' && source.value !== 'custom'",
|
||||||
|
sourceModel: 'credential',
|
||||||
|
sourceField: 'name',
|
||||||
|
ngClick: 'lookUpCredential()',
|
||||||
|
awRequiredWhen: {
|
||||||
|
reqExpression: "cloudCredentialRequired",
|
||||||
|
init: "false"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
source_regions: {
|
||||||
|
label: 'Regions',
|
||||||
|
type: 'select',
|
||||||
|
ngOptions: 'source.label for source in source_region_choices track by source.value',
|
||||||
|
multiSelect: true,
|
||||||
|
ngShow: "source && (source.value == 'rax' || source.value == 'ec2' || source.value == 'gce' || source.value == 'azure')",
|
||||||
|
addRequired: false,
|
||||||
|
editRequired: false,
|
||||||
|
dataTitle: 'Source Regions',
|
||||||
|
dataPlacement: 'right',
|
||||||
|
awPopOver: "<p>Click on the regions field to see a list of regions for your cloud provider. You can select multiple regions, " +
|
||||||
|
"or choose <em>All</em> to include all regions. Tower will only be updated with Hosts associated with the selected regions." +
|
||||||
|
"</p>",
|
||||||
|
dataContainer: 'body'
|
||||||
|
},
|
||||||
|
instance_filters: {
|
||||||
|
label: 'Instance Filters',
|
||||||
|
type: 'text',
|
||||||
|
ngShow: "source && source.value == 'ec2'",
|
||||||
|
addRequired: false,
|
||||||
|
editRequired: false,
|
||||||
|
dataTitle: 'Instance Filters',
|
||||||
|
dataPlacement: 'right',
|
||||||
|
awPopOver: "<p>Provide a comma-separated list of filter expressions. " +
|
||||||
|
"Hosts are imported to Tower when <em>ANY</em> of the filters match.</p>" +
|
||||||
|
"Limit to hosts having a tag:<br />\n" +
|
||||||
|
"<blockquote>tag-key=TowerManaged</blockquote>\n" +
|
||||||
|
"Limit to hosts using either key pair:<br />\n" +
|
||||||
|
"<blockquote>key-name=staging, key-name=production</blockquote>\n" +
|
||||||
|
"Limit to hosts where the Name tag begins with <em>test</em>:<br />\n" +
|
||||||
|
"<blockquote>tag:Name=test*</blockquote>\n" +
|
||||||
|
"<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'
|
||||||
|
},
|
||||||
|
group_by: {
|
||||||
|
label: 'Only Group By',
|
||||||
|
type: 'select',
|
||||||
|
ngShow: "source && source.value == 'ec2'",
|
||||||
|
ngOptions: 'source.label for source in group_by_choices track by source.value',
|
||||||
|
addRequired: false,
|
||||||
|
editRequired: false,
|
||||||
|
multiSelect: true,
|
||||||
|
dataTitle: 'Only Group By',
|
||||||
|
dataPlacement: 'right',
|
||||||
|
awPopOver: "<p>Select which groups to create automatically. " +
|
||||||
|
"Tower will create group names similar to the following examples based on the options selected:</p><ul>" +
|
||||||
|
"<li>Availability Zone: <strong>zones » us-east-1b</strong></li>" +
|
||||||
|
"<li>Image ID: <strong>images » ami-b007ab1e</strong></li>" +
|
||||||
|
"<li>Instance ID: <strong>instances » i-ca11ab1e</strong></li>" +
|
||||||
|
"<li>Instance Type: <strong>types » type_m1_medium</strong></li>" +
|
||||||
|
"<li>Key Name: <strong>keys » key_testing</strong></li>" +
|
||||||
|
"<li>Region: <strong>regions » us-east-1</strong></li>" +
|
||||||
|
"<li>Security Group: <strong>security_groups » security_group_default</strong></li>" +
|
||||||
|
"<li>Tags: <strong>tags » tag_Name » tag_Name_host1</strong></li>" +
|
||||||
|
"<li>VPC ID: <strong>vpcs » vpc-5ca1ab1e</strong></li>" +
|
||||||
|
"</ul><p>If blank, all groups above are created except <em>Instance ID</em>.</p>",
|
||||||
|
dataContainer: 'body'
|
||||||
|
},
|
||||||
|
inventory_script: {
|
||||||
|
label : "Custom Inventory Script",
|
||||||
|
labelClass: 'prepend-asterisk',
|
||||||
|
type: 'lookup',
|
||||||
|
ngShow: "source && source.value === 'custom'",
|
||||||
|
sourceModel: 'inventory_script',
|
||||||
|
sourceField: 'name',
|
||||||
|
ngClick: 'lookUpInventory_script()' ,
|
||||||
|
addRequired: true,
|
||||||
|
editRequired: true,
|
||||||
|
ngRequired: "source && source.value === 'custom'",
|
||||||
|
},
|
||||||
|
extra_vars: {
|
||||||
|
label: 'Environment Variables', //"{{vars_label}}" ,
|
||||||
|
ngShow: "source && source.value=='custom' ",
|
||||||
|
type: 'textarea',
|
||||||
|
class: 'Form-textAreaLabel',
|
||||||
|
addRequired: false,
|
||||||
|
editRequired: false,
|
||||||
|
rows: 6,
|
||||||
|
'default': '---',
|
||||||
|
parseTypeName: 'envParseType',
|
||||||
|
dataTitle: "Environment Variables",
|
||||||
|
dataPlacement: 'right',
|
||||||
|
awPopOver: "<p>Provide key/value pairs using either YAML or JSON.</p>" +
|
||||||
|
"JSON:<br />\n" +
|
||||||
|
"<blockquote>{<br />\"somevar\": \"somevalue\",<br />\"password\": \"magic\"<br /> }</blockquote>\n" +
|
||||||
|
"YAML:<br />\n" +
|
||||||
|
"<blockquote>---<br />somevar: somevalue<br />password: magic<br /></blockquote>\n",
|
||||||
|
dataContainer: 'body'
|
||||||
|
},
|
||||||
|
source_vars: {
|
||||||
|
label: 'Source Variables', //"{{vars_label}}" ,
|
||||||
|
ngShow: "source && (source.value == 'file' || source.value == 'ec2')",
|
||||||
|
type: 'textarea',
|
||||||
|
class: 'Form-textAreaLabel',
|
||||||
|
addRequired: false,
|
||||||
|
editRequird: false,
|
||||||
|
rows: 6,
|
||||||
|
'default': '---',
|
||||||
|
parseTypeName: 'envParseType',
|
||||||
|
dataTitle: "Source Variables",
|
||||||
|
dataPlacement: 'right',
|
||||||
|
awPopOver: "<p>Override variables found in ec2.ini and used by the inventory update script. For a detailed description of these variables " +
|
||||||
|
"<a href=\"https://github.com/ansible/ansible/blob/devel/contrib/inventory/ec2.ini\" target=\"_blank\">" +
|
||||||
|
"view ec2.ini in the Ansible github repo.</a></p>" +
|
||||||
|
"<p>Enter variables using either JSON or YAML syntax. Use the radio button to toggle between the two.</p>" +
|
||||||
|
"JSON:<br />\n" +
|
||||||
|
"<blockquote>{<br />\"somevar\": \"somevalue\",<br />\"password\": \"magic\"<br /> }</blockquote>\n" +
|
||||||
|
"YAML:<br />\n" +
|
||||||
|
"<blockquote>---<br />somevar: somevalue<br />password: magic<br /></blockquote>\n" +
|
||||||
|
'<p>View JSON examples at <a href="http://www.json.org" target="_blank">www.json.org</a></p>' +
|
||||||
|
'<p>View YAML examples at <a href="http://docs.ansible.com/YAMLSyntax.html" target="_blank">docs.ansible.com</a></p>',
|
||||||
|
dataContainer: 'body'
|
||||||
|
},
|
||||||
|
inventory_variables: {
|
||||||
|
label: 'Source Variables', //"{{vars_label}}" ,
|
||||||
|
|
||||||
|
ngShow: "source && (source.value == 'vmware' || " +
|
||||||
|
"source.value == 'openstack')",
|
||||||
|
type: 'textarea',
|
||||||
|
addRequired: false,
|
||||||
|
class: 'Form-textAreaLabel',
|
||||||
|
editRequird: false,
|
||||||
|
rows: 6,
|
||||||
|
'default': '---',
|
||||||
|
parseTypeName: 'envParseType',
|
||||||
|
dataTitle: "Source Variables",
|
||||||
|
dataPlacement: 'right',
|
||||||
|
awPopOver: "<p>Override variables found in vmware.ini and used by the inventory update script. For a detailed description of these variables " +
|
||||||
|
"<a href=\"https://github.com/ansible/ansible/blob/devel/contrib/inventory/vmware.ini\" target=\"_blank\">" +
|
||||||
|
"view vmware.ini in the Ansible github repo.</a></p>" +
|
||||||
|
"<p>Enter variables using either JSON or YAML syntax. Use the radio button to toggle between the two.</p>" +
|
||||||
|
"JSON:<br />\n" +
|
||||||
|
"<blockquote>{<br />\"somevar\": \"somevalue\",<br />\"password\": \"magic\"<br /> }</blockquote>\n" +
|
||||||
|
"YAML:<br />\n" +
|
||||||
|
"<blockquote>---<br />somevar: somevalue<br />password: magic<br /></blockquote>\n" +
|
||||||
|
'<p>View JSON examples at <a href="http://www.json.org" target="_blank">www.json.org</a></p>' +
|
||||||
|
'<p>View YAML examples at <a href="http://docs.ansible.com/YAMLSyntax.html" target="_blank">docs.ansible.com</a></p>',
|
||||||
|
dataContainer: 'body'
|
||||||
|
},
|
||||||
|
checkbox_group: {
|
||||||
|
label: 'Update Options',
|
||||||
|
type: 'checkbox_group',
|
||||||
|
ngShow: "source && (source.value !== 'manual' && source.value !== null)",
|
||||||
|
|
||||||
|
fields: [{
|
||||||
|
name: 'overwrite',
|
||||||
|
label: 'Overwrite',
|
||||||
|
type: 'checkbox',
|
||||||
|
ngShow: "source.value !== 'manual' && source.value !== null",
|
||||||
|
addRequired: false,
|
||||||
|
editRequired: false,
|
||||||
|
awPopOver: '<p>If checked, all child groups and hosts not found on the external source will be deleted from ' +
|
||||||
|
'the local inventory.</p><p>When not checked, local child hosts and groups not found on the external source will ' +
|
||||||
|
'remain untouched by the inventory update process.</p>',
|
||||||
|
dataTitle: 'Overwrite',
|
||||||
|
dataContainer: 'body',
|
||||||
|
dataPlacement: 'right',
|
||||||
|
labelClass: 'checkbox-options'
|
||||||
|
}, {
|
||||||
|
name: 'overwrite_vars',
|
||||||
|
label: 'Overwrite Variables',
|
||||||
|
type: 'checkbox',
|
||||||
|
ngShow: "source.value !== 'manual' && source.value !== null",
|
||||||
|
addRequired: false,
|
||||||
|
editRequired: false,
|
||||||
|
awPopOver: '<p>If checked, all variables for child groups and hosts will be removed and replaced by those ' +
|
||||||
|
'found on the external source.</p><p>When not checked, a merge will be performed, combining local variables with ' +
|
||||||
|
'those found on the external source.</p>',
|
||||||
|
dataTitle: 'Overwrite Variables',
|
||||||
|
dataContainer: 'body',
|
||||||
|
dataPlacement: 'right',
|
||||||
|
labelClass: 'checkbox-options'
|
||||||
|
}, {
|
||||||
|
name: 'update_on_launch',
|
||||||
|
label: 'Update on Launch',
|
||||||
|
type: 'checkbox',
|
||||||
|
ngShow: "source.value !== 'manual' && source.value !== null",
|
||||||
|
addRequired: false,
|
||||||
|
editRequired: false,
|
||||||
|
awPopOver: '<p>Each time a job runs using this inventory, refresh the inventory from the selected source before ' +
|
||||||
|
'executing job tasks.</p>',
|
||||||
|
dataTitle: 'Update on Launch',
|
||||||
|
dataContainer: 'body',
|
||||||
|
dataPlacement: 'right',
|
||||||
|
labelClass: 'checkbox-options'
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
update_cache_timeout: {
|
||||||
|
label: "Cache Timeout <span class=\"small-text\"> (seconds)</span>",
|
||||||
|
id: 'source-cache-timeout',
|
||||||
|
type: 'number',
|
||||||
|
integer: true,
|
||||||
|
min: 0,
|
||||||
|
ngShow: "source && source.value !== 'manual' && update_on_launch",
|
||||||
|
spinner: true,
|
||||||
|
"default": 0,
|
||||||
|
addRequired: false,
|
||||||
|
editRequired: false,
|
||||||
|
awPopOver: '<p>Time in seconds to consider an inventory sync to be current. During job runs and callbacks the task system will ' +
|
||||||
|
'evaluate the timestamp of the latest sync. If it is older than Cache Timeout, it is not considered current, ' +
|
||||||
|
'and a new inventory sync will be performed.</p>',
|
||||||
|
dataTitle: 'Cache Timeout',
|
||||||
|
dataPlacement: 'right',
|
||||||
|
dataContainer: "body"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
buttons: { },
|
buttons: {
|
||||||
|
save: {
|
||||||
|
ngClick: 'saveGroup()'
|
||||||
|
},
|
||||||
|
cancel: {
|
||||||
|
ngClick: 'formCancel()'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
related: { }
|
related: {
|
||||||
|
"notifications": {
|
||||||
|
include: "NotificationsList"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
relatedSets: function() {
|
||||||
|
return {
|
||||||
|
notifications: {
|
||||||
|
iterator: 'notification',
|
||||||
|
url: 'api/v1/notifiers/'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
});
|
})
|
||||||
|
.factory('GroupForm', ['GroupFormObject', 'NotificationsList',
|
||||||
|
function(GroupFormObject, NotificationsList) {
|
||||||
|
return function() {
|
||||||
|
var itm;
|
||||||
|
|
||||||
|
for (itm in GroupFormObject.related) {
|
||||||
|
if (GroupFormObject.related[itm].include === "NotificationsList") {
|
||||||
|
GroupFormObject.related[itm] = NotificationsList;
|
||||||
|
GroupFormObject.related[itm].generateList = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GroupFormObject;
|
||||||
|
};
|
||||||
|
}]);
|
||||||
|
|||||||
@@ -351,7 +351,6 @@ export default
|
|||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
include: "NotificationsList"
|
include: "NotificationsList"
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1,268 +0,0 @@
|
|||||||
/*************************************************
|
|
||||||
* Copyright (c) 2015 Ansible, Inc.
|
|
||||||
*
|
|
||||||
* All Rights Reserved
|
|
||||||
*************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ngdoc function
|
|
||||||
* @name forms.function:Source
|
|
||||||
* @description This form is for group model
|
|
||||||
*/
|
|
||||||
|
|
||||||
export default
|
|
||||||
angular.module('SourceFormDefinition', [])
|
|
||||||
.value('SourceForm', {
|
|
||||||
|
|
||||||
addTitle: 'Create Source',
|
|
||||||
editTitle: 'Edit Source',
|
|
||||||
showTitle: false,
|
|
||||||
cancelButton: false,
|
|
||||||
name: 'source',
|
|
||||||
well: false,
|
|
||||||
|
|
||||||
fields: {
|
|
||||||
source: {
|
|
||||||
label: 'Source',
|
|
||||||
type: 'select',
|
|
||||||
ngOptions: 'source.label for source in source_type_options track by source.value',
|
|
||||||
ngChange: 'sourceChange()',
|
|
||||||
addRequired: false,
|
|
||||||
editRequired: false
|
|
||||||
},
|
|
||||||
source_path: {
|
|
||||||
label: 'Script Path',
|
|
||||||
ngShow: "source && source.value == 'file'",
|
|
||||||
type: 'text',
|
|
||||||
awRequiredWhen: {
|
|
||||||
reqExpression: "sourcePathRequired",
|
|
||||||
init: "false"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
credential: {
|
|
||||||
label: 'Cloud Credential',
|
|
||||||
type: 'lookup',
|
|
||||||
ngShow: "source && source.value !== 'manual' && source.value !== 'custom'",
|
|
||||||
sourceModel: 'credential',
|
|
||||||
sourceField: 'name',
|
|
||||||
ngClick: 'lookUpCredential()',
|
|
||||||
awRequiredWhen: {
|
|
||||||
reqExpression: "cloudCredentialRequired",
|
|
||||||
init: "false"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
source_regions: {
|
|
||||||
label: 'Regions',
|
|
||||||
type: 'select',
|
|
||||||
ngOptions: 'source.label for source in source_region_choices track by source.value',
|
|
||||||
multiSelect: true,
|
|
||||||
ngShow: "source && (source.value == 'rax' || source.value == 'ec2' || source.value == 'gce' || source.value == 'azure')",
|
|
||||||
addRequired: false,
|
|
||||||
editRequired: false,
|
|
||||||
dataTitle: 'Source Regions',
|
|
||||||
dataPlacement: 'right',
|
|
||||||
awPopOver: "<p>Click on the regions field to see a list of regions for your cloud provider. You can select multiple regions, " +
|
|
||||||
"or choose <em>All</em> to include all regions. Tower will only be updated with Hosts associated with the selected regions." +
|
|
||||||
"</p>",
|
|
||||||
dataContainer: 'body'
|
|
||||||
},
|
|
||||||
instance_filters: {
|
|
||||||
label: 'Instance Filters',
|
|
||||||
type: 'text',
|
|
||||||
ngShow: "source && source.value == 'ec2'",
|
|
||||||
addRequired: false,
|
|
||||||
editRequired: false,
|
|
||||||
dataTitle: 'Instance Filters',
|
|
||||||
dataPlacement: 'right',
|
|
||||||
awPopOver: "<p>Provide a comma-separated list of filter expressions. " +
|
|
||||||
"Hosts are imported to Tower when <em>ANY</em> of the filters match.</p>" +
|
|
||||||
"Limit to hosts having a tag:<br />\n" +
|
|
||||||
"<blockquote>tag-key=TowerManaged</blockquote>\n" +
|
|
||||||
"Limit to hosts using either key pair:<br />\n" +
|
|
||||||
"<blockquote>key-name=staging, key-name=production</blockquote>\n" +
|
|
||||||
"Limit to hosts where the Name tag begins with <em>test</em>:<br />\n" +
|
|
||||||
"<blockquote>tag:Name=test*</blockquote>\n" +
|
|
||||||
"<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'
|
|
||||||
},
|
|
||||||
group_by: {
|
|
||||||
label: 'Only Group By',
|
|
||||||
type: 'select',
|
|
||||||
ngShow: "source && source.value == 'ec2'",
|
|
||||||
ngOptions: 'source.label for source in group_by_choices track by source.value',
|
|
||||||
addRequired: false,
|
|
||||||
editRequired: false,
|
|
||||||
multiSelect: true,
|
|
||||||
dataTitle: 'Only Group By',
|
|
||||||
dataPlacement: 'right',
|
|
||||||
awPopOver: "<p>Select which groups to create automatically. " +
|
|
||||||
"Tower will create group names similar to the following examples based on the options selected:</p><ul>" +
|
|
||||||
"<li>Availability Zone: <strong>zones » us-east-1b</strong></li>" +
|
|
||||||
"<li>Image ID: <strong>images » ami-b007ab1e</strong></li>" +
|
|
||||||
"<li>Instance ID: <strong>instances » i-ca11ab1e</strong></li>" +
|
|
||||||
"<li>Instance Type: <strong>types » type_m1_medium</strong></li>" +
|
|
||||||
"<li>Key Name: <strong>keys » key_testing</strong></li>" +
|
|
||||||
"<li>Region: <strong>regions » us-east-1</strong></li>" +
|
|
||||||
"<li>Security Group: <strong>security_groups » security_group_default</strong></li>" +
|
|
||||||
"<li>Tags: <strong>tags » tag_Name » tag_Name_host1</strong></li>" +
|
|
||||||
"<li>VPC ID: <strong>vpcs » vpc-5ca1ab1e</strong></li>" +
|
|
||||||
"</ul><p>If blank, all groups above are created except <em>Instance ID</em>.</p>",
|
|
||||||
dataContainer: 'body'
|
|
||||||
},
|
|
||||||
inventory_script: {
|
|
||||||
label : "Custom Inventory Script",
|
|
||||||
labelClass: 'prepend-asterisk',
|
|
||||||
type: 'lookup',
|
|
||||||
ngShow: "source && source.value === 'custom'",
|
|
||||||
sourceModel: 'inventory_script',
|
|
||||||
sourceField: 'name',
|
|
||||||
ngClick: 'lookUpInventory_script()' ,
|
|
||||||
addRequired: true,
|
|
||||||
editRequired: true,
|
|
||||||
ngRequired: "source && source.value === 'custom'",
|
|
||||||
},
|
|
||||||
extra_vars: {
|
|
||||||
label: 'Environment Variables', //"{{vars_label}}" ,
|
|
||||||
ngShow: "source && source.value=='custom' ",
|
|
||||||
type: 'textarea',
|
|
||||||
class: 'Form-textAreaLabel',
|
|
||||||
addRequired: false,
|
|
||||||
editRequired: false,
|
|
||||||
rows: 6,
|
|
||||||
'default': '---',
|
|
||||||
parseTypeName: 'envParseType',
|
|
||||||
dataTitle: "Environment Variables",
|
|
||||||
dataPlacement: 'right',
|
|
||||||
awPopOver: "<p>Provide key/value pairs using either YAML or JSON.</p>" +
|
|
||||||
"JSON:<br />\n" +
|
|
||||||
"<blockquote>{<br />\"somevar\": \"somevalue\",<br />\"password\": \"magic\"<br /> }</blockquote>\n" +
|
|
||||||
"YAML:<br />\n" +
|
|
||||||
"<blockquote>---<br />somevar: somevalue<br />password: magic<br /></blockquote>\n",
|
|
||||||
dataContainer: 'body'
|
|
||||||
},
|
|
||||||
source_vars: {
|
|
||||||
label: 'Source Variables', //"{{vars_label}}" ,
|
|
||||||
ngShow: "source && (source.value == 'file' || source.value == 'ec2')",
|
|
||||||
type: 'textarea',
|
|
||||||
class: 'Form-textAreaLabel',
|
|
||||||
addRequired: false,
|
|
||||||
editRequird: false,
|
|
||||||
rows: 6,
|
|
||||||
'default': '---',
|
|
||||||
parseTypeName: 'envParseType',
|
|
||||||
dataTitle: "Source Variables",
|
|
||||||
dataPlacement: 'right',
|
|
||||||
awPopOver: "<p>Override variables found in ec2.ini and used by the inventory update script. For a detailed description of these variables " +
|
|
||||||
"<a href=\"https://github.com/ansible/ansible/blob/devel/contrib/inventory/ec2.ini\" target=\"_blank\">" +
|
|
||||||
"view ec2.ini in the Ansible github repo.</a></p>" +
|
|
||||||
"<p>Enter variables using either JSON or YAML syntax. Use the radio button to toggle between the two.</p>" +
|
|
||||||
"JSON:<br />\n" +
|
|
||||||
"<blockquote>{<br />\"somevar\": \"somevalue\",<br />\"password\": \"magic\"<br /> }</blockquote>\n" +
|
|
||||||
"YAML:<br />\n" +
|
|
||||||
"<blockquote>---<br />somevar: somevalue<br />password: magic<br /></blockquote>\n" +
|
|
||||||
'<p>View JSON examples at <a href="http://www.json.org" target="_blank">www.json.org</a></p>' +
|
|
||||||
'<p>View YAML examples at <a href="http://docs.ansible.com/YAMLSyntax.html" target="_blank">docs.ansible.com</a></p>',
|
|
||||||
dataContainer: 'body'
|
|
||||||
},
|
|
||||||
inventory_variables: {
|
|
||||||
label: 'Source Variables', //"{{vars_label}}" ,
|
|
||||||
|
|
||||||
ngShow: "source && (source.value == 'vmware' || " +
|
|
||||||
"source.value == 'openstack')",
|
|
||||||
type: 'textarea',
|
|
||||||
addRequired: false,
|
|
||||||
class: 'Form-textAreaLabel',
|
|
||||||
editRequird: false,
|
|
||||||
rows: 6,
|
|
||||||
'default': '---',
|
|
||||||
parseTypeName: 'envParseType',
|
|
||||||
dataTitle: "Source Variables",
|
|
||||||
dataPlacement: 'right',
|
|
||||||
awPopOver: "<p>Override variables found in vmware.ini and used by the inventory update script. For a detailed description of these variables " +
|
|
||||||
"<a href=\"https://github.com/ansible/ansible/blob/devel/contrib/inventory/vmware.ini\" target=\"_blank\">" +
|
|
||||||
"view vmware.ini in the Ansible github repo.</a></p>" +
|
|
||||||
"<p>Enter variables using either JSON or YAML syntax. Use the radio button to toggle between the two.</p>" +
|
|
||||||
"JSON:<br />\n" +
|
|
||||||
"<blockquote>{<br />\"somevar\": \"somevalue\",<br />\"password\": \"magic\"<br /> }</blockquote>\n" +
|
|
||||||
"YAML:<br />\n" +
|
|
||||||
"<blockquote>---<br />somevar: somevalue<br />password: magic<br /></blockquote>\n" +
|
|
||||||
'<p>View JSON examples at <a href="http://www.json.org" target="_blank">www.json.org</a></p>' +
|
|
||||||
'<p>View YAML examples at <a href="http://docs.ansible.com/YAMLSyntax.html" target="_blank">docs.ansible.com</a></p>',
|
|
||||||
dataContainer: 'body'
|
|
||||||
},
|
|
||||||
checkbox_group: {
|
|
||||||
label: 'Update Options',
|
|
||||||
type: 'checkbox_group',
|
|
||||||
ngShow: "source && (source.value !== 'manual' && source.value !== null)",
|
|
||||||
|
|
||||||
fields: [{
|
|
||||||
name: 'overwrite',
|
|
||||||
label: 'Overwrite',
|
|
||||||
type: 'checkbox',
|
|
||||||
ngShow: "source.value !== 'manual' && source.value !== null",
|
|
||||||
addRequired: false,
|
|
||||||
editRequired: false,
|
|
||||||
awPopOver: '<p>If checked, all child groups and hosts not found on the external source will be deleted from ' +
|
|
||||||
'the local inventory.</p><p>When not checked, local child hosts and groups not found on the external source will ' +
|
|
||||||
'remain untouched by the inventory update process.</p>',
|
|
||||||
dataTitle: 'Overwrite',
|
|
||||||
dataContainer: 'body',
|
|
||||||
dataPlacement: 'right',
|
|
||||||
labelClass: 'checkbox-options'
|
|
||||||
}, {
|
|
||||||
name: 'overwrite_vars',
|
|
||||||
label: 'Overwrite Variables',
|
|
||||||
type: 'checkbox',
|
|
||||||
ngShow: "source.value !== 'manual' && source.value !== null",
|
|
||||||
addRequired: false,
|
|
||||||
editRequired: false,
|
|
||||||
awPopOver: '<p>If checked, all variables for child groups and hosts will be removed and replaced by those ' +
|
|
||||||
'found on the external source.</p><p>When not checked, a merge will be performed, combining local variables with ' +
|
|
||||||
'those found on the external source.</p>',
|
|
||||||
dataTitle: 'Overwrite Variables',
|
|
||||||
dataContainer: 'body',
|
|
||||||
dataPlacement: 'right',
|
|
||||||
labelClass: 'checkbox-options'
|
|
||||||
}, {
|
|
||||||
name: 'update_on_launch',
|
|
||||||
label: 'Update on Launch',
|
|
||||||
type: 'checkbox',
|
|
||||||
ngShow: "source.value !== 'manual' && source.value !== null",
|
|
||||||
addRequired: false,
|
|
||||||
editRequired: false,
|
|
||||||
awPopOver: '<p>Each time a job runs using this inventory, refresh the inventory from the selected source before ' +
|
|
||||||
'executing job tasks.</p>',
|
|
||||||
dataTitle: 'Update on Launch',
|
|
||||||
dataContainer: 'body',
|
|
||||||
dataPlacement: 'right',
|
|
||||||
labelClass: 'checkbox-options'
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
update_cache_timeout: {
|
|
||||||
label: "Cache Timeout <span class=\"small-text\"> (seconds)</span>",
|
|
||||||
id: 'source-cache-timeout',
|
|
||||||
type: 'number',
|
|
||||||
integer: true,
|
|
||||||
min: 0,
|
|
||||||
ngShow: "source && source.value !== 'manual' && update_on_launch",
|
|
||||||
spinner: true,
|
|
||||||
"default": 0,
|
|
||||||
addRequired: false,
|
|
||||||
editRequired: false,
|
|
||||||
awPopOver: '<p>Time in seconds to consider an inventory sync to be current. During job runs and callbacks the task system will ' +
|
|
||||||
'evaluate the timestamp of the latest sync. If it is older than Cache Timeout, it is not considered current, ' +
|
|
||||||
'and a new inventory sync will be performed.</p>',
|
|
||||||
dataTitle: 'Cache Timeout',
|
|
||||||
dataPlacement: 'right',
|
|
||||||
dataContainer: "body"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
buttons: {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
related: { }
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -18,7 +18,7 @@ export default
|
|||||||
angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name, 'GroupListDefinition', 'SearchHelper',
|
angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name, 'GroupListDefinition', 'SearchHelper',
|
||||||
'PaginationHelpers', listGenerator.name, 'GroupsHelper', 'InventoryHelper', 'SelectionHelper',
|
'PaginationHelpers', listGenerator.name, 'GroupsHelper', 'InventoryHelper', 'SelectionHelper',
|
||||||
'JobSubmissionHelper', 'RefreshHelper', 'PromptDialog', 'CredentialsListDefinition', 'InventoryTree',
|
'JobSubmissionHelper', 'RefreshHelper', 'PromptDialog', 'CredentialsListDefinition', 'InventoryTree',
|
||||||
'InventoryStatusDefinition', 'VariablesHelper', 'SchedulesListDefinition', 'SourceFormDefinition', 'StandardOutHelper',
|
'InventoryStatusDefinition', 'VariablesHelper', 'SchedulesListDefinition', 'StandardOutHelper',
|
||||||
'SchedulesHelper'
|
'SchedulesHelper'
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -713,11 +713,11 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
|
|||||||
.factory('GroupsEdit', ['$filter', '$rootScope', '$location', '$log', '$stateParams', '$compile', 'Rest', 'Alert', 'GroupForm', 'GenerateForm',
|
.factory('GroupsEdit', ['$filter', '$rootScope', '$location', '$log', '$stateParams', '$compile', 'Rest', 'Alert', 'GroupForm', 'GenerateForm',
|
||||||
'Prompt', 'ProcessErrors', 'GetBasePath', 'SetNodeName', 'ParseTypeChange', 'GetSourceTypeOptions', 'InventoryUpdate',
|
'Prompt', 'ProcessErrors', 'GetBasePath', 'SetNodeName', 'ParseTypeChange', 'GetSourceTypeOptions', 'InventoryUpdate',
|
||||||
'LookUpInit', 'Empty', 'Wait', 'GetChoices', 'UpdateGroup', 'SourceChange', 'Find',
|
'LookUpInit', 'Empty', 'Wait', 'GetChoices', 'UpdateGroup', 'SourceChange', 'Find',
|
||||||
'ParseVariableString', 'ToJSON', 'GroupsScheduleListInit', 'SourceForm', 'SetSchedulesInnerDialogSize', 'CreateSelect2',
|
'ParseVariableString', 'ToJSON', 'GroupsScheduleListInit', 'SetSchedulesInnerDialogSize', 'CreateSelect2',
|
||||||
function ($filter, $rootScope, $location, $log, $stateParams, $compile, Rest, Alert, GroupForm, GenerateForm, Prompt, ProcessErrors,
|
function ($filter, $rootScope, $location, $log, $stateParams, $compile, Rest, Alert, GroupForm, GenerateForm, Prompt, ProcessErrors,
|
||||||
GetBasePath, SetNodeName, ParseTypeChange, GetSourceTypeOptions, InventoryUpdate, LookUpInit, Empty, Wait,
|
GetBasePath, SetNodeName, ParseTypeChange, GetSourceTypeOptions, InventoryUpdate, LookUpInit, Empty, Wait,
|
||||||
GetChoices, UpdateGroup, SourceChange, Find, ParseVariableString, ToJSON, GroupsScheduleListInit,
|
GetChoices, UpdateGroup, SourceChange, Find, ParseVariableString, ToJSON, GroupsScheduleListInit,
|
||||||
SourceForm, SetSchedulesInnerDialogSize, CreateSelect2) {
|
SetSchedulesInnerDialogSize, CreateSelect2) {
|
||||||
return function (params) {
|
return function (params) {
|
||||||
|
|
||||||
var parent_scope = params.scope,
|
var parent_scope = params.scope,
|
||||||
@@ -756,14 +756,14 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
|
|||||||
var form_scope =
|
var form_scope =
|
||||||
generator.inject(GroupForm, { mode: mode, id: 'properties-tab', related: false, scope: properties_scope });
|
generator.inject(GroupForm, { mode: mode, id: 'properties-tab', related: false, scope: properties_scope });
|
||||||
var source_form_scope =
|
var source_form_scope =
|
||||||
generator.inject(SourceForm, { mode: mode, id: 'sources-tab', related: false, scope: sources_scope });
|
generator.inject(GroupForm, { mode: mode, id: 'sources-tab', related: false, scope: sources_scope });
|
||||||
|
|
||||||
//generator.reset();
|
//generator.reset();
|
||||||
|
|
||||||
GetSourceTypeOptions({ scope: sources_scope, variable: 'source_type_options' });
|
GetSourceTypeOptions({ scope: sources_scope, variable: 'source_type_options' });
|
||||||
sources_scope.source = SourceForm.fields.source['default'];
|
sources_scope.source = GroupForm.fields.source['default'];
|
||||||
sources_scope.sourcePathRequired = false;
|
sources_scope.sourcePathRequired = false;
|
||||||
sources_scope[SourceForm.fields.source_vars.parseTypeName] = 'yaml';
|
sources_scope[GroupForm.fields.source_vars.parseTypeName] = 'yaml';
|
||||||
sources_scope.update_cache_timeout = 0;
|
sources_scope.update_cache_timeout = 0;
|
||||||
properties_scope.parseType = 'yaml';
|
properties_scope.parseType = 'yaml';
|
||||||
|
|
||||||
@@ -795,7 +795,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
|
|||||||
|
|
||||||
function initSourceChange() {
|
function initSourceChange() {
|
||||||
parent_scope.showSchedulesTab = (mode === 'edit' && sources_scope.source && sources_scope.source.value!=="manual") ? true : false;
|
parent_scope.showSchedulesTab = (mode === 'edit' && sources_scope.source && sources_scope.source.value!=="manual") ? true : false;
|
||||||
SourceChange({ scope: sources_scope, form: SourceForm });
|
SourceChange({ scope: sources_scope, form: GroupForm });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set modal dimensions based on viewport width
|
// Set modal dimensions based on viewport width
|
||||||
@@ -921,17 +921,17 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
|
|||||||
else if ($(e.target).text() === 'Source') {
|
else if ($(e.target).text() === 'Source') {
|
||||||
if (sources_scope.source && (sources_scope.source.value === 'ec2')) {
|
if (sources_scope.source && (sources_scope.source.value === 'ec2')) {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
ParseTypeChange({ scope: sources_scope, variable: 'source_vars', parse_variable: SourceForm.fields.source_vars.parseTypeName,
|
ParseTypeChange({ scope: sources_scope, variable: 'source_vars', parse_variable: GroupForm.fields.source_vars.parseTypeName,
|
||||||
field_id: 'source_source_vars', onReady: waitStop });
|
field_id: 'source_source_vars', onReady: waitStop });
|
||||||
} else if (sources_scope.source && (sources_scope.source.value === 'vmware' ||
|
} else if (sources_scope.source && (sources_scope.source.value === 'vmware' ||
|
||||||
sources_scope.source.value === 'openstack')) {
|
sources_scope.source.value === 'openstack')) {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
ParseTypeChange({ scope: sources_scope, variable: 'inventory_variables', parse_variable: SourceForm.fields.inventory_variables.parseTypeName,
|
ParseTypeChange({ scope: sources_scope, variable: 'inventory_variables', parse_variable: GroupForm.fields.inventory_variables.parseTypeName,
|
||||||
field_id: 'source_inventory_variables', onReady: waitStop });
|
field_id: 'source_inventory_variables', onReady: waitStop });
|
||||||
}
|
}
|
||||||
else if (sources_scope.source && (sources_scope.source.value === 'custom')) {
|
else if (sources_scope.source && (sources_scope.source.value === 'custom')) {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
ParseTypeChange({ scope: sources_scope, variable: 'extra_vars', parse_variable: SourceForm.fields.extra_vars.parseTypeName,
|
ParseTypeChange({ scope: sources_scope, variable: 'extra_vars', parse_variable: GroupForm.fields.extra_vars.parseTypeName,
|
||||||
field_id: 'source_extra_vars', onReady: waitStop });
|
field_id: 'source_extra_vars', onReady: waitStop });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -975,7 +975,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
|
|||||||
Rest.get()
|
Rest.get()
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
var fld, i, j, flag, found, set, opts, list, form;
|
var fld, i, j, flag, found, set, opts, list, form;
|
||||||
form = SourceForm;
|
form = GroupForm;
|
||||||
for (fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
if (fld === 'checkbox_group') {
|
if (fld === 'checkbox_group') {
|
||||||
for (i = 0; i < form.fields[fld].fields.length; i++) {
|
for (i = 0; i < form.fields[fld].fields.length; i++) {
|
||||||
@@ -1320,7 +1320,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
|
|||||||
})
|
})
|
||||||
.error(function (data, status) {
|
.error(function (data, status) {
|
||||||
$('#group_tabs a:eq(1)').tab('show');
|
$('#group_tabs a:eq(1)').tab('show');
|
||||||
ProcessErrors(sources_scope, data, status, SourceForm, { hdr: 'Error!',
|
ProcessErrors(sources_scope, data, status, GroupForm, { hdr: 'Error!',
|
||||||
msg: 'Failed to update group inventory source. PUT status: ' + status });
|
msg: 'Failed to update group inventory source. PUT status: ' + status });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,31 +4,27 @@
|
|||||||
* All Rights Reserved
|
* All Rights Reserved
|
||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $stateParams, $compile, $state, $scope, Rest, Alert, GroupForm, GenerateForm, Prompt, ProcessErrors,
|
function manageGroupsDirectiveController($filter, $location, $log,
|
||||||
GetBasePath, SetNodeName, ParseTypeChange, GetSourceTypeOptions, InventoryUpdate, LookUpInit, Empty, Wait,
|
$stateParams, $compile, $state, $scope, Rest, Alert, GroupForm,
|
||||||
GetChoices, UpdateGroup, SourceChange, Find, ParseVariableString, ToJSON, GroupsScheduleListInit,
|
GenerateForm, Prompt, ProcessErrors, GetBasePath, SetNodeName,
|
||||||
SourceForm, SetSchedulesInnerDialogSize, CreateSelect2, ParamPass) {
|
ParseTypeChange, GetSourceTypeOptions, InventoryUpdate, LookUpInit, Empty,
|
||||||
|
Wait, GetChoices, UpdateGroup, SourceChange, Find, ParseVariableString,
|
||||||
|
ToJSON, GroupsScheduleListInit, SetSchedulesInnerDialogSize,
|
||||||
|
CreateSelect2, ToggleNotification, NotificationsListInit,
|
||||||
|
RelatedSearchInit, RelatedPaginateInit) {
|
||||||
|
|
||||||
var vm = this;
|
var vm = this;
|
||||||
var params = ParamPass.get();
|
|
||||||
if(params === undefined) {
|
var group_id = $stateParams.group_id,
|
||||||
params = {};
|
mode = $state.current.data.mode,
|
||||||
params.scope = $scope.$new();
|
|
||||||
}
|
|
||||||
var parent_scope = params.scope,
|
|
||||||
group_id = $stateParams.group_id,
|
|
||||||
mode = $state.current.data.mode, // 'add' or 'edit'
|
|
||||||
inventory_id = $stateParams.inventory_id,
|
inventory_id = $stateParams.inventory_id,
|
||||||
generator = GenerateForm,
|
generator = GenerateForm,
|
||||||
group_created = false,
|
group_created = false,
|
||||||
defaultUrl,
|
defaultUrl,
|
||||||
master = {},
|
master = {},
|
||||||
choicesReady,
|
form = GroupForm(),
|
||||||
modal_scope = parent_scope.$new(),
|
relatedSets = {},
|
||||||
properties_scope = parent_scope.$new(),
|
choicesReady, group;
|
||||||
sources_scope = parent_scope.$new(),
|
|
||||||
elem, group,
|
|
||||||
schedules_url = '';
|
|
||||||
|
|
||||||
if (mode === 'edit') {
|
if (mode === 'edit') {
|
||||||
defaultUrl = GetBasePath('groups') + group_id + '/';
|
defaultUrl = GetBasePath('groups') + group_id + '/';
|
||||||
@@ -41,151 +37,152 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
Rest.get()
|
Rest.get()
|
||||||
.success(function(data) {
|
.success(function(data) {
|
||||||
group = data;
|
group = data;
|
||||||
for (var fld in GroupForm.fields) {
|
for (var fld in form.fields) {
|
||||||
if (data[fld]) {
|
if (data[fld]) {
|
||||||
properties_scope[fld] = data[fld];
|
$scope[fld] = data[fld];
|
||||||
master[fld] = properties_scope[fld];
|
master[fld] = $scope[fld];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(mode === 'edit') {
|
if(mode === 'edit') {
|
||||||
schedules_url = data.related.inventory_source + 'schedules/';
|
// schedules_url = data.related.inventory_source + 'schedules/';
|
||||||
properties_scope.variable_url = data.related.variable_data;
|
$scope.variable_url = data.related.variable_data;
|
||||||
sources_scope.source_url = data.related.inventory_source;
|
$scope.source_url = data.related.inventory_source;
|
||||||
modal_scope.$emit('LoadSourceData');
|
$scope.source_id = $scope.source_url.split('/')[4];
|
||||||
|
$scope.$emit('LoadSourceData');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.error(function(data, status) {
|
.error(function(data, status) {
|
||||||
ProcessErrors(modal_scope, data, status, {
|
ProcessErrors($scope, data, status, {
|
||||||
hdr: 'Error!',
|
hdr: 'Error!',
|
||||||
msg: 'Failed to retrieve group: ' + defaultUrl + '. GET status: ' + status
|
msg: 'Failed to retrieve group: ' + defaultUrl + '. GET status: ' + status
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$('#properties-tab').empty();
|
|
||||||
$('#sources-tab').empty();
|
|
||||||
|
|
||||||
elem = document.getElementById('group-manage-panel');
|
|
||||||
$compile(elem)(modal_scope);
|
|
||||||
|
|
||||||
$scope.parseType = 'yaml';
|
$scope.parseType = 'yaml';
|
||||||
|
|
||||||
var form_scope =
|
generator.inject(form, {
|
||||||
generator.inject(GroupForm, {
|
mode: mode,
|
||||||
mode: mode,
|
id: 'group-manage-panel',
|
||||||
id: 'properties-tab',
|
tabs: true,
|
||||||
related: false,
|
scope: $scope
|
||||||
scope: properties_scope,
|
});
|
||||||
cancelButton: false,
|
|
||||||
});
|
|
||||||
var source_form_scope =
|
|
||||||
generator.inject(SourceForm, {
|
|
||||||
mode: mode,
|
|
||||||
id: 'sources-tab',
|
|
||||||
related: false,
|
|
||||||
scope: sources_scope,
|
|
||||||
cancelButton: false
|
|
||||||
});
|
|
||||||
|
|
||||||
generator.reset();
|
generator.reset();
|
||||||
|
|
||||||
GetSourceTypeOptions({
|
GetSourceTypeOptions({
|
||||||
scope: sources_scope,
|
scope: $scope,
|
||||||
variable: 'source_type_options'
|
variable: 'source_type_options'
|
||||||
});
|
});
|
||||||
sources_scope.source = SourceForm.fields.source['default'];
|
|
||||||
sources_scope.sourcePathRequired = false;
|
|
||||||
sources_scope[SourceForm.fields.source_vars.parseTypeName] = 'yaml';
|
|
||||||
sources_scope.update_cache_timeout = 0;
|
|
||||||
properties_scope.parseType = 'yaml';
|
|
||||||
|
|
||||||
function waitStop() {
|
|
||||||
Wait('stop');
|
$scope.source = form.fields.source['default'];
|
||||||
}
|
$scope.sourcePathRequired = false;
|
||||||
|
$scope[form.fields.source_vars.parseTypeName] = 'yaml';
|
||||||
|
$scope.update_cache_timeout = 0;
|
||||||
|
$scope.parseType = 'yaml';
|
||||||
|
|
||||||
function initSourceChange() {
|
function initSourceChange() {
|
||||||
parent_scope.showSchedulesTab = (mode === 'edit' && sources_scope.source && sources_scope.source.value !== "manual") ? true : false;
|
$scope.showSchedulesTab = (mode === 'edit' && $scope.source && $scope.source.value !== "manual") ? true : false;
|
||||||
SourceChange({
|
SourceChange({
|
||||||
scope: sources_scope,
|
scope: $scope,
|
||||||
form: SourceForm
|
form: form
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// JT -- this gets called after the properties & properties variables are loaded, and is emitted from (groupLoaded)
|
// JT -- this gets called after the properties & properties variables are loaded, and is emitted from (groupLoaded)
|
||||||
if (modal_scope.removeLoadSourceData) {
|
if ($scope.removeLoadSourceData) {
|
||||||
modal_scope.removeLoadSourceData();
|
$scope.removeLoadSourceData();
|
||||||
}
|
}
|
||||||
modal_scope.removeLoadSourceData = modal_scope.$on('LoadSourceData', function() {
|
$scope.removeLoadSourceData = $scope.$on('LoadSourceData', function() {
|
||||||
ParseTypeChange({
|
ParseTypeChange({
|
||||||
scope: form_scope,
|
scope: $scope,
|
||||||
variable: 'variables',
|
variable: 'variables',
|
||||||
parse_variable: 'parseType',
|
parse_variable: 'parseType',
|
||||||
field_id: 'group_variables'
|
field_id: 'group_variables'
|
||||||
});
|
});
|
||||||
|
|
||||||
if (sources_scope.source_url) {
|
NotificationsListInit({
|
||||||
|
scope: $scope,
|
||||||
|
url: GetBasePath('inventory_sources'),
|
||||||
|
id: $scope.source_id
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($scope.source_url) {
|
||||||
// get source data
|
// get source data
|
||||||
Rest.setUrl(sources_scope.source_url);
|
Rest.setUrl($scope.source_url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success(function(data) {
|
.success(function(data) {
|
||||||
var fld, i, j, flag, found, set, opts, list, form;
|
var fld, i, j, flag, found, set, opts, list;
|
||||||
form = SourceForm;
|
|
||||||
for (fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
if (fld === 'checkbox_group') {
|
if (fld === 'checkbox_group') {
|
||||||
for (i = 0; i < form.fields[fld].fields.length; i++) {
|
for (i = 0; i < form.fields[fld].fields.length; i++) {
|
||||||
flag = form.fields[fld].fields[i];
|
flag = form.fields[fld].fields[i];
|
||||||
if (data[flag.name] !== undefined) {
|
if (data[flag.name] !== undefined) {
|
||||||
sources_scope[flag.name] = data[flag.name];
|
$scope[flag.name] = data[flag.name];
|
||||||
master[flag.name] = sources_scope[flag.name];
|
master[flag.name] = $scope[flag.name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fld === 'source') {
|
if (fld === 'source') {
|
||||||
found = false;
|
found = false;
|
||||||
data.source = (data.source === "") ? "manual" : data.source;
|
data.source = (data.source === "") ? "manual" : data.source;
|
||||||
for (i = 0; i < sources_scope.source_type_options.length; i++) {
|
for (i = 0; i < $scope.source_type_options.length; i++) {
|
||||||
if (sources_scope.source_type_options[i].value === data.source) {
|
if ($scope.source_type_options[i].value === data.source) {
|
||||||
sources_scope.source = sources_scope.source_type_options[i];
|
$scope.source = $scope.source_type_options[i];
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found || sources_scope.source.value === "manual") {
|
if (!found || $scope.source.value === "manual") {
|
||||||
sources_scope.groupUpdateHide = true;
|
$scope.groupUpdateHide = true;
|
||||||
} else {
|
} else {
|
||||||
sources_scope.groupUpdateHide = false;
|
$scope.groupUpdateHide = false;
|
||||||
}
|
}
|
||||||
master.source = sources_scope.source;
|
master.source = $scope.source;
|
||||||
} else if (fld === 'source_vars') {
|
} else if (fld === 'source_vars') {
|
||||||
// Parse source_vars, converting to YAML.
|
// Parse source_vars, converting to YAML.
|
||||||
sources_scope.source_vars = ParseVariableString(data.source_vars);
|
$scope.source_vars = ParseVariableString(data.source_vars);
|
||||||
master.source_vars = sources_scope.variables;
|
master.source_vars = $scope.variables;
|
||||||
} else if (fld === "inventory_script") {
|
} else if (fld === "inventory_script") {
|
||||||
// the API stores it as 'source_script', we call it inventory_script
|
// the API stores it as 'source_script', we call it inventory_script
|
||||||
data.summary_fields['inventory_script'] = data.summary_fields.source_script;
|
data.summary_fields['inventory_script'] = data.summary_fields.source_script;
|
||||||
sources_scope.inventory_script = data.source_script;
|
$scope.inventory_script = data.source_script;
|
||||||
master.inventory_script = sources_scope.inventory_script;
|
master.inventory_script = $scope.inventory_script;
|
||||||
} else if (fld === "source_regions") {
|
} else if (fld === "source_regions") {
|
||||||
if (data[fld] === "") {
|
if (data[fld] === "") {
|
||||||
sources_scope[fld] = data[fld];
|
$scope[fld] = data[fld];
|
||||||
master[fld] = sources_scope[fld];
|
master[fld] = $scope[fld];
|
||||||
} else {
|
} else {
|
||||||
sources_scope[fld] = data[fld].split(",");
|
$scope[fld] = data[fld].split(",");
|
||||||
master[fld] = sources_scope[fld];
|
master[fld] = $scope[fld];
|
||||||
}
|
}
|
||||||
} else if (data[fld] !== undefined) {
|
} else if (data[fld] !== undefined &&
|
||||||
sources_scope[fld] = data[fld];
|
fld !== "description" &&
|
||||||
master[fld] = sources_scope[fld];
|
fld !== "name" &&
|
||||||
|
fld !== "variables") {
|
||||||
|
$scope[fld] = data[fld];
|
||||||
|
master[fld] = $scope[fld];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (form.fields[fld].sourceModel && data.summary_fields &&
|
if (form.fields[fld].sourceModel && data.summary_fields &&
|
||||||
data.summary_fields[form.fields[fld].sourceModel]) {
|
data.summary_fields[form.fields[fld].sourceModel]) {
|
||||||
sources_scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
|
$scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
|
||||||
data.summary_fields[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] =
|
master[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
|
||||||
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
|
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
relatedSets = form.relatedSets(data.related);
|
||||||
|
RelatedSearchInit({
|
||||||
|
scope: $scope,
|
||||||
|
form: form,
|
||||||
|
relatedSets: relatedSets
|
||||||
|
});
|
||||||
|
|
||||||
|
RelatedPaginateInit({
|
||||||
|
scope: $scope,
|
||||||
|
relatedSets: relatedSets
|
||||||
|
});
|
||||||
initSourceChange();
|
initSourceChange();
|
||||||
|
|
||||||
if (data.source_regions) {
|
if (data.source_regions) {
|
||||||
@@ -194,13 +191,13 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
data.source === 'gce' ||
|
data.source === 'gce' ||
|
||||||
data.source === 'azure') {
|
data.source === 'azure') {
|
||||||
if (data.source === 'ec2') {
|
if (data.source === 'ec2') {
|
||||||
set = sources_scope.ec2_regions;
|
set = $scope.ec2_regions;
|
||||||
} else if (data.source === 'rax') {
|
} else if (data.source === 'rax') {
|
||||||
set = sources_scope.rax_regions;
|
set = $scope.rax_regions;
|
||||||
} else if (data.source === 'gce') {
|
} else if (data.source === 'gce') {
|
||||||
set = sources_scope.gce_regions;
|
set = $scope.gce_regions;
|
||||||
} else if (data.source === 'azure') {
|
} else if (data.source === 'azure') {
|
||||||
set = sources_scope.azure_regions;
|
set = $scope.azure_regions;
|
||||||
}
|
}
|
||||||
opts = [];
|
opts = [];
|
||||||
list = data.source_regions.split(',');
|
list = data.source_regions.split(',');
|
||||||
@@ -216,7 +213,7 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
}
|
}
|
||||||
master.source_regions = opts;
|
master.source_regions = opts;
|
||||||
CreateSelect2({
|
CreateSelect2({
|
||||||
element: "#source_source_regions",
|
element: "group_source_regions",
|
||||||
opts: opts
|
opts: opts
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -229,7 +226,7 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
if (data.group_by && data.source === 'ec2') {
|
if (data.group_by && data.source === 'ec2') {
|
||||||
set = sources_scope.ec2_group_by;
|
set = $scope.ec2_group_by;
|
||||||
opts = [];
|
opts = [];
|
||||||
list = data.group_by.split(',');
|
list = data.group_by.split(',');
|
||||||
for (i = 0; i < list.length; i++) {
|
for (i = 0; i < list.length; i++) {
|
||||||
@@ -249,11 +246,14 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sources_scope.group_update_url = data.related.update;
|
$scope.group_update_url = data.related.update;
|
||||||
|
for (set in relatedSets) {
|
||||||
|
$scope.search(relatedSets[set].iterator);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.error(function(data, status) {
|
.error(function(data, status) {
|
||||||
sources_scope.source = "";
|
$scope.source = "";
|
||||||
ProcessErrors(modal_scope, data, status, null, {
|
ProcessErrors($scope, data, status, null, {
|
||||||
hdr: 'Error!',
|
hdr: 'Error!',
|
||||||
msg: 'Failed to retrieve inventory source. GET status: ' + status
|
msg: 'Failed to retrieve inventory source. GET status: ' + status
|
||||||
});
|
});
|
||||||
@@ -261,44 +261,44 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (sources_scope.removeScopeSourceTypeOptionsReady) {
|
if ($scope.remove$scopeSourceTypeOptionsReady) {
|
||||||
sources_scope.removeScopeSourceTypeOptionsReady();
|
$scope.remove$scopeSourceTypeOptionsReady();
|
||||||
}
|
}
|
||||||
sources_scope.removeScopeSourceTypeOptionsReady = sources_scope.$on('sourceTypeOptionsReady', function() {
|
$scope.remove$scopeSourceTypeOptionsReady = $scope.$on('sourceTypeOptionsReady', function() {
|
||||||
if (mode === 'add') {
|
if (mode === 'add') {
|
||||||
sources_scope.source = Find({
|
$scope.source = Find({
|
||||||
list: sources_scope.source_type_options,
|
list: $scope.source_type_options,
|
||||||
key: 'value',
|
key: 'value',
|
||||||
val: ''
|
val: ''
|
||||||
});
|
});
|
||||||
modal_scope.showSchedulesTab = false;
|
$scope.showSchedulesTab = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
choicesReady = 0;
|
choicesReady = 0;
|
||||||
|
|
||||||
if (sources_scope.removeChoicesReady) {
|
if ($scope.removeChoicesReady) {
|
||||||
sources_scope.removeChoicesReady();
|
$scope.removeChoicesReady();
|
||||||
}
|
}
|
||||||
sources_scope.removeChoicesReady = sources_scope.$on('choicesReadyGroup', function() {
|
$scope.removeChoicesReady = $scope.$on('choicesReadyGroup', function() {
|
||||||
CreateSelect2({
|
CreateSelect2({
|
||||||
element: '#source_source',
|
element: '#group_source',
|
||||||
multiple: false
|
multiple: false
|
||||||
});
|
});
|
||||||
modal_scope.$emit('LoadSourceData');
|
$scope.$emit('LoadSourceData');
|
||||||
|
|
||||||
choicesReady++;
|
choicesReady++;
|
||||||
if (choicesReady === 5) {
|
if (choicesReady === 5) {
|
||||||
if (mode !== 'edit') {
|
if (mode !== 'edit') {
|
||||||
properties_scope.variables = "---";
|
$scope.variables = "---";
|
||||||
master.variables = properties_scope.variables;
|
master.variables = $scope.variables;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load options for source regions
|
// Load options for source regions
|
||||||
GetChoices({
|
GetChoices({
|
||||||
scope: sources_scope,
|
scope: $scope,
|
||||||
url: GetBasePath('inventory_sources'),
|
url: GetBasePath('inventory_sources'),
|
||||||
field: 'source_regions',
|
field: 'source_regions',
|
||||||
variable: 'rax_regions',
|
variable: 'rax_regions',
|
||||||
@@ -307,7 +307,7 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
});
|
});
|
||||||
|
|
||||||
GetChoices({
|
GetChoices({
|
||||||
scope: sources_scope,
|
scope: $scope,
|
||||||
url: GetBasePath('inventory_sources'),
|
url: GetBasePath('inventory_sources'),
|
||||||
field: 'source_regions',
|
field: 'source_regions',
|
||||||
variable: 'ec2_regions',
|
variable: 'ec2_regions',
|
||||||
@@ -316,7 +316,7 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
});
|
});
|
||||||
|
|
||||||
GetChoices({
|
GetChoices({
|
||||||
scope: sources_scope,
|
scope: $scope,
|
||||||
url: GetBasePath('inventory_sources'),
|
url: GetBasePath('inventory_sources'),
|
||||||
field: 'source_regions',
|
field: 'source_regions',
|
||||||
variable: 'gce_regions',
|
variable: 'gce_regions',
|
||||||
@@ -325,7 +325,7 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
});
|
});
|
||||||
|
|
||||||
GetChoices({
|
GetChoices({
|
||||||
scope: sources_scope,
|
scope: $scope,
|
||||||
url: GetBasePath('inventory_sources'),
|
url: GetBasePath('inventory_sources'),
|
||||||
field: 'source_regions',
|
field: 'source_regions',
|
||||||
variable: 'azure_regions',
|
variable: 'azure_regions',
|
||||||
@@ -335,7 +335,7 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
|
|
||||||
// Load options for group_by
|
// Load options for group_by
|
||||||
GetChoices({
|
GetChoices({
|
||||||
scope: sources_scope,
|
scope: $scope,
|
||||||
url: GetBasePath('inventory_sources'),
|
url: GetBasePath('inventory_sources'),
|
||||||
field: 'group_by',
|
field: 'group_by',
|
||||||
variable: 'ec2_group_by',
|
variable: 'ec2_group_by',
|
||||||
@@ -345,15 +345,15 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
|
|
||||||
//Wait('start');
|
//Wait('start');
|
||||||
|
|
||||||
if (parent_scope.removeAddTreeRefreshed) {
|
if ($scope.removeAddTreeRefreshed) {
|
||||||
parent_scope.removeAddTreeRefreshed();
|
$scope.removeAddTreeRefreshed();
|
||||||
}
|
}
|
||||||
parent_scope.removeAddTreeRefreshed = parent_scope.$on('GroupTreeRefreshed', function() {
|
$scope.removeAddTreeRefreshed = $scope.$on('GroupTreeRefreshed', function() {
|
||||||
// Clean up
|
// Clean up
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
|
|
||||||
if (modal_scope.searchCleanUp) {
|
if ($scope.searchCleanUp) {
|
||||||
modal_scope.searchCleanup();
|
$scope.searchCleanup();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
//$('#group-modal-dialog').dialog('close');
|
//$('#group-modal-dialog').dialog('close');
|
||||||
@@ -362,19 +362,19 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (modal_scope.removeSaveComplete) {
|
if ($scope.removeSaveComplete) {
|
||||||
modal_scope.removeSaveComplete();
|
$scope.removeSaveComplete();
|
||||||
}
|
}
|
||||||
modal_scope.removeSaveComplete = modal_scope.$on('SaveComplete', function(e, error) {
|
$scope.removeSaveComplete = $scope.$on('SaveComplete', function(e, error) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
modal_scope.cancelPanel();
|
$scope.formCancel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (modal_scope.removeFormSaveSuccess) {
|
if ($scope.removeFormSaveSuccess) {
|
||||||
modal_scope.removeFormSaveSuccess();
|
$scope.removeFormSaveSuccess();
|
||||||
}
|
}
|
||||||
modal_scope.removeFormSaveSuccess = modal_scope.$on('formSaveSuccess', function() {
|
$scope.removeFormSaveSuccess = $scope.$on('formSaveSuccess', function() {
|
||||||
|
|
||||||
// Source data gets stored separately from the group. Validate and store Source
|
// Source data gets stored separately from the group. Validate and store Source
|
||||||
// related fields, then call SaveComplete to wrap things up.
|
// related fields, then call SaveComplete to wrap things up.
|
||||||
@@ -384,19 +384,19 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
group_by,
|
group_by,
|
||||||
data = {
|
data = {
|
||||||
group: group_id,
|
group: group_id,
|
||||||
source: ((sources_scope.source && sources_scope.source.value !== 'manual') ? sources_scope.source.value : ''),
|
source: (($scope.source && $scope.source.value !== 'manual') ? $scope.source.value : ''),
|
||||||
source_path: sources_scope.source_path,
|
source_path: $scope.source_path,
|
||||||
credential: sources_scope.credential,
|
credential: $scope.credential,
|
||||||
overwrite: sources_scope.overwrite,
|
overwrite: $scope.overwrite,
|
||||||
overwrite_vars: sources_scope.overwrite_vars,
|
overwrite_vars: $scope.overwrite_vars,
|
||||||
source_script: sources_scope.inventory_script,
|
source_script: $scope.inventory_script,
|
||||||
update_on_launch: sources_scope.update_on_launch,
|
update_on_launch: $scope.update_on_launch,
|
||||||
update_cache_timeout: (sources_scope.update_cache_timeout || 0)
|
update_cache_timeout: ($scope.update_cache_timeout || 0)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create a string out of selected list of regions
|
// Create a string out of selected list of regions
|
||||||
if (sources_scope.source_regions) {
|
if ($scope.source_regions) {
|
||||||
regions = $('#source_source_regions').select2("data");
|
regions = $('#group_source_regions').select2("data");
|
||||||
r = [];
|
r = [];
|
||||||
for (i = 0; i < regions.length; i++) {
|
for (i = 0; i < regions.length; i++) {
|
||||||
r.push(regions[i].id);
|
r.push(regions[i].id);
|
||||||
@@ -404,8 +404,8 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
data.source_regions = r.join();
|
data.source_regions = r.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sources_scope.source && (sources_scope.source.value === 'ec2')) {
|
if ($scope.source && ($scope.source.value === 'ec2')) {
|
||||||
data.instance_filters = sources_scope.instance_filters;
|
data.instance_filters = $scope.instance_filters;
|
||||||
// Create a string out of selected list of regions
|
// Create a string out of selected list of regions
|
||||||
group_by = $('#source_group_by').select2("data");
|
group_by = $('#source_group_by').select2("data");
|
||||||
r = [];
|
r = [];
|
||||||
@@ -415,59 +415,75 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
data.group_by = r.join();
|
data.group_by = r.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sources_scope.source && (sources_scope.source.value === 'ec2')) {
|
if ($scope.source && ($scope.source.value === 'ec2')) {
|
||||||
// for ec2, validate variable data
|
// for ec2, validate variable data
|
||||||
data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.source_vars, true);
|
data.source_vars = ToJSON($scope.envParseType, $scope.source_vars, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sources_scope.source && (sources_scope.source.value === 'custom')) {
|
if ($scope.source && ($scope.source.value === 'custom')) {
|
||||||
data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.extra_vars, true);
|
data.source_vars = ToJSON($scope.envParseType, $scope.extra_vars, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sources_scope.source && (sources_scope.source.value === 'vmware' ||
|
if ($scope.source && ($scope.source.value === 'vmware' ||
|
||||||
sources_scope.source.value === 'openstack')) {
|
$scope.source.value === 'openstack')) {
|
||||||
data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.inventory_variables, true);
|
data.source_vars = ToJSON($scope.envParseType, $scope.inventory_variables, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the API doesn't expect the credential to be passed with a custom inv script
|
// the API doesn't expect the credential to be passed with a custom inv script
|
||||||
if (sources_scope.source && sources_scope.source.value === 'custom') {
|
if ($scope.source && $scope.source.value === 'custom') {
|
||||||
delete(data.credential);
|
delete(data.credential);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parseError) {
|
if (!parseError) {
|
||||||
Rest.setUrl(sources_scope.source_url);
|
Rest.setUrl($scope.source_url);
|
||||||
Rest.put(data)
|
Rest.put(data)
|
||||||
.success(function() {
|
.success(function() {
|
||||||
modal_scope.$emit('SaveComplete', false);
|
$scope.$emit('SaveComplete', false);
|
||||||
})
|
})
|
||||||
.error(function(data, status) {
|
.error(function(data, status) {
|
||||||
$('#group_tabs a:eq(1)').tab('show');
|
$('#group_tabs a:eq(1)').tab('show');
|
||||||
ProcessErrors(sources_scope, data, status, SourceForm, {
|
ProcessErrors($scope, data, status, form, {
|
||||||
hdr: 'Error!',
|
hdr: 'Error!',
|
||||||
msg: 'Failed to update group inventory source. PUT status: ' + status
|
msg: 'Failed to update group inventory source. PUT status: ' + status
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$scope.toggleNotification = function(event, notifier_id, column) {
|
||||||
|
var notifier = this.notification;
|
||||||
|
try {
|
||||||
|
$(event.target).tooltip('hide');
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
ToggleNotification({
|
||||||
|
scope: $scope,
|
||||||
|
url: GetBasePath('inventory_sources'),
|
||||||
|
id: $scope.source_id,
|
||||||
|
notifier: notifier,
|
||||||
|
column: column,
|
||||||
|
callback: 'NotificationRefresh'
|
||||||
|
});
|
||||||
|
};
|
||||||
// Cancel
|
// Cancel
|
||||||
modal_scope.cancelPanel = function() {
|
$scope.formCancel = function() {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$state.go('inventoryManage', {}, {reload: true});
|
$state.go('inventoryManage', {}, {reload: true});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
modal_scope.saveGroup = function() {
|
$scope.saveGroup = function() {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
var fld, data, json_data;
|
var fld, data, json_data;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
json_data = ToJSON(properties_scope.parseType, properties_scope.variables, true);
|
json_data = ToJSON($scope.parseType, $scope.variables, true);
|
||||||
|
|
||||||
data = {};
|
data = {};
|
||||||
for (fld in GroupForm.fields) {
|
for (fld in form.fields) {
|
||||||
data[fld] = properties_scope[fld];
|
data[fld] = $scope[fld];
|
||||||
}
|
}
|
||||||
|
|
||||||
data.inventory = inventory_id;
|
data.inventory = inventory_id;
|
||||||
@@ -476,11 +492,11 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
if (mode === 'edit' || (mode === 'add' && group_created)) {
|
if (mode === 'edit' || (mode === 'add' && group_created)) {
|
||||||
Rest.put(data)
|
Rest.put(data)
|
||||||
.success(function() {
|
.success(function() {
|
||||||
modal_scope.$emit('formSaveSuccess');
|
$scope.$emit('formSaveSuccess');
|
||||||
})
|
})
|
||||||
.error(function(data, status) {
|
.error(function(data, status) {
|
||||||
$('#group_tabs a:eq(0)').tab('show');
|
$('#group_tabs a:eq(0)').tab('show');
|
||||||
ProcessErrors(properties_scope, data, status, GroupForm, {
|
ProcessErrors($scope, data, status, form, {
|
||||||
hdr: 'Error!',
|
hdr: 'Error!',
|
||||||
msg: 'Failed to update group: ' + group_id + '. PUT status: ' + status
|
msg: 'Failed to update group: ' + group_id + '. PUT status: ' + status
|
||||||
});
|
});
|
||||||
@@ -490,12 +506,13 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
.success(function(data) {
|
.success(function(data) {
|
||||||
group_created = true;
|
group_created = true;
|
||||||
group_id = data.id;
|
group_id = data.id;
|
||||||
sources_scope.source_url = data.related.inventory_source;
|
$scope.source_url = data.related.inventory_source;
|
||||||
modal_scope.$emit('formSaveSuccess');
|
$scope.source_id = $scope.source_url.split('/')[4];
|
||||||
|
$scope.$emit('formSaveSuccess');
|
||||||
})
|
})
|
||||||
.error(function(data, status) {
|
.error(function(data, status) {
|
||||||
$('#group_tabs a:eq(0)').tab('show');
|
$('#group_tabs a:eq(0)').tab('show');
|
||||||
ProcessErrors(properties_scope, data, status, GroupForm, {
|
ProcessErrors($scope, data, status, form, {
|
||||||
hdr: 'Error!',
|
hdr: 'Error!',
|
||||||
msg: 'Failed to create group: ' + group_id + '. POST status: ' + status
|
msg: 'Failed to create group: ' + group_id + '. POST status: ' + status
|
||||||
});
|
});
|
||||||
@@ -507,44 +524,49 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Start the update process
|
// Start the update process
|
||||||
modal_scope.updateGroup = function() {
|
$scope.updateGroup = function() {
|
||||||
if (sources_scope.source === "manual" || sources_scope.source === null) {
|
if ($scope.source === "manual" || $scope.source === null) {
|
||||||
Alert('Missing Configuration', 'The selected group is not configured for updates. You must first edit the group, provide Source settings, ' +
|
Alert('Missing Configuration', 'The selected group is not configured for updates. You must first edit the group, provide Source settings, ' +
|
||||||
'and then run an update.', 'alert-info');
|
'and then run an update.', 'alert-info');
|
||||||
} else if (sources_scope.status === 'updating') {
|
} else if ($scope.status === 'updating') {
|
||||||
Alert('Update in Progress', 'The inventory update process is currently running for group <em>' +
|
Alert('Update in Progress', 'The inventory update process is currently running for group <em>' +
|
||||||
$filter('sanitize')(sources_scope.summary_fields.group.name) + '</em>. Use the Refresh button to monitor the status.', 'alert-info', null, null, null, null, true);
|
$filter('sanitize')($scope.summary_fields.group.name) + '</em>. Use the Refresh button to monitor the status.', 'alert-info', null, null, null, null, true);
|
||||||
} else {
|
} else {
|
||||||
InventoryUpdate({
|
InventoryUpdate({
|
||||||
scope: parent_scope,
|
scope: $scope,
|
||||||
group_id: group_id,
|
group_id: group_id,
|
||||||
url: properties_scope.group_update_url,
|
url: $scope.group_update_url,
|
||||||
group_name: properties_scope.name,
|
group_name: $scope.name,
|
||||||
group_source: sources_scope.source.value
|
group_source: $scope.source.value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Change the lookup and regions when the source changes
|
// Change the lookup and regions when the source changes
|
||||||
sources_scope.sourceChange = function() {
|
$scope.sourceChange = function() {
|
||||||
sources_scope.credential_name = "";
|
$scope.credential_name = "";
|
||||||
sources_scope.credential = "";
|
$scope.credential = "";
|
||||||
if (sources_scope.credential_name_api_error) {
|
if ($scope.credential_name_api_error) {
|
||||||
delete sources_scope.credential_name_api_error;
|
delete $scope.credential_name_api_error;
|
||||||
}
|
}
|
||||||
initSourceChange();
|
initSourceChange();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
angular.extend(vm, {
|
angular.extend(vm, {
|
||||||
cancelPanel : modal_scope.cancelPanel,
|
formCancel : $scope.formCancel,
|
||||||
saveGroup: modal_scope.saveGroup
|
saveGroup: $scope.saveGroup
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ['$filter', '$rootScope', '$location', '$log', '$stateParams', '$compile', '$state', '$scope', 'Rest', 'Alert', 'GroupForm', 'GenerateForm',
|
export default ['$filter', '$location', '$log', '$stateParams',
|
||||||
'Prompt', 'ProcessErrors', 'GetBasePath', 'SetNodeName', 'ParseTypeChange', 'GetSourceTypeOptions', 'InventoryUpdate',
|
'$compile', '$state', '$scope', 'Rest', 'Alert', 'GroupForm',
|
||||||
'LookUpInit', 'Empty', 'Wait', 'GetChoices', 'UpdateGroup', 'SourceChange', 'Find',
|
'GenerateForm','Prompt', 'ProcessErrors', 'GetBasePath', 'SetNodeName',
|
||||||
'ParseVariableString', 'ToJSON', 'GroupsScheduleListInit', 'SourceForm', 'SetSchedulesInnerDialogSize', 'CreateSelect2', 'ParamPass',
|
'ParseTypeChange', 'GetSourceTypeOptions', 'InventoryUpdate', 'LookUpInit',
|
||||||
|
'Empty', 'Wait', 'GetChoices', 'UpdateGroup', 'SourceChange', 'Find',
|
||||||
|
'ParseVariableString', 'ToJSON', 'GroupsScheduleListInit',
|
||||||
|
'SetSchedulesInnerDialogSize', 'CreateSelect2',
|
||||||
|
'ToggleNotification', 'NotificationsListInit', 'RelatedSearchInit',
|
||||||
|
'RelatedPaginateInit',
|
||||||
manageGroupsDirectiveController
|
manageGroupsDirectiveController
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,20 +1,5 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="Form-exitHolder">
|
|
||||||
<button class="Form-exit" ng-click="vm.cancelPanel()">
|
|
||||||
<i class="fa fa-times-circle"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div id="group-manage-panel">
|
<div id="group-manage-panel">
|
||||||
<div id="properties-tab"></div>
|
<div id="properties-tab"></div>
|
||||||
<div id="sources-tab"></div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix">
|
|
||||||
<div class="ui-dialog-buttonset">
|
|
||||||
<button type="button" class="btn btn-primary Form-saveButton" id="Inventory-groupManage--okButton" ng-click="vm.saveGroup()">
|
|
||||||
Save</button>
|
|
||||||
<button type="button" class="btn btn-default Form-cancelButton" id="Inventory-groupManage--cancelButton" ng-click="vm.cancelPanel()">
|
|
||||||
Cancel</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user