Added some changes to fields in the source form.
This commit is contained in:
Jared Tabor 2014-11-21 13:44:03 -05:00
parent ee0e549978
commit ee3c838d74
6 changed files with 106 additions and 34 deletions

View File

@ -75,7 +75,7 @@ angular.module('SourceFormDefinition', [])
dataContainer: 'body'
},
group_by: {
label: 'Group By',
label: 'Only Group By',
type: 'text',
ngShow: "source && source.value == 'ec2'",
addRequired: false,
@ -83,40 +83,54 @@ angular.module('SourceFormDefinition', [])
awMultiselect: 'group_by_choices',
dataTitle: 'Group By',
dataPlacement: 'right',
awPopOver: "<p>FIXME: Create these automatic groups by default.</p>",
awPopOver: "<p>FIXME: Create these automatic groups by default. give examples</p>",
dataContainer: 'body'
},
group_tag_filters: {
label: 'Tag Filters',
type: 'text',
ngShow: "source && source.value == 'ec2' && group_by.value.indexOf('tag_keys') >= 0", // FIXME: Not sure what's needed to make the last expression work.
addRequired: false,
editRequired: false,
dataTitle: 'Tag Filters',
dataPlacement: 'right',
awPopOver: "<p>FIXME: When grouping by tags, specify which tag keys become groups.</p>",
dataContainer: 'body'
},
custom_script: {
// group_tag_filters: {
// label: 'Tag Filters',
// type: 'text',
// ngShow: "source && source.value == 'ec2' && group_by.value.indexOf('tag_keys') >= 0", // FIXME: Not sure what's needed to make the last expression work.
// addRequired: false,
// editRequired: false,
// dataTitle: 'Tag Filters',
// dataPlacement: 'right',
// awPopOver: "<p>FIXME: When grouping by tags, specify which tag keys become groups.</p>",
// dataContainer: 'body'
// },
source_script: {
label : "Custom Inventory Scripts",
type: 'lookup',
ngShow: "source && source.value !== '' && source.value === 'custom'",
sourceModel: 'custom_script',
sourceModel: 'source_script',
sourceField: 'name',
ngClick: 'lookUpCustomScript()',
ngClick: 'lookUpCustom_inventory()',
addRequired: false,
editRequired: false
},
source_vars: {
label: 'Source Variables',
ngShow: "source && (source.value == 'file' || source.value == 'ec2' || source.value == 'custom')",
extra_vars: {
label: 'Environment Variables', //"{{vars_label}}" ,
ngShow: "source && (source.value=='custom')",
type: 'textarea',
addRequired: false,
editRequird: false,
rows: 6,
'default': '---',
parseTypeName: 'envParseType',
dataTitle: 'Source Variables',
dataTitle: "Environment Variables", //'<p ng-show=source.value=="ec2">Source Variables<p>',
dataPlacement: 'right',
awPopOver: "<p>These are environment variables</p>",
dataContainer: 'body'
},
source_vars: {
label: 'Source Variables', //"{{vars_label}}" ,
ngShow: "source && (source.value == 'file' || source.value == 'ec2')",
type: 'textarea',
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/plugins/inventory/ec2.ini\" target=\"_blank\">" +

View File

@ -63,7 +63,7 @@ angular.module('CreateCustomInventoryHelper', [ 'Utilities', 'RestServices', 'Sc
SearchInit({
scope: scope,
set: 'custum_inventories',
set: 'custom_inventories',
list: list,
url: defaultUrl
});
@ -187,12 +187,10 @@ function($compile, SchedulerInit, Rest, Wait, CustomInventoryList, CustomInvento
view = GenerateList,
list = CustomInventoryList,
url = GetBasePath('inventory_scripts');
// base = $location.path().replace(/^\//, '').split('/')[0];
generator.inject(form, { id:'custom-script-dialog', mode: 'add' , scope:scope, related: false, breadCrumbs: false});
generator.reset();
// Save
scope.formSave = function () {
generator.clearApiErrors();
@ -211,7 +209,7 @@ function($compile, SchedulerInit, Rest, Wait, CustomInventoryList, CustomInvento
SearchInit({
scope: scope,
set: 'custum_inventories',
set: 'custom_inventories',
list: list,
url: url
});
@ -252,7 +250,6 @@ function($compile, CustomInventoryList, Rest, Wait, GenerateList, CustomInventor
list = CustomInventoryList,
master = {},
url = GetBasePath('inventory_scripts');
// base = $location.path().replace(/^\//, '').split('/')[0];
generator.inject(form, {
id:'custom-script-dialog',

View File

@ -207,13 +207,13 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
}
])
.factory('SourceChange', ['GetBasePath', 'CredentialList', 'LookUpInit', 'Empty', 'Wait', 'ParseTypeChange',
function (GetBasePath, CredentialList, LookUpInit, Empty, Wait, ParseTypeChange) {
.factory('SourceChange', ['GetBasePath', 'CredentialList', 'LookUpInit', 'Empty', 'Wait', 'ParseTypeChange', 'CustomInventoryList' ,
function (GetBasePath, CredentialList, LookUpInit, Empty, Wait, ParseTypeChange, CustomInventoryList) {
return function (params) {
var scope = params.scope,
form = params.form,
kind, url, callback;
kind, url, callback, invUrl;
if (!Empty(scope.source)) {
if (scope.source.value === 'file') {
@ -234,7 +234,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
$('#source_form').removeClass('squeeze');
} else if (scope.source.value === 'ec2') {
scope.source_region_choices = scope.ec2_regions;
//$('#s2id_group_source_regions').select2('data', []);
$('#s2id_source_source_regions').select2('data', [{
id: 'all',
text: 'All'
@ -273,6 +272,21 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
}]);
$('#source_form').addClass('squeeze');
}
if(scope.source.value==="custom"){
invUrl = GetBasePath('inventory_scripts');
LookUpInit({
url: invUrl,
scope: scope,
form: form,
// current_item: null,
list: CustomInventoryList,
field: 'source_script',
input_type: 'radio'
});
scope.extra_vars = (Empty(scope.source_vars)) ? "---" : scope.source_vars;
ParseTypeChange({ scope: scope, variable: 'extra_vars', parse_variable: form.fields.extra_vars.parseTypeName,
field_id: 'source_extra_vars', onReady: callback });
}
if (scope.source.value === 'rax' || scope.source.value === 'ec2'|| scope.source.value==='gce' || scope.source.value === 'azure' || scope.source.value === 'vmware') {
kind = (scope.source.value === 'rax') ? 'rax' : (scope.source.value==='gce') ? 'gce' : (scope.source.value==='azure') ? 'azure' : (scope.source.value === 'vmware') ? 'vmware' : 'aws' ;
url = GetBasePath('credentials') + '?cloud=true&kind=' + kind;
@ -850,6 +864,8 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched
Wait('start');
ParseTypeChange({ scope: sources_scope, variable: 'source_vars', parse_variable: SourceForm.fields.source_vars.parseTypeName,
field_id: 'source_source_vars', onReady: waitStop });
ParseTypeChange({ scope: sources_scope, variable: 'extra_vars', parse_variable: SourceForm.fields.extra_vars.parseTypeName,
field_id: 'source_extra_vars', onReady: waitStop });
}
}
else if ($(e.target).text() === 'Schedule') {
@ -946,7 +962,12 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched
// Parse source_vars, converting to YAML.
sources_scope.source_vars = ParseVariableString(data.source_vars);
master.source_vars = sources_scope.variables;
} else if (data[fld] !== undefined) {
}
// else if(fld === "source_script"){
// sources_scope[fld] = data
// }
else if (data[fld] !== undefined) {
sources_scope[fld] = data[fld];
master[fld] = sources_scope[fld];
}
@ -1144,6 +1165,7 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched
credential: sources_scope.credential,
overwrite: sources_scope.overwrite,
overwrite_vars: sources_scope.overwrite_vars,
source_script: sources_scope.source_script,
update_on_launch: sources_scope.update_on_launch,
update_cache_timeout: (sources_scope.update_cache_timeout || 0)
};
@ -1156,11 +1178,19 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched
}
data.source_regions = r.join();
if (sources_scope.source && (sources_scope.source.value === 'ec2' || sources_scope.source.value === 'custom')) {
if (sources_scope.source && (sources_scope.source.value === 'ec2')) {
// for ec2, validate variable data
data.source_vars = ToJSON(sources_scope.envParseType, sources_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(sources_scope.source.value === 'custom'){
delete(data.credential);
}
if (!parseError) {
Rest.setUrl(sources_scope.source_url);
Rest.put(data)

View File

@ -12,7 +12,7 @@
angular.module('CustomInventoryListDefinition', [])
.value('CustomInventoryList', {
name: 'custum_inventories',
name: 'custom_inventories',
iterator: 'custom_inventory',
selectTitle: 'Add custom inventory',
editTitle: 'Custom Inventories',

View File

@ -1,4 +1,5 @@
<div id="configure-jobs" >
<div id="configure-jobs" ><div>
<div class="tab-pane" id="configure-schedules-tab">
<div id="configure-schedules-overlay"></div>
<div id="configure-schedules-list"></div>

View File

@ -398,7 +398,37 @@
<div id="license-modal-dialog" style="display: none;"></div>
<div id="about-modal-dialog" style="display: none;" ng-include=" 'static/partials/cowsay-about.html ' "></div>
<div id="custom-script-dialog" style="display:none;" > </div>
<div id='configure-tower-dialog' style="display:none" ng-include = " ' static/partials/configure_tower.html' "></div>
<div id='configure-tower-dialog' style="display:none" >
<div id="configure-jobs" ></div>
<div class="tab-pane" id="configure-schedules-tab">
<div id="configure-schedules-overlay"></div>
<div id="configure-schedules-list"></div>
<div id="configure-schedules-form-container">
<div id="configure-schedules-title">
<h4 ng-bind="schedulesTitle"></h4>
<button type="button" class="close pull-right" ng-click="cancelScheduleForm()">x</button>
</div>
<div id="configure-schedules-form-container-body">
<div id="configure-schedules-form"></div>
<div id="configure-schedules-detail"></div>
</div>
<div id="configure-schedules-buttons" >
<a id="configure-schedules-flip-link" ng-show="formShowing" ng-click="showScheduleDetail()" href=""><i class="fa fa-search-plus"></i> View Details</a>
<a id="configure-schedules-flip-link" ng-show="!formShowing" ng-click="showScheduleDetail()" href=""><i class="fa fa-arrow-circle-left"></i> Back to options</a>
<button type="button" class="btn btn-default btn-sm" id="configure-schedule-delete-button" ng-show="mode==='edit'" ng-click="deleteSystemSchedule($event)"><i class="fa fa-trash-o"></i> Delete</button>
<button type="button" class="btn btn-default btn-sm" id="configure-reset-button" ng-click="cancelScheduleForm()"><i class="fa fa-times"></i> Cancel</button>
<button type="button" class="btn btn-primary btn-sm" id="configure-save-button" ng-click="saveScheduleForm()"><i class="fa fa-check"></i> Save</button>
</div>
</div>
</div>
</div>
<div id="prompt-for-days" style="display:none">
<form name="prompt_for_days_form" id="prompt_for_days_form">
How many days of data would you like to <b>keep</b>? <br>
<input type="number" min="1" id="days_to_keep" name="days_to_keep" value="30" ng-required="true" class="form-control ng-pristine ng-invalid-required ng-invalid" style="margin-top:10px;">
<div class="error" ng-show="prompt_for_days_form.days_to_keep.$dirty && copy_form.new_copy_name.$error.required">A value is required!</div></input>
</form>
</div>