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/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..85dc2c1cd6
--- /dev/null
+++ b/awx/ui/client/src/inventory-scripts/add/add.route.js
@@ -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();
+ }]
+ }
+};
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..8290da615c
--- /dev/null
+++ b/awx/ui/client/src/inventory-scripts/edit/edit.route.js
@@ -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
+ });
+ });
+ }
+ ],
+ }
+};
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