mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 03:10:42 -03:30
Adding files for custom inventory script modal
I'm adding the initial files and references in app.js and index.html for the custom inventory script modal window
This commit is contained in:
parent
d72d95b282
commit
27db190bed
@ -40,6 +40,7 @@ angular.module('Tower', [
|
||||
'PaginationHelpers',
|
||||
'RefreshHelper',
|
||||
'AdminListDefinition',
|
||||
'CustomInventoryListDefinition',
|
||||
'AWDirectives',
|
||||
'InventoriesListDefinition',
|
||||
'InventoryFormDefinition',
|
||||
@ -121,7 +122,9 @@ angular.module('Tower', [
|
||||
'SurveyQuestionFormDefinition',
|
||||
'PortalJobsListDefinition',
|
||||
'ConfigureTowerHelper',
|
||||
'ConfigureTowerJobsListDefinition'
|
||||
'ConfigureTowerJobsListDefinition',
|
||||
'CreateCustomInventoryHelper',
|
||||
'CustomInventoryListDefinition'
|
||||
])
|
||||
|
||||
.constant('AngularScheduler.partials', urlPrefix + 'lib/angular-scheduler/lib/')
|
||||
@ -434,9 +437,9 @@ angular.module('Tower', [
|
||||
}])
|
||||
|
||||
.run(['$compile', '$cookieStore', '$rootScope', '$log', 'CheckLicense', '$location', 'Authorization', 'LoadBasePaths', 'Timer', 'ClearScope', 'HideStream', 'Socket',
|
||||
'LoadConfig', 'Store', 'ShowSocketHelp', 'LicenseViewer', 'AboutAnsibleHelp', 'ConfigureTower',
|
||||
'LoadConfig', 'Store', 'ShowSocketHelp', 'LicenseViewer', 'AboutAnsibleHelp', 'ConfigureTower', 'CreateCustomInventory' ,
|
||||
function ($compile, $cookieStore, $rootScope, $log, CheckLicense, $location, Authorization, LoadBasePaths, Timer, ClearScope, HideStream, Socket,
|
||||
LoadConfig, Store, ShowSocketHelp, LicenseViewer, AboutAnsibleHelp, ConfigureTower) {
|
||||
LoadConfig, Store, ShowSocketHelp, LicenseViewer, AboutAnsibleHelp, ConfigureTower, CreateCustomInventory) {
|
||||
|
||||
|
||||
var e, html, sock, checkCount = 0;
|
||||
@ -595,6 +598,12 @@ angular.module('Tower', [
|
||||
});
|
||||
};
|
||||
|
||||
$rootScope.createCustomInv = function(){
|
||||
CreateCustomInventory({
|
||||
parent_scope: $rootScope
|
||||
});
|
||||
};
|
||||
|
||||
html = "<a href=\"\" ng-click=\"socketHelp()\" aw-pop-over=\"{{ socketTip }}\" aw-pop-over-watch=\"socketTip\" data-placement=\"bottom\" data-trigger=\"hover\" " +
|
||||
"data-popover-title=\"Live Events\" data-container=\"body\" style=\"font-size: 10px;\"><i class=\"fa icon-socket-{{ socketStatus }}\"></i></a>";
|
||||
e = angular.element(document.getElementById('socket-beacon-div'));
|
||||
|
||||
187
awx/ui/static/js/forms/CustomInventory.js
Normal file
187
awx/ui/static/js/forms/CustomInventory.js
Normal file
@ -0,0 +1,187 @@
|
||||
/*********************************************
|
||||
* Copyright (c) 2014 AnsibleWorks, Inc.
|
||||
*
|
||||
* Organization.js
|
||||
* Form definition for Organization model
|
||||
*
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name forms.function:Organizations
|
||||
* @description This form is for adding/editing an organization
|
||||
*/
|
||||
angular.module('CustomInventoryFormDefinition', [])
|
||||
.value('CustomInventoryForm', {
|
||||
|
||||
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'
|
||||
}
|
||||
},
|
||||
|
||||
fields: {
|
||||
name: {
|
||||
label: 'Name',
|
||||
type: 'text',
|
||||
addRequired: true,
|
||||
editRequired: true,
|
||||
capitalize: false
|
||||
},
|
||||
description: {
|
||||
label: 'Description',
|
||||
type: 'text',
|
||||
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",
|
||||
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"
|
||||
},
|
||||
},
|
||||
|
||||
buttons: { //for now always generates <button> tags
|
||||
save: {
|
||||
ngClick: 'formSave()', //$scope.function to call on click, optional
|
||||
ngDisabled: true //Disable when $pristine or $invalid, optional
|
||||
},
|
||||
reset: {
|
||||
ngClick: 'formReset()',
|
||||
ngDisabled: true //Disabled when $pristine
|
||||
}
|
||||
},
|
||||
|
||||
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
|
||||
@ -63,6 +63,50 @@ angular.module('SourceFormDefinition', [])
|
||||
"</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>Open the <a href=http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstances.html target='_blank'>documentation</a> for a complete list of filter options.</p>",
|
||||
dataContainer: 'body'
|
||||
},
|
||||
group_by: {
|
||||
label: 'Group By',
|
||||
type: 'text',
|
||||
ngShow: "source && source.value == 'ec2'",
|
||||
addRequired: false,
|
||||
editRequired: false,
|
||||
awMultiselect: 'group_by_choices',
|
||||
dataTitle: 'Group By',
|
||||
dataPlacement: 'right',
|
||||
awPopOver: "<p>FIXME: Create these automatic groups by default.</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: {
|
||||
label : "Custom Inventory Scripts",
|
||||
type: 'lookup',
|
||||
ngShow: "source && source.value !== '' && source.value === 'custom'",
|
||||
sourceModel: 'custom_script',
|
||||
sourceField: 'name',
|
||||
ngClick: 'lookUpCustomScript()',
|
||||
addRequired: false,
|
||||
editRequired: false
|
||||
},
|
||||
source_vars: {
|
||||
label: 'Source Variables',
|
||||
ngShow: "source && (source.value == 'file' || source.value == 'ec2' || source.value == 'custom')",
|
||||
|
||||
479
awx/ui/static/js/helpers/CustomInventory.js
Normal file
479
awx/ui/static/js/helpers/CustomInventory.js
Normal file
@ -0,0 +1,479 @@
|
||||
/*********************************************
|
||||
* Copyright (c) 2014 AnsibleWorks, Inc.
|
||||
*/
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name helpers.function:Schedules
|
||||
* @description
|
||||
* Schedules Helper
|
||||
*
|
||||
* Display the scheduler widget in a dialog
|
||||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
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) {
|
||||
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'),
|
||||
list = CustomInventoryList,
|
||||
view = GenerateList,
|
||||
scheduleUrl = GetBasePath('system_job_templates'),
|
||||
form = CustomInventoryForm,
|
||||
generator = GenerateForm,
|
||||
buttons = [
|
||||
{
|
||||
"label": "Close",
|
||||
"onClick": function() {
|
||||
// $(this).dialog('close');
|
||||
scope.cancelConfigure();
|
||||
},
|
||||
"icon": "fa-times",
|
||||
"class": "btn btn-default",
|
||||
"id": "configure-close-button"
|
||||
}
|
||||
];
|
||||
|
||||
scope.cleanupJob = true;
|
||||
|
||||
if(scope.removeOpenConfig) {
|
||||
scope.removeOpenConfig();
|
||||
}
|
||||
scope.removeOpenConfig = scope.$on('OpenConfig', function() {
|
||||
$('#configure-tower-dialog').dialog('open');
|
||||
$('#configure-close-button').focus();
|
||||
$('#configure-close-button').blur();
|
||||
});
|
||||
|
||||
view.inject( list, {
|
||||
id : 'configure-jobs',
|
||||
mode: 'edit',
|
||||
scope: scope,
|
||||
breadCrumbs: false,
|
||||
activityStream: false,
|
||||
showSearch: true
|
||||
});
|
||||
|
||||
SearchInit({
|
||||
scope: scope,
|
||||
set: 'configure_jobs',
|
||||
list: list,
|
||||
url: defaultUrl
|
||||
});
|
||||
PaginateInit({
|
||||
scope: scope,
|
||||
list: list,
|
||||
url: defaultUrl
|
||||
});
|
||||
|
||||
scope.search(list.iterator);
|
||||
|
||||
SchedulesControllerInit({
|
||||
scope: scope,
|
||||
parent_scope: parent_scope,
|
||||
// list: list
|
||||
});
|
||||
|
||||
|
||||
CreateDialog({
|
||||
id: 'configure-tower-dialog',
|
||||
title: 'Inventory Script',
|
||||
target: 'configure-tower-dialog',
|
||||
scope: scope,
|
||||
buttons: buttons,
|
||||
width: 670,
|
||||
height: 800,
|
||||
minWidth: 400,
|
||||
callback: callback,
|
||||
onClose: function () {
|
||||
// Destroy on close
|
||||
$('.tooltip').each(function () {
|
||||
// Remove any lingering tooltip <div> elements
|
||||
$(this).remove();
|
||||
});
|
||||
$('.popover').each(function () {
|
||||
// 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();
|
||||
$(this).dialog('destroy');
|
||||
scope.cancelConfigure();
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Cancel
|
||||
scope.cancelConfigure = function () {
|
||||
try {
|
||||
$('#configure-tower-dialog').dialog('close');
|
||||
}
|
||||
catch(e) {
|
||||
//ignore
|
||||
}
|
||||
if (scope.searchCleanup) {
|
||||
scope.searchCleanup();
|
||||
}
|
||||
// if (!Empty(parent_scope) && parent_scope.restoreSearch) {
|
||||
// parent_scope.restoreSearch();
|
||||
// }
|
||||
else {
|
||||
Wait('stop');
|
||||
}
|
||||
};
|
||||
|
||||
scope.submitJob = function (id) {
|
||||
Wait('start');
|
||||
scheduleUrl += id+'/launch/';
|
||||
CreateDialog({
|
||||
id: 'prompt-for-days' ,
|
||||
title: "Cleanup Job",
|
||||
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"
|
||||
}]
|
||||
});
|
||||
|
||||
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.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 });
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
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) {
|
||||
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;
|
||||
|
||||
// <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';
|
||||
|
||||
|
||||
// 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';
|
||||
});
|
||||
}
|
||||
if (mode === 'edit') {
|
||||
scope.$apply(function() {
|
||||
scheduler.setRRule(schedule.rrule);
|
||||
scheduler.setName(schedule.name);
|
||||
scope.schedulerPurgeDays = (!Empty(scope.days)) ? Number(scope.days) : 30;
|
||||
});
|
||||
}
|
||||
};
|
||||
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 });
|
||||
});
|
||||
};
|
||||
|
||||
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.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 });
|
||||
});
|
||||
}
|
||||
else {
|
||||
scope.$emit('ScheduleReady');
|
||||
}
|
||||
};
|
||||
}]);
|
||||
79
awx/ui/static/js/lists/CustomInventory.js
Normal file
79
awx/ui/static/js/lists/CustomInventory.js
Normal file
@ -0,0 +1,79 @@
|
||||
/*********************************************
|
||||
* Copyright (c) 2014 AnsibleWorks, Inc.
|
||||
*
|
||||
* Credentials.js
|
||||
* List view object for Credential data model.
|
||||
*
|
||||
* @dict
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
angular.module('CustomInventoryListDefinition', [])
|
||||
.value('CustomInventoryList', {
|
||||
|
||||
name: 'custum_inventories',
|
||||
iterator: 'custom_inventory',
|
||||
selectTitle: 'Add custom inventory',
|
||||
editTitle: 'Custom Inventories',
|
||||
selectInstructions: "<p>Select existing credentials by clicking each credential or checking the related checkbox. When " +
|
||||
"finished, click the blue <em>Select</em> button, located bottom right.</p> <p>Create a brand new credential by clicking " +
|
||||
"the <i class=\"fa fa-plus\"></i> button.</p><div class=\"popover-footer\"><span class=\"key\">esc</span> or click to close</div>",
|
||||
index: false,
|
||||
hover: true,
|
||||
|
||||
fields: {
|
||||
name: {
|
||||
key: true,
|
||||
label: 'Name',
|
||||
columnClass: 'col-md-3 col-sm-9 col-xs-9',
|
||||
modalColumnClass: 'col-md-8'
|
||||
},
|
||||
description: {
|
||||
label: 'Description',
|
||||
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: {
|
||||
add: {
|
||||
mode: 'all', // One of: edit, select, all
|
||||
ngClick: 'addCustomInv()',
|
||||
awToolTip: 'Create a new credential'
|
||||
},
|
||||
stream: {
|
||||
ngClick: "showActivity()",
|
||||
awToolTip: "View Activity Stream",
|
||||
mode: 'edit'
|
||||
}
|
||||
},
|
||||
|
||||
fieldActions: {
|
||||
edit: {
|
||||
ngClick: "editCredential(credential.id)",
|
||||
icon: 'fa-edit',
|
||||
label: 'Edit',
|
||||
"class": 'btn-sm',
|
||||
awToolTip: 'Edit credential',
|
||||
dataPlacement: 'top'
|
||||
},
|
||||
|
||||
"delete": {
|
||||
ngClick: "deleteCredential(credential.id, credential.name)",
|
||||
icon: 'fa-trash',
|
||||
label: 'Delete',
|
||||
"class": 'btn-sm',
|
||||
awToolTip: 'Delete credential',
|
||||
dataPlacement: 'top'
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -89,6 +89,7 @@
|
||||
<script src="{{ STATIC_URL }}js/forms/Hosts.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/forms/Groups.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/forms/Credentials.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/forms/CustomInventory.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/forms/JobTemplates.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/forms/Jobs.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/forms/Projects.js"></script>
|
||||
@ -114,6 +115,7 @@
|
||||
<script src="{{ STATIC_URL }}js/lists/InventoryGroups.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/lists/InventoryHosts.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/lists/Credentials.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/lists/CustomInventory.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/lists/JobTemplates.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/lists/PortalJobTemplates.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/lists/Projects.js"></script>
|
||||
@ -133,6 +135,7 @@
|
||||
<script src="{{ STATIC_URL }}js/helpers/SocketHelper.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/helpers/LoadConfig.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/helpers/ConfigureTower.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/helpers/CustomInventory.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/helpers/refresh-related.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/helpers/related-search.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/helpers/refresh.js"></script>
|
||||
@ -196,8 +199,9 @@
|
||||
|
||||
<a href="" id="mobile_about" ng-click ="viewAboutTower()" ng-hide="portalMode===true">About Tower</a> </li>
|
||||
<a href="" id="mobile_view_user" ng-click="viewCurrentUser()" ng-hide="portalMode===true">Account Settings</a></li>
|
||||
<a id="main_configure_tower" ng-click="configureTower()" ng-show="user_is_superuser" href="" ng-hide="portalMode===true">Configure Tower</a></li>
|
||||
<a href="https://ansibleworks.zendesk.com/anonymous_requests/new" id="mobile_contact_support" target="_blank" ng-hide="portalMode===true">Contact Support</a></li>
|
||||
<a id="mobile_custom_inv" ng-click="createCustomInv()" ng-show="user_is_superuser" href="" ng-hide="portalMode===true">Inventory Script</a></li>
|
||||
<a id="mobile_configure_tower" ng-click="configureTower()" ng-show="user_is_superuser" href="" ng-hide="portalMode===true">Management Jobs</a></li>
|
||||
<a id="mobile_munin" target="_blank" ng-show="user_is_superuser" href="/munin" ng-hide="portalMode===true">Monitor Tower</a></li>
|
||||
<a href="#portal" id="mobile_portal_link" ng-hide="portalMode===true">Portal Mode</a></li>
|
||||
<a href="" id="mobile_view_license" ng-click="viewLicense()" ng-hide="portalMode===true">View License</a></li>
|
||||
@ -237,8 +241,9 @@
|
||||
<ul class="nav navbar-nav" id="account-submenu">
|
||||
<li><a href="" id="main_about" ng-click ="viewAboutTower()" ng-hide="portalMode===true">About Tower</a> </li>
|
||||
<li><a id="main_view_user" href="" ng-click="viewCurrentUser()" ng-hide="portalMode===true">Account Settings</a></li>
|
||||
<li><a id="main_configure_tower" ng-click="configureTower()" ng-show="user_is_superuser" href="" ng-hide="portalMode===true">Configure Tower</a></li>
|
||||
<li><a id="main_contact_support" target="_blank" href="https://ansibleworks.zendesk.com/anonymous_requests/new" ng-hide="portalMode===true">Contact Support</a></li>
|
||||
<li> <a id="main_custom_inv" ng-click="createCustomInv()" ng-show="user_is_superuser" href="" ng-hide="portalMode===true">Inventory Script</a></li>
|
||||
<li><a id="main_configure_tower" ng-click="configureTower()" ng-show="user_is_superuser" href="" ng-hide="portalMode===true">Management Jobs</a></li>
|
||||
<li><a id="main_munin" target="_blank" ng-show="user_is_superuser" href="/munin" ng-hide="portalMode===true">Monitor Tower</a></li>
|
||||
<li><a href="#portal" id="main_view_portal_link" >Portal Mode</a></li>
|
||||
<li><a id="main_view_license" href="" ng-click="viewLicense()" ng-hide="portalMode===true">View License</a></li>
|
||||
@ -256,8 +261,9 @@
|
||||
<ul class="dropdown-menu" id="account-submenu">
|
||||
<li><a href="" id="main_about" ng-click ="viewAboutTower()" ng-hide="portalMode===true">About Tower</a> </li>
|
||||
<li><a id="main_view_user" href="" ng-click="viewCurrentUser()" ng-hide="portalMode===true">Account Settings</a></li>
|
||||
<li><a id="configure_tower" ng-click="configureTower()" ng-show="user_is_superuser" href="" ng-hide="portalMode===true">Configure Tower</a></li>
|
||||
<li><a id="main_contact_support" target="_blank" href="https://ansibleworks.zendesk.com/anonymous_requests/new" ng-hide="portalMode===true">Contact Support</a></li>
|
||||
<li> <a id="main_custom_inv" ng-click="createCustomInv()" ng-show="user_is_superuser" href="" ng-hide="portalMode===true">Inventory Script</a></li>
|
||||
<li><a id="configure_tower" ng-click="configureTower()" ng-show="user_is_superuser" href="" ng-hide="portalMode===true">Management Jobs</a></li>
|
||||
<li><a id="main_munin" target="_blank" ng-show="user_is_superuser" href="/munin" ng-hide="portalMode===true">Monitor Tower</a></li>
|
||||
<li><a href="#portal" id="main_view_portal_link" ng-hide="portalMode===true">Portal Mode</a></li>
|
||||
<li><a id="main_view_license" href="" ng-click="viewLicense()" ng-hide="portalMode===true">View License</a></li>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user