mirror of
https://github.com/ansible/awx.git
synced 2026-05-24 17:17:45 -02:30
AC-1292 auto-resize groups height and scroll content when necessary.
This commit is contained in:
@@ -531,7 +531,7 @@ function InventoriesEdit($scope, $location, $routeParams, $compile, $log, $rootS
|
||||
}
|
||||
$scope.removeGroupTreeLoaded = $scope.$on('GroupTreeLoaded', function (event, inventory_name, groups) {
|
||||
// Add breadcrumbs
|
||||
var e, inventoryAutoHelp;
|
||||
var e, html, inventoryAutoHelp;
|
||||
e = angular.element(document.getElementById('breadcrumbs'));
|
||||
e.html(Breadcrumbs({ list: list, mode: 'edit' }));
|
||||
$compile(e)($scope);
|
||||
@@ -541,8 +541,14 @@ function InventoriesEdit($scope, $location, $routeParams, $compile, $log, $rootS
|
||||
mode: 'edit',
|
||||
id: 'groups-container',
|
||||
breadCrumbs: false,
|
||||
searchSize: 'col-lg-5 col-md-5 col-sm-5'
|
||||
searchSize: 'col-lg-5 col-md-5 col-sm-5',
|
||||
skipTableHead: true
|
||||
});
|
||||
|
||||
// Keep the table header fixed while allowing the table body to scroll and still use <table> element
|
||||
html = "<table class=\"table table-condensed\" id=\"groups-table-header\">" + generator.buildHeader() + "</table>\n";
|
||||
$(html).insertBefore('#groups-container .list-table-container');
|
||||
|
||||
$scope.groups = groups;
|
||||
$scope.inventory_name = inventory_name;
|
||||
|
||||
@@ -595,7 +601,6 @@ function InventoriesEdit($scope, $location, $routeParams, $compile, $log, $rootS
|
||||
|
||||
});
|
||||
|
||||
|
||||
// Called after tree data is reloaded on refresh button click.
|
||||
if ($scope.removeGroupTreeRefreshed) {
|
||||
$scope.removeGroupTreeRefreshed();
|
||||
|
||||
@@ -18,10 +18,23 @@ angular.module('InventoryHelper', ['RestServices', 'Utilities', 'OrganizationLis
|
||||
function (ApplyEllipsis) {
|
||||
return function () {
|
||||
// Call to set or restore window resize
|
||||
var timeOut;
|
||||
$(window).resize(function () {
|
||||
clearTimeout(timeOut);
|
||||
timeOut = setTimeout(function () {
|
||||
|
||||
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() {
|
||||
// Hack to stop group-name div slipping to a new line
|
||||
$('#groups_table .name-column').each(function () {
|
||||
var td_width = $(this).width(),
|
||||
@@ -33,8 +46,8 @@ angular.module('InventoryHelper', ['RestServices', 'Utilities', 'OrganizationLis
|
||||
});
|
||||
ApplyEllipsis('#groups_table .group-name a');
|
||||
ApplyEllipsis('#hosts_table .host-name a');
|
||||
}, 100);
|
||||
});
|
||||
setGroupsHeight();
|
||||
}, 500));
|
||||
};
|
||||
}
|
||||
])
|
||||
|
||||
@@ -16,7 +16,7 @@ angular.module('InventoryGroupsDefinition', [])
|
||||
hover: false,
|
||||
hasChildren: true,
|
||||
filterBy: '{ show: true }',
|
||||
'class': 'table-condensed table-no-border',
|
||||
'class': 'table-no-border',
|
||||
|
||||
fields: {
|
||||
name: {
|
||||
@@ -26,7 +26,7 @@ angular.module('InventoryGroupsDefinition', [])
|
||||
columnClick: "showHosts(group.id,group.group_id, false)",
|
||||
ngClass: "group.selected_class",
|
||||
hasChildren: true,
|
||||
columnClass: 'col-lg-10 col-md-10 col-sm-10 col-xs-8',
|
||||
columnClass: 'col-lg-10 col-md-10 col-sm-10 col-xs-9',
|
||||
nosort: true,
|
||||
awDroppable: "{{ group.isDroppable }}",
|
||||
awDraggable: "{{ group.isDraggable }}",
|
||||
@@ -63,7 +63,7 @@ angular.module('InventoryGroupsDefinition', [])
|
||||
|
||||
fieldActions: {
|
||||
|
||||
columnClass: 'col-lg-2 col-md-2 col-sm-2 col-xs-4',
|
||||
columnClass: 'col-lg-2 col-md-2 col-sm-2 col-xs-3',
|
||||
|
||||
sync_status: {
|
||||
mode: 'all',
|
||||
|
||||
@@ -28,7 +28,7 @@ angular.module('InventoryHostsDefinition', [])
|
||||
label: 'Hosts',
|
||||
ngClick: "editHost(host.id)",
|
||||
searchPlaceholder: "search_place_holder",
|
||||
columnClass: 'col-lg-10 col-md-10 col-sm-10 col-xs-8',
|
||||
columnClass: 'col-lg-10 col-md-10 col-sm-10 col-xs-9',
|
||||
dataHostId: "{{ host.id }}",
|
||||
dataType: "host",
|
||||
awDraggable: "true"
|
||||
@@ -51,7 +51,7 @@ angular.module('InventoryHostsDefinition', [])
|
||||
|
||||
fieldActions: {
|
||||
|
||||
columnClass: 'col-lg-2 col-md-2 col-sm-2 col-xs-4',
|
||||
columnClass: 'col-lg-2 col-md-2 col-sm-2 col-xs-3',
|
||||
|
||||
enabled_flag: {
|
||||
iconClass: "{{ 'fa icon-enabled-' + host.enabled }}",
|
||||
|
||||
@@ -1324,6 +1324,16 @@ input[type="checkbox"].checkbox-no-label {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#groups-table-header {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#groups-container {
|
||||
.list-table-container {
|
||||
overflow: auto;
|
||||
}
|
||||
}
|
||||
|
||||
#inventories_table i[class*="icon-job-"],
|
||||
#home_groups_table i[class*="icon-job-"] {
|
||||
margin-left: 10px;
|
||||
@@ -1664,18 +1674,6 @@ tr td button i {
|
||||
|
||||
}
|
||||
|
||||
/* Portrait tablet to landscape and desktop */
|
||||
|
||||
/*@media (max-width: 1200px) {
|
||||
.site-footer {
|
||||
.logo {
|
||||
text-align: center;
|
||||
padding-top: 20px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@media (min-width: 768px) and (max-width: 1199px) {
|
||||
|
||||
.level-1,
|
||||
@@ -1709,6 +1707,7 @@ tr td button i {
|
||||
}
|
||||
|
||||
#hosts-container.col-lg-6 {
|
||||
margin-top: 15px;
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
.well {
|
||||
@@ -1804,6 +1803,7 @@ tr td button i {
|
||||
}
|
||||
|
||||
#hosts-container.col-lg-6 {
|
||||
margin-toop: 15px;
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
@@ -12,14 +12,18 @@
|
||||
angular.module('ListGenerator', ['GeneratorHelpers'])
|
||||
.factory('GenerateList', ['$location', '$compile', '$rootScope', 'SearchWidget', 'PaginateWidget', 'Attr', 'Icon',
|
||||
'Column', 'DropDown', 'NavigationLink', 'Button', 'SelectIcon', 'Breadcrumbs',
|
||||
function ($location, $compile, $rootScope, SearchWidget, PaginateWidget, Attr, Icon, Column, DropDown, NavigationLink, Button, SelectIcon,
|
||||
Breadcrumbs) {
|
||||
function ($location, $compile, $rootScope, SearchWidget, PaginateWidget, Attr, Icon, Column, DropDown, NavigationLink,
|
||||
Button, SelectIcon, Breadcrumbs) {
|
||||
return {
|
||||
|
||||
setList: function (list) {
|
||||
this.list = list;
|
||||
},
|
||||
|
||||
setOptions: function(options) {
|
||||
this.options = options;
|
||||
},
|
||||
|
||||
attr: Attr,
|
||||
|
||||
icon: Icon,
|
||||
@@ -60,6 +64,7 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
|
||||
element = angular.element(document.getElementById('htmlTemplate'));
|
||||
}
|
||||
|
||||
this.setOptions(options);
|
||||
this.setList(list);
|
||||
element.html(this.build(options)); // Inject the html
|
||||
|
||||
@@ -292,46 +297,10 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
|
||||
html += (options.mode === 'summary') ? ' table-summary' : '';
|
||||
html += "\" ";
|
||||
html += ">\n";
|
||||
html += "<thead>\n";
|
||||
html += "<tr>\n";
|
||||
if (list.index) {
|
||||
html += "<th class=\"col-lg-1 col-md-1 col-sm-2 hidden-xs\">#</th>\n";
|
||||
|
||||
if (!options.skipTableHead) {
|
||||
html += this.buildHeader(options);
|
||||
}
|
||||
for (fld in list.fields) {
|
||||
if ((list.fields[fld].searchOnly === undefined || list.fields[fld].searchOnly === false) &&
|
||||
!(options.mode === 'lookup' && list.fields[fld].excludeModal !== undefined && list.fields[fld].excludeModal === true)) {
|
||||
html += "<th class=\"list-header";
|
||||
html += (list.fields[fld].columnClass) ? " " + list.fields[fld].columnClass : "";
|
||||
html += "\" id=\"" + list.iterator + "-" + fld + "-header\"";
|
||||
html += (list.fields[fld].columnShow) ? " ng-show=\"" + list.fields[fld].columnShow + "\" " : "";
|
||||
html += (list.fields[fld].nosort === undefined || list.fields[fld].nosort !== true) ? " ng-click=\"sort('" + list.iterator + "','" + fld + "')\"" : "";
|
||||
html += ">";
|
||||
html += list.fields[fld].label;
|
||||
if (list.fields[fld].nosort === undefined || list.fields[fld].nosort !== true) {
|
||||
html += " <i class=\"fa ";
|
||||
if (list.fields[fld].key) {
|
||||
if (list.fields[fld].desc) {
|
||||
html += "fa-sort-down";
|
||||
} else {
|
||||
html += "fa-sort-up";
|
||||
}
|
||||
} else {
|
||||
html += "fa-sort";
|
||||
}
|
||||
html += "\"></i></a>";
|
||||
}
|
||||
html += "</th>\n";
|
||||
}
|
||||
}
|
||||
if (options.mode === 'select' || options.mode === 'lookup') {
|
||||
html += "<th>Select</th>";
|
||||
} else if (options.mode === 'edit' && list.fieldActions) {
|
||||
html += "<th class=\"actions-column";
|
||||
html += (list.fieldActions && list.fieldActions.columnClass) ? " " + list.fieldActions.columnClass : "";
|
||||
html += "\">Actions</th>\n";
|
||||
}
|
||||
html += "</tr>\n";
|
||||
html += "</thead>\n";
|
||||
|
||||
// table body
|
||||
html += "<tbody>\n";
|
||||
@@ -460,8 +429,58 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
|
||||
}
|
||||
}
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
buildHeader: function(options) {
|
||||
var list = this.list,
|
||||
fld, html;
|
||||
|
||||
if (options === undefined) {
|
||||
options = this.options;
|
||||
}
|
||||
|
||||
html = "<thead>\n";
|
||||
html += "<tr>\n";
|
||||
if (list.index) {
|
||||
html += "<th class=\"col-lg-1 col-md-1 col-sm-2 hidden-xs\">#</th>\n";
|
||||
}
|
||||
for (fld in list.fields) {
|
||||
if ((list.fields[fld].searchOnly === undefined || list.fields[fld].searchOnly === false) &&
|
||||
!(options.mode === 'lookup' && list.fields[fld].excludeModal !== undefined && list.fields[fld].excludeModal === true)) {
|
||||
html += "<th class=\"list-header";
|
||||
html += (list.fields[fld].columnClass) ? " " + list.fields[fld].columnClass : "";
|
||||
html += "\" id=\"" + list.iterator + "-" + fld + "-header\"";
|
||||
html += (list.fields[fld].columnShow) ? " ng-show=\"" + list.fields[fld].columnShow + "\" " : "";
|
||||
html += (list.fields[fld].nosort === undefined || list.fields[fld].nosort !== true) ? " ng-click=\"sort('" + list.iterator + "','" + fld + "')\"" : "";
|
||||
html += ">";
|
||||
html += list.fields[fld].label;
|
||||
if (list.fields[fld].nosort === undefined || list.fields[fld].nosort !== true) {
|
||||
html += " <i class=\"fa ";
|
||||
if (list.fields[fld].key) {
|
||||
if (list.fields[fld].desc) {
|
||||
html += "fa-sort-down";
|
||||
} else {
|
||||
html += "fa-sort-up";
|
||||
}
|
||||
} else {
|
||||
html += "fa-sort";
|
||||
}
|
||||
html += "\"></i></a>";
|
||||
}
|
||||
html += "</th>\n";
|
||||
}
|
||||
}
|
||||
if (options.mode === 'select' || options.mode === 'lookup') {
|
||||
html += "<th>Select</th>";
|
||||
} else if (options.mode === 'edit' && list.fieldActions) {
|
||||
html += "<th class=\"actions-column";
|
||||
html += (list.fieldActions && list.fieldActions.columnClass) ? " " + list.fieldActions.columnClass : "";
|
||||
html += "\">Actions</th>\n";
|
||||
}
|
||||
html += "</tr>\n";
|
||||
html += "</thead>\n";
|
||||
return html;
|
||||
}
|
||||
};
|
||||
}
|
||||
]);
|
||||
}]);
|
||||
Reference in New Issue
Block a user