Inventory detail page changes. Added accordion. Added custom theme to tree. Fixed tooltips. Added button labels.

This commit is contained in:
chouseknecht
2013-05-30 14:57:38 -04:00
parent 4fae801355
commit f16f41fc99
17 changed files with 538 additions and 200 deletions

View File

@@ -19,16 +19,25 @@ function HostsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
var list = HostList
var base = $location.path().replace(/^\//,'').split('/')[0];
var base2 = $location.path().replace(/^\//,'').split('/')[2];
var defaultUrl = GetBasePath('hosts');
var view = GenerateList;
var mode = (base == 'hosts') ? 'edit' : 'select';
var mode = (base == 'hosts' || base2 == 'hosts') ? 'edit' : 'select';
var scope = view.inject(list, { mode: mode }); // Inject our view
scope.selected = [];
scope['inventory_id'] = $routeParams.inventory_id;
if (base == 'hosts' || base2 == 'hosts') {
scope['showAddButton'] = false;
}
else {
scope['showAddButton'] = true;
}
SearchInit({ scope: scope, set: 'hosts', list: list, url: defaultUrl });
PaginateInit({ scope: scope, list: list, url: defaultUrl });
scope.search(list.iterator);
LoadBreadCrumbs();
scope.addHost = function() {
@@ -36,7 +45,7 @@ function HostsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
}
scope.editHost = function(id) {
$location.path($location.path() + '/' + id);
$location.path('/inventories/' + $routeParams.inventory_id + '/hosts/' + id);
}
scope.deleteHost = function(id, name) {

View File

@@ -216,7 +216,20 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
var base = $location.path().replace(/^\//,'').split('/')[0];
var master = {};
var id = $routeParams.id;
var relatedSets = {};
var relatedSets = {};
var hostsUrl;
scope['inventory_id'] = id;
// Retrieve each related set and any lookups
if (scope.inventoryLoadedRemove) {
scope.inventoryLoadedRemove();
}
scope.inventoryLoadedRemove = scope.$on('inventoryLoaded', function() {
scope.groupName = 'All Hosts';
scope.createButtonShow = false;
scope.search(relatedSets['hosts'].iterator);
});
// Retrieve detail record and prepopulate the form
Rest.setUrl(defaultUrl + ':id/');
@@ -244,19 +257,12 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
field: 'organization'
});
var related = data.related;
for (var set in form.related) {
if (related[set]) {
relatedSets[set] = { url: related[set], iterator: form.related[set].iterator };
}
}
// Load the tree view
TreeInit({ scope: scope, inventory: data });
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
//RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
//RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
hostsUrl = data.related.hosts;
relatedSets['hosts'] = { url: hostsUrl, iterator: 'host' };
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
scope.$emit('inventoryLoaded');
})
.error( function(data, status, headers, config) {
@@ -293,7 +299,7 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
// Related set: Add button
scope.add = function(set) {
$rootScope.flashMessage = null;
$location.path('/' + base + '/' + $routeParams.id + '/' + set + '/add');
$location.path('/' + base + '/' + $routeParams.id + '/groups/' + scope.group_id + '/' + set + '/add');
};
// Related set: Edit button
@@ -391,14 +397,14 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
},
"_disabled": (nodeType == 'all-hosts-group') ? true : false
},
addHost: {
label: 'Add Host',
action: function(obj) {
LoadBreadCrumbs({ path: '/groups/' + $(obj).attr('id'), title: $(obj).attr('name') });
changePath($location.path() + '/groups/' + $(obj).attr('id') + '/hosts');
},
"_disabled": (nodeType == 'all-hosts-group') ? true : false
},
// addHost: {
// label: 'Add Host',
// action: function(obj) {
// LoadBreadCrumbs({ path: '/groups/' + $(obj).attr('id'), title: $(obj).attr('name') });
// changePath($location.path() + '/groups/' + $(obj).attr('id') + '/hosts');
// },
// "_disabled": (nodeType == 'all-hosts-group') ? true : false
// },
edit: {
label: 'Edit Group',
action: function(obj) { changePath($location.path() + '/groups/' + $(obj).attr('id')); },
@@ -440,11 +446,39 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
}
}
}
scope.$on('NodeSelect', function(e, n) {
var node = $('li[name="' + n.data + '"]');
var type = node.attr('type');
var url;
$('#tree-view').jstree('open_node',node);
if (type == 'group') {
url = node.attr('all');
scope.createButtonShow = true;
scope.group_id = node.attr('id');
scope.groupName = n.data;
}
else if (type == 'all-hosts-group') {
url = node.attr('url');
scope.createButtonShow = false;
scope.groupName = 'All Hosts';
}
else if (type == 'inventory-node') {
url = node.attr('hosts');
scope.createButtonShow = false;
scope.groupName = 'All Hosts';
}
relatedSets['hosts'] = { url: url, iterator: 'host' };
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
scope.search('host');
scope.$digest();
});
}
InventoriesEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'InventoryForm',
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt',
'OrganizationList', 'TreeInit', 'GetBasePath'];
'OrganizationList', 'TreeInit', 'GetBasePath'
];

View File

@@ -230,7 +230,10 @@ function TeamsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
TeamLookUpOrganizationInit({ scope: scope });
// Retrieve each related set and any lookups
scope.$on('teamLoaded', function() {
if (scope.teamLoadedRemove) {
scope.teamLoadedRemove();
}
scope.teamLoadedRemove = scope.$on('teamLoaded', function() {
Rest.setUrl(scope['organization_url']);
Rest.get()
.success( function(data, status, headers, config) {