Added AS to /inventories/hosts/N and /inventories/groups/N as well has /home/[groups, hosts]. Fixed CSS container sizing issue, so widget will not overlap footer.

This commit is contained in:
Chris Houseknecht 2013-11-19 18:52:26 +00:00
parent d681d0972a
commit 4661a9e97a
9 changed files with 85 additions and 26 deletions

View File

@ -10,7 +10,7 @@
function InventoryGroups ($scope, $rootScope, $compile, $location, $log, $routeParams, InventoryGroupsForm,
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, Prompt,
BuildTree, GetBasePath, GroupsList, GroupsAdd, GroupsEdit, LoadInventory,
GroupsDelete, EditInventory, InventoryStatus)
GroupsDelete, EditInventory, InventoryStatus, Stream)
{
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
@ -108,6 +108,8 @@ function InventoryGroups ($scope, $rootScope, $compile, $location, $log, $routeP
}
});
scope.showActivity = function() { Stream(); }
scope.addGroup = function() {
GroupsList({ "inventory_id": id, group_id: scope.group_id });
}
@ -159,6 +161,6 @@ InventoryGroups.$inject = [
'$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'InventoryGroupsForm',
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'Prompt',
'BuildTree', 'GetBasePath', 'GroupsList', 'GroupsAdd', 'GroupsEdit', 'LoadInventory',
'GroupsDelete', 'EditInventory', 'InventoryStatus'
'GroupsDelete', 'EditInventory', 'InventoryStatus', 'Stream'
];

View File

@ -50,7 +50,7 @@ Home.$inject=[ '$routeParams', '$scope', '$rootScope', '$location', 'Wait', 'Obj
function HomeGroups ($location, $routeParams, HomeGroupList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
GetBasePath, SearchInit, PaginateInit, FormatDate, HostsStatusMsg, UpdateStatusMsg, ViewUpdateStatus) {
GetBasePath, SearchInit, PaginateInit, FormatDate, HostsStatusMsg, UpdateStatusMsg, ViewUpdateStatus, Stream) {
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope.
@ -158,18 +158,19 @@ function HomeGroups ($location, $routeParams, HomeGroupList, GenerateList, Proce
scope.search(list.iterator);
LoadBreadCrumbs();
scope.showActivity = function() { Stream(); }
scope.viewUpdateStatus = function(id) { ViewUpdateStatus({ scope: scope, group_id: id }) };
}
HomeGroups.$inject = [ '$location', '$routeParams', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'HostsStatusMsg', 'UpdateStatusMsg', 'ViewUpdateStatus'
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'HostsStatusMsg', 'UpdateStatusMsg', 'ViewUpdateStatus', 'Stream'
];
function HomeHosts ($location, $routeParams, HomeHostList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
GetBasePath, SearchInit, PaginateInit, FormatDate, SetHostStatus, ToggleHostEnabled, HostsEdit) {
GetBasePath, SearchInit, PaginateInit, FormatDate, SetHostStatus, ToggleHostEnabled, HostsEdit, Stream) {
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope.
@ -213,7 +214,8 @@ function HomeHosts ($location, $routeParams, HomeHostList, GenerateList, Process
scope.search(list.iterator);
LoadBreadCrumbs();
scope.showActivity = function() { Stream(); }
scope.toggle_host_enabled = function(id, sources) { ToggleHostEnabled(id, sources, scope); }
scope.editHost = function(host_id, host_name) {
@ -233,6 +235,6 @@ function HomeHosts ($location, $routeParams, HomeHostList, GenerateList, Process
HomeGroups.$inject = [ '$location', '$routeParams', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'HostsStatusMsg', 'UpdateStatusMsg', 'ViewUpdateStatus',
'SetHostStatus', 'ToggleHostEnabled', 'HostsEdit'
'SetHostStatus', 'ToggleHostEnabled', 'HostsEdit', 'Stream'
];

View File

@ -14,7 +14,7 @@ function InventoryHosts ($scope, $rootScope, $compile, $location, $log, $routePa
RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpInit, Prompt,
GetBasePath, HostsList, HostsAdd, HostsEdit, HostsDelete,
HostsReload, BuildTree, EditHostGroups, InventoryHostsHelp, HelpDialog, Wait,
ToggleHostEnabled)
ToggleHostEnabled, Stream)
{
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope.
@ -40,6 +40,8 @@ function InventoryHosts ($scope, $rootScope, $compile, $location, $log, $routePa
LoadBreadCrumbs({ path: '/inventories/' + id, title: inventory_name });
});
scope.showActivity = function() { Stream(); }
scope.filterHosts = function() {
HostsReload({ scope: scope, inventory_id: scope['inventory_id'], group_id: scope['group_id'] });
}
@ -164,6 +166,6 @@ InventoryHosts.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$lo
'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt',
'GetBasePath', 'HostsList', 'HostsAdd', 'HostsEdit', 'HostsDelete',
'HostsReload', 'BuildTree', 'EditHostGroups', 'InventoryHostsHelp', 'HelpDialog', 'Wait',
'ToggleHostEnabled'
'ToggleHostEnabled', 'Stream'
];

View File

@ -104,7 +104,16 @@ angular.module('InventoryHostsFormDefinition', [])
iconSize: 'large',
ngClick: "showHelp()",
id: "hosts-page-help"
}
},
stream: {
'class': "btn-primary btn-xs activity-btn",
ngClick: "showActivity()",
awToolTip: "View Activity Stream",
dataPlacement: "top",
icon: "icon-comments-alt",
mode: 'edit',
iconSize: 'large'
}
},
fieldActions: {

View File

@ -110,7 +110,15 @@ angular.module('HomeGroupListDefinition', [])
},
actions: {
stream: {
'class': "btn-primary btn-xs activity-btn",
ngClick: "showActivity()",
awToolTip: "View Activity Stream",
dataPlacement: "top",
icon: "icon-comments-alt",
mode: 'all',
iconSize: 'large'
}
},
fieldActions: {

View File

@ -81,6 +81,15 @@ angular.module('HomeHostListDefinition', [])
},
actions: {
stream: {
'class': "btn-primary btn-xs activity-btn",
ngClick: "showActivity()",
awToolTip: "View Activity Stream",
dataPlacement: "top",
icon: "icon-comments-alt",
mode: 'all',
iconSize: 'large'
}
},
fieldActions: {

View File

@ -135,6 +135,15 @@ angular.module('InventorySummaryDefinition', [])
awToolTip: "Refresh the page",
ngClick: "refresh()",
iconSize: 'large'
},
stream: {
'class': "btn-primary btn-xs activity-btn",
ngClick: "showActivity()",
awToolTip: "View Activity Stream",
dataPlacement: "top",
icon: "icon-comments-alt",
mode: 'all',
iconSize: 'large'
}
},

View File

@ -10,7 +10,17 @@
angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefinition', 'SearchHelper', 'PaginateHelper',
'RefreshHelper', 'ListGenerator', 'StreamWidget'])
.factory('ShowStream', [ function() {
.factory('setStreamHeight', [ function() {
return function() {
// Try not to overlap footer. Because stream is positioned absolute, the parent
// doesn't resize correctly when stream is loaded.
var stream = $('#stream-container');
var height = stream.height() + 50;
$('#tab-content-container').css({ "min-height": height });
}
}])
.factory('ShowStream', [ 'setStreamHeight', function(setStreamHeight) {
return function() {
// Slide in the Stream widget
@ -24,10 +34,8 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
'min-height': '100%',
'background-color': '#FFF'
});
// Try not to overlap footer. Because stream is positioned absolute, the parent
// doesn't resize correctly when stream is loaded.
$('#tab-content-container').css({ 'min-height': stream.height() + 50 });
setStreamHeight();
// Slide in stream
stream.show('slide', {'direction': 'left'}, {'duration': 500, 'queue': false });
@ -172,7 +180,6 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
.success( function(data, status, headers, config) {
// load up the form
var results = data;
$('#form-modal').on('show.bs.modal', function (e) {
$('#form-modal-body').css({
width:'auto', //probably not needed
@ -230,9 +237,9 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
.factory('Stream', ['$rootScope', '$location', 'Rest', 'GetBasePath', 'ProcessErrors', 'Wait', 'StreamList', 'SearchInit',
'PaginateInit', 'GenerateList', 'FormatDate', 'ShowStream', 'HideStream', 'BuildDescription', 'FixUrl', 'BuildUrl',
'ShowDetail', 'StreamBreadCrumbs',
'ShowDetail', 'StreamBreadCrumbs', 'setStreamHeight',
function($rootScope, $location, Rest, GetBasePath, ProcessErrors, Wait, StreamList, SearchInit, PaginateInit, GenerateList,
FormatDate, ShowStream, HideStream, BuildDescription, FixUrl, BuildUrl, ShowDetail, StreamBreadCrumbs) {
FormatDate, ShowStream, HideStream, BuildDescription, FixUrl, BuildUrl, ShowDetail, StreamBreadCrumbs, setStreamHeight) {
return function(params) {
var list = StreamList;
@ -240,13 +247,20 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
var view = GenerateList;
var base = $location.path().replace(/^\//,'').split('/')[0];
if (base !== 'home') {
if ($location.path() !== '/home') {
// Restrict what we're looking at based on the path
var type = (base == 'inventories') ? 'inventory' : base.replace(/s$/,'');
var paths = $location.path().split('/');
paths.splice(0,1);
if (paths.length > 1 && /^\d+/.test(paths[1])) {
defaultUrl += '?object1=' + type + '&object1_id=' + paths[i];
if (paths.length > 1 && /^\d+/.test(paths[paths.length - 1])) {
type = paths[paths.length - 2];
type = (type == 'inventories') ? 'inventory' : type.replace(/s$/,'');
defaultUrl += '?object1=' + type + '&object1_id=' + paths[paths.length - 1];
}
else if (paths.length > 1) {
type = paths[paths.length - 1];
type = (type == 'inventories') ? 'inventory' : type.replace(/s$/,'');
defaultUrl += '?or__object1=' + type + '&or__object2=' + type;
}
else {
defaultUrl += '?or__object1=' + type + '&or__object2=' + type;
@ -284,10 +298,10 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
ShowDetail(id);
}
if (scope.removePostRefresh) {
scope.removePostRefresh();
if (scope.removeStreamPostRefresh) {
scope.removeStreamPostRefresh();
}
scope.removePostRefresh = scope.$on('PostRefresh', function() {
scope.removeStreamPostRefresh = scope.$on('PostRefresh', function() {
for (var i=0; i < scope['activities'].length; i++) {
// Convert event_time date to local time zone
cDate = new Date(scope['activities'][i].timestamp);
@ -332,7 +346,10 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
// Description
scope['activities'][i].description = BuildDescription(scope['activities'][i]);
}
// Give ng-repeate a chance to show the data before adjusting the page size.
setTimeout(function() { setStreamHeight(); }, 500);
});
// Initialize search and paginate pieces and load data

View File

@ -1378,6 +1378,7 @@ tr td button i {
#stream-container {
display: none;
border-radius: 8px;
z-index: 20; /* has to be greater than tree selector */
}
#stream-content {