mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 19:30:39 -03:30
Storable inventory script
Added the list and form for adding/editing/deleting custom inventory scripts.
This commit is contained in:
parent
3d98fe02b6
commit
0ffb979e8e
@ -16,24 +16,9 @@ angular.module('CustomInventoryFormDefinition', [])
|
||||
|
||||
addTitle: 'Create Custom Inventory', //Title in add mode
|
||||
editTitle: '{{ name }}', //Title in edit mode
|
||||
name: 'organization', //entity or model name in singular form
|
||||
well: true,
|
||||
// collapse: true,
|
||||
// collapseTitle: "Properties",
|
||||
// collapseMode: 'edit',
|
||||
// collapseOpen: true,
|
||||
|
||||
actions: {
|
||||
stream: {
|
||||
'class': "btn-primary btn-xs activity-btn",
|
||||
ngClick: "showActivity()",
|
||||
awToolTip: "View Activity Stream",
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'edit',
|
||||
iconSize: 'large'
|
||||
}
|
||||
},
|
||||
name: 'custom_inventory', //entity or model name in singular form
|
||||
well: false,
|
||||
showActions: false,
|
||||
|
||||
fields: {
|
||||
name: {
|
||||
@ -49,30 +34,16 @@ angular.module('CustomInventoryFormDefinition', [])
|
||||
addRequired: false,
|
||||
editRequired: false
|
||||
},
|
||||
// script: {
|
||||
// label: 'Custom Script',
|
||||
// type: 'textarea',
|
||||
// addRequired: false,
|
||||
// editRequired: false
|
||||
// }
|
||||
script: {
|
||||
// labelBind: 'sshKeyDataLabel',
|
||||
label: 'Custom Script',
|
||||
type: 'textarea',
|
||||
// ngShow: "kind.value == 'ssh' || kind.value == 'scm' || " +
|
||||
// "kind.value == 'gce' || kind.value == 'azure'",
|
||||
// awRequiredWhen: {
|
||||
// variable: 'key_required',
|
||||
// init: true
|
||||
// },
|
||||
hintText: "Hint: drag and drop an inventory script on the field below",
|
||||
hintText: "Drag and drop an inventory script on the field below",
|
||||
addRequired: true,
|
||||
editRequired: true,
|
||||
awDropFile: true,
|
||||
'class': 'ssh-key-field',
|
||||
rows: 10,
|
||||
awPopOver: "<p>Drag and drop your custom inventory script file here or create one in the field to import your custom inventory. </p>",
|
||||
// awPopOverWatch: "",
|
||||
dataTitle: 'Custom Script',
|
||||
dataPlacement: 'right',
|
||||
dataContainer: "body"
|
||||
@ -90,98 +61,6 @@ angular.module('CustomInventoryFormDefinition', [])
|
||||
}
|
||||
},
|
||||
|
||||
related: {
|
||||
|
||||
users: {
|
||||
type: 'collection',
|
||||
title: 'Users',
|
||||
iterator: 'user',
|
||||
open: false,
|
||||
|
||||
actions: {
|
||||
add: {
|
||||
ngClick: "add('users')",
|
||||
label: 'Add',
|
||||
icon: 'icon-plus',
|
||||
awToolTip: 'Add a new user'
|
||||
}
|
||||
},
|
||||
|
||||
fields: {
|
||||
username: {
|
||||
key: true,
|
||||
label: 'Username'
|
||||
},
|
||||
first_name: {
|
||||
label: 'First Name'
|
||||
},
|
||||
last_name: {
|
||||
label: 'Last Name'
|
||||
}
|
||||
},
|
||||
|
||||
fieldActions: {
|
||||
edit: {
|
||||
label: 'Edit',
|
||||
ngClick: "edit('users', user.id, user.username)",
|
||||
icon: 'icon-edit',
|
||||
'class': 'btn-default',
|
||||
awToolTip: 'Edit user'
|
||||
},
|
||||
"delete": {
|
||||
label: 'Delete',
|
||||
ngClick: "delete('users', user.id, user.username, 'users')",
|
||||
icon: 'icon-trash',
|
||||
"class": 'btn-danger',
|
||||
awToolTip: 'Remove user'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
admins: { // Assumes a plural name (e.g. things)
|
||||
type: 'collection',
|
||||
title: 'Administrators',
|
||||
iterator: 'admin', // Singular form of name (e.g. thing)
|
||||
open: false, // Open accordion on load?
|
||||
base: '/users',
|
||||
actions: { // Actions displayed top right of list
|
||||
add: {
|
||||
ngClick: "add('admins')",
|
||||
icon: 'icon-plus',
|
||||
label: 'Add',
|
||||
awToolTip: 'Add new administrator'
|
||||
}
|
||||
},
|
||||
fields: {
|
||||
username: {
|
||||
key: true,
|
||||
label: 'Username'
|
||||
},
|
||||
first_name: {
|
||||
label: 'First Name'
|
||||
},
|
||||
last_name: {
|
||||
label: 'Last Name'
|
||||
}
|
||||
},
|
||||
fieldActions: { // Actions available on each row
|
||||
edit: {
|
||||
label: 'Edit',
|
||||
ngClick: "edit('users', admin.id, admin.username)",
|
||||
icon: 'icon-edit',
|
||||
awToolTip: 'Edit administrator',
|
||||
'class': 'btn-default'
|
||||
},
|
||||
"delete": {
|
||||
label: 'Delete',
|
||||
ngClick: "delete('admins', admin.id, admin.username, 'administrators')",
|
||||
icon: 'icon-trash',
|
||||
"class": 'btn-danger',
|
||||
awToolTip: 'Remove administrator'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}); //OrganizationForm
|
||||
|
||||
@ -16,22 +16,18 @@
|
||||
angular.module('CreateCustomInventoryHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', 'SearchHelper', 'PaginationHelpers', 'ListGenerator', 'ModalDialog',
|
||||
'GeneratorHelpers', 'CustomInventoryFormDefinition'])
|
||||
|
||||
.factory('CreateCustomInventory', ['Wait', 'CreateDialog', 'CustomInventoryList', 'GenerateList', 'GetBasePath' , 'SearchInit' , 'PaginateInit', 'PlaybookRun', 'LoadSchedulesScope',
|
||||
'SchedulesList', 'SchedulesControllerInit' , 'ConfigureTowerSchedule', 'Rest' , 'ProcessErrors', 'CustomInventoryForm', 'GenerateForm',
|
||||
function(Wait, CreateDialog, CustomInventoryList, GenerateList, GetBasePath, SearchInit, PaginateInit, PlaybookRun, LoadSchedulesScope,
|
||||
SchedulesList, SchedulesControllerInit, ConfigureTowerSchedule, Rest, ProcessErrors, CustomInventoryForm, GenerateForm) {
|
||||
.factory('CreateCustomInventory', ['Wait', 'CreateDialog', 'CustomInventoryList', 'GenerateList', 'GetBasePath' , 'SearchInit' , 'PaginateInit', 'PlaybookRun', 'CustomInventoryAdd',
|
||||
'SchedulesList', 'CustomInventoryEdit', 'Rest' , 'ProcessErrors', 'CustomInventoryForm', 'GenerateForm', 'Prompt',
|
||||
function(Wait, CreateDialog, CustomInventoryList, GenerateList, GetBasePath, SearchInit, PaginateInit, PlaybookRun, CustomInventoryAdd,
|
||||
SchedulesList, CustomInventoryEdit, Rest, ProcessErrors, CustomInventoryForm, GenerateForm, Prompt) {
|
||||
return function(params) {
|
||||
// Set modal dimensions based on viewport width
|
||||
|
||||
var scope = params.parent_scope.$new(),
|
||||
parent_scope = params.parent_scope,
|
||||
callback = 'OpenConfig',
|
||||
defaultUrl = GetBasePath('system_job_templates'),
|
||||
defaultUrl = GetBasePath('inventory_scripts'),
|
||||
list = CustomInventoryList,
|
||||
view = GenerateList,
|
||||
scheduleUrl = GetBasePath('system_job_templates'),
|
||||
form = CustomInventoryForm,
|
||||
generator = GenerateForm,
|
||||
buttons = [
|
||||
{
|
||||
"label": "Close",
|
||||
@ -41,7 +37,7 @@ angular.module('CreateCustomInventoryHelper', [ 'Utilities', 'RestServices', 'Sc
|
||||
},
|
||||
"icon": "fa-times",
|
||||
"class": "btn btn-default",
|
||||
"id": "configure-close-button"
|
||||
"id": "script-close-button"
|
||||
}
|
||||
];
|
||||
|
||||
@ -51,13 +47,13 @@ angular.module('CreateCustomInventoryHelper', [ 'Utilities', 'RestServices', 'Sc
|
||||
scope.removeOpenConfig();
|
||||
}
|
||||
scope.removeOpenConfig = scope.$on('OpenConfig', function() {
|
||||
$('#configure-tower-dialog').dialog('open');
|
||||
$('#configure-close-button').focus();
|
||||
$('#configure-close-button').blur();
|
||||
$('#custom-script-dialog').dialog('open');
|
||||
$('#script-close-button').focus();
|
||||
$('#script-close-button').blur();
|
||||
});
|
||||
|
||||
view.inject( list, {
|
||||
id : 'configure-jobs',
|
||||
id : 'custom-script-dialog',
|
||||
mode: 'edit',
|
||||
scope: scope,
|
||||
breadCrumbs: false,
|
||||
@ -67,7 +63,7 @@ angular.module('CreateCustomInventoryHelper', [ 'Utilities', 'RestServices', 'Sc
|
||||
|
||||
SearchInit({
|
||||
scope: scope,
|
||||
set: 'configure_jobs',
|
||||
set: 'custum_inventories',
|
||||
list: list,
|
||||
url: defaultUrl
|
||||
});
|
||||
@ -79,20 +75,20 @@ angular.module('CreateCustomInventoryHelper', [ 'Utilities', 'RestServices', 'Sc
|
||||
|
||||
scope.search(list.iterator);
|
||||
|
||||
SchedulesControllerInit({
|
||||
scope: scope,
|
||||
parent_scope: parent_scope,
|
||||
// list: list
|
||||
});
|
||||
// SchedulesControllerInit({
|
||||
// scope: scope,
|
||||
// parent_scope: parent_scope,
|
||||
// // list: list
|
||||
// });
|
||||
|
||||
|
||||
CreateDialog({
|
||||
id: 'configure-tower-dialog',
|
||||
id: 'custom-script-dialog',
|
||||
title: 'Inventory Script',
|
||||
target: 'configure-tower-dialog',
|
||||
target: 'custom-script-dialog',
|
||||
scope: scope,
|
||||
buttons: buttons,
|
||||
width: 670,
|
||||
width: 700,
|
||||
height: 800,
|
||||
minWidth: 400,
|
||||
callback: callback,
|
||||
@ -106,12 +102,12 @@ angular.module('CreateCustomInventoryHelper', [ 'Utilities', 'RestServices', 'Sc
|
||||
// remove lingering popover <div> elements
|
||||
$(this).remove();
|
||||
});
|
||||
$("#configure-jobs").show();
|
||||
$("#configure-schedules-form-container").hide();
|
||||
$('#configure-schedules-list').empty();
|
||||
$('#configure-schedules-form').empty();
|
||||
$('#configure-schedules-detail').empty();
|
||||
$('#configure-tower-dialog').hide();
|
||||
// $("#configure-jobs").show();
|
||||
// $("#configure-schedules-form-container").hide();
|
||||
// $('#configure-schedules-list').empty();
|
||||
// $('#configure-schedules-form').empty();
|
||||
// $('#configure-schedules-detail').empty();
|
||||
// $('#configure-tower-dialog').hide();
|
||||
$(this).dialog('destroy');
|
||||
scope.cancelConfigure();
|
||||
},
|
||||
@ -122,7 +118,7 @@ angular.module('CreateCustomInventoryHelper', [ 'Utilities', 'RestServices', 'Sc
|
||||
// Cancel
|
||||
scope.cancelConfigure = function () {
|
||||
try {
|
||||
$('#configure-tower-dialog').dialog('close');
|
||||
$('#custom-script-dialog').dialog('close');
|
||||
}
|
||||
catch(e) {
|
||||
//ignore
|
||||
@ -138,342 +134,194 @@ angular.module('CreateCustomInventoryHelper', [ 'Utilities', 'RestServices', 'Sc
|
||||
}
|
||||
};
|
||||
|
||||
scope.submitJob = function (id) {
|
||||
Wait('start');
|
||||
scheduleUrl += id+'/launch/';
|
||||
CreateDialog({
|
||||
id: 'prompt-for-days' ,
|
||||
title: "Cleanup Job",
|
||||
scope.editCustomInv = function(id){
|
||||
CustomInventoryEdit({
|
||||
scope: scope,
|
||||
width: 500,
|
||||
height: 300,
|
||||
minWidth: 200,
|
||||
callback: 'PromptForDays',
|
||||
buttons: [{
|
||||
"label": "Cancel",
|
||||
"onClick": function() {
|
||||
$(this).dialog('close');
|
||||
|
||||
},
|
||||
"icon": "fa-times",
|
||||
"class": "btn btn-default",
|
||||
"id": "prompt-for-days-button"
|
||||
},{
|
||||
"label": "Launch",
|
||||
"onClick": function() {
|
||||
var extra_vars = {"days": $("#days_to_keep").val() },
|
||||
data = {};
|
||||
data.extra_vars = JSON.stringify(extra_vars);
|
||||
|
||||
Rest.setUrl(scheduleUrl);
|
||||
Rest.post(data)
|
||||
.success(function() {
|
||||
Wait('stop');
|
||||
$("#prompt-for-days").dialog("close");
|
||||
$("#configure-tower-dialog").dialog('close');
|
||||
})
|
||||
.error(function(data, status) {
|
||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||
msg: 'Failed updating job ' + scope.job_template_id + ' with variables. PUT returned: ' + status });
|
||||
});
|
||||
},
|
||||
"icon": "fa-rocket",
|
||||
"class": "btn btn-primary",
|
||||
"id": "prompt-for-days-button"
|
||||
}]
|
||||
id: id
|
||||
});
|
||||
|
||||
if (scope.removePromptForDays) {
|
||||
scope.removePromptForDays();
|
||||
}
|
||||
scope.removePromptForDays = scope.$on('PromptForDays', function() {
|
||||
// $('#configure-tower-dialog').dialog('close');
|
||||
$('#prompt-for-days').show();
|
||||
$('#prompt-for-days').dialog('open');
|
||||
Wait('stop');
|
||||
});
|
||||
|
||||
|
||||
|
||||
};
|
||||
scope.deleteCustomInv = function(id, name){
|
||||
|
||||
scope.configureSchedule = function(id, name) {
|
||||
Rest.setUrl(scheduleUrl+id+'/schedules/');
|
||||
Rest.get()
|
||||
.success(function(data) {
|
||||
if(data.count>0){
|
||||
scope.days=data.results[0].extra_data.days;
|
||||
ConfigureTowerSchedule({
|
||||
scope: scope,
|
||||
mode: 'edit',
|
||||
url: scheduleUrl+id+'/schedules/'
|
||||
});
|
||||
} else {
|
||||
ConfigureTowerSchedule({
|
||||
scope: scope,
|
||||
mode: 'add',
|
||||
url: scheduleUrl+id+'/schedules/',
|
||||
name: name
|
||||
});
|
||||
}
|
||||
})
|
||||
.error(function(data, status) {
|
||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||
msg: 'Failed updating job ' + scope.job_template_id + ' with variables. PUT returned: ' + status });
|
||||
});
|
||||
var action = function () {
|
||||
$('#prompt-modal').modal('hide');
|
||||
Wait('start');
|
||||
var url = defaultUrl + id + '/';
|
||||
Rest.setUrl(url);
|
||||
Rest.destroy()
|
||||
.success(function () {
|
||||
scope.search(list.iterator);
|
||||
})
|
||||
.error(function (data, status) {
|
||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||
});
|
||||
};
|
||||
|
||||
Prompt({
|
||||
hdr: 'Delete',
|
||||
body: "<div class\"alert alert-info\">Are you sure you want to delete " + name + "?</div>",
|
||||
action: action
|
||||
});
|
||||
};
|
||||
|
||||
scope.addCustomInv = function(){
|
||||
// generator.inject(form, { mode: 'add', related: false, scope: $scope, });
|
||||
generator.inject(form, { id:'configure-jobs', mode: 'add' , scope:scope, related: false, breadCrumbs: false});
|
||||
generator.reset();
|
||||
CustomInventoryAdd({
|
||||
scope: scope
|
||||
});
|
||||
};
|
||||
|
||||
parent_scope.refreshJobs = function(){
|
||||
scope.search(SchedulesList.iterator);
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
}])
|
||||
|
||||
|
||||
.factory('ConfigureTowerSchedule', ['$compile','SchedulerInit', 'Rest', 'Wait', 'SetSchedulesInnerDialogSize', 'SchedulePost', 'ProcessErrors', 'GetBasePath', 'Empty', 'Prompt',
|
||||
function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, ProcessErrors, GetBasePath, Empty, Prompt) {
|
||||
.factory('CustomInventoryAdd', ['$compile','SchedulerInit', 'Rest', 'Wait', 'CustomInventoryList', 'CustomInventoryForm', 'ProcessErrors', 'GetBasePath', 'Empty', 'GenerateForm',
|
||||
'SearchInit' , 'PaginateInit', 'GenerateList',
|
||||
function($compile, SchedulerInit, Rest, Wait, CustomInventoryList, CustomInventoryForm, ProcessErrors, GetBasePath, Empty, GenerateForm,
|
||||
SearchInit, PaginateInit, GenerateList) {
|
||||
return function(params) {
|
||||
var parent_scope = params.scope,
|
||||
mode = params.mode, // 'add' or 'edit'
|
||||
url = params.url,
|
||||
scope = parent_scope.$new(),
|
||||
id = params.id || undefined,
|
||||
name = params.name || undefined,
|
||||
schedule = {},
|
||||
scheduler,
|
||||
target,
|
||||
showForm,
|
||||
list,
|
||||
detail,
|
||||
restoreList,
|
||||
container,
|
||||
elem;
|
||||
var scope = params.scope,
|
||||
generator = GenerateForm,
|
||||
form = CustomInventoryForm,
|
||||
view = GenerateList,
|
||||
list = CustomInventoryList,
|
||||
url = GetBasePath('inventory_scripts');
|
||||
// base = $location.path().replace(/^\//, '').split('/')[0];
|
||||
|
||||
// <div id='configure-tower-dialog' style="display:none">
|
||||
// <div id="configure-jobs-list"></div>
|
||||
// <div id="configure-schedule-form"></div>
|
||||
// </div>
|
||||
|
||||
// Wait('start');
|
||||
// detail = $('#schedules-detail').hide();
|
||||
// list = $('#schedules-list');
|
||||
// target = $('#schedules-form');
|
||||
// container = $('#schedules-form-container');
|
||||
|
||||
Wait('start');
|
||||
// $('#configure-jobs').hide();
|
||||
detail = $('#configure-schedules-detail').hide();
|
||||
list = $('#configure-schedules-list');
|
||||
target = $('#configure-schedules-form');
|
||||
container = $('#configure-schedules-form-container');
|
||||
$("#configure-jobs").show();
|
||||
$("#configure-schedules-form-container").hide();
|
||||
scope.mode = mode;
|
||||
// Clean up any lingering stuff
|
||||
container.hide();
|
||||
target.empty();
|
||||
$('.tooltip').each(function () {
|
||||
$(this).remove();
|
||||
});
|
||||
$('.popover').each(function () {
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
elem = angular.element(document.getElementById('configure-schedules-form-container'));
|
||||
$compile(elem)(scope);
|
||||
|
||||
if (scope.removeScheduleReady) {
|
||||
scope.removeScheduleReady();
|
||||
}
|
||||
scope.removeScheduleReady = scope.$on('ScheduleReady', function() {
|
||||
// Insert the scheduler widget into the hidden div
|
||||
scheduler = SchedulerInit({ scope: scope, requireFutureStartTime: false });
|
||||
scheduler.inject('configure-schedules-form', false);
|
||||
scheduler.injectDetail('configure-schedules-detail', false);
|
||||
scheduler.clear();
|
||||
scope.formShowing = true;
|
||||
scope.showRRuleDetail = false;
|
||||
scope.schedulesTitle = (mode === 'edit') ? 'Edit Schedule' : 'Create Schedule';
|
||||
generator.inject(form, { id:'custom-script-dialog', mode: 'add' , scope:scope, related: false, breadCrumbs: false});
|
||||
generator.reset();
|
||||
|
||||
|
||||
// display the scheduler widget
|
||||
showForm = function() {
|
||||
$('#configure-jobs').show('slide', { direction: 'left' }, 500);
|
||||
$('#configure-jobs').hide();
|
||||
Wait('stop');
|
||||
$('#configure-schedules-overlay').width($('#configure-schedules-tab')
|
||||
.width()).height($('#configure-schedules-tab').height()).show();
|
||||
container.width($('#configure-schedules-tab').width() - 18);
|
||||
SetSchedulesInnerDialogSize();
|
||||
container.show('slide', { direction: 'right' }, 300);
|
||||
// scope.schedulerPurgeDays = (!Empty(scope.days)) ? Number(scope.days) : 30;
|
||||
target.show();
|
||||
if(mode==="add"){
|
||||
scope.$apply(function(){
|
||||
scope.schedulerPurgeDays = 30;
|
||||
scope.schedulerName = name+' Schedule';
|
||||
// Save
|
||||
scope.formSave = function () {
|
||||
generator.clearApiErrors();
|
||||
Wait('start');
|
||||
Rest.setUrl(url);
|
||||
Rest.post({ name: scope.name, description: scope.description, script: scope.script })
|
||||
.success(function () {
|
||||
view.inject( list, {
|
||||
id : 'custom-script-dialog',
|
||||
mode: 'edit',
|
||||
scope: scope,
|
||||
breadCrumbs: false,
|
||||
activityStream: false,
|
||||
showSearch: true
|
||||
});
|
||||
}
|
||||
if (mode === 'edit') {
|
||||
scope.$apply(function() {
|
||||
scheduler.setRRule(schedule.rrule);
|
||||
scheduler.setName(schedule.name);
|
||||
scope.schedulerPurgeDays = (!Empty(scope.days)) ? Number(scope.days) : 30;
|
||||
|
||||
SearchInit({
|
||||
scope: scope,
|
||||
set: 'custum_inventories',
|
||||
list: list,
|
||||
url: url
|
||||
});
|
||||
}
|
||||
};
|
||||
setTimeout(function() { showForm(); }, 1000);
|
||||
});
|
||||
|
||||
restoreList = function() {
|
||||
// $('#group-save-button').prop('disabled', false);
|
||||
$('#configure-jobs').show('slide', { direction: 'right' }, 500);
|
||||
// $('#configure-jobs').width($('#configure-jobs').width()).height($('#configure-jobs').height()).hide();
|
||||
// parent_scope.refreshSchedules();
|
||||
list.show('slide', { direction: 'right' }, 500);
|
||||
$('#configure-schedules-overlay').width($('#configure-schedules-tab').width()).height($('#configure-schedules-tab').height()).hide();
|
||||
parent_scope.refreshSchedules();
|
||||
|
||||
};
|
||||
|
||||
scope.showScheduleDetail = function() {
|
||||
if (scope.formShowing) {
|
||||
if (scheduler.isValid()) {
|
||||
detail.width($('#configure-schedules-form').width()).height($('#configure-schedules-form').height());
|
||||
target.hide();
|
||||
detail.show();
|
||||
scope.formShowing = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
detail.hide();
|
||||
target.show();
|
||||
scope.formShowing = true;
|
||||
}
|
||||
};
|
||||
|
||||
if (scope.removeScheduleSaved) {
|
||||
scope.removeScheduleSaved();
|
||||
}
|
||||
scope.removeScheduleSaved = scope.$on('ScheduleSaved', function() {
|
||||
Wait('stop');
|
||||
container.hide('slide', { direction: 'left' }, 500, restoreList);
|
||||
scope.$destroy();
|
||||
});
|
||||
|
||||
scope.saveScheduleForm = function() {
|
||||
var extra_vars;
|
||||
if (scheduler.isValid()) {
|
||||
scope.schedulerIsValid = true;
|
||||
url = (mode==="edit") ? GetBasePath('schedules')+id+'/' : url;
|
||||
|
||||
extra_vars = {
|
||||
"days" : scope.scheduler_form.schedulerPurgeDays.$viewValue
|
||||
};
|
||||
schedule.extra_data = JSON.stringify(extra_vars);
|
||||
|
||||
SchedulePost({
|
||||
scope: scope,
|
||||
url: url,
|
||||
scheduler: scheduler,
|
||||
callback: 'ScheduleSaved',
|
||||
mode: mode,
|
||||
schedule: schedule
|
||||
});
|
||||
}
|
||||
else {
|
||||
scope.schedulerIsValid = false;
|
||||
}
|
||||
};
|
||||
|
||||
scope.deleteSystemSchedule = function(){
|
||||
var hdr = 'Delete Schedule',
|
||||
action = function () {
|
||||
Wait('start');
|
||||
Rest.setUrl(schedule.url);
|
||||
Rest.destroy()
|
||||
.success(function () {
|
||||
$('#prompt-modal').modal('hide');
|
||||
Wait('stop');
|
||||
// scope.$emit(callback, id);
|
||||
scope.cancelScheduleForm();
|
||||
})
|
||||
.error(function (data, status) {
|
||||
try {
|
||||
$('#prompt-modal').modal('hide');
|
||||
}
|
||||
catch(e) {
|
||||
// ignore
|
||||
}
|
||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url +
|
||||
' failed. DELETE returned: ' + status });
|
||||
PaginateInit({
|
||||
scope: scope,
|
||||
list: list,
|
||||
url: url
|
||||
});
|
||||
};
|
||||
|
||||
Prompt({
|
||||
hdr: hdr,
|
||||
body: "<div class=\"alert alert-info\">Are you sure you want to delete the <em>" + scope.schedulerName + "</em> schedule?</div>",
|
||||
action: action,
|
||||
backdrop: false
|
||||
});
|
||||
// }
|
||||
// } else {
|
||||
// //a schedule doesn't exist
|
||||
// $("#prompt_action_btn").text('OK');
|
||||
// $('#prompt_cancel_btn').hide();
|
||||
// var action2 = function(){
|
||||
// $('#prompt-modal').modal('hide');
|
||||
// $("#prompt_action_btn").text('Yes');
|
||||
// $('#prompt_cancel_btn').show();
|
||||
// };
|
||||
// Prompt({
|
||||
// hdr: "Delete",
|
||||
// body: "<div class=\"alert alert-info\">No schedule exists for that job. </div>",
|
||||
// action: action2,
|
||||
// backdrop: false
|
||||
// });
|
||||
// }
|
||||
// })
|
||||
// .error(function(data, status) {
|
||||
// ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||
// msg: 'Failed updating job ' + scope.job_template_id + ' with variables. PUT returned: ' + status });
|
||||
// });
|
||||
};
|
||||
scope.search(list.iterator);
|
||||
Wait('stop');
|
||||
Wait('stop');
|
||||
|
||||
scope.cancelScheduleForm = function() {
|
||||
container.hide('slide', { direction: 'right' }, 500, restoreList);
|
||||
scope.$destroy();
|
||||
};
|
||||
|
||||
if (mode === 'edit') {
|
||||
// Get the existing record
|
||||
Rest.setUrl(url); //GetBasePath('schedules')+id+'/');
|
||||
Rest.get()
|
||||
.success(function(data) {
|
||||
schedule = data.results[0];
|
||||
id = schedule.id;
|
||||
if (!/DTSTART/.test(schedule.rrule)) {
|
||||
schedule.rrule += ";DTSTART=" + schedule.dtstart.replace(/\.\d+Z$/,'Z');
|
||||
}
|
||||
schedule.rrule = schedule.rrule.replace(/ RRULE:/,';');
|
||||
schedule.rrule = schedule.rrule.replace(/DTSTART:/,'DTSTART=');
|
||||
scope.$emit('ScheduleReady');
|
||||
})
|
||||
.error(function(data,status){
|
||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||
msg: 'Failed to get: ' + url + ' GET returned: ' + status });
|
||||
.error(function (data, status) {
|
||||
ProcessErrors(scope, data, status, form, { hdr: 'Error!',
|
||||
msg: 'Failed to add new inventory script. Post returned status: ' + status });
|
||||
});
|
||||
}
|
||||
else {
|
||||
scope.$emit('ScheduleReady');
|
||||
}
|
||||
};
|
||||
|
||||
// Cancel
|
||||
scope.formReset = function () {
|
||||
generator.reset();
|
||||
};
|
||||
};
|
||||
}])
|
||||
|
||||
.factory('CustomInventoryEdit', ['$compile','CustomInventoryList', 'Rest', 'Wait', 'GenerateList', 'CustomInventoryForm', 'ProcessErrors', 'GetBasePath', 'Empty', 'GenerateForm',
|
||||
'SearchInit', 'PaginateInit', '$routeParams',
|
||||
function($compile, CustomInventoryList, Rest, Wait, GenerateList, CustomInventoryForm, ProcessErrors, GetBasePath, Empty, GenerateForm,
|
||||
SearchInit, PaginateInit, $routeParams) {
|
||||
return function(params) {
|
||||
var scope = params.scope,
|
||||
id = params.id,
|
||||
generator = GenerateForm,
|
||||
form = CustomInventoryForm,
|
||||
view = GenerateList,
|
||||
list = CustomInventoryList,
|
||||
master = {},
|
||||
url = GetBasePath('inventory_scripts');
|
||||
// base = $location.path().replace(/^\//, '').split('/')[0];
|
||||
|
||||
generator.inject(form, {
|
||||
id:'custom-script-dialog',
|
||||
mode: 'edit' ,
|
||||
scope:scope,
|
||||
related: false,
|
||||
breadCrumbs: false,
|
||||
activityStream: false
|
||||
});
|
||||
generator.reset();
|
||||
|
||||
// Retrieve detail record and prepopulate the form
|
||||
Wait('start');
|
||||
Rest.setUrl(url + id+'/');
|
||||
Rest.get()
|
||||
.success(function (data) {
|
||||
var fld;
|
||||
for (fld in form.fields) {
|
||||
if (data[fld]) {
|
||||
scope[fld] = data[fld];
|
||||
master[fld] = data[fld];
|
||||
}
|
||||
}
|
||||
Wait('stop');
|
||||
})
|
||||
.error(function (data, status) {
|
||||
ProcessErrors(scope, data, status, form, { hdr: 'Error!',
|
||||
msg: 'Failed to retrieve inventory script: ' + $routeParams.id + '. GET status: ' + status });
|
||||
});
|
||||
|
||||
scope.formSave = function () {
|
||||
generator.clearApiErrors();
|
||||
Wait('start');
|
||||
Rest.setUrl(url+ id+'/');
|
||||
Rest.put({ name: scope.name, description: scope.description, script: scope.script })
|
||||
.success(function () {
|
||||
view.inject( list, {
|
||||
id : 'custom-script-dialog',
|
||||
mode: 'edit',
|
||||
scope: scope,
|
||||
breadCrumbs: false,
|
||||
activityStream: false,
|
||||
showSearch: true
|
||||
});
|
||||
|
||||
SearchInit({
|
||||
scope: scope,
|
||||
set: 'custum_inventories',
|
||||
list: list,
|
||||
url: url
|
||||
});
|
||||
PaginateInit({
|
||||
scope: scope,
|
||||
list: list,
|
||||
url: url
|
||||
});
|
||||
|
||||
scope.search(list.iterator);
|
||||
Wait('stop');
|
||||
|
||||
})
|
||||
.error(function (data, status) {
|
||||
ProcessErrors(scope, data, status, form, { hdr: 'Error!',
|
||||
msg: 'Failed to add new inventory script. Post returned status: ' + status });
|
||||
});
|
||||
};
|
||||
|
||||
scope.formReset = function () {
|
||||
generator.reset();
|
||||
};
|
||||
};
|
||||
}]);
|
||||
|
||||
@ -34,14 +34,6 @@ angular.module('CustomInventoryListDefinition', [])
|
||||
excludeModal: true,
|
||||
columnClass: 'col-md-5 hidden-sm hidden-xs'
|
||||
},
|
||||
// kind: {
|
||||
// label: 'Type',
|
||||
// searchType: 'select',
|
||||
// searchOptions: [], // will be set by Options call to credentials resource
|
||||
// excludeModal: true,
|
||||
// nosort: true,
|
||||
// columnClass: 'col-md-3 hidden-sm hidden-xs'
|
||||
// }
|
||||
},
|
||||
|
||||
actions: {
|
||||
@ -50,16 +42,11 @@ angular.module('CustomInventoryListDefinition', [])
|
||||
ngClick: 'addCustomInv()',
|
||||
awToolTip: 'Create a new credential'
|
||||
},
|
||||
stream: {
|
||||
ngClick: "showActivity()",
|
||||
awToolTip: "View Activity Stream",
|
||||
mode: 'edit'
|
||||
}
|
||||
},
|
||||
|
||||
fieldActions: {
|
||||
edit: {
|
||||
ngClick: "editCredential(credential.id)",
|
||||
ngClick: "editCustomInv(custom_inventory.id)",
|
||||
icon: 'fa-edit',
|
||||
label: 'Edit',
|
||||
"class": 'btn-sm',
|
||||
@ -68,7 +55,7 @@ angular.module('CustomInventoryListDefinition', [])
|
||||
},
|
||||
|
||||
"delete": {
|
||||
ngClick: "deleteCredential(credential.id, credential.name)",
|
||||
ngClick: "deleteCustomInv(custom_inventory.id, custom_inventory.name)",
|
||||
icon: 'fa-trash',
|
||||
label: 'Delete',
|
||||
"class": 'btn-sm',
|
||||
|
||||
30
awx/ui/static/partials/configure_tower.html
Normal file
30
awx/ui/static/partials/configure_tower.html
Normal file
@ -0,0 +1,30 @@
|
||||
<div id="configure-jobs" >
|
||||
<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>
|
||||
@ -396,38 +396,10 @@
|
||||
<div id="login-modal-dialog" style="display: none;"></div>
|
||||
<div id="help-modal-dialog" style="display: none;"></div>
|
||||
<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='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>
|
||||
<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><!-- container -->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user