Files
awx/awx/ui/static/js/widgets/DashboardJobs.js
Chris Houseknecht 5d1b5624e3 Dashboard
Fixed missing search dialog on jobs list.
2014-06-30 10:12:50 -04:00

111 lines
4.1 KiB
JavaScript

/*********************************************
* Copyright (c) 2014 AnsibleWorks, Inc.
*
* Dashboard.js
*
* The new dashboard
*
*/
'use strict';
angular.module('DashboardJobsWidget', ['RestServices', 'Utilities'])
.factory('DashboardJobs', ['$rootScope', '$compile', 'LoadSchedulesScope', 'LoadJobsScope', 'JobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath',
function ($rootScope, $compile, LoadSchedulesScope, LoadJobsScope, JobsList, ScheduledJobsList, GetChoices, GetBasePath) {
return function (params) {
var scope = params.scope,
target = params.target,
choicesCount = 0,
listCount = 0,
jobs_scope = scope.$new(true),
scheduled_scope = scope.$new(true),
max_rows = 15,
html, e;
html = '';
html += "<ul id=\"job_status_tabs\" class=\"nav nav-tabs\">\n";
html += "<li class=\"active\"><a id=\"active_jobs_link\" ng-click=\"toggleTab($event, 'active_jobs_link', 'job_status_tabs')\"\n";
html += " href=\"#active-jobs-tab\" data-toggle=\"tab\">Jobs</a></li>\n";
html += "<li><a id=\"scheduled_jobs_link\" ng-click=\"toggleTab($event, 'scheduled_jobs_link', 'job_status_tabs')\"\n";
html += "href=\"#scheduled-jobs-tab\" data-toggle=\"tab\">Schedule</a></li>\n";
html += "</ul>\n";
html += "<div class=\"tab-content\">\n";
html += "<div class=\"tab-pane active\" id=\"active-jobs-tab\">\n";
html += "<div class=\"row search-row\">\n";
html += "<div class=\"col-md-4\" id=\"active-jobs-search-container\"></div>\n";
html += "</div>\n"; //row
html += "<div class=\"job-list\" id=\"active-jobs-container\">\n";
html += "<div id=\"active-jobs\" class=\"job-list-target\"></div>\n";
html += "</div>\n"; //list
html += "</div>\n"; //active-jobs-tab
html += "<div class=\"tab-pane\" id=\"scheduled-jobs-tab\"></div>\n";
html += "</div>\n";
e = angular.element(document.getElementById(target));
e.html(html);
$compile(e)(scope);
if (scope.removeListLoaded) {
scope.removeListLoaded();
}
scope.removeListLoaded = scope.$on('listLoaded', function() {
listCount++;
if (listCount === 1) {
//api_complete = true;
scope.$emit('WidgetLoaded');
}
});
// After all choices are ready, load up the lists and populate the page
if (scope.removeBuildJobsList) {
scope.removeBuildJobsList();
}
scope.removeBuildJobsList = scope.$on('buildJobsList', function() {
if (JobsList.fields.type) {
JobsList.fields.type.searchOptions = scope.type_choices;
}
LoadJobsScope({
parent_scope: scope,
scope: jobs_scope,
list: JobsList,
id: 'active-jobs',
url: GetBasePath('unified_jobs') + '?status__in=running,completed,failed,successful,error,canceled',
pageSize: max_rows
});
LoadSchedulesScope({
parent_scope: scope,
scope: scheduled_scope,
list: ScheduledJobsList,
id: 'scheduled-jobs-tab',
url: GetBasePath('schedules') + '?next_run__isnull=false',
pageSize: max_rows
});
});
if (scope.removeChoicesReady) {
scope.removeChoicesReady();
}
scope.removeChoicesReady = scope.$on('choicesReady', function() {
choicesCount++;
if (choicesCount === 2) {
scope.$emit('buildJobsList');
}
});
GetChoices({
scope: scope,
url: GetBasePath('unified_jobs'),
field: 'status',
variable: 'status_choices',
callback: 'choicesReady'
});
GetChoices({
scope: scope,
url: GetBasePath('unified_jobs'),
field: 'type',
variable: 'type_choices',
callback: 'choicesReady'
});
};
}]);