diff --git a/awx/ui/static/js/widgets/PortalJobs.js b/awx/ui/static/js/widgets/PortalJobs.js index dddfde7a45..8fee74ff41 100644 --- a/awx/ui/static/js/widgets/PortalJobs.js +++ b/awx/ui/static/js/widgets/PortalJobs.js @@ -11,33 +11,19 @@ 'use strict'; angular.module('PortalJobsWidget', ['RestServices', 'Utilities']) -.factory('PortalJobsWidget', ['$rootScope', '$compile', 'LoadSchedulesScope', 'LoadJobsScope', 'PortalJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', 'PortalJobTemplateList', - function ($rootScope, $compile, LoadSchedulesScope, LoadJobsScope, PortalJobsList, ScheduledJobsList, GetChoices, GetBasePath, PortalJobTemplateList) { +.factory('PortalJobsWidget', ['$rootScope', '$compile', 'LoadSchedulesScope', 'LoadJobsScope', 'PortalJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', 'PortalJobTemplateList' , + function ($rootScope, $compile, LoadSchedulesScope, LoadJobsScope, PortalJobsList, ScheduledJobsList, GetChoices, GetBasePath, PortalJobTemplateList ) { return function (params) { var scope = params.scope, target = params.target, + filter = params.filter || "User" , choicesCount = 0, listCount = 0, jobs_scope = scope.$new(true), max_rows, user, - html, e; - - html = ''; - html += "
\n"; - html += "
\n"; - html += "\n"; //row - html += "
\n"; - html += "
\n"; - html += "
\n"; //list - html += "
\n"; //active-jobs-tab - html += "
\n"; - - e = angular.element(document.getElementById(target)); - e.html(html); - $compile(e)(scope); + html, e, + url; if (scope.removeListLoaded) { scope.removeListLoaded(); @@ -59,18 +45,17 @@ angular.module('PortalJobsWidget', ['RestServices', 'Utilities']) PortalJobsList.fields.type.searchOptions = scope.type_choices; } user = scope.$parent.current_user.id; + url = (filter === "Team" ) ? GetBasePath('jobs') : GetBasePath('jobs')+'?created_by='+user ; LoadJobsScope({ parent_scope: scope, scope: jobs_scope, list: PortalJobsList, id: 'active-jobs', - url: GetBasePath('jobs')+'?created_by='+user, + url: url , //GetBasePath('jobs')+'?created_by='+user, pageSize: max_rows, spinner: true }); - - $(window).resize(_.debounce(function() { resizePortalJobsWidget(); }, 500)); @@ -87,6 +72,47 @@ angular.module('PortalJobsWidget', ['RestServices', 'Utilities']) } }); + + scope.filterPortalJobs = function(filter) { + $("#active-jobs").empty(); + $("#active-jobs-search-container").empty(); + user = scope.$parent.current_user.id; + url = (filter === "Team" ) ? GetBasePath('jobs') : GetBasePath('jobs')+'?created_by='+user ; + LoadJobsScope({ + parent_scope: scope, + scope: jobs_scope, + list: PortalJobsList, + id: 'active-jobs', + url: url , //GetBasePath('jobs')+'?created_by='+user, + pageSize: max_rows, + spinner: true + }); + }; + + html = ''; + html += "
\n"; + html += "
\n"; + html += "\n"; //row + + html += "
\n"; + html += "
\n"; + html += "
\n"; //list + html += "
\n"; //active-jobs-tab + html += "
\n"; + + e = angular.element(document.getElementById(target)); + e.html(html); + $compile(e)(scope); + + GetChoices({ scope: scope, url: GetBasePath('unified_jobs'),