Dashboard

Built the job status dashboard widget.
This commit is contained in:
Chris Houseknecht
2014-06-27 15:41:50 -04:00
parent d46aa1c4de
commit 8477cb150e
9 changed files with 166 additions and 124 deletions

View File

@@ -10,13 +10,19 @@
'use strict';
angular.module('DashboardJobsWidget', ['RestServices', 'Utilities'])
.factory('DashboardJobs', ['$rootScope', '$compile', 'Rest', 'GetBasePath', 'ProcessErrors', 'Wait', function ($rootScope, $compile) {
.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";
@@ -31,7 +37,68 @@ angular.module('DashboardJobsWidget', ['RestServices', 'Utilities'])
e = angular.element(document.getElementById(target));
e.html(html);
$compile(e)(scope);
scope.$emit('WidgetLoaded');
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-tab',
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'
});
};
}]);