AC-951 Whenever the object name is not available or starts with '_delete' check for the name in changes.name. Also fixed server deep link issues between activity stream, home/group and home/inventory, and inventory.

This commit is contained in:
chris Houseknecht
2014-01-20 18:48:58 -05:00
parent e5d148ac18
commit 8860b5c2ad
7 changed files with 106 additions and 42 deletions

View File

@@ -95,7 +95,7 @@ Home.$inject=['$scope', '$compile', '$routeParams', '$rootScope', '$location', '
function HomeGroups ($location, $routeParams, HomeGroupList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, function HomeGroups ($location, $routeParams, HomeGroupList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
GetBasePath, SearchInit, PaginateInit, FormatDate, GetHostsStatusMsg, GetSyncStatusMsg, ViewUpdateStatus, Stream) { GetBasePath, SearchInit, PaginateInit, FormatDate, GetHostsStatusMsg, GetSyncStatusMsg, ViewUpdateStatus, Stream, GroupsEdit) {
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope. //scope.
@@ -155,6 +155,14 @@ function HomeGroups ($location, $routeParams, HomeGroupList, GenerateList, Proce
scope[list.iterator + 'SearchSelectValue'] = null; scope[list.iterator + 'SearchSelectValue'] = null;
} }
if ($routeParams['id']) {
scope[list.iterator + 'InputDisable'] = false;
scope[list.iterator + 'SearchValue'] = $routeParams['id'];
scope[list.iterator + 'SearchField'] = 'id';
scope[list.iterator + 'SearchFieldLabel'] = list.fields['id'].label;
scope[list.iterator + 'SearchSelectValue'] = null;
}
if ($routeParams['has_active_failures']) { if ($routeParams['has_active_failures']) {
scope[list.iterator + 'InputDisable'] = true; scope[list.iterator + 'InputDisable'] = true;
scope[list.iterator + 'SearchValue'] = $routeParams['has_active_failures']; scope[list.iterator + 'SearchValue'] = $routeParams['has_active_failures'];
@@ -206,6 +214,10 @@ function HomeGroups ($location, $routeParams, HomeGroupList, GenerateList, Proce
LoadBreadCrumbs(); LoadBreadCrumbs();
scope.showActivity = function() { Stream(); } scope.showActivity = function() { Stream(); }
scope.editGroup = function(group_id, inventory_id) {
GroupsEdit({ scope: scope, group_id: group_id, inventory_id: inventory_id, groups_reload: false });
}
scope.viewUpdateStatus = function(id) { scope.viewUpdateStatus = function(id) {
scope.groups = scope.home_groups; scope.groups = scope.home_groups;
@@ -216,12 +228,12 @@ function HomeGroups ($location, $routeParams, HomeGroupList, GenerateList, Proce
HomeGroups.$inject = [ '$location', '$routeParams', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', HomeGroups.$inject = [ '$location', '$routeParams', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'GetHostsStatusMsg', 'GetSyncStatusMsg', 'ViewUpdateStatus', 'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'GetHostsStatusMsg', 'GetSyncStatusMsg', 'ViewUpdateStatus',
'Stream' 'Stream', 'GroupsEdit'
]; ];
function HomeHosts ($location, $routeParams, HomeHostList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, function HomeHosts ($location, $routeParams, HomeHostList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
GetBasePath, SearchInit, PaginateInit, FormatDate, SetHostStatus, ToggleHostEnabled, HostsEdit, Stream) { GetBasePath, SearchInit, PaginateInit, FormatDate, SetHostStatus, ToggleHostEnabled, HostsEdit, Stream, Find) {
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope. //scope.
@@ -254,6 +266,14 @@ function HomeHosts ($location, $routeParams, HomeHostList, GenerateList, Process
scope[HomeHostList.iterator + 'SearchFieldLabel'] = list.fields['name'].label; scope[HomeHostList.iterator + 'SearchFieldLabel'] = list.fields['name'].label;
} }
if ($routeParams['id']) {
scope[HomeHostList.iterator + 'InputDisable'] = false;
scope[HomeHostList.iterator + 'SearchValue'] = $routeParams['id'];
scope[HomeHostList.iterator + 'SearchField'] = 'id';
scope[HomeHostList.iterator + 'SearchFieldLabel'] = list.fields['id'].label;
scope[HomeHostList.iterator + 'SearchSelectValue'] = null;
}
if ($routeParams['has_active_failures']) { if ($routeParams['has_active_failures']) {
scope[HomeHostList.iterator + 'InputDisable'] = true; scope[HomeHostList.iterator + 'InputDisable'] = true;
scope[HomeHostList.iterator + 'SearchValue'] = $routeParams['has_active_failures']; scope[HomeHostList.iterator + 'SearchValue'] = $routeParams['has_active_failures'];
@@ -270,20 +290,15 @@ function HomeHosts ($location, $routeParams, HomeHostList, GenerateList, Process
scope.toggle_host_enabled = function(id, sources) { ToggleHostEnabled({ host_id: id, external_source: sources, scope: scope }); } scope.toggle_host_enabled = function(id, sources) { ToggleHostEnabled({ host_id: id, external_source: sources, scope: scope }); }
scope.editHost = function(host_id, host_name) { scope.editHost = function(host_id, host_name) {
var host; var host = Find({ list: scope.hosts, key: 'id', val: host_id });
for (var i=0; i < scope['hosts'].length; i++) {
if (scope['hosts'][i].id == host_id) {
host = scope['hosts'][i];
break;
}
}
if (host) { if (host) {
HostsEdit({ host_id: host_id, inventory_id: host.inventory, group_id: null, hostsReload: false }); HostsEdit({ scope: scope, host_id: host_id, inventory_id: host.inventory, group_id: null, hostsReload: false });
} }
} }
} }
HomeHosts.$inject = [ '$location', '$routeParams', 'HomeHostList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', HomeHosts.$inject = [ '$location', '$routeParams', 'HomeHostList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'SetHostStatus', 'ToggleHostEnabled', 'HostsEdit', 'Stream' 'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'SetHostStatus', 'ToggleHostEnabled', 'HostsEdit', 'Stream',
'Find'
]; ];

View File

@@ -417,7 +417,7 @@ function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateLis
} }
$scope.editGroup = function(group_id, tree_id) { $scope.editGroup = function(group_id, tree_id) {
GroupsEdit({ scope: $scope, inventory_id: $scope.inventory_id, group_id: group_id, tree_id: tree_id }); GroupsEdit({ scope: $scope, inventory_id: $scope.inventory_id, group_id: group_id, tree_id: tree_id, groups_reload: true });
} }
// Launch inventory sync // Launch inventory sync

View File

@@ -580,16 +580,17 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
.factory('GroupsEdit', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GroupForm', 'GenerateForm', .factory('GroupsEdit', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GroupForm', 'GenerateForm',
'Prompt', 'ProcessErrors', 'GetBasePath', 'SetNodeName', 'ParseTypeChange', 'GetSourceTypeOptions', 'InventoryUpdate', 'Prompt', 'ProcessErrors', 'GetBasePath', 'SetNodeName', 'ParseTypeChange', 'GetSourceTypeOptions', 'InventoryUpdate',
'GetUpdateIntervalOptions', 'LookUpInit', 'Empty', 'Wait', 'GetChoices', 'UpdateGroup', 'SourceChange', 'GetUpdateIntervalOptions', 'LookUpInit', 'Empty', 'Wait', 'GetChoices', 'UpdateGroup', 'SourceChange', 'Find',
function($rootScope, $location, $log, $routeParams, Rest, Alert, GroupForm, GenerateForm, Prompt, ProcessErrors, function($rootScope, $location, $log, $routeParams, Rest, Alert, GroupForm, GenerateForm, Prompt, ProcessErrors,
GetBasePath, SetNodeName, ParseTypeChange, GetSourceTypeOptions, InventoryUpdate, GetUpdateIntervalOptions, GetBasePath, SetNodeName, ParseTypeChange, GetSourceTypeOptions, InventoryUpdate, GetUpdateIntervalOptions,
LookUpInit, Empty, Wait, GetChoices, UpdateGroup, SourceChange) { LookUpInit, Empty, Wait, GetChoices, UpdateGroup, SourceChange, Find) {
return function(params) { return function(params) {
var parent_scope = params.scope; var parent_scope = params.scope;
var group_id = params.group_id; var group_id = params.group_id;
var tree_id = params.tree_id; var tree_id = params.tree_id;
var inventory_id = params.inventory_id; var inventory_id = params.inventory_id;
var groups_reload = params.groups_reload;
var generator = GenerateForm; var generator = GenerateForm;
var form = GroupForm; var form = GroupForm;
@@ -809,15 +810,26 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
scope.removeSaveComplete = scope.$on('SaveComplete', function(e, error) { scope.removeSaveComplete = scope.$on('SaveComplete', function(e, error) {
if (!error) { if (!error) {
// Update the view with any changes // Update the view with any changes
UpdateGroup({ if (groups_reload) {
scope: parent_scope, UpdateGroup({
group_id: group_id, scope: parent_scope,
properties: { group_id: group_id,
name: scope.name, properties: {
description: scope.description, name: scope.name,
has_inventory_sources: (scope.source) ? true : false description: scope.description,
} has_inventory_sources: (scope.source) ? true : false
}); }
});
}
else if (scope.home_groups) {
// When home.groups controller is calling, update the groups array
var g = Find({ list: parent_scope.home_groups, key: 'id', val: group_id });
if (g) {
g.name = scope.name;
g.description = scope.description;
}
}
//Clean up //Clean up
if (scope.searchCleanUp) if (scope.searchCleanUp)
scope.searchCleanup(); scope.searchCleanup();
@@ -827,12 +839,13 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
$('#form-modal').modal('hide'); $('#form-modal').modal('hide');
// Change the selected group // Change the selected group
if (parent_scope.selected_tree_id !== tree_id) if (groups_reload && parent_scope.selected_tree_id !== tree_id) {
parent_scope.showHosts(tree_id, group_id, false); parent_scope.showHosts(tree_id, group_id, false);
} }
else { else {
Wait('stop'); Wait('stop');
} }
}
}); });
if (scope.removeFormSaveSuccess) { if (scope.removeFormSaveSuccess) {

View File

@@ -22,16 +22,16 @@ angular.module('HomeGroupListDefinition', [])
name: { name: {
key: true, key: true,
label: 'Group', label: 'Group',
ngClick: "\{\{ 'GroupsEdit(' + group.id + ')' \}\}", ngClick: "editGroup(group.id, group.inventory)",
columnClass: 'col-lg-3 col-md3 col-sm-2', columnClass: 'col-lg-3 col-md3 col-sm-2'
linkTo: "\{\{ '/#/inventories/' + group.inventory + '/' \}\}" //linkTo: "\{\{ '/#/inventories/' + group.inventory + '/' \}\}"
}, },
inventory_name: { inventory_name: {
label: 'Inventory', label: 'Inventory',
sourceModel: 'inventory', sourceModel: 'inventory',
sourceField: 'name', sourceField: 'name',
columnClass: 'col-lg-3 col-md3 col-sm-2', columnClass: 'col-lg-3 col-md3 col-sm-2',
linkTo: "\{\{ '/#/inventories/' + group.inventory \}\}" linkTo: "\{\{ '/#/inventories/' + group.inventory + '/' \}\}"
}, },
failed_hosts: { failed_hosts: {
label: 'Failed Hosts', label: 'Failed Hosts',
@@ -107,6 +107,10 @@ angular.module('HomeGroupListDefinition', [])
searchOnly: true, searchOnly: true,
sourceModel: 'inventory_source', sourceModel: 'inventory_source',
sourceField: 'status' sourceField: 'status'
},
id: {
label: 'ID',
searchOnly: true
} }
}, },

View File

@@ -31,7 +31,7 @@ angular.module('HomeHostListDefinition', [])
sourceModel: 'inventory', sourceModel: 'inventory',
sourceField: 'name', sourceField: 'name',
columnClass: 'col-lg-3 col-md3 col-sm-2', columnClass: 'col-lg-3 col-md3 col-sm-2',
linkTo: "\{\{ '/#/inventories/?name=' + host.summary_fields.inventory.name \}\}" linkTo: "\{\{ '/#/inventories/' + host.inventory \}\}"
}, },
active_failures: { active_failures: {
label: 'Job Status', label: 'Job Status',
@@ -77,6 +77,10 @@ angular.module('HomeHostListDefinition', [])
searchType: 'boolean', searchType: 'boolean',
searchValue: 'true', searchValue: 'true',
searchOnly: true searchOnly: true
},
id: {
label: 'ID',
searchOnly: true
} }
}, },

View File

@@ -41,7 +41,8 @@ angular.module('StreamListDefinition', [])
label: 'Action', label: 'Action',
ngBindHtml: 'activity.description', ngBindHtml: 'activity.description',
nosort: true, nosort: true,
searchable: false searchable: false,
columnClass: 'col-lg-7'
}, },
system_event: { system_event: {
label: 'System event', label: 'System event',

View File

@@ -121,13 +121,13 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
switch(obj.base) { switch(obj.base) {
case 'group': case 'group':
case 'host': case 'host':
url += 'home/' + obj.base + 's/?name=' + obj.name; url += 'home/' + obj.base + 's/?id=' + obj.id;
break; break;
case 'inventory': case 'inventory':
url += 'inventories/' + obj.id; url += 'inventories/' + obj.id + '/';
break; break;
default: default:
url += obj.base + 's/' + obj.id; url += obj.base + 's/' + obj.id + '/';
} }
return url; return url;
} }
@@ -135,6 +135,11 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
.factory('BuildDescription', ['FixUrl', 'BuildUrl', function(FixUrl, BuildUrl) { .factory('BuildDescription', ['FixUrl', 'BuildUrl', function(FixUrl, BuildUrl) {
return function(activity) { return function(activity) {
function stripDeleted(s) {
return s.replace(/^_deleted_\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d+\+\d+:\d+_/,'');
}
var descr = ''; var descr = '';
var descr_nolink; var descr_nolink;
descr += activity.operation; descr += activity.operation;
@@ -142,25 +147,47 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
descr_nolink = descr; descr_nolink = descr;
var obj1 = activity.object1; var obj1 = activity.object1;
var obj2 = activity.object2; var obj2 = activity.object2;
if (activity.summary_fields[obj2] && activity.summary_fields[obj2][0].name) { var name;
if (activity.summary_fields[obj2] && activity.summary_fields[obj2][0].name
&& !/^_delete/.test(activity.summary_fields[obj2][0].name)) {
activity.summary_fields[obj2][0]['base'] = obj2; activity.summary_fields[obj2][0]['base'] = obj2;
descr += obj2 + ' <a href=\"' + BuildUrl(activity.summary_fields[obj2][0]) + '\">' descr += obj2 + ' <a href=\"' + BuildUrl(activity.summary_fields[obj2][0]) + '\">'
+ activity.summary_fields[obj2][0].name + '</a>' + ( (activity.operation == 'disassociate') ? ' from ' : ' to ' ); + activity.summary_fields[obj2][0].name + '</a>' + ( (activity.operation == 'disassociate') ? ' from ' : ' to ' );
descr_nolink += obj2 + ' ' + activity.summary_fields[obj2][0].name + ( (activity.operation == 'disassociate') ? ' from ' : ' to ' ); descr_nolink += obj2 + ' ' + activity.summary_fields[obj2][0].name + ( (activity.operation == 'disassociate') ? ' from ' : ' to ' );
} }
else if (activity.object2) { else if (activity.object2) {
descr += activity.object2[0] + ( (activity.operation == 'disassociate') ? ' from ' : ' to ' ); name = '';
descr_nolink += activity.object2[0] + ( (activity.operation == 'disassociate') ? ' from ' : ' to ' ); if (activity.summary_fields[obj2] && activity.summary_fields[obj2][0].name) {
name = ' ' + stripDeleted(activity.summary_fields[obj2][0].name);
}
descr += activity.object2[0] + name + ( (activity.operation == 'disassociate') ? ' from ' : ' to ' );
descr_nolink += activity.object2[0] + name + ( (activity.operation == 'disassociate') ? ' from ' : ' to ' );
} }
if (activity.summary_fields[obj1] && activity.summary_fields[obj1][0].name) { if (activity.summary_fields[obj1] && activity.summary_fields[obj1][0].name
&& !/^\_delete/.test(activity.summary_fields[obj1][0].name)) {
activity.summary_fields[obj1][0]['base'] = obj1; activity.summary_fields[obj1][0]['base'] = obj1;
descr += obj1 + ' <a href=\"' + BuildUrl(activity.summary_fields[obj1][0]) + '\">' descr += obj1 + ' <a href=\"' + BuildUrl(activity.summary_fields[obj1][0]) + '\">'
+ activity.summary_fields[obj1][0].name + '</a>'; + activity.summary_fields[obj1][0].name + '</a>';
descr_nolink += obj1 + ' ' + activity.summary_fields[obj1][0].name; descr_nolink += obj1 + ' ' + activity.summary_fields[obj1][0].name;
} }
else if (activity.object1) { else if (activity.object1) {
descr += activity.object1; name = '';
descr_nolink += activity.object1; if ( ((!(activity.summary_fields[obj1] && activity.summary_fields[obj1][0].name)) ||
activity.summary_fields[obj1] && activity.summary_fields[obj1][0].name &&
/^_delete/.test(activity.summary_fields[obj1][0].name))
&& (activity.changes && activity.changes.name) ) {
if (typeof activity.changes.name == 'string') {
name = ' ' + activity.changes.name;
}
else if (typeof activity.changes.name == 'object' && Array.isArray(activity.changes.name)) {
name = ' ' + activity.changes.name[0]
}
}
else if (activity.summary_fields[obj1] && activity.summary_fields[obj1][0].name) {
name = ' ' + stripDeleted(activity.summary_fields[obj1][0].name);
}
descr += activity.object1 + name;
descr_nolink += activity.object1 + name;
} }
activity['description'] = descr; activity['description'] = descr;
activity['description_nolink'] = descr_nolink; activity['description_nolink'] = descr_nolink;