AC-1271 fixed job page display. Now using window width and height rather than document. Also, if window height < 800px, use default page size of 5 rows and let containers auto-size themselves.

This commit is contained in:
chouseknecht
2014-05-21 17:42:53 -04:00
parent e5ee7e5383
commit 473c8d3b26

View File

@@ -7,12 +7,12 @@
* Controller functions for the Inventory model. * Controller functions for the Inventory model.
* *
*/ */
'use strict'; 'use strict';
function JobsListController ($scope, $compile, $routeParams, ClearScope, Breadcrumbs, LoadBreadCrumbs, LoadSchedulesScope, LoadJobsScope, RunningJobsList, CompletedJobsList, QueuedJobsList, function JobsListController ($scope, $compile, $routeParams, ClearScope, Breadcrumbs, LoadBreadCrumbs, LoadSchedulesScope, LoadJobsScope, RunningJobsList, CompletedJobsList, QueuedJobsList,
ScheduledJobsList, GetChoices, GetBasePath, Wait, Socket) { ScheduledJobsList, GetChoices, GetBasePath, Wait, Socket) {
ClearScope(); ClearScope();
var e, var e,
@@ -29,7 +29,7 @@ function JobsListController ($scope, $compile, $routeParams, ClearScope, Breadcr
scope: $scope, scope: $scope,
endpoint: "jobs" endpoint: "jobs"
}); });
event_socket.init(); event_socket.init();
event_socket.on("status_changed", function(data) { event_socket.on("status_changed", function(data) {
@@ -40,7 +40,7 @@ function JobsListController ($scope, $compile, $routeParams, ClearScope, Breadcr
event_queue.push(data); event_queue.push(data);
} }
}); });
function processEvent(event) { function processEvent(event) {
expecting = 0; expecting = 0;
switch(event.status) { switch(event.status) {
@@ -230,7 +230,7 @@ function JobsListController ($scope, $compile, $routeParams, ClearScope, Breadcr
variable: 'status_choices', variable: 'status_choices',
callback: 'choicesReady' callback: 'choicesReady'
}); });
GetChoices({ GetChoices({
scope: $scope, scope: $scope,
url: GetBasePath('unified_jobs'), url: GetBasePath('unified_jobs'),
@@ -241,10 +241,11 @@ function JobsListController ($scope, $compile, $routeParams, ClearScope, Breadcr
// Set the height of each container and calc max number of rows containers can hold // Set the height of each container and calc max number of rows containers can hold
function setHeight() { function setHeight() {
var docw = $(document).width(), var docw = $(window).width(),
doch = $(window).height(),
available_height, available_height,
search_row, page_row, height, header, row_height; search_row, page_row, height, header, row_height;
if (docw > 1240) { if (docw > 1240 && doch > 800) {
// customize the container height and # of rows based on available viewport height // customize the container height and # of rows based on available viewport height
available_height = $(window).height() - $('.main-menu').outerHeight() - $('#main_tabs').outerHeight() - $('#breadcrumbs').outerHeight() - $('.site-footer').outerHeight() - 25; available_height = $(window).height() - $('.main-menu').outerHeight() - $('#main_tabs').outerHeight() - $('#breadcrumbs').outerHeight() - $('.site-footer').outerHeight() - 25;
$('.jobs-list-container').each(function() { $('.jobs-list-container').each(function() {
@@ -259,7 +260,7 @@ function JobsListController ($scope, $compile, $routeParams, ClearScope, Breadcr
max_rows = Math.floor(height / row_height); max_rows = Math.floor(height / row_height);
} }
else { else {
// when width < 1240px put things back to their default state // when width < 1240px || height < 800px put things back to their default state
$('.jobs-list-container').each(function() { $('.jobs-list-container').each(function() {
$(this).css({ 'height': 'auto' }); $(this).css({ 'height': 'auto' });
}); });
@@ -299,7 +300,7 @@ function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, J
choicesCount = 0; choicesCount = 0;
generator.inject(JobForm, { mode: 'edit', related: true, scope: $scope }); generator.inject(JobForm, { mode: 'edit', related: true, scope: $scope });
$scope.job_id = id; $scope.job_id = id;
$scope.parseType = 'yaml'; $scope.parseType = 'yaml';
$scope.statusSearchSpin = false; $scope.statusSearchSpin = false;
@@ -354,7 +355,7 @@ function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, J
} else { } else {
$scope.$emit('jobTemplateLoadFinished'); $scope.$emit('jobTemplateLoadFinished');
} }
}); });
// Turn off 'Wait' after both cloud credential and playbook list come back // Turn off 'Wait' after both cloud credential and playbook list come back
@@ -364,7 +365,7 @@ function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, J
$scope.removeJobTemplateLoadFinished = $scope.$on('jobTemplateLoadFinished', function () { $scope.removeJobTemplateLoadFinished = $scope.$on('jobTemplateLoadFinished', function () {
loadingFinishedCount++; loadingFinishedCount++;
if (loadingFinishedCount >= 2) { if (loadingFinishedCount >= 2) {
// The initial template load finished. Now load related jobs, which // The initial template load finished. Now load related jobs, which
// will turn off the 'working' spinner. // will turn off the 'working' spinner.
Wait('stop'); Wait('stop');
} }
@@ -398,11 +399,11 @@ function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, J
Rest.setUrl(defaultUrl + ':id/'); Rest.setUrl(defaultUrl + ':id/');
Rest.get({ params: { id: id } }) Rest.get({ params: { id: id } })
.success(function (data) { .success(function (data) {
var i, fld; var i, fld;
LoadBreadCrumbs(); LoadBreadCrumbs();
$scope.status = data.status; $scope.status = data.status;
$scope.created = FormatDate(data.created); $scope.created = FormatDate(data.created);
$scope.modified = FormatDate(data.modified); $scope.modified = FormatDate(data.modified);
@@ -479,7 +480,7 @@ function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, J
} }
return true; return true;
}); });
$scope.$emit('jobLoaded', data.related.cloud_credential, data.project, data.playbook); $scope.$emit('jobLoaded', data.related.cloud_credential, data.project, data.playbook);
}) })
.error(function (data, status) { .error(function (data, status) {