From 2485f86471b5d0a5681a3b6fc7b2f4489c395323 Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Wed, 30 Jul 2014 14:05:45 -0400 Subject: [PATCH] Job templates Added ability to launch a job from th job template detail page. --- awx/ui/static/js/controllers/JobTemplates.js | 17 +++++++++++++---- awx/ui/static/js/forms/JobTemplates.js | 6 ++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/awx/ui/static/js/controllers/JobTemplates.js b/awx/ui/static/js/controllers/JobTemplates.js index ccbb66702b..03bdceab23 100644 --- a/awx/ui/static/js/controllers/JobTemplates.js +++ b/awx/ui/static/js/controllers/JobTemplates.js @@ -340,7 +340,8 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList, CredentialList, ProjectList, LookUpInit, GetBasePath, md5Setup, ParseTypeChange, JobStatusToolTip, FormatDate, Wait, Stream, Empty, Prompt, ParseVariableString, ToJSON, SchedulesControllerInit, JobsControllerInit, JobsListUpdate, - GetChoices, SchedulesListInit, SchedulesList, CallbackHelpInit) { + GetChoices, SchedulesListInit, SchedulesList, CallbackHelpInit, PlaybookRun) +{ ClearScope(); @@ -577,8 +578,8 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP } $scope.removeLoadJobs = $scope.$on('LoadJobs', function() { // Retrieve detail record and prepopulate the form - Rest.setUrl(defaultUrl + ':id/'); - Rest.get({ params: { id: id } }) + Rest.setUrl(defaultUrl + id); + Rest.get() .success(function (data) { var fld, i; LoadBreadCrumbs({ path: '/job_templates/' + id, title: data.name }); @@ -788,6 +789,14 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP $location.path('/' + set + '/' + id); }; + // Launch a job using the selected template + $scope.launch = function() { + PlaybookRun({ + scope: $scope, + id: id + }); + }; + // Related set: Delete button $scope['delete'] = function (set, itm_id, name, title) { $rootScope.flashMessage = null; @@ -824,5 +833,5 @@ JobTemplatesEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$l 'ReturnToCaller', 'ClearScope', 'InventoryList', 'CredentialList', 'ProjectList', 'LookUpInit', 'GetBasePath', 'md5Setup', 'ParseTypeChange', 'JobStatusToolTip', 'FormatDate', 'Wait', 'Stream', 'Empty', 'Prompt', 'ParseVariableString', 'ToJSON', 'SchedulesControllerInit', 'JobsControllerInit', 'JobsListUpdate', 'GetChoices', - 'SchedulesListInit', 'SchedulesList', 'CallbackHelpInit' + 'SchedulesListInit', 'SchedulesList', 'CallbackHelpInit', 'PlaybookRun' ]; \ No newline at end of file diff --git a/awx/ui/static/js/forms/JobTemplates.js b/awx/ui/static/js/forms/JobTemplates.js index ef25a2c86f..1fec57dad0 100644 --- a/awx/ui/static/js/forms/JobTemplates.js +++ b/awx/ui/static/js/forms/JobTemplates.js @@ -26,6 +26,12 @@ angular.module('JobTemplateFormDefinition', ['SchedulesListDefinition', 'Complet collapseOpen: true, //Always open first panel actions: { + submit: { + ngClick: 'launch()', + awToolTip: 'Start a job using this template', + dataPlacement: 'top', + mode: 'edit' + }, stream: { 'class': "btn-primary btn-xs activity-btn", ngClick: "showActivity()",