elements
- $(this).remove();
- });
- $('.popover').each(function () {
- // remove lingering popover
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 = "
Are you sure you want to delete " + name + "?
";
- 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;
-
- };
- };
- }]);
diff --git a/awx/ui/client/src/helpers/Groups.js b/awx/ui/client/src/helpers/Groups.js
index 553f236c66..3ec0ad2a86 100644
--- a/awx/ui/client/src/helpers/Groups.js
+++ b/awx/ui/client/src/helpers/Groups.js
@@ -3,7 +3,7 @@
*
* All Rights Reserved
*************************************************/
-
+
'use strict';
/**
@@ -235,8 +235,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
* TODO: Document
*
*/
-.factory('SourceChange', ['GetBasePath', 'CredentialList', 'LookUpInit', 'Empty', 'Wait', 'ParseTypeChange', 'CustomInventoryList', 'CreateSelect2',
- function (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, inventoryScriptsListObject, CreateSelect2) {
return function (params) {
var scope = params.scope,
@@ -289,7 +289,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
scope: scope,
form: form,
hdr: "Select Custom Inventory",
- list: CustomInventoryList,
+ list: inventoryScriptsListObject,
field: 'source_script',
input_type: 'radio'
});
diff --git a/awx/ui/client/src/helpers/PaginationHelpers.js b/awx/ui/client/src/helpers/PaginationHelpers.js
index 1f35ad70ae..652e17c7f2 100644
--- a/awx/ui/client/src/helpers/PaginationHelpers.js
+++ b/awx/ui/client/src/helpers/PaginationHelpers.js
@@ -3,7 +3,7 @@
*
* All Rights Reserved
*************************************************/
-
+
/**
* @ngdoc function
* @name helpers.function:PaginationHelpers
@@ -28,7 +28,7 @@ export default
scope[iterator + '_num_pages'] = Math.ceil((count / scope[iterator + '_page_size']));
scope[iterator + '_num_pages'] = (scope[iterator + '_num_pages'] <= 0) ? 1 : scope[iterator + '_num_pages'];
scope[iterator + '_total_rows'] = count;
- $('#pagination-links li:eq(1)').removeAttr('class');
+ $('#'+iterator+'-pagination #pagination-links li:eq(1)').removeAttr('class');
// Which page are we on?
if (Empty(next) && previous) {
// no next page, but there is a previous page
@@ -36,7 +36,7 @@ export default
} else if (next && Empty(previous)) {
// next page available, but no previous page
scope[iterator + '_page'] = 1;
- $('#pagination-links li:eq(1)').attr('class', 'disabled');
+ $('#'+iterator+'-pagination #pagination-links li:eq(1)').attr('class', 'disabled');
} else if (next && previous) {
// we're in between next and previous
scope[iterator + '_page'] = parseInt(previous.match(/page=\d+/)[0].replace(/page=/, '')) + 1;
diff --git a/awx/ui/client/src/helpers/Schedules.js b/awx/ui/client/src/helpers/Schedules.js
index 0aa0f2e6fe..6c07823926 100644
--- a/awx/ui/client/src/helpers/Schedules.js
+++ b/awx/ui/client/src/helpers/Schedules.js
@@ -75,8 +75,10 @@ export default
};
}])
- .factory('EditSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait', 'Rest', 'ProcessErrors', 'GetBasePath', 'SchedulePost',
- function(SchedulerInit, ShowSchedulerModal, Wait, Rest, ProcessErrors, GetBasePath, SchedulePost) {
+ .factory('EditSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait',
+ 'Rest', 'ProcessErrors', 'GetBasePath', 'SchedulePost',
+ function(SchedulerInit, ShowSchedulerModal, Wait, Rest, ProcessErrors,
+ GetBasePath, SchedulePost) {
return function(params) {
var scope = params.scope,
id = params.id,
@@ -84,6 +86,63 @@ export default
schedule, scheduler,
url = GetBasePath('schedules') + id + '/';
+ delete scope.isFactCleanup;
+ delete scope.cleanupJob;
+
+ function setGranularity(){
+ var a,b, prompt_for_days,
+ keep_unit,
+ granularity,
+ granularity_keep_unit;
+
+ if(scope.cleanupJob){
+ scope.schedulerPurgeDays = Number(schedule.extra_data.days);
+ // scope.scheduler_form.schedulerPurgeDays.$setViewValue( Number(schedule.extra_data.days));
+ }
+ else if(scope.isFactCleanup){
+ scope.keep_unit_choices = [{
+ "label" : "Days",
+ "value" : "d"
+ },
+ {
+ "label": "Weeks",
+ "value" : "w"
+ },
+ {
+ "label" : "Years",
+ "value" : "y"
+ }];
+ scope.granularity_keep_unit_choices = [{
+ "label" : "Days",
+ "value" : "d"
+ },
+ {
+ "label": "Weeks",
+ "value" : "w"
+ },
+ {
+ "label" : "Years",
+ "value" : "y"
+ }];
+ // the API returns something like 20w or 1y
+ a = schedule.extra_data.older_than; // "20y"
+ b = schedule.extra_data.granularity; // "1w"
+ prompt_for_days = Number(_.initial(a,1).join('')); // 20
+ keep_unit = _.last(a); // "y"
+ granularity = Number(_.initial(b,1).join('')); // 1
+ granularity_keep_unit = _.last(b); // "w"
+
+ scope.keep_amount = prompt_for_days;
+ scope.granularity_keep_amount = granularity;
+ scope.keep_unit = _.find(scope.keep_unit_choices, function(i){
+ return i.value === keep_unit;
+ });
+ scope.granularity_keep_unit =_.find(scope.granularity_keep_unit_choices, function(i){
+ return i.value === granularity_keep_unit;
+ });
+ }
+ }
+
if (scope.removeDialogReady) {
scope.removeDialogReady();
}
@@ -94,6 +153,10 @@ export default
scope.$apply(function() {
scheduler.setRRule(schedule.rrule);
scheduler.setName(schedule.name);
+ if(scope.isFactCleanup || scope.cleanupJob){
+ setGranularity();
+ }
+
});
}, 300);
});
@@ -112,7 +175,6 @@ export default
}
schedule.rrule = schedule.rrule.replace(/ RRULE:/,';');
schedule.rrule = schedule.rrule.replace(/DTSTART:/,'DTSTART=');
-
ShowSchedulerModal({ scope: scope, callback: 'DialogReady', title: 'Edit Schedule' });
scope.showRRuleDetail = false;
});
@@ -141,6 +203,8 @@ export default
});
};
+
+
$('#scheduler-tabs li a').on('shown.bs.tab', function(e) {
if ($(e.target).text() === 'Details') {
if (!scheduler.isValid()) {
@@ -156,6 +220,13 @@ export default
Rest.get()
.success(function(data) {
schedule = data;
+ if(schedule.hasOwnProperty('extra_data')) {
+ if(schedule.extra_data.hasOwnProperty('granularity')){
+ scope.isFactCleanup = true;
+ } else {
+ scope.cleanupJob = true;
+ }
+ }
scope.$emit('ScheduleFound');
})
.error(function(data,status){
@@ -181,6 +252,43 @@ export default
else if (!Empty($routeParams.id)) {
url += $routeParams.id + '/schedules/';
}
+ else if (!Empty($routeParams.management_job)) {
+ url += $routeParams.management_job + '/schedules/';
+ if(scope.management_job.id === 4){
+ scope.isFactCleanup = true;
+ scope.keep_unit_choices = [{
+ "label" : "Days",
+ "value" : "d"
+ },
+ {
+ "label": "Weeks",
+ "value" : "w"
+ },
+ {
+ "label" : "Years",
+ "value" : "y"
+ }];
+ scope.granularity_keep_unit_choices = [{
+ "label" : "Days",
+ "value" : "d"
+ },
+ {
+ "label": "Weeks",
+ "value" : "w"
+ },
+ {
+ "label" : "Years",
+ "value" : "y"
+ }];
+ scope.prompt_for_days_facts_form.keep_amount.$setViewValue(30);
+ scope.prompt_for_days_facts_form.granularity_keep_amount.$setViewValue(1);
+ scope.keep_unit = scope.keep_unit_choices[0];
+ scope.granularity_keep_unit = scope.granularity_keep_unit_choices[1];
+ }
+ else {
+ scope.cleanupJob = true;
+ }
+ }
if (scope.removeDialogReady) {
scope.removeDialogReady();
@@ -239,7 +347,7 @@ export default
mode = params.mode,
schedule = (params.schedule) ? params.schedule : {},
callback = params.callback,
- newSchedule, rrule;
+ newSchedule, rrule, extra_vars;
if (scheduler.isValid()) {
Wait('start');
@@ -248,6 +356,20 @@ export default
schedule.name = newSchedule.name;
schedule.rrule = RRuleToAPI(rrule.toString());
schedule.description = (/error/.test(rrule.toText())) ? '' : rrule.toText();
+
+ if (scope.isFactCleanup) {
+ extra_vars = {
+ "older_than": scope.scheduler_form.keep_amount.$viewValue + scope.scheduler_form.keep_unit.$viewValue.value,
+ "granularity": scope.scheduler_form.granularity_keep_amount.$viewValue + scope.scheduler_form.granularity_keep_unit.$viewValue.value
+ };
+ } else if (scope.cleanupJob) {
+ extra_vars = {
+ "days" : scope.scheduler_form.schedulerPurgeDays.$viewValue
+ };
+ }
+ schedule.extra_data = JSON.stringify(extra_vars);
+
+
Rest.setUrl(url);
if (mode === 'add') {
Rest.post(schedule)
@@ -442,8 +564,10 @@ export default
}])
- .factory('SchedulesControllerInit', ['$location', 'ToggleSchedule', 'DeleteSchedule', 'EditSchedule', 'AddSchedule',
- function($location, ToggleSchedule, DeleteSchedule, EditSchedule, AddSchedule) {
+ .factory('SchedulesControllerInit', ['$location', 'ToggleSchedule',
+ 'DeleteSchedule', 'EditSchedule', 'AddSchedule',
+ function($location, ToggleSchedule, DeleteSchedule, EditSchedule,
+ AddSchedule) {
return function(params) {
var scope = params.scope,
parent_scope = params.parent_scope,
diff --git a/awx/ui/client/src/inventory-scripts/add/add.controller.js b/awx/ui/client/src/inventory-scripts/add/add.controller.js
new file mode 100644
index 0000000000..29f431726a
--- /dev/null
+++ b/awx/ui/client/src/inventory-scripts/add/add.controller.js
@@ -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();
+ };
+
+ }
+ ];
diff --git a/awx/ui/client/src/inventory-scripts/add/add.partial.html b/awx/ui/client/src/inventory-scripts/add/add.partial.html
new file mode 100644
index 0000000000..a9e7a04b9b
--- /dev/null
+++ b/awx/ui/client/src/inventory-scripts/add/add.partial.html
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
diff --git a/awx/ui/client/src/inventory-scripts/add/add.route.js b/awx/ui/client/src/inventory-scripts/add/add.route.js
new file mode 100644
index 0000000000..d9259cf596
--- /dev/null
+++ b/awx/ui/client/src/inventory-scripts/add/add.route.js
@@ -0,0 +1,19 @@
+/*************************************************
+ * Copyright (c) 2015 Ansible, Inc.
+ *
+ * All Rights Reserved
+ *************************************************/
+
+import {templateUrl} from '../../shared/template-url/template-url.factory';
+
+export default {
+ name: 'inventoryScriptsAdd',
+ route: '/inventory_scripts/add',
+ templateUrl: templateUrl('inventory-scripts/add/add'),
+ controller: 'addController',
+ resolve: {
+ features: ['FeaturesService', function(FeaturesService) {
+ return FeaturesService.get();
+ }]
+ }
+};
diff --git a/awx/ui/client/src/inventory-scripts/add/main.js b/awx/ui/client/src/inventory-scripts/add/main.js
new file mode 100644
index 0000000000..f996e43b13
--- /dev/null
+++ b/awx/ui/client/src/inventory-scripts/add/main.js
@@ -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);
+ }]);
diff --git a/awx/ui/client/src/inventory-scripts/edit/edit.controller.js b/awx/ui/client/src/inventory-scripts/edit/edit.controller.js
new file mode 100644
index 0000000000..0d2d2c52ed
--- /dev/null
+++ b/awx/ui/client/src/inventory-scripts/edit/edit.controller.js
@@ -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;
+
+ };
+
+ }
+ ];
diff --git a/awx/ui/client/src/inventory-scripts/edit/edit.partial.html b/awx/ui/client/src/inventory-scripts/edit/edit.partial.html
new file mode 100644
index 0000000000..854bcf4fad
--- /dev/null
+++ b/awx/ui/client/src/inventory-scripts/edit/edit.partial.html
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
diff --git a/awx/ui/client/src/inventory-scripts/edit/edit.route.js b/awx/ui/client/src/inventory-scripts/edit/edit.route.js
new file mode 100644
index 0000000000..0215420bdd
--- /dev/null
+++ b/awx/ui/client/src/inventory-scripts/edit/edit.route.js
@@ -0,0 +1,46 @@
+/*************************************************
+ * Copyright (c) 2015 Ansible, Inc.
+ *
+ * All Rights Reserved
+ *************************************************/
+
+import {templateUrl} from '../../shared/template-url/template-url.factory';
+
+export default {
+ name: 'inventoryScriptsEdit',
+ route: '/inventory_scripts/:inventory_script',
+ templateUrl: templateUrl('inventory-scripts/edit/edit'),
+ 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
+ });
+ });
+ }
+ ]
+ }
+};
diff --git a/awx/ui/client/src/inventory-scripts/edit/main.js b/awx/ui/client/src/inventory-scripts/edit/main.js
new file mode 100644
index 0000000000..e0e3326800
--- /dev/null
+++ b/awx/ui/client/src/inventory-scripts/edit/main.js
@@ -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);
+ }]);
diff --git a/awx/ui/client/src/inventory-scripts/inventory-scripts.form.js b/awx/ui/client/src/inventory-scripts/inventory-scripts.form.js
new file mode 100644
index 0000000000..f430dfe5d2
--- /dev/null
+++ b/awx/ui/client/src/inventory-scripts/inventory-scripts.form.js
@@ -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: "
Drag and drop your custom inventory script file here or create one in the field to import your custom inventory. " +
+ "
Script must begin with a hashbang sequence: i.e.... #!/usr/bin/env python
",
+ dataTitle: 'Custom Script',
+ dataPlacement: 'right',
+ dataContainer: "body"
+ },
+ },
+
+ buttons: { //for now always generates