Added custom scroll bar to inventory groups container. Moved group container auto-resize and height calc function to helper methods. Now using full window height, pushing footer off the page. Changed custom sroll directive to use the dark-thin theme.

This commit is contained in:
chouseknecht
2014-05-20 14:04:36 -04:00
parent e03a7792ca
commit 77ccfc49f2
5 changed files with 58 additions and 48 deletions

View File

@@ -7,15 +7,15 @@
* Controller functions for the Inventory model. * Controller functions for the Inventory model.
* *
*/ */
'use strict'; 'use strict';
function InventoriesList($scope, $rootScope, $location, $log, $routeParams, $compile, $filter, Rest, Alert, InventoryList, GenerateList, function InventoriesList($scope, $rootScope, $location, $log, $routeParams, $compile, $filter, Rest, Alert, InventoryList, GenerateList,
LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, Wait, Stream, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, Wait, Stream,
EditInventoryProperties, Find, Empty, LogViewer) { EditInventoryProperties, Find, Empty, LogViewer) {
//ClearScope(); //ClearScope();
var list = InventoryList, var list = InventoryList,
defaultUrl = GetBasePath('inventory'), defaultUrl = GetBasePath('inventory'),
view = GenerateList, view = GenerateList,
@@ -60,7 +60,7 @@ function InventoriesList($scope, $rootScope, $location, $log, $routeParams, $com
list: list, list: list,
url: defaultUrl url: defaultUrl
}); });
PaginateInit({ PaginateInit({
scope: $scope, scope: $scope,
list: list, list: list,
@@ -168,7 +168,7 @@ function InventoriesList($scope, $rootScope, $location, $log, $routeParams, $com
$scope.removeHostSummaryReady(); $scope.removeHostSummaryReady();
} }
$scope.removeHostSummaryReady = $scope.$on('HostSummaryReady', function(e, event, data) { $scope.removeHostSummaryReady = $scope.$on('HostSummaryReady', function(e, event, data) {
var html, title = "Recent Jobs"; var html, title = "Recent Jobs";
Wait('stop'); Wait('stop');
if (data.count > 0) { if (data.count > 0) {
@@ -182,7 +182,7 @@ function InventoriesList($scope, $rootScope, $location, $log, $routeParams, $com
html += "</tr>\n"; html += "</tr>\n";
html += "</thead>\n"; html += "</thead>\n";
html += "<tbody>\n"; html += "<tbody>\n";
data.results.forEach(function(row) { data.results.forEach(function(row) {
html += "<tr>\n"; html += "<tr>\n";
html += "<td><a ng-click=\"viewJob('" + row.url + "')\" " + "aw-tool-tip=\"" + row.status.charAt(0).toUpperCase() + row.status.slice(1) + html += "<td><a ng-click=\"viewJob('" + row.url + "')\" " + "aw-tool-tip=\"" + row.status.charAt(0).toUpperCase() + row.status.slice(1) +
@@ -210,7 +210,7 @@ function InventoriesList($scope, $rootScope, $location, $log, $routeParams, $com
} }
$scope.removeGroupSummaryReady = $scope.$on('GroupSummaryReady', function(e, event, inventory, data) { $scope.removeGroupSummaryReady = $scope.$on('GroupSummaryReady', function(e, event, inventory, data) {
var html, title; var html, title;
Wait('stop'); Wait('stop');
// Build the html for our popover // Build the html for our popover
@@ -367,7 +367,7 @@ InventoriesList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeP
function InventoriesAdd($scope, $rootScope, $compile, $location, $log, $routeParams, InventoryForm, GenerateForm, Rest, function InventoriesAdd($scope, $rootScope, $compile, $location, $log, $routeParams, InventoryForm, GenerateForm, Rest,
Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, GenerateList, OrganizationList, SearchInit, PaginateInit, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, GenerateList, OrganizationList, SearchInit, PaginateInit,
LookUpInit, GetBasePath, ParseTypeChange, Wait) { LookUpInit, GetBasePath, ParseTypeChange, Wait) {
ClearScope(); ClearScope();
// Inject dynamic view // Inject dynamic view
@@ -380,10 +380,10 @@ function InventoriesAdd($scope, $rootScope, $compile, $location, $log, $routePar
form.formFieldSize = null; form.formFieldSize = null;
generator.inject(form, { mode: 'add', related: false, scope: $scope }); generator.inject(form, { mode: 'add', related: false, scope: $scope });
generator.reset(); generator.reset();
LoadBreadCrumbs(); LoadBreadCrumbs();
$scope.inventoryParseType = 'yaml'; $scope.inventoryParseType = 'yaml';
ParseTypeChange({ scope: $scope, variable: 'inventory_variables', parse_variable: 'inventoryParseType', ParseTypeChange({ scope: $scope, variable: 'inventory_variables', parse_variable: 'inventoryParseType',
field_id: 'inventory_inventory_variables' }); field_id: 'inventory_inventory_variables' });
@@ -476,7 +476,7 @@ function InventoriesEdit($scope, $location, $routeParams, $compile, $log, $rootS
InventoryUpdate, Alert, ToggleChildren, ViewUpdateStatus, GroupsCancelUpdate, Find, EditInventoryProperties, HostsEdit, InventoryUpdate, Alert, ToggleChildren, ViewUpdateStatus, GroupsCancelUpdate, Find, EditInventoryProperties, HostsEdit,
HostsDelete, ToggleHostEnabled, CopyMoveGroup, CopyMoveHost, Stream, GetBasePath, ShowJobSummary, ApplyEllipsis, WatchInventoryWindowResize, HostsDelete, ToggleHostEnabled, CopyMoveGroup, CopyMoveHost, Stream, GetBasePath, ShowJobSummary, ApplyEllipsis, WatchInventoryWindowResize,
HelpDialog, InventoryGroupsHelp, Store, ViewJob) { HelpDialog, InventoryGroupsHelp, Store, ViewJob) {
ClearScope(); ClearScope();
var generator = GenerateList, var generator = GenerateList,
@@ -709,7 +709,7 @@ function InventoriesEdit($scope, $location, $routeParams, $compile, $log, $rootS
var group = Find({ list: $scope.groups, key: 'id', val: id }); var group = Find({ list: $scope.groups, key: 'id', val: id });
if (group) { if (group) {
if (Empty(group.source)) { if (Empty(group.source)) {
// if no source, do nothing. // if no source, do nothing.
} else if (group.status === 'updating') { } else if (group.status === 'updating') {
Alert('Update in Progress', 'The inventory update process is currently running for group <em>' + Alert('Update in Progress', 'The inventory update process is currently running for group <em>' +
group.name + '</em>. Use the Refresh button to monitor the status.', 'alert-info'); group.name + '</em>. Use the Refresh button to monitor the status.', 'alert-info');

View File

@@ -14,26 +14,31 @@ angular.module('InventoryHelper', ['RestServices', 'Utilities', 'OrganizationLis
'InventoryHelper', 'InventoryFormDefinition', 'ParseHelper', 'SearchHelper', 'VariablesHelper', 'InventoryHelper', 'InventoryFormDefinition', 'ParseHelper', 'SearchHelper', 'VariablesHelper',
]) ])
.factory('WatchInventoryWindowResize', ['ApplyEllipsis', .factory('GetContainerHeight', [ function() {
function (ApplyEllipsis) { return function() {
return $(window).height() - $('.main-menu').outerHeight() - $('#main_tabs').outerHeight() - $('#breadcrumbs').outerHeight() -
$('.site-footer').outerHeight() - $('#groups-container .list-actions').outerHeight() - $('#groups-table-header').height() - 15;
};
}])
.factory('SetGroupContainerHeight', [ 'GetContainerHeight', function(GetContainerHeight) {
return function() {
var height;
if ($(window).width() > 1210) {
height = GetContainerHeight();
$('#groups-container .list-table-container').height(height);
}
else {
$('#groups-container .list-table-container').height('auto');
}
$('#groups-container .list-table-container').mCustomScrollbar("update");
};
}])
.factory('WatchInventoryWindowResize', ['ApplyEllipsis', 'SetGroupContainerHeight',
function (ApplyEllipsis, SetGroupContainerHeight) {
return function () { return function () {
// Call to set or restore window resize // Call to set or restore window resize
SetGroupContainerHeight();
function setGroupsHeight() {
// Attempt to set the group height
var height;
if ($(window).width() > 1210) {
height = $(window).height() - $('.main-menu').outerHeight() - $('#main_tabs').outerHeight() - $('#breadcrumbs').outerHeight() -
($('.site-footer').outerHeight() * 2) - $('#groups-container .list-actions').outerHeight() - $('#groups-table-header').height() - 20;
$('#groups-container .list-table-container').height(height);
}
else {
$('#groups-container .list-table-container').height('auto');
}
}
setGroupsHeight();
$(window).resize(_.debounce(function() { $(window).resize(_.debounce(function() {
// Hack to stop group-name div slipping to a new line // Hack to stop group-name div slipping to a new line
$('#groups_table .name-column').each(function () { $('#groups_table .name-column').each(function () {
@@ -46,7 +51,7 @@ angular.module('InventoryHelper', ['RestServices', 'Utilities', 'OrganizationLis
}); });
ApplyEllipsis('#groups_table .group-name a'); ApplyEllipsis('#groups_table .group-name a');
ApplyEllipsis('#hosts_table .host-name a'); ApplyEllipsis('#hosts_table .host-name a');
setGroupsHeight(); SetGroupContainerHeight();
}, 500)); }, 500));
}; };
} }

View File

@@ -17,6 +17,7 @@ angular.module('InventoryGroupsDefinition', [])
hasChildren: true, hasChildren: true,
filterBy: '{ show: true }', filterBy: '{ show: true }',
'class': 'table-no-border', 'class': 'table-no-border',
awCustomScroll: true,
fields: { fields: {
name: { name: {
@@ -64,6 +65,7 @@ angular.module('InventoryGroupsDefinition', [])
fieldActions: { fieldActions: {
columnClass: 'col-lg-2 col-md-2 col-sm-2 col-xs-3', columnClass: 'col-lg-2 col-md-2 col-sm-2 col-xs-3',
label: false,
sync_status: { sync_status: {
mode: 'all', mode: 'all',

View File

@@ -729,7 +729,7 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
scrollButtons: { scrollButtons: {
enable: true enable: true
}, },
theme: 'dark-thick', theme: 'dark-thin',
mouseWheel: true, mouseWheel: true,
scrollInertia: 300, scrollInertia: 300,
callbacks: { callbacks: {
@@ -761,7 +761,7 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
$(this).find('.btn').toggleClass('btn-info'); $(this).find('.btn').toggleClass('btn-info');
} }
$(this).find('.btn').toggleClass('btn-default'); $(this).find('.btn').toggleClass('btn-default');
// Add data-after-toggle="functionName" to the btn-group, and we'll // Add data-after-toggle="functionName" to the btn-group, and we'll
// execute here. The newly active choice is passed as a parameter. // execute here. The newly active choice is passed as a parameter.
if ($(this).attr('data-after-toggle')) { if ($(this).attr('data-after-toggle')) {

View File

@@ -63,15 +63,15 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
} else { } else {
element = angular.element(document.getElementById('htmlTemplate')); element = angular.element(document.getElementById('htmlTemplate'));
} }
this.setOptions(options); this.setOptions(options);
this.setList(list); this.setList(list);
element.html(this.build(options)); // Inject the html element.html(this.build(options)); // Inject the html
if (options.prepend) { if (options.prepend) {
element.prepend(options.prepend); element.prepend(options.prepend);
} }
if (options.append) { if (options.append) {
element.append(options.append); element.append(options.append);
} }
@@ -84,10 +84,10 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
$compile(element)(this.scope); $compile(element)(this.scope);
// Reset the scope to prevent displaying old data from our last visit to this list // Reset the scope to prevent displaying old data from our last visit to this list
//this.scope[list.name] = null; //this.scope[list.name] = null;
this.scope[list.iterator] = []; this.scope[list.iterator] = [];
// Remove any lingering tooltip and popover <div> elements // Remove any lingering tooltip and popover <div> elements
$('.tooltip').each(function() { $('.tooltip').each(function() {
$(this).remove(); $(this).remove();
@@ -102,7 +102,7 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
try { try {
$('#help-modal').empty().dialog('destroy'); $('#help-modal').empty().dialog('destroy');
} catch (e) { } catch (e) {
//ignore any errors should the dialog not be initialized //ignore any errors should the dialog not be initialized
} }
/*if (options.mode === 'lookup') { /*if (options.mode === 'lookup') {
@@ -126,8 +126,8 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
build: function (options) { build: function (options) {
// //
// Generate HTML. Do NOT call this function directly. Called by inject(). Returns an HTML // Generate HTML. Do NOT call this function directly. Called by inject(). Returns an HTML
// string to be injected into the current view. // string to be injected into the current view.
// //
var html = '', var html = '',
list = this.list, list = this.list,
@@ -178,7 +178,7 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
html += "</div>\n"; html += "</div>\n";
html += "</div>\n"; html += "</div>\n";
} }
if (options.showSearch=== undefined || options.showSearch === true) { if (options.showSearch=== undefined || options.showSearch === true) {
html += "<div class=\"row\">\n"; html += "<div class=\"row\">\n";
if (list.name !== 'groups') { if (list.name !== 'groups') {
@@ -285,9 +285,11 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
html += (options.mode === 'edit' || options.mode === 'summary') ? list.editTitle : list.addTitle; html += (options.mode === 'edit' || options.mode === 'summary') ? list.editTitle : list.addTitle;
html += "</div>\n"; html += "</div>\n";
} }
// table header row // table header row
html += "<div class=\"list-table-container\">\n"; html += "<div class=\"list-table-container\"";
html += (list.awCustomScroll) ? " aw-custom-scroll " : "";
html += ">\n";
html += "<table id=\"" + list.name + "_table\" "; html += "<table id=\"" + list.name + "_table\" ";
html += "class=\"table table-condensed"; html += "class=\"table table-condensed";
html += (list['class']) ? " " + list['class'] : ""; html += (list['class']) ? " " + list['class'] : "";
@@ -297,7 +299,7 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
html += (options.mode === 'summary') ? ' table-summary' : ''; html += (options.mode === 'summary') ? ' table-summary' : '';
html += "\" "; html += "\" ";
html += ">\n"; html += ">\n";
if (!options.skipTableHead) { if (!options.skipTableHead) {
html += this.buildHeader(options); html += this.buildHeader(options);
} }
@@ -435,11 +437,11 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
buildHeader: function(options) { buildHeader: function(options) {
var list = this.list, var list = this.list,
fld, html; fld, html;
if (options === undefined) { if (options === undefined) {
options = this.options; options = this.options;
} }
html = "<thead>\n"; html = "<thead>\n";
html += "<tr>\n"; html += "<tr>\n";
if (list.index) { if (list.index) {
@@ -473,7 +475,8 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
} }
if (options.mode === 'select' || options.mode === 'lookup') { if (options.mode === 'select' || options.mode === 'lookup') {
html += "<th>Select</th>"; html += "<th>Select</th>";
} else if (options.mode === 'edit' && list.fieldActions) { } else if (options.mode === 'edit' && list.fieldActions &&
(list.fieldActions.label === undefined || list.fieldActions.label)) {
html += "<th class=\"actions-column"; html += "<th class=\"actions-column";
html += (list.fieldActions && list.fieldActions.columnClass) ? " " + list.fieldActions.columnClass : ""; html += (list.fieldActions && list.fieldActions.columnClass) ? " " + list.fieldActions.columnClass : "";
html += "\">Actions</th>\n"; html += "\">Actions</th>\n";