mirror of
https://github.com/ansible/awx.git
synced 2026-05-15 05:17:36 -02:30
demodalizing inventory scripts
and refactoring to use es6 modules
This commit is contained in:
@@ -29,6 +29,7 @@ import {CredentialsAdd, CredentialsEdit, CredentialsList} from './controllers/Cr
|
|||||||
import {JobsListController} from './controllers/Jobs';
|
import {JobsListController} from './controllers/Jobs';
|
||||||
import {PortalController} from './controllers/Portal';
|
import {PortalController} from './controllers/Portal';
|
||||||
import systemTracking from './system-tracking/main';
|
import systemTracking from './system-tracking/main';
|
||||||
|
import inventoryScripts from './inventory-scripts/main';
|
||||||
import routeExtensions from './shared/route-extensions/main';
|
import routeExtensions from './shared/route-extensions/main';
|
||||||
import breadcrumbs from './shared/breadcrumbs/main';
|
import breadcrumbs from './shared/breadcrumbs/main';
|
||||||
|
|
||||||
@@ -67,6 +68,7 @@ import './shared/Socket';
|
|||||||
import './job-templates/main';
|
import './job-templates/main';
|
||||||
import './shared/features/main';
|
import './shared/features/main';
|
||||||
|
|
||||||
|
|
||||||
/*#if DEBUG#*/
|
/*#if DEBUG#*/
|
||||||
import {__deferLoadIfEnabled} from './debug';
|
import {__deferLoadIfEnabled} from './debug';
|
||||||
__deferLoadIfEnabled();
|
__deferLoadIfEnabled();
|
||||||
@@ -81,6 +83,7 @@ var tower = angular.module('Tower', [
|
|||||||
browserData.name,
|
browserData.name,
|
||||||
breadcrumbs.name,
|
breadcrumbs.name,
|
||||||
systemTracking.name,
|
systemTracking.name,
|
||||||
|
inventoryScripts.name,
|
||||||
setupMenu.name,
|
setupMenu.name,
|
||||||
mainMenu.name,
|
mainMenu.name,
|
||||||
dashboard.name,
|
dashboard.name,
|
||||||
@@ -104,7 +107,6 @@ var tower = angular.module('Tower', [
|
|||||||
'PaginationHelpers',
|
'PaginationHelpers',
|
||||||
'RefreshHelper',
|
'RefreshHelper',
|
||||||
'AdminListDefinition',
|
'AdminListDefinition',
|
||||||
'CustomInventoryListDefinition',
|
|
||||||
'AWDirectives',
|
'AWDirectives',
|
||||||
'AdhocFormDefinition',
|
'AdhocFormDefinition',
|
||||||
'InventoriesListDefinition',
|
'InventoriesListDefinition',
|
||||||
@@ -183,8 +185,6 @@ var tower = angular.module('Tower', [
|
|||||||
'PortalJobsListDefinition',
|
'PortalJobsListDefinition',
|
||||||
'ConfigureTowerHelper',
|
'ConfigureTowerHelper',
|
||||||
'ConfigureTowerJobsListDefinition',
|
'ConfigureTowerJobsListDefinition',
|
||||||
'CreateCustomInventoryHelper',
|
|
||||||
'CustomInventoryListDefinition',
|
|
||||||
'AdhocHelper',
|
'AdhocHelper',
|
||||||
'features',
|
'features',
|
||||||
'longDateFilter'
|
'longDateFilter'
|
||||||
@@ -896,6 +896,17 @@ var tower = angular.module('Tower', [
|
|||||||
}
|
}
|
||||||
}).
|
}).
|
||||||
|
|
||||||
|
// when('/inventory_scripts', {
|
||||||
|
// name: 'inventoryScriptsList',
|
||||||
|
// templateUrl: urlPrefix + 'partials/inventory_scripts.html',
|
||||||
|
// controller: InventoryScriptsList,
|
||||||
|
// resolve: {
|
||||||
|
// features: ['FeaturesService', function(FeaturesService) {
|
||||||
|
// return FeaturesService.get();
|
||||||
|
// }]
|
||||||
|
// }
|
||||||
|
// }).
|
||||||
|
|
||||||
when('/license', {
|
when('/license', {
|
||||||
name: 'license',
|
name: 'license',
|
||||||
templateUrl: urlPrefix + 'partials/license.html',
|
templateUrl: urlPrefix + 'partials/license.html',
|
||||||
@@ -933,9 +944,9 @@ var tower = angular.module('Tower', [
|
|||||||
}])
|
}])
|
||||||
|
|
||||||
.run(['$compile', '$cookieStore', '$rootScope', '$log', 'CheckLicense', '$location', 'Authorization', 'LoadBasePaths', 'Timer', 'ClearScope', 'HideStream', 'Socket',
|
.run(['$compile', '$cookieStore', '$rootScope', '$log', 'CheckLicense', '$location', 'Authorization', 'LoadBasePaths', 'Timer', 'ClearScope', 'HideStream', 'Socket',
|
||||||
'LoadConfig', 'Store', 'ShowSocketHelp', 'AboutAnsibleHelp', 'ConfigureTower', 'CreateCustomInventory',
|
'LoadConfig', 'Store', 'ShowSocketHelp', 'AboutAnsibleHelp', 'ConfigureTower',
|
||||||
function ($compile, $cookieStore, $rootScope, $log, CheckLicense, $location, Authorization, LoadBasePaths, Timer, ClearScope, HideStream, Socket,
|
function ($compile, $cookieStore, $rootScope, $log, CheckLicense, $location, Authorization, LoadBasePaths, Timer, ClearScope, HideStream, Socket,
|
||||||
LoadConfig, Store, ShowSocketHelp, AboutAnsibleHelp, ConfigureTower, CreateCustomInventory) {
|
LoadConfig, Store, ShowSocketHelp, AboutAnsibleHelp, ConfigureTower) {
|
||||||
|
|
||||||
|
|
||||||
var sock;
|
var sock;
|
||||||
@@ -1150,12 +1161,6 @@ var tower = angular.module('Tower', [
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$rootScope.createCustomInv = function(){
|
|
||||||
CreateCustomInventory({
|
|
||||||
parent_scope: $rootScope
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
}); // end of 'ConfigReady'
|
}); // end of 'ConfigReady'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
import ActivityDetail from "./forms/ActivityDetail";
|
import ActivityDetail from "./forms/ActivityDetail";
|
||||||
import Credentials from "./forms/Credentials";
|
import Credentials from "./forms/Credentials";
|
||||||
import Adhoc from "./forms/Adhoc";
|
import Adhoc from "./forms/Adhoc";
|
||||||
import CustomInventory from "./forms/CustomInventory";
|
|
||||||
import EventsViewer from "./forms/EventsViewer";
|
import EventsViewer from "./forms/EventsViewer";
|
||||||
import Groups from "./forms/Groups";
|
import Groups from "./forms/Groups";
|
||||||
import HostGroups from "./forms/HostGroups";
|
import HostGroups from "./forms/HostGroups";
|
||||||
@@ -37,7 +36,6 @@ export
|
|||||||
{ ActivityDetail,
|
{ ActivityDetail,
|
||||||
Credentials,
|
Credentials,
|
||||||
Adhoc,
|
Adhoc,
|
||||||
CustomInventory,
|
|
||||||
EventsViewer,
|
EventsViewer,
|
||||||
Groups,
|
Groups,
|
||||||
HostGroups,
|
HostGroups,
|
||||||
|
|||||||
@@ -1,78 +0,0 @@
|
|||||||
/*************************************************
|
|
||||||
* Copyright (c) 2015 Ansible, Inc.
|
|
||||||
*
|
|
||||||
* All Rights Reserved
|
|
||||||
*************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ngdoc function
|
|
||||||
* @name forms.function:CustomInventory
|
|
||||||
* @description This form is for adding/editing an organization
|
|
||||||
*/
|
|
||||||
|
|
||||||
export default
|
|
||||||
angular.module('CustomInventoryFormDefinition', [])
|
|
||||||
.value('CustomInventoryForm', {
|
|
||||||
|
|
||||||
addTitle: 'Create Custom Inventory', //Title in add mode
|
|
||||||
editTitle: '{{ name }}', //Title in edit mode
|
|
||||||
name: 'custom_inventory', //entity or model name in singular form
|
|
||||||
well: false,
|
|
||||||
showActions: false,
|
|
||||||
|
|
||||||
fields: {
|
|
||||||
name: {
|
|
||||||
label: 'Name',
|
|
||||||
type: 'text',
|
|
||||||
addRequired: true,
|
|
||||||
editRequired: true,
|
|
||||||
capitalize: false
|
|
||||||
},
|
|
||||||
description: {
|
|
||||||
label: 'Description',
|
|
||||||
type: 'text',
|
|
||||||
addRequired: false,
|
|
||||||
editRequired: false
|
|
||||||
},
|
|
||||||
organization: {
|
|
||||||
label: 'Organization',
|
|
||||||
type: 'lookup',
|
|
||||||
awRequiredWhen: {
|
|
||||||
variable: "orgrequired",
|
|
||||||
init: true
|
|
||||||
},
|
|
||||||
sourceModel: 'organization',
|
|
||||||
sourceField: 'name',
|
|
||||||
ngClick: 'lookUpOrganization()'
|
|
||||||
},
|
|
||||||
script: {
|
|
||||||
label: 'Custom Script',
|
|
||||||
type: 'textarea',
|
|
||||||
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. " +
|
|
||||||
"<br><br> Script must begin with a hashbang sequence: i.e.... #!/usr/bin/env python</p>",
|
|
||||||
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
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}); //OrganizationForm
|
|
||||||
@@ -10,9 +10,7 @@ import './lists';
|
|||||||
import AboutAnsible from "./helpers/AboutAnsible";
|
import AboutAnsible from "./helpers/AboutAnsible";
|
||||||
import Access from "./helpers/Access";
|
import Access from "./helpers/Access";
|
||||||
import Children from "./helpers/Children";
|
import Children from "./helpers/Children";
|
||||||
import ConfigureTower from "./helpers/ConfigureTower";
|
|
||||||
import Credentials from "./helpers/Credentials";
|
import Credentials from "./helpers/Credentials";
|
||||||
import CustomInventory from "./helpers/CustomInventory";
|
|
||||||
import EventViewer from "./helpers/EventViewer";
|
import EventViewer from "./helpers/EventViewer";
|
||||||
import Events from "./helpers/Events";
|
import Events from "./helpers/Events";
|
||||||
import Groups from "./helpers/Groups";
|
import Groups from "./helpers/Groups";
|
||||||
@@ -51,9 +49,7 @@ export
|
|||||||
{ AboutAnsible,
|
{ AboutAnsible,
|
||||||
Access,
|
Access,
|
||||||
Children,
|
Children,
|
||||||
ConfigureTower,
|
|
||||||
Credentials,
|
Credentials,
|
||||||
CustomInventory,
|
|
||||||
EventViewer,
|
EventViewer,
|
||||||
Events,
|
Events,
|
||||||
Groups,
|
Groups,
|
||||||
|
|||||||
@@ -1,362 +0,0 @@
|
|||||||
/*************************************************
|
|
||||||
* Copyright (c) 2015 Ansible, Inc.
|
|
||||||
*
|
|
||||||
* All Rights Reserved
|
|
||||||
*************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ngdoc function
|
|
||||||
* @name helpers.function:CustomInventory
|
|
||||||
* @description
|
|
||||||
* Schedules Helper
|
|
||||||
*
|
|
||||||
* Display the scheduler widget in a dialog
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
import listGenerator from '../shared/list-generator/main';
|
|
||||||
|
|
||||||
export default
|
|
||||||
angular.module('CreateCustomInventoryHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', 'SearchHelper', 'PaginationHelpers', listGenerator.name, 'ModalDialog',
|
|
||||||
'GeneratorHelpers', 'CustomInventoryFormDefinition'])
|
|
||||||
|
|
||||||
.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(),
|
|
||||||
callback = 'OpenConfig',
|
|
||||||
defaultUrl = GetBasePath('inventory_scripts'),
|
|
||||||
list = CustomInventoryList,
|
|
||||||
view = GenerateList,
|
|
||||||
buttons = [
|
|
||||||
{
|
|
||||||
"label": "Close",
|
|
||||||
"onClick": function() {
|
|
||||||
// $(this).dialog('close');
|
|
||||||
scope.cancelConfigure();
|
|
||||||
},
|
|
||||||
"icon": "fa-times",
|
|
||||||
"class": "btn btn-default",
|
|
||||||
"id": "script-close-button"
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
scope.cleanupJob = true;
|
|
||||||
|
|
||||||
if(scope.removeOpenConfig) {
|
|
||||||
scope.removeOpenConfig();
|
|
||||||
}
|
|
||||||
scope.removeOpenConfig = scope.$on('OpenConfig', function() {
|
|
||||||
$('#custom-script-dialog').dialog('open');
|
|
||||||
$('#script-close-button').focus();
|
|
||||||
$('#script-close-button').blur();
|
|
||||||
});
|
|
||||||
|
|
||||||
view.inject( list, {
|
|
||||||
id : 'custom-script-dialog',
|
|
||||||
mode: 'edit',
|
|
||||||
scope: scope,
|
|
||||||
breadCrumbs: false,
|
|
||||||
activityStream: false,
|
|
||||||
showSearch: true
|
|
||||||
});
|
|
||||||
|
|
||||||
SearchInit({
|
|
||||||
scope: scope,
|
|
||||||
set: 'source_scripts' , // 'custom_inventories',
|
|
||||||
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: 'custom-script-dialog',
|
|
||||||
title: 'Inventory Scripts',
|
|
||||||
target: 'custom-script-dialog',
|
|
||||||
scope: scope,
|
|
||||||
buttons: buttons,
|
|
||||||
width: 700,
|
|
||||||
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 {
|
|
||||||
$('#custom-script-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.editCustomInv = function(id){
|
|
||||||
CustomInventoryEdit({
|
|
||||||
scope: scope,
|
|
||||||
id: id
|
|
||||||
});
|
|
||||||
};
|
|
||||||
scope.deleteCustomInv = function(id, name){
|
|
||||||
|
|
||||||
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 });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
var bodyHtml = "<div class=\"alert alert-info\">Are you sure you want to delete " + name + "?</div>";
|
|
||||||
Prompt({
|
|
||||||
hdr: 'Delete',
|
|
||||||
body: bodyHtml,
|
|
||||||
action: action
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
scope.addCustomInv = function(){
|
|
||||||
CustomInventoryAdd({
|
|
||||||
scope: scope
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
}])
|
|
||||||
|
|
||||||
|
|
||||||
.factory('CustomInventoryAdd', ['$compile','SchedulerInit', 'Rest', 'Wait', 'CustomInventoryList', 'CustomInventoryForm', 'ProcessErrors', 'GetBasePath', 'Empty', 'GenerateForm',
|
|
||||||
'SearchInit' , 'PaginateInit', 'generateList', 'LookUpInit', 'OrganizationList',
|
|
||||||
function($compile, SchedulerInit, Rest, Wait, CustomInventoryList, CustomInventoryForm, ProcessErrors, GetBasePath, Empty, GenerateForm,
|
|
||||||
SearchInit, PaginateInit, GenerateList, LookUpInit, OrganizationList) {
|
|
||||||
return function(params) {
|
|
||||||
var scope = params.scope,
|
|
||||||
generator = GenerateForm,
|
|
||||||
form = CustomInventoryForm,
|
|
||||||
view = GenerateList,
|
|
||||||
list = CustomInventoryList,
|
|
||||||
url = GetBasePath('inventory_scripts');
|
|
||||||
|
|
||||||
generator.inject(form, { id:'custom-script-dialog', mode: 'add' , scope:scope, related: false, breadCrumbs: false});
|
|
||||||
generator.reset();
|
|
||||||
|
|
||||||
LookUpInit({
|
|
||||||
url: GetBasePath('organization'),
|
|
||||||
scope: scope,
|
|
||||||
form: form,
|
|
||||||
// hdr: "Select Custom Inventory",
|
|
||||||
list: OrganizationList,
|
|
||||||
field: 'organization',
|
|
||||||
input_type: 'radio'
|
|
||||||
});
|
|
||||||
|
|
||||||
// Save
|
|
||||||
scope.formSave = function () {
|
|
||||||
generator.clearApiErrors();
|
|
||||||
Wait('start');
|
|
||||||
Rest.setUrl(url);
|
|
||||||
Rest.post({ name: scope.name, description: scope.description, organization: scope.organization, 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: 'source_scripts', //'custom_inventories',
|
|
||||||
list: list,
|
|
||||||
url: url
|
|
||||||
});
|
|
||||||
PaginateInit({
|
|
||||||
scope: scope,
|
|
||||||
list: list,
|
|
||||||
url: url
|
|
||||||
});
|
|
||||||
|
|
||||||
scope.search(list.iterator);
|
|
||||||
Wait('stop');
|
|
||||||
Wait('stop');
|
|
||||||
|
|
||||||
})
|
|
||||||
.error(function (data, status) {
|
|
||||||
ProcessErrors(scope, data, status, form, { hdr: 'Error!',
|
|
||||||
msg: 'Failed to add new inventory script. POST returned status: ' + status });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Cancel
|
|
||||||
scope.formReset = function () {
|
|
||||||
generator.reset();
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}])
|
|
||||||
|
|
||||||
.factory('CustomInventoryEdit', ['$compile','CustomInventoryList', 'Rest', 'Wait', 'generateList', 'CustomInventoryForm', 'ProcessErrors', 'GetBasePath', 'Empty', 'GenerateForm',
|
|
||||||
'SearchInit', 'PaginateInit', '$routeParams', 'OrganizationList', 'LookUpInit',
|
|
||||||
function($compile, CustomInventoryList, Rest, Wait, GenerateList, CustomInventoryForm, ProcessErrors, GetBasePath, Empty, GenerateForm,
|
|
||||||
SearchInit, PaginateInit, $routeParams, OrganizationList, LookUpInit) {
|
|
||||||
return function(params) {
|
|
||||||
var scope = params.scope,
|
|
||||||
id = params.id,
|
|
||||||
generator = GenerateForm,
|
|
||||||
form = CustomInventoryForm,
|
|
||||||
view = GenerateList,
|
|
||||||
list = CustomInventoryList,
|
|
||||||
master = {},
|
|
||||||
url = GetBasePath('inventory_scripts');
|
|
||||||
|
|
||||||
generator.inject(form, {
|
|
||||||
id:'custom-script-dialog',
|
|
||||||
mode: 'edit' ,
|
|
||||||
scope:scope,
|
|
||||||
related: false,
|
|
||||||
breadCrumbs: false,
|
|
||||||
activityStream: false
|
|
||||||
});
|
|
||||||
generator.reset();
|
|
||||||
LookUpInit({
|
|
||||||
url: GetBasePath('organization'),
|
|
||||||
scope: scope,
|
|
||||||
form: form,
|
|
||||||
// hdr: "Select Custom Inventory",
|
|
||||||
list: OrganizationList,
|
|
||||||
field: 'organization',
|
|
||||||
input_type: 'radio'
|
|
||||||
});
|
|
||||||
|
|
||||||
// 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];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (form.fields[fld].sourceModel && data.summary_fields &&
|
|
||||||
data.summary_fields[form.fields[fld].sourceModel]) {
|
|
||||||
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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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, organization: scope.organization, 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: 'source_scripts', //'custom_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. PUT returned status: ' + status });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
scope.formReset = function () {
|
|
||||||
generator.reset();
|
|
||||||
for (var fld in master) {
|
|
||||||
scope[fld] = master[fld];
|
|
||||||
}
|
|
||||||
scope.organization_name = master.organization_name;
|
|
||||||
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}]);
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* All Rights Reserved
|
* All Rights Reserved
|
||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -235,8 +235,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
|
|||||||
* TODO: Document
|
* TODO: Document
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
.factory('SourceChange', ['GetBasePath', 'CredentialList', 'LookUpInit', 'Empty', 'Wait', 'ParseTypeChange', 'CustomInventoryList', 'CreateSelect2',
|
.factory('SourceChange', ['GetBasePath', 'CredentialList', 'LookUpInit', 'Empty', 'Wait', 'ParseTypeChange', 'inventoryScriptsListObject', 'CreateSelect2',
|
||||||
function (GetBasePath, CredentialList, LookUpInit, Empty, Wait, ParseTypeChange, CustomInventoryList, CreateSelect2) {
|
function (GetBasePath, CredentialList, LookUpInit, Empty, Wait, ParseTypeChange, inventoryScriptsListObject, CreateSelect2) {
|
||||||
return function (params) {
|
return function (params) {
|
||||||
|
|
||||||
var scope = params.scope,
|
var scope = params.scope,
|
||||||
@@ -289,7 +289,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
|
|||||||
scope: scope,
|
scope: scope,
|
||||||
form: form,
|
form: form,
|
||||||
hdr: "Select Custom Inventory",
|
hdr: "Select Custom Inventory",
|
||||||
list: CustomInventoryList,
|
list: inventoryScriptsListObject,
|
||||||
field: 'source_script',
|
field: 'source_script',
|
||||||
input_type: 'radio'
|
input_type: 'radio'
|
||||||
});
|
});
|
||||||
|
|||||||
67
awx/ui/client/src/inventory-scripts/add/add.controller.js
Normal file
67
awx/ui/client/src/inventory-scripts/add/add.controller.js
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
export default
|
||||||
|
[ '$compile','SchedulerInit', 'Rest', 'Wait',
|
||||||
|
'inventoryScriptsFormObject', 'ProcessErrors', 'GetBasePath', 'Empty',
|
||||||
|
'GenerateForm', 'SearchInit' , 'PaginateInit',
|
||||||
|
'LookUpInit', 'OrganizationList', '$scope', 'transitionTo',
|
||||||
|
function(
|
||||||
|
$compile, SchedulerInit, Rest, Wait,
|
||||||
|
inventoryScriptsFormObject, ProcessErrors, GetBasePath, Empty,
|
||||||
|
GenerateForm, SearchInit, PaginateInit,
|
||||||
|
LookUpInit, OrganizationList, $scope, transitionTo
|
||||||
|
) {
|
||||||
|
var scope = $scope,
|
||||||
|
generator = GenerateForm,
|
||||||
|
form = inventoryScriptsFormObject,
|
||||||
|
url = GetBasePath('inventory_scripts');
|
||||||
|
|
||||||
|
generator.inject(form, {
|
||||||
|
mode: 'add' ,
|
||||||
|
scope:scope,
|
||||||
|
related: false
|
||||||
|
});
|
||||||
|
generator.reset();
|
||||||
|
|
||||||
|
LookUpInit({
|
||||||
|
url: GetBasePath('organization'),
|
||||||
|
scope: scope,
|
||||||
|
form: form,
|
||||||
|
list: OrganizationList,
|
||||||
|
field: 'organization',
|
||||||
|
input_type: 'radio'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Save
|
||||||
|
scope.formSave = function () {
|
||||||
|
generator.clearApiErrors();
|
||||||
|
Wait('start');
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.post({
|
||||||
|
name: scope.name,
|
||||||
|
description: scope.description,
|
||||||
|
organization: scope.organization,
|
||||||
|
script: scope.script
|
||||||
|
})
|
||||||
|
.success(function () {
|
||||||
|
transitionTo('inventoryScriptsList');
|
||||||
|
Wait('stop');
|
||||||
|
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors(scope, data, status, form, { hdr: 'Error!',
|
||||||
|
msg: 'Failed to add new inventory script. POST returned status: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Cancel
|
||||||
|
scope.formReset = function () {
|
||||||
|
generator.reset();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
];
|
||||||
12
awx/ui/client/src/inventory-scripts/add/add.partial.html
Normal file
12
awx/ui/client/src/inventory-scripts/add/add.partial.html
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<breadcrumbs>
|
||||||
|
<breadcrumb path="/setup" title="Setup"></breadcrumb>
|
||||||
|
<breadcrumb path="/inventory_scripts" title="Inventory Scripts"></breadcrumb>
|
||||||
|
<breadcrumb
|
||||||
|
path="/inventory_scripts/add"
|
||||||
|
title="Create Inventory Script">
|
||||||
|
</breadcrumb>
|
||||||
|
</breadcrumbs>
|
||||||
|
|
||||||
|
<div class="tab-pane" id="inventory_scripts_add">
|
||||||
|
<div ng-cloak id="htmlTemplate"></div>
|
||||||
|
</div>
|
||||||
17
awx/ui/client/src/inventory-scripts/add/add.route.js
Normal file
17
awx/ui/client/src/inventory-scripts/add/add.route.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'inventoryScriptsAdd',
|
||||||
|
route: '/inventory_scripts/add',
|
||||||
|
templateUrl: '/static/js/inventory-scripts/add/add.partial.html',
|
||||||
|
controller: 'addController',
|
||||||
|
resolve: {
|
||||||
|
features: ['FeaturesService', function(FeaturesService) {
|
||||||
|
return FeaturesService.get();
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
||||||
17
awx/ui/client/src/inventory-scripts/add/main.js
Normal file
17
awx/ui/client/src/inventory-scripts/add/main.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
import route from './add.route';
|
||||||
|
import controller from './add.controller';
|
||||||
|
|
||||||
|
export default
|
||||||
|
angular.module('inventoryScriptsAdd', [])
|
||||||
|
.controller('addController', controller)
|
||||||
|
.config(['$routeProvider', function($routeProvider) {
|
||||||
|
var url = route.route;
|
||||||
|
delete route.route;
|
||||||
|
$routeProvider.when(url, route);
|
||||||
|
}]);
|
||||||
103
awx/ui/client/src/inventory-scripts/edit/edit.controller.js
Normal file
103
awx/ui/client/src/inventory-scripts/edit/edit.controller.js
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
export default
|
||||||
|
[ 'Rest', 'Wait',
|
||||||
|
'inventoryScriptsFormObject', 'ProcessErrors', 'GetBasePath',
|
||||||
|
'GenerateForm', 'SearchInit' , 'PaginateInit',
|
||||||
|
'LookUpInit', 'OrganizationList', 'inventory_script',
|
||||||
|
'$scope', 'transitionTo',
|
||||||
|
function(
|
||||||
|
Rest, Wait,
|
||||||
|
inventoryScriptsFormObject, ProcessErrors, GetBasePath,
|
||||||
|
GenerateForm, SearchInit, PaginateInit,
|
||||||
|
LookUpInit, OrganizationList, inventory_script,
|
||||||
|
$scope, transitionTo
|
||||||
|
) {
|
||||||
|
var generator = GenerateForm,
|
||||||
|
id = inventory_script.id,
|
||||||
|
form = inventoryScriptsFormObject,
|
||||||
|
master = {},
|
||||||
|
url = GetBasePath('inventory_scripts');
|
||||||
|
|
||||||
|
$scope.inventory_script = inventory_script;
|
||||||
|
generator.inject(form, {
|
||||||
|
mode: 'edit' ,
|
||||||
|
scope:$scope,
|
||||||
|
breadCrumbs: true,
|
||||||
|
related: false,
|
||||||
|
activityStream: false
|
||||||
|
});
|
||||||
|
generator.reset();
|
||||||
|
LookUpInit({
|
||||||
|
url: GetBasePath('organization'),
|
||||||
|
scope: $scope,
|
||||||
|
form: form,
|
||||||
|
// hdr: "Select Custom Inventory",
|
||||||
|
list: OrganizationList,
|
||||||
|
field: 'organization',
|
||||||
|
input_type: 'radio'
|
||||||
|
});
|
||||||
|
|
||||||
|
// 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];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (form.fields[fld].sourceModel && data.summary_fields &&
|
||||||
|
data.summary_fields[form.fields[fld].sourceModel]) {
|
||||||
|
$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];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Wait('stop');
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
||||||
|
msg: 'Failed to retrieve inventory script: ' + id + '. GET status: ' + status });
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.formSave = function () {
|
||||||
|
generator.clearApiErrors();
|
||||||
|
Wait('start');
|
||||||
|
Rest.setUrl(url+ id+'/');
|
||||||
|
Rest.put({
|
||||||
|
name: $scope.name,
|
||||||
|
description: $scope.description,
|
||||||
|
organization: $scope.organization,
|
||||||
|
script: $scope.script
|
||||||
|
})
|
||||||
|
.success(function () {
|
||||||
|
transitionTo('inventoryScriptsList');
|
||||||
|
Wait('stop');
|
||||||
|
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
||||||
|
msg: 'Failed to add new inventory script. PUT returned status: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.formReset = function () {
|
||||||
|
generator.reset();
|
||||||
|
for (var fld in master) {
|
||||||
|
$scope[fld] = master[fld];
|
||||||
|
}
|
||||||
|
$scope.organization_name = master.organization_name;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
];
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<breadcrumbs>
|
||||||
|
<breadcrumb path="/setup" title="Setup"></breadcrumb>
|
||||||
|
<breadcrumb path="/inventory_scripts" title="Inventory Scripts"></breadcrumb>
|
||||||
|
<breadcrumb path="/inventory_scripts/{{inventory_script.id}}" title="{{inventory_script.name}}" current="true"></breadcrumb>
|
||||||
|
</breadcrumbs>
|
||||||
|
|
||||||
|
<div class="tab-pane" id="inventory_scripts_edit">
|
||||||
|
<div ng-cloak id="htmlTemplate"></div>
|
||||||
|
</div>
|
||||||
44
awx/ui/client/src/inventory-scripts/edit/edit.route.js
Normal file
44
awx/ui/client/src/inventory-scripts/edit/edit.route.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'inventoryScriptsEdit',
|
||||||
|
route: '/inventory_scripts/:inventory_script',
|
||||||
|
templateUrl: '/static/js/inventory-scripts/edit/edit.partial.html',
|
||||||
|
controller: 'editController',
|
||||||
|
resolve: {
|
||||||
|
features: ['FeaturesService', function(FeaturesService) {
|
||||||
|
return FeaturesService.get();
|
||||||
|
}],
|
||||||
|
inventory_script:
|
||||||
|
[ '$route',
|
||||||
|
'$q',
|
||||||
|
'Rest',
|
||||||
|
'GetBasePath',
|
||||||
|
'ProcessErrors',
|
||||||
|
function($route, $q, rest, getBasePath, ProcessErrors) {
|
||||||
|
if ($route.current.hasModelKey('inventory_script')) {
|
||||||
|
return $q.when($route.current.params.model.inventory_script);
|
||||||
|
}
|
||||||
|
|
||||||
|
var inventoryScriptId = $route.current.params.inventory_script;
|
||||||
|
|
||||||
|
var url = getBasePath('inventory_scripts') + inventoryScriptId + '/';
|
||||||
|
rest.setUrl(url);
|
||||||
|
return rest.get()
|
||||||
|
.then(function(data) {
|
||||||
|
return data.data;
|
||||||
|
}).catch(function (response) {
|
||||||
|
ProcessErrors(null, response.data, response.status, null, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to get inventory script info. GET returned status: ' +
|
||||||
|
response.status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
};
|
||||||
17
awx/ui/client/src/inventory-scripts/edit/main.js
Normal file
17
awx/ui/client/src/inventory-scripts/edit/main.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
import route from './edit.route';
|
||||||
|
import controller from './edit.controller';
|
||||||
|
|
||||||
|
export default
|
||||||
|
angular.module('inventoryScriptsEdit', [])
|
||||||
|
.controller('editController', controller)
|
||||||
|
.config(['$routeProvider', function($routeProvider) {
|
||||||
|
var url = route.route;
|
||||||
|
delete route.route;
|
||||||
|
$routeProvider.when(url, route);
|
||||||
|
}]);
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name forms.function:CustomInventory
|
||||||
|
* @description This form is for adding/editing an organization
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default function() {
|
||||||
|
return {
|
||||||
|
|
||||||
|
// addTitle: 'Create Custom Inventory',
|
||||||
|
// editTitle: '{{ name }}',
|
||||||
|
// name: 'custom_inventory',
|
||||||
|
well: true,
|
||||||
|
showActions: true,
|
||||||
|
|
||||||
|
fields: {
|
||||||
|
name: {
|
||||||
|
label: 'Name',
|
||||||
|
type: 'text',
|
||||||
|
addRequired: true,
|
||||||
|
editRequired: true,
|
||||||
|
capitalize: false
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
label: 'Description',
|
||||||
|
type: 'text',
|
||||||
|
addRequired: false,
|
||||||
|
editRequired: false
|
||||||
|
},
|
||||||
|
organization: {
|
||||||
|
label: 'Organization',
|
||||||
|
type: 'lookup',
|
||||||
|
awRequiredWhen: {
|
||||||
|
variable: "orgrequired",
|
||||||
|
init: true
|
||||||
|
},
|
||||||
|
sourceModel: 'organization',
|
||||||
|
sourceField: 'name',
|
||||||
|
ngClick: 'lookUpOrganization()'
|
||||||
|
},
|
||||||
|
script: {
|
||||||
|
label: 'Custom Script',
|
||||||
|
type: 'textarea',
|
||||||
|
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. " +
|
||||||
|
"<br><br> Script must begin with a hashbang sequence: i.e.... #!/usr/bin/env python</p>",
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -3,24 +3,19 @@
|
|||||||
*
|
*
|
||||||
* All Rights Reserved
|
* All Rights Reserved
|
||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default
|
|
||||||
angular.module('CustomInventoryListDefinition', [])
|
|
||||||
.value('CustomInventoryList', {
|
|
||||||
|
|
||||||
name: 'source_scripts' , // 'custom_inventories',
|
export default function(){
|
||||||
iterator: 'source_script', //'custom_inventory',
|
return {
|
||||||
selectTitle: 'Add custom inventory',
|
name: 'inventory_scripts' ,
|
||||||
editTitle: 'Custom Inventories',
|
iterator: 'inventory_script',
|
||||||
index: false,
|
index: false,
|
||||||
hover: false,
|
hover: false,
|
||||||
|
|
||||||
fields: {
|
fields: {
|
||||||
name: {
|
name: {
|
||||||
key: true,
|
key: true,
|
||||||
noLink: true,
|
|
||||||
label: 'Name',
|
label: 'Name',
|
||||||
columnClass: 'col-md-3 col-sm-9 col-xs-9',
|
columnClass: 'col-md-3 col-sm-9 col-xs-9',
|
||||||
modalColumnClass: 'col-md-8'
|
modalColumnClass: 'col-md-8'
|
||||||
@@ -32,8 +27,7 @@ export default
|
|||||||
},
|
},
|
||||||
organization: {
|
organization: {
|
||||||
label: 'Organization',
|
label: 'Organization',
|
||||||
ngBind: 'source_script.summary_fields.organization.name',
|
ngBind: 'inventory_script.summary_fields.organization.name',
|
||||||
// linkTo: '/#/organizations/{{ custom_inventory.organization }}',
|
|
||||||
sourceModel: 'organization',
|
sourceModel: 'organization',
|
||||||
sourceField: 'name',
|
sourceField: 'name',
|
||||||
excludeModal: true,
|
excludeModal: true,
|
||||||
@@ -51,7 +45,7 @@ export default
|
|||||||
|
|
||||||
fieldActions: {
|
fieldActions: {
|
||||||
edit: {
|
edit: {
|
||||||
ngClick: "editCustomInv(source_script.id)",
|
ngClick: "editCustomInv(inventory_script.id)",
|
||||||
icon: 'fa-edit',
|
icon: 'fa-edit',
|
||||||
label: 'Edit',
|
label: 'Edit',
|
||||||
"class": 'btn-sm',
|
"class": 'btn-sm',
|
||||||
@@ -59,7 +53,7 @@ export default
|
|||||||
dataPlacement: 'top'
|
dataPlacement: 'top'
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
ngClick: "deleteCustomInv(source_script.id, source_script.name)",
|
ngClick: "deleteCustomInv(inventory_script.id, inventory_script.name)",
|
||||||
icon: 'fa-trash',
|
icon: 'fa-trash',
|
||||||
label: 'Delete',
|
label: 'Delete',
|
||||||
"class": 'btn-sm',
|
"class": 'btn-sm',
|
||||||
@@ -67,4 +61,5 @@ export default
|
|||||||
dataPlacement: 'top'
|
dataPlacement: 'top'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
}
|
||||||
79
awx/ui/client/src/inventory-scripts/list/list.controller.js
Normal file
79
awx/ui/client/src/inventory-scripts/list/list.controller.js
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
export default
|
||||||
|
[ '$rootScope','Wait', 'generateList', 'inventoryScriptsListObject',
|
||||||
|
'GetBasePath' , 'SearchInit' , 'PaginateInit',
|
||||||
|
'Rest' , 'ProcessErrors', 'Prompt', 'transitionTo',
|
||||||
|
function(
|
||||||
|
$rootScope,Wait, GenerateList, inventoryScriptsListObject,
|
||||||
|
GetBasePath, SearchInit, PaginateInit,
|
||||||
|
Rest, ProcessErrors, Prompt, transitionTo
|
||||||
|
) {
|
||||||
|
var scope = $rootScope.$new(),
|
||||||
|
defaultUrl = GetBasePath('inventory_scripts'),
|
||||||
|
list = inventoryScriptsListObject,
|
||||||
|
view = GenerateList;
|
||||||
|
|
||||||
|
view.inject( list, {
|
||||||
|
id : 'inventory_scripts',
|
||||||
|
mode: 'edit',
|
||||||
|
scope: scope,
|
||||||
|
breadCrumbs: false,
|
||||||
|
activityStream: false,
|
||||||
|
showSearch: true
|
||||||
|
});
|
||||||
|
|
||||||
|
SearchInit({
|
||||||
|
scope: scope,
|
||||||
|
set: 'inventory_scripts',
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
PaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
|
||||||
|
scope.search(list.iterator);
|
||||||
|
|
||||||
|
scope.editCustomInv = function(){
|
||||||
|
transitionTo('inventoryScriptsEdit', {
|
||||||
|
inventory_script: this.inventory_script
|
||||||
|
});
|
||||||
|
};
|
||||||
|
scope.deleteCustomInv = function(id, name){
|
||||||
|
|
||||||
|
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 });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var bodyHtml = "<div class=\"alert alert-info\">Are you sure you want to delete " + name + "?</div>";
|
||||||
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
|
body: bodyHtml,
|
||||||
|
action: action
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
scope.addCustomInv = function(){
|
||||||
|
transitionTo('inventoryScriptsAdd');
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
];
|
||||||
18
awx/ui/client/src/inventory-scripts/list/list.partial.html
Normal file
18
awx/ui/client/src/inventory-scripts/list/list.partial.html
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<breadcrumbs>
|
||||||
|
<breadcrumb path="/setup" title="Setup"></breadcrumb>
|
||||||
|
<breadcrumb path="/inventory_scripts" title="Inventory Scripts"></breadcrumb>
|
||||||
|
<breadcrumb
|
||||||
|
path="/inventory_scripts/add"
|
||||||
|
title="Create Inventory Script"
|
||||||
|
ng-if="mode == 'add'">
|
||||||
|
</breadcrumb>
|
||||||
|
<breadcrumb
|
||||||
|
path="/inventory_scripts/{{source_script.id}}"
|
||||||
|
title="{{inventory_scripts}}"
|
||||||
|
ng-if="organization_id">
|
||||||
|
</breadcrumb>
|
||||||
|
</breadcrumbs>
|
||||||
|
|
||||||
|
<div class="tab-pane" id="inventory_scripts">
|
||||||
|
<div ng-cloak id="htmlTemplate"></div>
|
||||||
|
</div>
|
||||||
17
awx/ui/client/src/inventory-scripts/list/list.route.js
Normal file
17
awx/ui/client/src/inventory-scripts/list/list.route.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'inventoryScriptsList',
|
||||||
|
route: '/inventory_scripts',
|
||||||
|
templateUrl: '/static/js/inventory-scripts/list/list.partial.html',
|
||||||
|
controller: 'listController',
|
||||||
|
resolve: {
|
||||||
|
features: ['FeaturesService', function(FeaturesService) {
|
||||||
|
return FeaturesService.get();
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
||||||
25
awx/ui/client/src/inventory-scripts/list/list.service.js
Normal file
25
awx/ui/client/src/inventory-scripts/list/list.service.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
var rest, getBasePath;
|
||||||
|
|
||||||
|
export default
|
||||||
|
[ 'Rest',
|
||||||
|
'GetBasePath',
|
||||||
|
function(_rest, _getBasePath) {
|
||||||
|
rest = _rest;
|
||||||
|
getBasePath = _getBasePath;
|
||||||
|
return deleteInventoryScript;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
function deleteInventoryScript(id) {
|
||||||
|
var url = getBasePath('inventory_scripts');
|
||||||
|
|
||||||
|
url = url + id;
|
||||||
|
rest.setUrl(url);
|
||||||
|
return rest.destroy();
|
||||||
|
}
|
||||||
17
awx/ui/client/src/inventory-scripts/list/main.js
Normal file
17
awx/ui/client/src/inventory-scripts/list/main.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
import route from './list.route';
|
||||||
|
import controller from './list.controller';
|
||||||
|
|
||||||
|
export default
|
||||||
|
angular.module('inventoryScriptsList', [])
|
||||||
|
.controller('listController', controller)
|
||||||
|
.config(['$routeProvider', function($routeProvider) {
|
||||||
|
var url = route.route;
|
||||||
|
delete route.route;
|
||||||
|
$routeProvider.when(url, route);
|
||||||
|
}]);
|
||||||
20
awx/ui/client/src/inventory-scripts/main.js
Normal file
20
awx/ui/client/src/inventory-scripts/main.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
import inventoryScriptsList from './list/main';
|
||||||
|
import inventoryScriptsAdd from './add/main';
|
||||||
|
import inventoryScriptsEdit from './edit/main';
|
||||||
|
import list from './inventory-scripts.list';
|
||||||
|
import form from './inventory-scripts.form';
|
||||||
|
|
||||||
|
export default
|
||||||
|
angular.module('inventoryScripts', [
|
||||||
|
inventoryScriptsList.name,
|
||||||
|
inventoryScriptsAdd.name,
|
||||||
|
inventoryScriptsEdit.name
|
||||||
|
])
|
||||||
|
.factory('inventoryScriptsListObject', list)
|
||||||
|
.factory('inventoryScriptsFormObject', form);
|
||||||
@@ -8,9 +8,7 @@ import Admins from "./lists/Admins";
|
|||||||
import CloudCredentials from "./lists/CloudCredentials";
|
import CloudCredentials from "./lists/CloudCredentials";
|
||||||
import CompletedJobs from "./lists/CompletedJobs";
|
import CompletedJobs from "./lists/CompletedJobs";
|
||||||
import AllJobs from "./lists/AllJobs";
|
import AllJobs from "./lists/AllJobs";
|
||||||
import ConfigureTowerJobs from "./lists/ConfigureTowerJobs";
|
|
||||||
import Credentials from "./lists/Credentials";
|
import Credentials from "./lists/Credentials";
|
||||||
import CustomInventory from "./lists/CustomInventory";
|
|
||||||
import Groups from "./lists/Groups";
|
import Groups from "./lists/Groups";
|
||||||
import HomeGroups from "./lists/HomeGroups";
|
import HomeGroups from "./lists/HomeGroups";
|
||||||
import HomeHosts from "./lists/HomeHosts";
|
import HomeHosts from "./lists/HomeHosts";
|
||||||
@@ -39,9 +37,7 @@ export
|
|||||||
CloudCredentials,
|
CloudCredentials,
|
||||||
CompletedJobs,
|
CompletedJobs,
|
||||||
AllJobs,
|
AllJobs,
|
||||||
ConfigureTowerJobs,
|
|
||||||
Credentials,
|
Credentials,
|
||||||
CustomInventory,
|
|
||||||
Groups,
|
Groups,
|
||||||
HomeGroups,
|
HomeGroups,
|
||||||
HomeHosts,
|
HomeHosts,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ export default
|
|||||||
angular.module('setupMenu',
|
angular.module('setupMenu',
|
||||||
[ 'AboutAnsibleHelpModal',
|
[ 'AboutAnsibleHelpModal',
|
||||||
'ConfigureTowerHelper',
|
'ConfigureTowerHelper',
|
||||||
'CreateCustomInventoryHelper',
|
|
||||||
icon.name
|
icon.name
|
||||||
])
|
])
|
||||||
.config(['$routeProvider', function($routeProvider) {
|
.config(['$routeProvider', function($routeProvider) {
|
||||||
@@ -13,4 +12,3 @@ export default
|
|||||||
delete route.route;
|
delete route.route;
|
||||||
$routeProvider.when(url, route);
|
$routeProvider.when(url, route);
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|||||||
@@ -66,19 +66,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<button class="SetupItem SetupItem--button SetupItem--aside HoverIcon Media" ng-click="showInventoryScriptsModal()" ng-if="user_is_superuser">
|
<a link-to="inventoryScriptsList" class="SetupItem SetupItem--aside HoverIcon Media">
|
||||||
<div class="SetupItem-firefoxFlexButtonFix">
|
<i class="HoverIcon-icon HoverIcon-icon--opacity HoverIcon-icon--color Media-figure SetupItem-icon SetupItem-icon--aside ">
|
||||||
<i class="HoverIcon-icon HoverIcon-icon--opacity HoverIcon-icon--color Media-figure SetupItem-icon SetupItem-icon--aside ">
|
<aw-icon name="InventoryScripts"></aw-icon>
|
||||||
<aw-icon name="InventoryScripts"></aw-icon>
|
</i>
|
||||||
</i>
|
<div class="Media-block">
|
||||||
<div class="Media-block">
|
<h4 class="SetupItem-title SetupItem-title--aside">Inventory Scripts</h4>
|
||||||
<h4 class="SetupItem-title SetupItem-title--aside">Inventory Scripts</h4>
|
<p class="SetupItem-description SetupItem-description--aside">
|
||||||
<p class="SetupItem-description SetupItem-description--aside">
|
Create and edit scripts to dynamically load hosts from any source.
|
||||||
Create and edit scripts to dynamically load hosts from any source.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</a>
|
||||||
<a link-to="license" class="SetupItem SetupItem--button SetupItem--aside SetupItem--noIcon">
|
<a link-to="license" class="SetupItem SetupItem--button SetupItem--aside SetupItem--noIcon">
|
||||||
<h4 class="SetupItem-title SetupItem-title--aside">View Your License</h4>
|
<h4 class="SetupItem-title SetupItem-title--aside">View Your License</h4>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -3,13 +3,11 @@ export default
|
|||||||
'$rootScope',
|
'$rootScope',
|
||||||
'AboutAnsibleHelp',
|
'AboutAnsibleHelp',
|
||||||
'ConfigureTower',
|
'ConfigureTower',
|
||||||
'CreateCustomInventory',
|
|
||||||
function(
|
function(
|
||||||
$scope,
|
$scope,
|
||||||
$rootScope,
|
$rootScope,
|
||||||
showAboutModal,
|
showAboutModal,
|
||||||
configureTower,
|
configureTower
|
||||||
showInventoryScriptsModal
|
|
||||||
) {
|
) {
|
||||||
$scope.showAboutModal = showAboutModal;
|
$scope.showAboutModal = showAboutModal;
|
||||||
|
|
||||||
@@ -19,9 +17,5 @@ export default
|
|||||||
parent_scope: $rootScope
|
parent_scope: $rootScope
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.showInventoryScriptsModal = showInventoryScriptsModal.bind(null,
|
|
||||||
{ parent_scope: $rootScope
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -152,9 +152,9 @@
|
|||||||
|
|
||||||
<div id="login-modal-dialog" style="display: none;"></div>
|
<div id="login-modal-dialog" style="display: none;"></div>
|
||||||
<div id="help-modal-dialog" style="display: none;"></div>
|
<div id="help-modal-dialog" style="display: none;"></div>
|
||||||
|
|
||||||
<div id="about-modal-dialog" style="display: none;" ng-include=" '{{ STATIC_URL }}assets/cowsay-about.html ' "></div>
|
<div id="about-modal-dialog" style="display: none;" ng-include=" '{{ STATIC_URL }}assets/cowsay-about.html ' "></div>
|
||||||
<div id="custom-script-dialog" style="display:none;" > </div>
|
|
||||||
<div id='configure-tower-dialog' style="display:none" >
|
<div id='configure-tower-dialog' style="display:none" >
|
||||||
<div id="configure-jobs" ></div>
|
<div id="configure-jobs" ></div>
|
||||||
<div class="tab-pane" id="configure-schedules-tab">
|
<div class="tab-pane" id="configure-schedules-tab">
|
||||||
|
|||||||
Reference in New Issue
Block a user