From 27db190bedac2167f9ef257f6187d31a2ae032c7 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Tue, 18 Nov 2014 16:49:48 -0500 Subject: [PATCH] Adding files for custom inventory script modal I'm adding the initial files and references in app.js and index.html for the custom inventory script modal window --- awx/ui/static/js/app.js | 15 +- awx/ui/static/js/forms/CustomInventory.js | 187 ++++++++ awx/ui/static/js/forms/Source.js | 44 ++ awx/ui/static/js/helpers/CustomInventory.js | 479 ++++++++++++++++++++ awx/ui/static/js/lists/CustomInventory.js | 79 ++++ awx/ui/templates/ui/index.html | 12 +- 6 files changed, 810 insertions(+), 6 deletions(-) create mode 100644 awx/ui/static/js/forms/CustomInventory.js create mode 100644 awx/ui/static/js/helpers/CustomInventory.js create mode 100644 awx/ui/static/js/lists/CustomInventory.js diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index 077b4d1998..845009e8b4 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -40,6 +40,7 @@ angular.module('Tower', [ 'PaginationHelpers', 'RefreshHelper', 'AdminListDefinition', + 'CustomInventoryListDefinition', 'AWDirectives', 'InventoriesListDefinition', 'InventoryFormDefinition', @@ -121,7 +122,9 @@ angular.module('Tower', [ 'SurveyQuestionFormDefinition', 'PortalJobsListDefinition', 'ConfigureTowerHelper', - 'ConfigureTowerJobsListDefinition' + 'ConfigureTowerJobsListDefinition', + 'CreateCustomInventoryHelper', + 'CustomInventoryListDefinition' ]) .constant('AngularScheduler.partials', urlPrefix + 'lib/angular-scheduler/lib/') @@ -434,9 +437,9 @@ angular.module('Tower', [ }]) .run(['$compile', '$cookieStore', '$rootScope', '$log', 'CheckLicense', '$location', 'Authorization', 'LoadBasePaths', 'Timer', 'ClearScope', 'HideStream', 'Socket', - 'LoadConfig', 'Store', 'ShowSocketHelp', 'LicenseViewer', 'AboutAnsibleHelp', 'ConfigureTower', + 'LoadConfig', 'Store', 'ShowSocketHelp', 'LicenseViewer', 'AboutAnsibleHelp', 'ConfigureTower', 'CreateCustomInventory' , function ($compile, $cookieStore, $rootScope, $log, CheckLicense, $location, Authorization, LoadBasePaths, Timer, ClearScope, HideStream, Socket, - LoadConfig, Store, ShowSocketHelp, LicenseViewer, AboutAnsibleHelp, ConfigureTower) { + LoadConfig, Store, ShowSocketHelp, LicenseViewer, AboutAnsibleHelp, ConfigureTower, CreateCustomInventory) { var e, html, sock, checkCount = 0; @@ -595,6 +598,12 @@ angular.module('Tower', [ }); }; + $rootScope.createCustomInv = function(){ + CreateCustomInventory({ + parent_scope: $rootScope + }); + }; + html = ""; e = angular.element(document.getElementById('socket-beacon-div')); diff --git a/awx/ui/static/js/forms/CustomInventory.js b/awx/ui/static/js/forms/CustomInventory.js new file mode 100644 index 0000000000..d6fee2e21f --- /dev/null +++ b/awx/ui/static/js/forms/CustomInventory.js @@ -0,0 +1,187 @@ +/********************************************* + * Copyright (c) 2014 AnsibleWorks, Inc. + * + * Organization.js + * Form definition for Organization model + * + * + */ + /** + * @ngdoc function + * @name forms.function:Organizations + * @description This form is for adding/editing an organization +*/ +angular.module('CustomInventoryFormDefinition', []) + .value('CustomInventoryForm', { + + addTitle: 'Create Custom Inventory', //Title in add mode + editTitle: '{{ name }}', //Title in edit mode + name: 'organization', //entity or model name in singular form + well: true, + // collapse: true, + // collapseTitle: "Properties", + // collapseMode: 'edit', + // collapseOpen: true, + + actions: { + stream: { + 'class': "btn-primary btn-xs activity-btn", + ngClick: "showActivity()", + awToolTip: "View Activity Stream", + dataPlacement: "top", + icon: "icon-comments-alt", + mode: 'edit', + iconSize: 'large' + } + }, + + fields: { + name: { + label: 'Name', + type: 'text', + addRequired: true, + editRequired: true, + capitalize: false + }, + description: { + label: 'Description', + type: 'text', + addRequired: false, + editRequired: false + }, + // script: { + // label: 'Custom Script', + // type: 'textarea', + // addRequired: false, + // editRequired: false + // } + script: { + // labelBind: 'sshKeyDataLabel', + label: 'Custom Script', + type: 'textarea', + // ngShow: "kind.value == 'ssh' || kind.value == 'scm' || " + + // "kind.value == 'gce' || kind.value == 'azure'", + // awRequiredWhen: { + // variable: 'key_required', + // init: true + // }, + hintText: "Hint: drag and drop an inventory script on the field below", + addRequired: true, + editRequired: true, + awDropFile: true, + 'class': 'ssh-key-field', + rows: 10, + awPopOver: "

Drag and drop your custom inventory script file here or create one in the field to import your custom inventory.

", + // awPopOverWatch: "", + dataTitle: 'Custom Script', + dataPlacement: 'right', + dataContainer: "body" + }, + }, + + buttons: { //for now always generates