Merge pull request #5021 from mabashian/4235-add-workflows-dashboard

Add workflow job templates to the recently used templates list on the dashboard
This commit is contained in:
Michael Abashian
2017-01-30 15:16:01 -05:00
committed by GitHub
3 changed files with 25 additions and 8 deletions

View File

@@ -47,7 +47,7 @@ export function Home($scope, $compile, $stateParams, $rootScope, $location, $log
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard jobs list: ' + status }); ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard jobs list: ' + status });
}); });
Rest.setUrl(GetBasePath("job_templates") + "?order_by=-last_job_run&page_size=5&last_job_run__isnull=false"); Rest.setUrl(GetBasePath("unified_job_templates") + "?order_by=-last_job_run&page_size=5&last_job_run__isnull=false&type=workflow_job_template,job_template");
Rest.get() Rest.get()
.success(function (data) { .success(function (data) {
$scope.dashboardJobTemplatesListData = data.results; $scope.dashboardJobTemplatesListData = data.results;
@@ -123,7 +123,7 @@ export function Home($scope, $compile, $stateParams, $rootScope, $location, $log
.error(function (data, status) { .error(function (data, status) {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard jobs list: ' + status }); ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard jobs list: ' + status });
}); });
Rest.setUrl(GetBasePath("job_templates") + "?order_by=-last_job_run&page_size=5&last_job_run__isnull=false"); Rest.setUrl(GetBasePath("unified_job_templates") + "?order_by=-last_job_run&page_size=5&last_job_run__isnull=false&type=workflow_job_template,job_template");
Rest.get() Rest.get()
.success(function (data) { .success(function (data) {
data = data.results; data = data.results;

View File

@@ -3,7 +3,8 @@ export default
[ 'InitiatePlaybookRun', [ 'InitiatePlaybookRun',
'templateUrl', 'templateUrl',
'$state', '$state',
function JobTemplatesList(InitiatePlaybookRun, templateUrl, $state) { 'Alert',
function JobTemplatesList(InitiatePlaybookRun, templateUrl, $state, Alert) {
return { return {
restrict: 'E', restrict: 'E',
link: link, link: link,
@@ -32,7 +33,8 @@ export default
launch_url: job_template.url, launch_url: job_template.url,
edit_url: job_template.url.replace('api/v1', '#'), edit_url: job_template.url.replace('api/v1', '#'),
name: job_template.name, name: job_template.name,
id: job_template.id id: job_template.id,
type: job_template.type
}; }); }; });
scope.snapRows = (list.length < 4); scope.snapRows = (list.length < 4);
@@ -42,8 +44,23 @@ export default
return (status === "successful"); return (status === "successful");
}; };
scope.launchJobTemplate = function(jobTemplateId){ scope.launchJobTemplate = function(template){
InitiatePlaybookRun({ scope: scope, id: jobTemplateId, job_type: 'job_template' }); if(template) {
if(template.type && (template.type === 'Job Template' || template.type === 'job_template')) {
InitiatePlaybookRun({ scope: scope, id: template.id, job_type: 'job_template' });
}
else if(template.type && (template.type === 'Workflow Job Template' || template.type === 'workflow_job_template')) {
InitiatePlaybookRun({ scope: scope, id: template.id, job_type: 'workflow_job_template' });
}
else {
// Something went wrong - Let the user know that we're unable to launch because we don't know
// what type of job template this is
Alert('Error: Unable to determine template type', 'We were unable to determine this template\'s type while launching.');
}
}
else {
Alert('Error: Unable to launch template', 'Template parameter is missing');
}
}; };
scope.editJobTemplate = function (jobTemplateId) { scope.editJobTemplate = function (jobTemplateId) {

View File

@@ -1,7 +1,7 @@
<div class="DashboardList" ng-hide="noJobTemplates"> <div class="DashboardList" ng-hide="noJobTemplates">
<div class="DashboardList-header"> <div class="DashboardList-header">
<h3 class="DashboardList-headerText"> <h3 class="DashboardList-headerText">
<translate>RECENTLY USED JOB TEMPLATES</translate> <translate>RECENTLY USED TEMPLATES</translate>
</h3> </h3>
<a href="/#/templates" class="DashboardList-viewAll"> <a href="/#/templates" class="DashboardList-viewAll">
<translate>VIEW ALL</translate> <translate>VIEW ALL</translate>
@@ -34,7 +34,7 @@
</td> </td>
<td class="List-actionsContainer"> <td class="List-actionsContainer">
<div class="List-actionButtonCell"> <div class="List-actionButtonCell">
<button class="List-actionButton" ng-click="launchJobTemplate(job_template.id)"> <button class="List-actionButton" ng-click="launchJobTemplate(job_template)">
<i class="icon-launch"></i> <i class="icon-launch"></i>
</button> </button>
<button class="List-actionButton" ng-click="editJobTemplate(job_template.id)"> <button class="List-actionButton" ng-click="editJobTemplate(job_template.id)">