1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

Merge pull request #1641 from jaredevantabor/notifications

Adding notifications panel to inventory sources
This commit is contained in:
Jared Tabor 2016-04-22 10:49:54 -07:00
commit b5d0fb256f
7 changed files with 489 additions and 487 deletions

View File

@ -24,7 +24,6 @@ import LogViewerStatus from "./forms/LogViewerStatus";
import Organizations from "./forms/Organizations";
import ProjectStatus from "./forms/ProjectStatus";
import Projects from "./forms/Projects";
import Source from "./forms/Source";
import Teams from "./forms/Teams";
import Users from "./forms/Users";
@ -50,7 +49,6 @@ export
Organizations,
ProjectStatus,
Projects,
Source,
Teams,
Users
};

View File

@ -12,12 +12,11 @@
export default
angular.module('GroupFormDefinition', [])
.value('GroupForm', {
.value('GroupFormObject', {
addTitle: 'Create Group',
editTitle: 'Edit Group',
editTitle: '{{ name }}',
showTitle: true,
cancelButton: false,
name: 'group',
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>',
dataContainer: 'body',
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 &raquo; us-east-1b</strong></li>" +
"<li>Image ID: <strong>images &raquo; ami-b007ab1e</strong></li>" +
"<li>Instance ID: <strong>instances &raquo; i-ca11ab1e</strong></li>" +
"<li>Instance Type: <strong>types &raquo; type_m1_medium</strong></li>" +
"<li>Key Name: <strong>keys &raquo; key_testing</strong></li>" +
"<li>Region: <strong>regions &raquo; us-east-1</strong></li>" +
"<li>Security Group: <strong>security_groups &raquo; security_group_default</strong></li>" +
"<li>Tags: <strong>tags &raquo; tag_Name &raquo; tag_Name_host1</strong></li>" +
"<li>VPC ID: <strong>vpcs &raquo; 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;
};
}]);

View File

@ -351,7 +351,6 @@ export default
},
"notifications": {
include: "NotificationsList"
}
},

View File

@ -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 &raquo; us-east-1b</strong></li>" +
"<li>Image ID: <strong>images &raquo; ami-b007ab1e</strong></li>" +
"<li>Instance ID: <strong>instances &raquo; i-ca11ab1e</strong></li>" +
"<li>Instance Type: <strong>types &raquo; type_m1_medium</strong></li>" +
"<li>Key Name: <strong>keys &raquo; key_testing</strong></li>" +
"<li>Region: <strong>regions &raquo; us-east-1</strong></li>" +
"<li>Security Group: <strong>security_groups &raquo; security_group_default</strong></li>" +
"<li>Tags: <strong>tags &raquo; tag_Name &raquo; tag_Name_host1</strong></li>" +
"<li>VPC ID: <strong>vpcs &raquo; 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: { }
});

View File

@ -18,7 +18,7 @@ export default
angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name, 'GroupListDefinition', 'SearchHelper',
'PaginationHelpers', listGenerator.name, 'GroupsHelper', 'InventoryHelper', 'SelectionHelper',
'JobSubmissionHelper', 'RefreshHelper', 'PromptDialog', 'CredentialsListDefinition', 'InventoryTree',
'InventoryStatusDefinition', 'VariablesHelper', 'SchedulesListDefinition', 'SourceFormDefinition', 'StandardOutHelper',
'InventoryStatusDefinition', 'VariablesHelper', 'SchedulesListDefinition', 'StandardOutHelper',
'SchedulesHelper'
])
@ -713,11 +713,11 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
.factory('GroupsEdit', ['$filter', '$rootScope', '$location', '$log', '$stateParams', '$compile', 'Rest', 'Alert', 'GroupForm', 'GenerateForm',
'Prompt', 'ProcessErrors', 'GetBasePath', 'SetNodeName', 'ParseTypeChange', 'GetSourceTypeOptions', 'InventoryUpdate',
'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,
GetBasePath, SetNodeName, ParseTypeChange, GetSourceTypeOptions, InventoryUpdate, LookUpInit, Empty, Wait,
GetChoices, UpdateGroup, SourceChange, Find, ParseVariableString, ToJSON, GroupsScheduleListInit,
SourceForm, SetSchedulesInnerDialogSize, CreateSelect2) {
SetSchedulesInnerDialogSize, CreateSelect2) {
return function (params) {
var parent_scope = params.scope,
@ -756,14 +756,14 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
var form_scope =
generator.inject(GroupForm, { mode: mode, id: 'properties-tab', related: false, scope: properties_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();
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[SourceForm.fields.source_vars.parseTypeName] = 'yaml';
sources_scope[GroupForm.fields.source_vars.parseTypeName] = 'yaml';
sources_scope.update_cache_timeout = 0;
properties_scope.parseType = 'yaml';
@ -795,7 +795,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
function initSourceChange() {
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
@ -921,17 +921,17 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
else if ($(e.target).text() === 'Source') {
if (sources_scope.source && (sources_scope.source.value === 'ec2')) {
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 });
} else if (sources_scope.source && (sources_scope.source.value === 'vmware' ||
sources_scope.source.value === 'openstack')) {
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 });
}
else if (sources_scope.source && (sources_scope.source.value === 'custom')) {
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 });
}
}
@ -975,7 +975,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
Rest.get()
.success(function (data) {
var fld, i, j, flag, found, set, opts, list, form;
form = SourceForm;
form = GroupForm;
for (fld in form.fields) {
if (fld === 'checkbox_group') {
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) {
$('#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 });
});
}

View File

@ -4,31 +4,27 @@
* All Rights Reserved
*************************************************/
function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $stateParams, $compile, $state, $scope, Rest, Alert, GroupForm, GenerateForm, Prompt, ProcessErrors,
GetBasePath, SetNodeName, ParseTypeChange, GetSourceTypeOptions, InventoryUpdate, LookUpInit, Empty, Wait,
GetChoices, UpdateGroup, SourceChange, Find, ParseVariableString, ToJSON, GroupsScheduleListInit,
SourceForm, SetSchedulesInnerDialogSize, CreateSelect2, ParamPass) {
function manageGroupsDirectiveController($filter, $location, $log,
$stateParams, $compile, $state, $scope, Rest, Alert, GroupForm,
GenerateForm, Prompt, ProcessErrors, GetBasePath, SetNodeName,
ParseTypeChange, GetSourceTypeOptions, InventoryUpdate, LookUpInit, Empty,
Wait, GetChoices, UpdateGroup, SourceChange, Find, ParseVariableString,
ToJSON, GroupsScheduleListInit, SetSchedulesInnerDialogSize,
CreateSelect2, ToggleNotification, NotificationsListInit,
RelatedSearchInit, RelatedPaginateInit) {
var vm = this;
var params = ParamPass.get();
if(params === undefined) {
params = {};
params.scope = $scope.$new();
}
var parent_scope = params.scope,
group_id = $stateParams.group_id,
mode = $state.current.data.mode, // 'add' or 'edit'
var group_id = $stateParams.group_id,
mode = $state.current.data.mode,
inventory_id = $stateParams.inventory_id,
generator = GenerateForm,
group_created = false,
defaultUrl,
master = {},
choicesReady,
modal_scope = parent_scope.$new(),
properties_scope = parent_scope.$new(),
sources_scope = parent_scope.$new(),
elem, group,
schedules_url = '';
form = GroupForm(),
relatedSets = {},
choicesReady, group;
if (mode === 'edit') {
defaultUrl = GetBasePath('groups') + group_id + '/';
@ -41,151 +37,151 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
Rest.get()
.success(function(data) {
group = data;
for (var fld in GroupForm.fields) {
$scope.source_id = data.related.inventory_source.split('/')[4];
for (var fld in form.fields) {
if (data[fld]) {
properties_scope[fld] = data[fld];
master[fld] = properties_scope[fld];
$scope[fld] = data[fld];
master[fld] = $scope[fld];
}
}
if(mode === 'edit') {
schedules_url = data.related.inventory_source + 'schedules/';
properties_scope.variable_url = data.related.variable_data;
sources_scope.source_url = data.related.inventory_source;
modal_scope.$emit('LoadSourceData');
$scope.variable_url = data.related.variable_data;
$scope.source_url = data.related.inventory_source;
$scope.$emit('LoadSourceData');
}
})
.error(function(data, status) {
ProcessErrors(modal_scope, data, status, {
ProcessErrors($scope, data, status, {
hdr: 'Error!',
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';
var form_scope =
generator.inject(GroupForm, {
mode: mode,
id: 'properties-tab',
related: false,
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.inject(form, {
mode: mode,
id: 'group-manage-panel',
tabs: true,
scope: $scope
});
generator.reset();
GetSourceTypeOptions({
scope: sources_scope,
scope: $scope,
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() {
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({
scope: sources_scope,
form: SourceForm
scope: $scope,
form: form
});
}
// JT -- this gets called after the properties & properties variables are loaded, and is emitted from (groupLoaded)
if (modal_scope.removeLoadSourceData) {
modal_scope.removeLoadSourceData();
if ($scope.removeLoadSourceData) {
$scope.removeLoadSourceData();
}
modal_scope.removeLoadSourceData = modal_scope.$on('LoadSourceData', function() {
$scope.removeLoadSourceData = $scope.$on('LoadSourceData', function() {
ParseTypeChange({
scope: form_scope,
scope: $scope,
variable: 'variables',
parse_variable: 'parseType',
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
Rest.setUrl(sources_scope.source_url);
Rest.setUrl($scope.source_url);
Rest.get()
.success(function(data) {
var fld, i, j, flag, found, set, opts, list, form;
form = SourceForm;
var fld, i, j, flag, found, set, opts, list;
for (fld in form.fields) {
if (fld === 'checkbox_group') {
for (i = 0; i < form.fields[fld].fields.length; i++) {
flag = form.fields[fld].fields[i];
if (data[flag.name] !== undefined) {
sources_scope[flag.name] = data[flag.name];
master[flag.name] = sources_scope[flag.name];
$scope[flag.name] = data[flag.name];
master[flag.name] = $scope[flag.name];
}
}
}
if (fld === 'source') {
found = false;
data.source = (data.source === "") ? "manual" : data.source;
for (i = 0; i < sources_scope.source_type_options.length; i++) {
if (sources_scope.source_type_options[i].value === data.source) {
sources_scope.source = sources_scope.source_type_options[i];
for (i = 0; i < $scope.source_type_options.length; i++) {
if ($scope.source_type_options[i].value === data.source) {
$scope.source = $scope.source_type_options[i];
found = true;
}
}
if (!found || sources_scope.source.value === "manual") {
sources_scope.groupUpdateHide = true;
if (!found || $scope.source.value === "manual") {
$scope.groupUpdateHide = true;
} else {
sources_scope.groupUpdateHide = false;
$scope.groupUpdateHide = false;
}
master.source = sources_scope.source;
master.source = $scope.source;
} else if (fld === 'source_vars') {
// Parse source_vars, converting to YAML.
sources_scope.source_vars = ParseVariableString(data.source_vars);
master.source_vars = sources_scope.variables;
$scope.source_vars = ParseVariableString(data.source_vars);
master.source_vars = $scope.variables;
} else if (fld === "inventory_script") {
// the API stores it as 'source_script', we call it inventory_script
data.summary_fields['inventory_script'] = data.summary_fields.source_script;
sources_scope.inventory_script = data.source_script;
master.inventory_script = sources_scope.inventory_script;
$scope.inventory_script = data.source_script;
master.inventory_script = $scope.inventory_script;
} else if (fld === "source_regions") {
if (data[fld] === "") {
sources_scope[fld] = data[fld];
master[fld] = sources_scope[fld];
$scope[fld] = data[fld];
master[fld] = $scope[fld];
} else {
sources_scope[fld] = data[fld].split(",");
master[fld] = sources_scope[fld];
$scope[fld] = data[fld].split(",");
master[fld] = $scope[fld];
}
} else if (data[fld] !== undefined) {
sources_scope[fld] = data[fld];
master[fld] = sources_scope[fld];
} else if (data[fld] !== undefined &&
fld !== "description" &&
fld !== "name" &&
fld !== "variables") {
$scope[fld] = data[fld];
master[fld] = $scope[fld];
}
if (form.fields[fld].sourceModel && data.summary_fields &&
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];
master[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();
if (data.source_regions) {
@ -194,13 +190,13 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
data.source === 'gce' ||
data.source === 'azure') {
if (data.source === 'ec2') {
set = sources_scope.ec2_regions;
set = $scope.ec2_regions;
} else if (data.source === 'rax') {
set = sources_scope.rax_regions;
set = $scope.rax_regions;
} else if (data.source === 'gce') {
set = sources_scope.gce_regions;
set = $scope.gce_regions;
} else if (data.source === 'azure') {
set = sources_scope.azure_regions;
set = $scope.azure_regions;
}
opts = [];
list = data.source_regions.split(',');
@ -216,7 +212,7 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
}
master.source_regions = opts;
CreateSelect2({
element: "#source_source_regions",
element: "group_source_regions",
opts: opts
});
@ -229,7 +225,7 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
}];
}
if (data.group_by && data.source === 'ec2') {
set = sources_scope.ec2_group_by;
set = $scope.ec2_group_by;
opts = [];
list = data.group_by.split(',');
for (i = 0; i < list.length; i++) {
@ -249,11 +245,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) {
sources_scope.source = "";
ProcessErrors(modal_scope, data, status, null, {
$scope.source = "";
ProcessErrors($scope, data, status, null, {
hdr: 'Error!',
msg: 'Failed to retrieve inventory source. GET status: ' + status
});
@ -261,44 +260,44 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
}
});
if (sources_scope.removeScopeSourceTypeOptionsReady) {
sources_scope.removeScopeSourceTypeOptionsReady();
if ($scope.remove$scopeSourceTypeOptionsReady) {
$scope.remove$scopeSourceTypeOptionsReady();
}
sources_scope.removeScopeSourceTypeOptionsReady = sources_scope.$on('sourceTypeOptionsReady', function() {
$scope.remove$scopeSourceTypeOptionsReady = $scope.$on('sourceTypeOptionsReady', function() {
if (mode === 'add') {
sources_scope.source = Find({
list: sources_scope.source_type_options,
$scope.source = Find({
list: $scope.source_type_options,
key: 'value',
val: ''
});
modal_scope.showSchedulesTab = false;
$scope.showSchedulesTab = false;
}
});
choicesReady = 0;
if (sources_scope.removeChoicesReady) {
sources_scope.removeChoicesReady();
if ($scope.removeChoicesReady) {
$scope.removeChoicesReady();
}
sources_scope.removeChoicesReady = sources_scope.$on('choicesReadyGroup', function() {
$scope.removeChoicesReady = $scope.$on('choicesReadyGroup', function() {
CreateSelect2({
element: '#source_source',
element: '#group_source',
multiple: false
});
modal_scope.$emit('LoadSourceData');
$scope.$emit('LoadSourceData');
choicesReady++;
if (choicesReady === 5) {
if (mode !== 'edit') {
properties_scope.variables = "---";
master.variables = properties_scope.variables;
$scope.variables = "---";
master.variables = $scope.variables;
}
}
});
// Load options for source regions
GetChoices({
scope: sources_scope,
scope: $scope,
url: GetBasePath('inventory_sources'),
field: 'source_regions',
variable: 'rax_regions',
@ -307,7 +306,7 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
});
GetChoices({
scope: sources_scope,
scope: $scope,
url: GetBasePath('inventory_sources'),
field: 'source_regions',
variable: 'ec2_regions',
@ -316,7 +315,7 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
});
GetChoices({
scope: sources_scope,
scope: $scope,
url: GetBasePath('inventory_sources'),
field: 'source_regions',
variable: 'gce_regions',
@ -325,7 +324,7 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
});
GetChoices({
scope: sources_scope,
scope: $scope,
url: GetBasePath('inventory_sources'),
field: 'source_regions',
variable: 'azure_regions',
@ -335,7 +334,7 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
// Load options for group_by
GetChoices({
scope: sources_scope,
scope: $scope,
url: GetBasePath('inventory_sources'),
field: 'group_by',
variable: 'ec2_group_by',
@ -345,15 +344,15 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
//Wait('start');
if (parent_scope.removeAddTreeRefreshed) {
parent_scope.removeAddTreeRefreshed();
if ($scope.removeAddTreeRefreshed) {
$scope.removeAddTreeRefreshed();
}
parent_scope.removeAddTreeRefreshed = parent_scope.$on('GroupTreeRefreshed', function() {
$scope.removeAddTreeRefreshed = $scope.$on('GroupTreeRefreshed', function() {
// Clean up
Wait('stop');
if (modal_scope.searchCleanUp) {
modal_scope.searchCleanup();
if ($scope.searchCleanUp) {
$scope.searchCleanup();
}
try {
//$('#group-modal-dialog').dialog('close');
@ -362,19 +361,19 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
}
});
if (modal_scope.removeSaveComplete) {
modal_scope.removeSaveComplete();
if ($scope.removeSaveComplete) {
$scope.removeSaveComplete();
}
modal_scope.removeSaveComplete = modal_scope.$on('SaveComplete', function(e, error) {
$scope.removeSaveComplete = $scope.$on('SaveComplete', function(e, error) {
if (!error) {
modal_scope.cancelPanel();
$scope.formCancel();
}
});
if (modal_scope.removeFormSaveSuccess) {
modal_scope.removeFormSaveSuccess();
if ($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
// related fields, then call SaveComplete to wrap things up.
@ -384,19 +383,19 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
group_by,
data = {
group: group_id,
source: ((sources_scope.source && sources_scope.source.value !== 'manual') ? sources_scope.source.value : ''),
source_path: sources_scope.source_path,
credential: sources_scope.credential,
overwrite: sources_scope.overwrite,
overwrite_vars: sources_scope.overwrite_vars,
source_script: sources_scope.inventory_script,
update_on_launch: sources_scope.update_on_launch,
update_cache_timeout: (sources_scope.update_cache_timeout || 0)
source: (($scope.source && $scope.source.value !== 'manual') ? $scope.source.value : ''),
source_path: $scope.source_path,
credential: $scope.credential,
overwrite: $scope.overwrite,
overwrite_vars: $scope.overwrite_vars,
source_script: $scope.inventory_script,
update_on_launch: $scope.update_on_launch,
update_cache_timeout: ($scope.update_cache_timeout || 0)
};
// Create a string out of selected list of regions
if (sources_scope.source_regions) {
regions = $('#source_source_regions').select2("data");
if ($scope.source_regions) {
regions = $('#group_source_regions').select2("data");
r = [];
for (i = 0; i < regions.length; i++) {
r.push(regions[i].id);
@ -404,8 +403,8 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
data.source_regions = r.join();
}
if (sources_scope.source && (sources_scope.source.value === 'ec2')) {
data.instance_filters = sources_scope.instance_filters;
if ($scope.source && ($scope.source.value === 'ec2')) {
data.instance_filters = $scope.instance_filters;
// Create a string out of selected list of regions
group_by = $('#source_group_by').select2("data");
r = [];
@ -415,59 +414,75 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
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
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')) {
data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.extra_vars, true);
if ($scope.source && ($scope.source.value === 'custom')) {
data.source_vars = ToJSON($scope.envParseType, $scope.extra_vars, true);
}
if (sources_scope.source && (sources_scope.source.value === 'vmware' ||
sources_scope.source.value === 'openstack')) {
data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.inventory_variables, true);
if ($scope.source && ($scope.source.value === 'vmware' ||
$scope.source.value === 'openstack')) {
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
if (sources_scope.source && sources_scope.source.value === 'custom') {
if ($scope.source && $scope.source.value === 'custom') {
delete(data.credential);
}
if (!parseError) {
Rest.setUrl(sources_scope.source_url);
Rest.setUrl($scope.source_url);
Rest.put(data)
.success(function() {
modal_scope.$emit('SaveComplete', false);
$scope.$emit('SaveComplete', false);
})
.error(function(data, status) {
$('#group_tabs a:eq(1)').tab('show');
ProcessErrors(sources_scope, data, status, SourceForm, {
ProcessErrors($scope, data, status, form, {
hdr: 'Error!',
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
modal_scope.cancelPanel = function() {
$scope.formCancel = function() {
Wait('stop');
$state.go('inventoryManage', {}, {reload: true});
};
// Save
modal_scope.saveGroup = function() {
$scope.saveGroup = function() {
Wait('start');
var fld, data, json_data;
try {
json_data = ToJSON(properties_scope.parseType, properties_scope.variables, true);
json_data = ToJSON($scope.parseType, $scope.variables, true);
data = {};
for (fld in GroupForm.fields) {
data[fld] = properties_scope[fld];
for (fld in form.fields) {
data[fld] = $scope[fld];
}
data.inventory = inventory_id;
@ -476,11 +491,11 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
if (mode === 'edit' || (mode === 'add' && group_created)) {
Rest.put(data)
.success(function() {
modal_scope.$emit('formSaveSuccess');
$scope.$emit('formSaveSuccess');
})
.error(function(data, status) {
$('#group_tabs a:eq(0)').tab('show');
ProcessErrors(properties_scope, data, status, GroupForm, {
ProcessErrors($scope, data, status, form, {
hdr: 'Error!',
msg: 'Failed to update group: ' + group_id + '. PUT status: ' + status
});
@ -490,12 +505,13 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
.success(function(data) {
group_created = true;
group_id = data.id;
sources_scope.source_url = data.related.inventory_source;
modal_scope.$emit('formSaveSuccess');
$scope.source_url = data.related.inventory_source;
$scope.source_id = $scope.source_url.split('/')[4];
$scope.$emit('formSaveSuccess');
})
.error(function(data, status) {
$('#group_tabs a:eq(0)').tab('show');
ProcessErrors(properties_scope, data, status, GroupForm, {
ProcessErrors($scope, data, status, form, {
hdr: 'Error!',
msg: 'Failed to create group: ' + group_id + '. POST status: ' + status
});
@ -507,44 +523,49 @@ function manageGroupsDirectiveController($filter, $rootScope, $location, $log, $
};
// Start the update process
modal_scope.updateGroup = function() {
if (sources_scope.source === "manual" || sources_scope.source === null) {
$scope.updateGroup = function() {
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, ' +
'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>' +
$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 {
InventoryUpdate({
scope: parent_scope,
scope: $scope,
group_id: group_id,
url: properties_scope.group_update_url,
group_name: properties_scope.name,
group_source: sources_scope.source.value
url: $scope.group_update_url,
group_name: $scope.name,
group_source: $scope.source.value
});
}
};
// Change the lookup and regions when the source changes
sources_scope.sourceChange = function() {
sources_scope.credential_name = "";
sources_scope.credential = "";
if (sources_scope.credential_name_api_error) {
delete sources_scope.credential_name_api_error;
$scope.sourceChange = function() {
$scope.credential_name = "";
$scope.credential = "";
if ($scope.credential_name_api_error) {
delete $scope.credential_name_api_error;
}
initSourceChange();
};
angular.extend(vm, {
cancelPanel : modal_scope.cancelPanel,
saveGroup: modal_scope.saveGroup
formCancel : $scope.formCancel,
saveGroup: $scope.saveGroup
});
}
export default ['$filter', '$rootScope', '$location', '$log', '$stateParams', '$compile', '$state', '$scope', 'Rest', 'Alert', 'GroupForm', 'GenerateForm',
'Prompt', 'ProcessErrors', 'GetBasePath', 'SetNodeName', 'ParseTypeChange', 'GetSourceTypeOptions', 'InventoryUpdate',
'LookUpInit', 'Empty', 'Wait', 'GetChoices', 'UpdateGroup', 'SourceChange', 'Find',
'ParseVariableString', 'ToJSON', 'GroupsScheduleListInit', 'SourceForm', 'SetSchedulesInnerDialogSize', 'CreateSelect2', 'ParamPass',
export default ['$filter', '$location', '$log', '$stateParams',
'$compile', '$state', '$scope', 'Rest', 'Alert', 'GroupForm',
'GenerateForm','Prompt', 'ProcessErrors', 'GetBasePath', 'SetNodeName',
'ParseTypeChange', 'GetSourceTypeOptions', 'InventoryUpdate', 'LookUpInit',
'Empty', 'Wait', 'GetChoices', 'UpdateGroup', 'SourceChange', 'Find',
'ParseVariableString', 'ToJSON', 'GroupsScheduleListInit',
'SetSchedulesInnerDialogSize', 'CreateSelect2',
'ToggleNotification', 'NotificationsListInit', 'RelatedSearchInit',
'RelatedPaginateInit',
manageGroupsDirectiveController
];

View File

@ -1,20 +1,5 @@
<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="properties-tab"></div>
<div id="sources-tab"></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 id="properties-tab"></div>
</div>
</div>