AC-331 final clean up

This commit is contained in:
chouseknecht 2013-08-22 11:26:23 -04:00
parent f8b186b24a
commit 4ea3c23e5a
6 changed files with 57 additions and 29 deletions

View File

@ -77,6 +77,10 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res
scope.viewJobs = function(id) {
$location.url('/jobs/?inventory__int=' + id + '&order_by=status');
}
scope.viewFailedJobs = function(id) {
$location.url('/jobs/?inventory__int=' + id + '&status=failed&order_by=status');
}
}
InventoriesList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'InventoryList', 'GenerateList',
@ -482,11 +486,10 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
HostsDelete({ scope: scope, "inventory_id": id, group_id: scope.group_id, host_id: host_id, host_name: host_name,
request: 'delete' });
}
/* scope.removeHost = function(host_id, host_name) {
HostsDelete({ scope: scope, "inventory_id": id, group_id: scope.group_id, host_id: host_id, host_name: host_name,
request: 'remove' });
} */
scope.viewJobs = function(last_job) {
$location.url('/jobs/?id__int=' + last_job );
}
scope.viewLastEvents = function(host_id, last_job, host_name, last_job_name) {
// Choose View-> Latest job events

View File

@ -50,6 +50,11 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest,
scope[list.iterator + 'SearchValue'] = $routeParams['inventory__int'];
scope[list.iterator + 'SearchFieldLabel'] = 'Inventory ID';
}
if ($routeParams['id__int']) {
scope[list.iterator + 'SearchField'] = 'id';
scope[list.iterator + 'SearchValue'] = $routeParams['id__int'];
scope[list.iterator + 'SearchFieldLabel'] = 'Job ID';
}
scope.search(list.iterator);
// Called from Inventories page, failed jobs link. Now sort by status so faild jobs appear at top of list

View File

@ -122,9 +122,10 @@ angular.module('InventoryFormDefinition', [])
dropdown: {
type: 'DropDown',
label: 'View',
"class": "btn-sm",
ngDisabled: 'host.last_job == null',
options: [
{ ngClick: 'viewJobs(\{\{ host.id \}\})', label: 'Jobs' },
{ ngClick: 'viewJobs(\{\{ host.last_job \}\})', label: 'Latest job' },
{ ngClick: "viewLastEvents(\{\{ host.id \}\}, '\{\{ host.last_job \}\}', '\{\{ host.name \}\}', " +
"'\{\{ host.summary_fields.last_job.name \}\}')", label: 'Latest job events' },
{ ngClick: "viewLastSummary(\{\{ host.id \}\}, '\{\{ host.last_job \}\}', '\{\{ host.name \}\}', " +

View File

@ -37,20 +37,6 @@ angular.module('InventoriesListDefinition', [])
sourceField: 'name',
excludeModal: true
}
/*,
has_active_failures: {
label: 'Failed Jobs?',
showValue: false,
text: 'View failures',
ngShow: "\{\{ inventory.has_active_failures \}\}",
icon: 'icon-exclamation-sign',
"class": 'active-failures-\{\{ inventory.has_active_failures \}\}',
ngClick: 'viewJobs(\{\{ inventory.id \}\})',
searchField: 'has_active_failures',
searchType: 'boolean',
searchOptions: [{ name: "No", value: 0 }, { name: "Yes", value: 1 }],
excludeModal: true
}*/
},
actions: {
@ -65,6 +51,17 @@ angular.module('InventoriesListDefinition', [])
},
fieldActions: {
dropdown: {
type: 'DropDown',
label: 'View',
'class': 'btn-xs',
options: [
{ ngClick: 'viewJobs(\{\{ inventory.id \}\})', label: 'Jobs' },
{ ngClick: "viewFailedJobs(\{\{ inventory.id \}\})", label: 'Failed jobs' }
]
},
edit: {
label: 'Edit',
ngClick: "editInventory(\{\{ inventory.id \}\})",

View File

@ -98,14 +98,22 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers'])
var list = params['list'];
var fld = params['fld'];
var options = params['options'];
var base = params['base'];
var field = list['fields'][fld];
var field;
html = "<td>\n";
html += "<div class=\"btn-group btn-group-sm\">\n";
if (params.type) {
field = list[params.type][fld];
}
else {
field = list['fields'][fld];
}
html = (params.td == undefined || params.td !== false) ? "<td>\n" : "";
html += "<div class=\"btn-group\">\n";
html += "<button type=\"button\" ";
html += (field.ngDisabled) ? "ng-disabled=\"" + field.ngDisabled + "\" " : "";
html += "class=\"btn btn-default btn-mini dropdown-toggle\" data-toggle=\"dropdown\">";
html += "class=\"btn btn-default";
html += (field['class']) ? " " + field['class'] : " btn-xs";
html += " dropdown-toggle\" data-toggle=\"dropdown\">";
html += field.label;
html += " <span class=\"caret\"></span></button>\n";
html += "<ul class=\"dropdown-menu pull-right\" role=\"menu\" aria-labelledby=\"dropdownMenu1\">\n";
@ -118,7 +126,8 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers'])
}
html += "</ul>\n";
html += "</div>\n";
html += "</td>\n";
html += (params.td == undefined || params.td !== false) ? "</td>\n" : "";
return html;

View File

@ -9,8 +9,8 @@
angular.module('ListGenerator', ['GeneratorHelpers'])
.factory('GenerateList', [ '$location', '$compile', '$rootScope', 'SearchWidget', 'PaginateWidget', 'Attr', 'Icon',
'Column',
function($location, $compile, $rootScope, SearchWidget, PaginateWidget, Attr, Icon, Column) {
'Column', 'DropDown',
function($location, $compile, $rootScope, SearchWidget, PaginateWidget, Attr, Icon, Column, DropDown) {
return {
setList: function(list) {
@ -279,7 +279,20 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
// Row level actions
html += "<td class=\"actions\">";
for (action in list.fieldActions) {
html += this.button(list.fieldActions[action]);
if (list.fieldActions[action].type && list.fieldActions[action].type == 'DropDown') {
html += DropDown({
list: list,
fld: action,
options: options,
base: base,
type: 'fieldActions',
td: false
});
}
else {
console.log('here');
html += this.button(list.fieldActions[action]);
}
}
html += "</td>";
}