mirror of
https://github.com/ansible/awx.git
synced 2026-05-24 09:07:45 -02:30
AC-1017 Added events and hosts links to the job status fly-out. Fixed a bug in search where claring the value and hitting enter did not switch the icon back to the magnifying glass. Linted Search.js and Hosts.js helpers.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
"jquery": true,
|
||||
"esnext": true,
|
||||
"globalstrict": true,
|
||||
"globals": { "angular":false, "alert":false, "$AnsibleConfig":true, "$basePath":true },
|
||||
"globals": { "angular":false, "alert":false, "$AnsibleConfig":true, "$basePath":true, "jsyaml":false },
|
||||
"strict": false,
|
||||
"quotmark": false,
|
||||
"smarttabs": true,
|
||||
|
||||
@@ -7,13 +7,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* jshint loopfunc: true */
|
||||
|
||||
angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'HostListDefinition',
|
||||
'SearchHelper', 'PaginationHelpers', 'ListGenerator', 'AuthService', 'HostsHelper',
|
||||
'InventoryHelper', 'RelatedSearchHelper', 'InventoryFormDefinition', 'SelectionHelper',
|
||||
'HostGroupsFormDefinition'
|
||||
])
|
||||
|
||||
|
||||
.factory('SetEnabledMsg', [ function() {
|
||||
return function(host) {
|
||||
if (host.has_inventory_sources) {
|
||||
@@ -24,24 +25,24 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
// Clickable
|
||||
host.enabledToolTip = (host.enabled) ? 'Host is available. Click to toggle.' : 'Host is not available. Click to toggle.';
|
||||
}
|
||||
}
|
||||
};
|
||||
}])
|
||||
|
||||
.factory('SetHostStatus', ['SetEnabledMsg', function(SetEnabledMsg) {
|
||||
return function(host) {
|
||||
// Set status related fields on a host object
|
||||
host.activeFailuresLink = '/#/hosts/' + host.id + '/job_host_summaries/?inventory=' + host.inventory +
|
||||
'&host_name=' + escape(host.name);
|
||||
if (host.has_active_failures == true) {
|
||||
'&host_name=' + encodeURI(host.name);
|
||||
if (host.has_active_failures === true) {
|
||||
host.badgeToolTip = 'Most recent job failed. Click to view jobs.';
|
||||
host.active_failures = 'failed';
|
||||
}
|
||||
else if (host.has_active_failures == false && host.last_job == null) {
|
||||
else if (host.has_active_failures === false && host.last_job === null) {
|
||||
host.has_active_failures = 'none';
|
||||
host.badgeToolTip = "No job data available.";
|
||||
host.active_failures = 'n/a';
|
||||
}
|
||||
else if (host.has_active_failures == false && host.last_job !== null) {
|
||||
else if (host.has_active_failures === false && host.last_job !== null) {
|
||||
host.badgeToolTip = "Most recent job successful. Click to view jobs.";
|
||||
host.active_failures = 'success';
|
||||
}
|
||||
@@ -49,18 +50,26 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
host.enabled_flag = host.enabled;
|
||||
SetEnabledMsg(host);
|
||||
|
||||
}
|
||||
};
|
||||
}])
|
||||
|
||||
.factory('SetStatus', ['SetEnabledMsg', 'Empty', function(SetEnabledMsg, Empty) {
|
||||
return function(params) {
|
||||
|
||||
var scope = params.scope;
|
||||
var host = params.host;
|
||||
var html, title;
|
||||
var scope = params.scope,
|
||||
host = params.host,
|
||||
i, html, title;
|
||||
|
||||
function ellipsis(a) {
|
||||
if (a.length > 25) {
|
||||
return a.substr(0,25) + '...';
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
function setMsg(host) {
|
||||
if (host.has_active_failures == true || (host.has_active_failures == false && host.last_job !== null)) {
|
||||
var j, job, jobs;
|
||||
if (host.has_active_failures === true || (host.has_active_failures === false && host.last_job !== null)) {
|
||||
if (host.has_active_failures === true) {
|
||||
host.badgeToolTip = 'Most recent job failed. Click to view jobs.';
|
||||
host.active_failures = 'failed';
|
||||
@@ -71,27 +80,31 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
}
|
||||
if (host.summary_fields.recent_jobs.length > 0) {
|
||||
// build html table of job status info
|
||||
var jobs = host.summary_fields.recent_jobs.sort(
|
||||
jobs = host.summary_fields.recent_jobs.sort(
|
||||
function(a,b) {
|
||||
// reverse numerical order
|
||||
return -1 * (a - b);
|
||||
});
|
||||
title = "Recent Jobs";
|
||||
html = "<table class=\"table table-condensed\" style=\"width: 100%\">\n";
|
||||
html = "<table class=\"table table-condensed host-flyout\" style=\"width: 100%\">\n";
|
||||
html += "<thead>\n";
|
||||
html += "<tr>\n";
|
||||
html += "<th>ID</td>\n";
|
||||
html += "<th class=\"text-center\">Status</td>\n";
|
||||
html += "<th>View</th>\n";
|
||||
html += "<th>Name</td>\n";
|
||||
html += "</tr>\n";
|
||||
html += "</thead>\n";
|
||||
html += "<tbody>\n";
|
||||
for (var j=0; j < jobs.length; j++) {
|
||||
var job = jobs[j];
|
||||
for (j=0; j < jobs.length; j++) {
|
||||
job = jobs[j];
|
||||
html += "<tr>\n";
|
||||
html += "<td><a ng-click=\"showJobSummary(" + job.id + ")\">" + job.id + "</a></td>\n";
|
||||
html += "<td class=\"text-center\"><a ng-click=\"showJobSummary(" + job.id + ")\"><i class=\"fa icon-job-" + job.status + "\"></i></a></td>\n";
|
||||
html += "<td class=\"break\">" + "language_features/roletest.yml(limit:all:cloud)therealsuperlonglaskaname</td>\n";
|
||||
html += "<td class=\"text-center\"><a ng-click=\"showJobSummary(" + job.id + ")\"><i class=\"fa icon-job-" +
|
||||
job.status + "\"></i></a></td>\n";
|
||||
html += "<td><a href=\"/#/jobs/" + job.id + "/job_events/?host=" + encodeURI(host.name) + "\">Events</a> " +
|
||||
"<a href=\"/#/jobs/" + job.id + "/job_host_summaries/?host_name=" + encodeURI(host.name) + "\">Hosts</a></td>\n";
|
||||
html += "<td class=\"break\">" + ellipsis(job.name) + "</td>\n";
|
||||
html += "</tr>\n";
|
||||
}
|
||||
html += "</tbody>\n";
|
||||
@@ -102,7 +115,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
html = '<p>No recent job data available for this host.</p>';
|
||||
}
|
||||
}
|
||||
else if (host.has_active_failures == false && host.last_job == null) {
|
||||
else if (host.has_active_failures === false && host.last_job === null) {
|
||||
host.has_active_failures = 'none';
|
||||
host.badgeToolTip = "No job data available.";
|
||||
host.active_failures = 'n/a';
|
||||
@@ -118,13 +131,13 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
}
|
||||
else {
|
||||
// update all hosts
|
||||
for (var i=0; i < scope.hosts.length; i++) {
|
||||
for (i=0; i < scope.hosts.length; i++) {
|
||||
setMsg(scope.hosts[i]);
|
||||
SetEnabledMsg(scope.hosts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}])
|
||||
|
||||
.factory('HostsReload', [ '$routeParams', 'Empty', 'InventoryHosts', 'GetBasePath', 'SearchInit', 'PaginateInit', 'Wait',
|
||||
@@ -133,13 +146,12 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
ApplyEllipsis) {
|
||||
return function(params) {
|
||||
|
||||
var scope = params.scope;
|
||||
var group_id = params.group_id;
|
||||
var tree_id = params.tree_id
|
||||
var inventory_id = params.inventory_id;
|
||||
var scope = params.scope,
|
||||
group_id = params.group_id,
|
||||
inventory_id = params.inventory_id,
|
||||
list = InventoryHosts,
|
||||
|
||||
var list = InventoryHosts;
|
||||
var url = ( !Empty(group_id) ) ? GetBasePath('groups') + group_id + '/all_hosts/' :
|
||||
url = ( !Empty(group_id) ) ? GetBasePath('groups') + group_id + '/all_hosts/' :
|
||||
GetBasePath('inventory') + inventory_id + '/hosts/';
|
||||
|
||||
scope.search_place_holder='Search ' + scope.selected_group_name;
|
||||
@@ -147,7 +159,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
if (scope.removePostRefresh) {
|
||||
scope.removePostRefresh();
|
||||
}
|
||||
scope.removePostRefresh = scope.$on('PostRefresh', function(e) {
|
||||
scope.removePostRefresh = scope.$on('PostRefresh', function() {
|
||||
for (var i=0; i < scope.hosts.length; i++) {
|
||||
//Set tooltip for host enabled flag
|
||||
scope.hosts[i].enabled_flag = scope.hosts[i].enabled;
|
||||
@@ -162,11 +174,11 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
SearchInit({ scope: scope, set: 'hosts', list: list, url: url });
|
||||
PaginateInit({ scope: scope, list: list, url: url });
|
||||
|
||||
if ($routeParams['host_name']) {
|
||||
if ($routeParams.host_name) {
|
||||
scope[list.iterator + 'InputDisable'] = false;
|
||||
scope[list.iterator + 'SearchValue'] = $routeParams['host_name'];
|
||||
scope[list.iterator + 'SearchValue'] = $routeParams.host_name;
|
||||
scope[list.iterator + 'SearchField'] = 'name';
|
||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields['name'].label;
|
||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields.name.label;
|
||||
scope[list.iterator + 'SearchSelectValue'] = null;
|
||||
}
|
||||
|
||||
@@ -174,42 +186,39 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
scope[list.iterator + 'InputDisable'] = true;
|
||||
scope[list.iterator + 'SearchValue'] = 'true';
|
||||
scope[list.iterator + 'SearchField'] = 'has_active_failures';
|
||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields['has_active_failures'].label;
|
||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields.has_active_failures.label;
|
||||
scope[list.iterator + 'SearchSelectValue'] = { value: 1 };
|
||||
}
|
||||
|
||||
scope.search(list.iterator);
|
||||
|
||||
}
|
||||
};
|
||||
}])
|
||||
|
||||
.factory('InjectHosts', ['GenerateList', 'InventoryHosts', 'HostsReload',
|
||||
function(GenerateList, InventoryHosts, HostsReload) {
|
||||
return function(params) {
|
||||
|
||||
var scope = params.scope;
|
||||
var inventory_id = params.inventory_id;
|
||||
var group_id = params.group_id;
|
||||
var tree_id = params.tree_id;
|
||||
var scope = params.scope,
|
||||
inventory_id = params.inventory_id,
|
||||
group_id = params.group_id,
|
||||
tree_id = params.tree_id,
|
||||
generator = GenerateList;
|
||||
|
||||
// Inject the list html
|
||||
var generator = GenerateList;
|
||||
generator.inject(InventoryHosts, { scope: scope, mode: 'edit', id: 'hosts-container', breadCrumbs: false, searchSize: 'col-lg-6 col-md-6 col-sm-6' });
|
||||
|
||||
// Load data
|
||||
HostsReload({ scope: scope, group_id: group_id, tree_id: tree_id, inventory_id: inventory_id });
|
||||
}
|
||||
};
|
||||
}])
|
||||
|
||||
.factory('ToggleHostEnabled', [ 'GetBasePath', 'Rest', 'Wait', 'ProcessErrors', 'Alert', 'Find', 'SetEnabledMsg',
|
||||
function(GetBasePath, Rest, Wait, ProcessErrors, Alert, Find, SetEnabledMsg) {
|
||||
return function(params) {
|
||||
|
||||
var id = params.host_id;
|
||||
var external_source = params.external_source;
|
||||
var scope = params.scope
|
||||
|
||||
var host;
|
||||
var id = params.host_id,
|
||||
external_source = params.external_source,
|
||||
scope = params.scope,
|
||||
host;
|
||||
|
||||
function setMsg(host) {
|
||||
host.enabled = (host.enabled) ? false : true;
|
||||
@@ -225,10 +234,10 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
|
||||
Rest.setUrl(GetBasePath('hosts') + id + '/');
|
||||
Rest.put(host)
|
||||
.success( function(data, status, headers, config) {
|
||||
.success( function() {
|
||||
Wait('stop');
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
.error( function(data, status) {
|
||||
// Flip the enabled flag back
|
||||
setMsg(host);
|
||||
Wait('stop');
|
||||
@@ -241,34 +250,34 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
' After disabling it, run an inventory sync to see the new status reflected here.',
|
||||
'alert-info');
|
||||
}
|
||||
}
|
||||
};
|
||||
}])
|
||||
|
||||
.factory('HostsList', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'HostList', 'GenerateList',
|
||||
'Prompt', 'SearchInit', 'PaginateInit', 'ProcessErrors', 'GetBasePath', 'HostsAdd', 'HostsReload',
|
||||
'SelectionInit',
|
||||
'Prompt', 'SearchInit', 'PaginateInit', 'ProcessErrors', 'GetBasePath', 'HostsAdd', 'HostsReload', 'SelectionInit',
|
||||
function($rootScope, $location, $log, $routeParams, Rest, Alert, HostList, GenerateList, Prompt, SearchInit,
|
||||
PaginateInit, ProcessErrors, GetBasePath, HostsAdd, HostsReload, SelectionInit) {
|
||||
return function(params) {
|
||||
|
||||
var inventory_id = params.inventory_id;
|
||||
var group_id = params.group_id;
|
||||
|
||||
var list = HostList;
|
||||
var inventory_id = params.inventory_id,
|
||||
group_id = params.group_id,
|
||||
list = HostList,
|
||||
generator = GenerateList,
|
||||
defaultUrl, scope;
|
||||
|
||||
list.iterator = 'subhost'; //Override the iterator and name so the scope of the modal dialog
|
||||
list.name = 'subhosts'; //will not conflict with the parent scope
|
||||
|
||||
var view = GenerateList;
|
||||
|
||||
var scope = view.inject(list, {
|
||||
|
||||
scope = generator.inject(list, {
|
||||
id: 'form-modal-body',
|
||||
mode: 'select',
|
||||
breadCrumbs: false,
|
||||
selectButton: false
|
||||
});
|
||||
|
||||
var defaultUrl = GetBasePath('inventory') + inventory_id + '/hosts/?not__groups__id=' + scope.group_id;
|
||||
defaultUrl = GetBasePath('inventory') + inventory_id + '/hosts/?not__groups__id=' + scope.group_id;
|
||||
|
||||
scope.formModalActionLabel = 'Select';
|
||||
scope.formModalHeader = 'Add Existing Hosts';
|
||||
@@ -299,9 +308,9 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
scope.createHost = function() {
|
||||
$('#form-modal').modal('hide');
|
||||
HostsAdd({ scope: params.scope, inventory_id: inventory_id, group_id: group_id });
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
}])
|
||||
|
||||
|
||||
@@ -311,15 +320,14 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
GetBasePath, HostsReload, ParseTypeChange, Wait, WatchInventoryWindowResize) {
|
||||
return function(params) {
|
||||
|
||||
var parent_scope = params.scope;
|
||||
var inventory_id = parent_scope.inventory_id;
|
||||
var group_id = parent_scope.selected_group_id;
|
||||
|
||||
// Inject dynamic view
|
||||
var defaultUrl = GetBasePath('groups') + group_id + '/hosts/';
|
||||
var form = HostForm;
|
||||
var generator = GenerateForm;
|
||||
var scope = generator.inject(form, {mode: 'add', modal: true, related: false});
|
||||
var parent_scope = params.scope,
|
||||
inventory_id = parent_scope.inventory_id,
|
||||
group_id = parent_scope.selected_group_id,
|
||||
defaultUrl = GetBasePath('groups') + group_id + '/hosts/',
|
||||
form = HostForm,
|
||||
generator = GenerateForm,
|
||||
scope = generator.inject(form, {mode: 'add', modal: true, related: false}),
|
||||
master={};
|
||||
|
||||
scope.formModalActionLabel = 'Save';
|
||||
scope.formModalHeader = 'Create New Host';
|
||||
@@ -339,7 +347,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
//$('#form-modal').on('hidden', function () { scope.$emit('hostsReload'); });
|
||||
|
||||
generator.reset();
|
||||
var master={};
|
||||
master={};
|
||||
|
||||
if (!scope.$$phase) {
|
||||
scope.$digest();
|
||||
@@ -356,7 +364,8 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
scope: parent_scope,
|
||||
group_id: parent_scope.selected_group_id,
|
||||
tree_id: parent_scope.selected_tree_id,
|
||||
inventory_id: parent_scope.inventory_id });
|
||||
inventory_id: parent_scope.inventory_id
|
||||
});
|
||||
|
||||
WatchInventoryWindowResize();
|
||||
});
|
||||
@@ -367,14 +376,15 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
Wait('start');
|
||||
|
||||
try {
|
||||
var fld, json_data, data={};
|
||||
scope.formModalActionDisabled = true;
|
||||
|
||||
// Make sure we have valid variable data
|
||||
if (scope.parseType == 'json') {
|
||||
var json_data = JSON.parse(scope.variables); //make sure JSON parses
|
||||
if (scope.parseType === 'json') {
|
||||
json_data = JSON.parse(scope.variables); //make sure JSON parses
|
||||
}
|
||||
else {
|
||||
var json_data = jsyaml.load(scope.variables); //parse yaml
|
||||
json_data = jsyaml.load(scope.variables); //parse yaml
|
||||
}
|
||||
|
||||
// Make sure our JSON is actually an object
|
||||
@@ -382,28 +392,27 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
throw "failed to return an object!";
|
||||
}
|
||||
|
||||
var data = {}
|
||||
for (var fld in form.fields) {
|
||||
if (fld != 'variables') {
|
||||
for (fld in form.fields) {
|
||||
if (fld !== 'variables') {
|
||||
data[fld] = scope[fld];
|
||||
}
|
||||
}
|
||||
|
||||
data['inventory'] = inventory_id;
|
||||
data.inventory = inventory_id;
|
||||
|
||||
if ($.isEmptyObject(json_data)) {
|
||||
data['variables'] = "";
|
||||
data.variables = "";
|
||||
}
|
||||
else {
|
||||
data['variables'] = JSON.stringify(json_data, undefined, '\t');
|
||||
data.variables = JSON.stringify(json_data, undefined, '\t');
|
||||
}
|
||||
|
||||
Rest.setUrl(defaultUrl);
|
||||
Rest.post(data)
|
||||
.success( function(data, status, headers, config) {
|
||||
.success( function() {
|
||||
scope.$emit('HostSaveComplete');
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
.error( function(data, status) {
|
||||
Wait('stop');
|
||||
scope.formModalActionDisabled = false;
|
||||
ProcessErrors(scope, data, status, form,
|
||||
@@ -415,7 +424,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
scope.formModalActionDisabled = false;
|
||||
Alert("Error", "Error parsing host variables. Parser returned: " + err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Cancel
|
||||
scope.formReset = function() {
|
||||
@@ -425,9 +434,9 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
|
||||
scope.cancelModal = function() {
|
||||
WatchInventoryWindowResize();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
}])
|
||||
|
||||
|
||||
@@ -438,17 +447,15 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
GetBasePath, HostsReload, ParseTypeChange, Wait, Find, SetStatus, ApplyEllipsis, WatchInventoryWindowResize) {
|
||||
return function(params) {
|
||||
|
||||
var parent_scope = params.scope;
|
||||
var host_id = params.host_id;
|
||||
var inventory_id = params.inventory_id;
|
||||
var group_id = params.group_id;
|
||||
|
||||
var generator = GenerateForm;
|
||||
var form = HostForm;
|
||||
var defaultUrl = GetBasePath('hosts') + host_id + '/';
|
||||
var scope = generator.inject(form, { mode: 'edit', modal: true, related: false, show_modal: false });
|
||||
var master = {};
|
||||
var relatedSets = {};
|
||||
var parent_scope = params.scope,
|
||||
host_id = params.host_id,
|
||||
inventory_id = params.inventory_id,
|
||||
generator = GenerateForm,
|
||||
form = HostForm,
|
||||
defaultUrl = GetBasePath('hosts') + host_id + '/',
|
||||
scope = generator.inject(form, { mode: 'edit', modal: true, related: false, show_modal: false }),
|
||||
master = {},
|
||||
relatedSets = {};
|
||||
|
||||
generator.reset();
|
||||
scope.formModalActionLabel = 'Save';
|
||||
@@ -457,7 +464,6 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
scope.parseType = 'yaml';
|
||||
ParseTypeChange(scope);
|
||||
|
||||
|
||||
if (scope.hostLoadedRemove) {
|
||||
scope.hostLoadedRemove();
|
||||
}
|
||||
@@ -466,7 +472,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
if (scope.variable_url) {
|
||||
Rest.setUrl(scope.variable_url);
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
.success( function(data) {
|
||||
if ($.isEmptyObject(data)) {
|
||||
scope.variables = "---";
|
||||
}
|
||||
@@ -476,7 +482,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
Wait('stop');
|
||||
$('#form-modal').modal('show');
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
.error( function(data, status) {
|
||||
scope.variables = null;
|
||||
ProcessErrors(scope, data, status, form,
|
||||
{ hdr: 'Error!', msg: 'Failed to retrieve host variables. GET returned status: ' + status });
|
||||
@@ -495,15 +501,16 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
// Retrieve detail record and prepopulate the form
|
||||
Rest.setUrl(defaultUrl);
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
for (var fld in form.fields) {
|
||||
.success( function(data) {
|
||||
var set, fld, related;
|
||||
for (fld in form.fields) {
|
||||
if (data[fld]) {
|
||||
scope[fld] = data[fld];
|
||||
master[fld] = scope[fld];
|
||||
}
|
||||
}
|
||||
var related = data.related;
|
||||
for (var set in form.related) {
|
||||
related = data.related;
|
||||
for (set in form.related) {
|
||||
if (related[set]) {
|
||||
relatedSets[set] = { url: related[set], iterator: form.related[set].iterator };
|
||||
}
|
||||
@@ -511,7 +518,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
scope.variable_url = data.related.variable_data;
|
||||
scope.$emit('hostLoaded');
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
.error( function(data, status) {
|
||||
ProcessErrors(scope, data, status, form,
|
||||
{ hdr: 'Error!', msg: 'Failed to retrieve host: ' + host_id + '. GET returned status: ' + status });
|
||||
});
|
||||
@@ -522,8 +529,8 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
}
|
||||
scope.removeSaveCompleted = scope.$on('saveCompleted', function() {
|
||||
// Update the name on the list
|
||||
var host = Find({ list: parent_scope.hosts, key: 'id', val: host_id });
|
||||
var old_name = host.name;
|
||||
var host = Find({ list: parent_scope.hosts, key: 'id', val: host_id }),
|
||||
old_name = host.name;
|
||||
host.name = scope.name;
|
||||
host.enabled = scope.enabled;
|
||||
host.enabled_flag = scope.enabled;
|
||||
@@ -554,13 +561,13 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
Wait('start');
|
||||
|
||||
try {
|
||||
|
||||
// Make sure we have valid variable data
|
||||
if (scope.parseType == 'json') {
|
||||
var json_data = JSON.parse(scope.variables); //make sure JSON parses
|
||||
var fld, json_data, data={};
|
||||
if (scope.parseType === 'json') {
|
||||
json_data = JSON.parse(scope.variables); //make sure JSON parses
|
||||
}
|
||||
else {
|
||||
var json_data = jsyaml.load(scope.variables); //parse yaml
|
||||
json_data = jsyaml.load(scope.variables); //parse yaml
|
||||
}
|
||||
|
||||
// Make sure our JSON is actually an object
|
||||
@@ -568,25 +575,24 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
throw "failed to return an object!";
|
||||
}
|
||||
|
||||
var data = {}
|
||||
for (var fld in form.fields) {
|
||||
for (fld in form.fields) {
|
||||
data[fld] = scope[fld];
|
||||
}
|
||||
data['inventory'] = inventory_id;
|
||||
data.inventory = inventory_id;
|
||||
|
||||
if ($.isEmptyObject(json_data)) {
|
||||
data['variables'] = "";
|
||||
data.variables = "";
|
||||
}
|
||||
else {
|
||||
data['variables'] = JSON.stringify(json_data, undefined, '\t');
|
||||
data.variables = JSON.stringify(json_data, undefined, '\t');
|
||||
}
|
||||
|
||||
Rest.setUrl(defaultUrl);
|
||||
Rest.put(data)
|
||||
.success( function(data, status, headers, config) {
|
||||
.success( function() {
|
||||
scope.$emit('saveCompleted');
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
.error( function(data, status) {
|
||||
Wait('stop');
|
||||
ProcessErrors(scope, data, status, form,
|
||||
{ hdr: 'Error!', msg: 'Failed to update host: ' + host_id + '. PUT returned status: ' + status });
|
||||
@@ -605,13 +611,13 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
scope[fld] = master[fld];
|
||||
}
|
||||
scope.parseType = 'yaml';
|
||||
}
|
||||
};
|
||||
|
||||
scope.cancelModal = function() {
|
||||
WatchInventoryWindowResize();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
}])
|
||||
|
||||
|
||||
@@ -621,14 +627,15 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
return function(params) {
|
||||
// Remove the selected host from the current group by disassociating
|
||||
|
||||
var scope = params.scope;
|
||||
var host_id = params.host_id;
|
||||
var host_name = params.host_name;
|
||||
var action_to_take, body,
|
||||
scope = params.scope,
|
||||
host_id = params.host_id,
|
||||
host_name = params.host_name,
|
||||
|
||||
var url = (scope.selected_group_id == null) ? GetBasePath('inventory') + scope.inventory_id + '/hosts/' :
|
||||
GetBasePath('groups') + scope.selected_group_id + '/hosts/';
|
||||
url = (scope.selected_group_id === null) ? GetBasePath('inventory') + scope.inventory_id + '/hosts/' :
|
||||
GetBasePath('groups') + scope.selected_group_id + '/hosts/',
|
||||
|
||||
var group = (scope.selected_tree_id) ? Find({ list: scope.groups, key: 'id', val: scope.selected_tree_id }) : null;
|
||||
group = (scope.selected_tree_id) ? Find({ list: scope.groups, key: 'id', val: scope.selected_tree_id }) : null;
|
||||
|
||||
if (scope.removeHostsReload) {
|
||||
scope.removeHostsReload();
|
||||
@@ -637,125 +644,42 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
scope.showHosts(scope.selected_tree_id, scope.selected_group_id, false);
|
||||
});
|
||||
|
||||
var action_to_take = function() {
|
||||
action_to_take = function() {
|
||||
$('#prompt-modal').on('hidden.bs.modal', function(){ Wait('start'); });
|
||||
$('#prompt-modal').modal('hide');
|
||||
Rest.setUrl(url);
|
||||
Rest.post({ id: host_id, disassociate: 1 })
|
||||
.success( function(data, status, headers, config) {
|
||||
.success( function() {
|
||||
scope.$emit('hostsReload');
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
.error( function(data, status) {
|
||||
Wait('stop');
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Attempt to delete ' + host_name + ' failed. POST returned status: ' + status });
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var body = (group) ? '<p>Are you sure you want to delete host <em>' + host_name + '</em> from group <em>' + group.name + '</em>?</p>' :
|
||||
body = (group) ? '<p>Are you sure you want to delete host <em>' + host_name + '</em> from group <em>' + group.name + '</em>?</p>' :
|
||||
'<p>Are you sure you want to delete host <em>' + host_name + '</em>?</p>';
|
||||
|
||||
Prompt({ hdr: 'Delete Host', body: body, action: action_to_take, 'class': 'btn-danger' });
|
||||
|
||||
}
|
||||
};
|
||||
}])
|
||||
|
||||
/*
|
||||
.factory('HostsReload', ['$location', '$routeParams', 'SearchInit', 'PaginateInit', 'InventoryHostsForm', 'GetBasePath', 'Wait',
|
||||
'SetHostStatus',
|
||||
function($location, $routeParams, SearchInit, PaginateInit, InventoryHostsForm, GetBasePath, Wait, SetHostStatus) {
|
||||
return function(params) {
|
||||
// Rerfresh the Hosts view on right side of page
|
||||
|
||||
var scope = params.scope;
|
||||
var group_id = scope.group_id;
|
||||
var postAction = params.action;
|
||||
|
||||
scope['hosts'] = null;
|
||||
scope['toggleAllFlag'] = false;
|
||||
scope['hostDeleteHide'] = true;
|
||||
|
||||
var url = (group_id !== null && group_id !== undefined) ? GetBasePath('groups') + group_id + '/all_hosts/' :
|
||||
GetBasePath('inventory') + params.inventory_id + '/hosts/';
|
||||
|
||||
// Set the groups value in each element of hosts array
|
||||
if (scope.removePostRefresh) {
|
||||
scope.removePostRefresh();
|
||||
}
|
||||
scope.removePostRefresh = scope.$on('PostRefresh', function() {
|
||||
|
||||
// Add a list of groups to each host
|
||||
var groups, descr, found, list;
|
||||
for (var i=0; i < scope.hosts.length; i++) {
|
||||
groups = scope.hosts[i].summary_fields.groups;
|
||||
scope.hosts[i].groups = '';
|
||||
for (var k=0; k < groups.length; k++) {
|
||||
if (!groups[k].name.match(/^_deleted/)) {
|
||||
scope.hosts[i].groups += groups[k].name + ', '
|
||||
}
|
||||
}
|
||||
scope.hosts[i].groups = scope.hosts[i].groups.replace(/\, $/,'');
|
||||
}
|
||||
|
||||
for (var i=0; i < scope.hosts.length; i++) {
|
||||
SetHostStatus(scope.hosts[i]);
|
||||
}
|
||||
|
||||
if (group_id == null || group_id == undefined) {
|
||||
if (!scope.hosts.length) {
|
||||
scope.$emit('ShowHelp');
|
||||
}
|
||||
}
|
||||
|
||||
if (postAction) {
|
||||
postAction();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
SearchInit({ scope: scope, set: 'hosts', list: InventoryHostsForm, url: url });
|
||||
PaginateInit({ scope: scope, list: InventoryHostsForm, url: url });
|
||||
|
||||
if ($routeParams['has_active_failures']) {
|
||||
//scope.resetSearch(InventoryHostsForm.iterator);
|
||||
scope[InventoryHostsForm.iterator + 'InputDisable'] = true;
|
||||
scope[InventoryHostsForm.iterator + 'SearchValue'] = $routeParams['has_active_failures'];
|
||||
scope[InventoryHostsForm.iterator + 'SearchField'] = 'has_active_failures';
|
||||
scope[InventoryHostsForm.iterator + 'SearchFieldLabel'] = InventoryHostsForm.fields['has_active_failures'].label;
|
||||
scope[InventoryHostsForm.iterator + 'SearchSelectValue'] = ($routeParams['has_active_failures'] == 'true') ? { value: 1 } : { value: 0 };
|
||||
|
||||
}
|
||||
else if ($routeParams['name']) {
|
||||
scope[InventoryHostsForm.iterator + 'InputDisable'] = false;
|
||||
scope[InventoryHostsForm.iterator + 'SearchValue'] = $routeParams['name'];
|
||||
scope[InventoryHostsForm.iterator + 'SearchField'] = 'name';
|
||||
scope[InventoryHostsForm.iterator + 'SearchFieldLabel'] = InventoryHostsForm.fields['name'].label;
|
||||
scope[InventoryHostsForm.iterator + 'SearchSelectValue'] = null;
|
||||
}
|
||||
|
||||
scope.search(InventoryHostsForm.iterator);
|
||||
|
||||
if (!params.scope.$$phase) {
|
||||
params.scope.$digest();
|
||||
}
|
||||
}
|
||||
}])
|
||||
|
||||
*/
|
||||
|
||||
.factory('EditHostGroups', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GenerateForm',
|
||||
'Prompt', 'ProcessErrors', 'GetBasePath', 'HostsReload', 'ParseTypeChange', 'Wait',
|
||||
function($rootScope, $location, $log, $routeParams, Rest, Alert, GenerateForm, Prompt, ProcessErrors,
|
||||
GetBasePath, HostsReload, ParseTypeChange, Wait) {
|
||||
.factory('EditHostGroups', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GenerateForm', 'Prompt',
|
||||
'ProcessErrors', 'GetBasePath', 'HostsReload', 'ParseTypeChange', 'Wait',
|
||||
function($rootScope, $location, $log, $routeParams, Rest, Alert, GenerateForm, Prompt, ProcessErrors, GetBasePath, HostsReload,
|
||||
ParseTypeChange, Wait) {
|
||||
return function(params) {
|
||||
|
||||
var host_id = params.host_id;
|
||||
var inventory_id = params.inventory_id;
|
||||
var generator = GenerateForm;
|
||||
var actions = [];
|
||||
var host_id = params.host_id,
|
||||
inventory_id = params.inventory_id,
|
||||
generator = GenerateForm,
|
||||
actions = [],
|
||||
i, html, defaultUrl, scope, postAction;
|
||||
|
||||
//var html="<div class=\"host-groups-title\"><h4>{{ host.name }}</h4></div>\n";
|
||||
var html = "<div class=\"row host-groups\">\n";
|
||||
html = "<div class=\"row host-groups\">\n";
|
||||
html += "<div class=\"col-lg-6\">\n";
|
||||
html += "<label>Available Groups:</label>\n";
|
||||
html += "<select multiple class=\"form-control\" name=\"available-groups\" ng-model=\"selectedGroups\" ng-change=\"leftChange()\" " +
|
||||
@@ -777,11 +701,11 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
html += "</div>\n";
|
||||
html += "</div>\n";
|
||||
|
||||
var defaultUrl = GetBasePath('hosts') + host_id + '/';
|
||||
var scope = generator.inject(null, { mode: 'edit', modal: true, related: false, html: html });
|
||||
defaultUrl = GetBasePath('hosts') + host_id + '/';
|
||||
scope = generator.inject(null, { mode: 'edit', modal: true, related: false, html: html });
|
||||
|
||||
for (var i=0; i < scope.hosts.length; i++) {
|
||||
if (scope.hosts[i].id == host_id) {
|
||||
for (i=0; i < scope.hosts.length; i++) {
|
||||
if (scope.hosts[i].id === host_id) {
|
||||
scope.host = scope.hosts[i];
|
||||
}
|
||||
}
|
||||
@@ -802,11 +726,11 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
if (scope.hostGroupChangeRemove) {
|
||||
scope.hostGroupChangeRemove();
|
||||
}
|
||||
scope.hostGroupChangeRemove = scope.$on('hostGroupChange', function(e) {
|
||||
scope.hostGroupChangeRemove = scope.$on('hostGroupChange', function() {
|
||||
actions.pop();
|
||||
if (actions.length == 0) {
|
||||
var postAction = function() {
|
||||
setTimeout(function() { Wait('stop') }, 500);
|
||||
if (actions.length === 0) {
|
||||
postAction = function() {
|
||||
setTimeout(function() { Wait('stop'); }, 500);
|
||||
};
|
||||
HostsReload({ scope: scope, inventory_id: inventory_id, group_id: scope.group_id , action: postAction });
|
||||
}
|
||||
@@ -814,16 +738,16 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
|
||||
// Save changes
|
||||
scope.formModalAction = function() {
|
||||
var found;
|
||||
var i, j, found;
|
||||
|
||||
$('#form-modal').modal('hide');
|
||||
Wait('start');
|
||||
|
||||
// removed host from deleted groups
|
||||
for (var i=0; i < scope.original_groups.length; i++) {
|
||||
for (i=0; i < scope.original_groups.length; i++) {
|
||||
found = false;
|
||||
for (var j=0; j < scope.host_groups.length; j++) {
|
||||
if (scope.original_groups[i].id == scope.host_groups[j].id) {
|
||||
for (j=0; j < scope.host_groups.length; j++) {
|
||||
if (scope.original_groups[i].id === scope.host_groups[j].id) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
@@ -832,10 +756,10 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
actions.push({ group_id: scope.original_groups[i].id , action: 'delete' });
|
||||
Rest.setUrl(GetBasePath('groups') + scope.original_groups[i].id + '/hosts/');
|
||||
Rest.post({ id: host_id, disassociate: 1 })
|
||||
.success( function(data, status, headers, config) {
|
||||
.success( function() {
|
||||
scope.$emit('hostGroupChange');
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
.error( function(data, status) {
|
||||
scope.$emit('hostGroupChange');
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Attempt to remove host from group ' + scope.original_groups[i].name +
|
||||
@@ -845,10 +769,10 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
}
|
||||
|
||||
// add host to new groups
|
||||
for (var i=0; i < scope.host_groups.length; i++) {
|
||||
for (i=0; i < scope.host_groups.length; i++) {
|
||||
found = false;
|
||||
for (var j=0; j < scope.original_groups.length; j++) {
|
||||
if (scope.original_groups[j].id == scope.host_groups[i].id) {
|
||||
for (j=0; j < scope.original_groups.length; j++) {
|
||||
if (scope.original_groups[j].id === scope.host_groups[i].id) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
@@ -857,10 +781,10 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
actions.push({ group_id: scope.host_groups[i].id , action: 'add' });
|
||||
Rest.setUrl(GetBasePath('groups') + scope.host_groups[i].id + '/hosts/');
|
||||
Rest.post(scope.host)
|
||||
.success( function(data, status, headers, config) {
|
||||
.success( function() {
|
||||
scope.$emit('hostGroupChange');
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
.error( function(data, status) {
|
||||
scope.$emit('hostGroupChange');
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Attempt to add host to group ' + scope.host_groups[i].name +
|
||||
@@ -868,7 +792,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
scope.leftChange = function() {
|
||||
// Select/deselect on available groups list
|
||||
@@ -880,7 +804,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
else {
|
||||
scope.rightButtonDisabled = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
scope.rightChange = function() {
|
||||
// Select/deselect made on host groups list
|
||||
@@ -892,30 +816,32 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
else {
|
||||
scope.leftButtonDisabled = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
scope.moveLeft = function() {
|
||||
// Remove selected groups from the list of assigned groups
|
||||
for (var i=0; i < scope.assignedGroups.length; i++){
|
||||
for (var j=0 ; j < scope.host_groups.length; j++) {
|
||||
if (scope.host_groups[j].id == scope.assignedGroups[i].id) {
|
||||
|
||||
var i, j, found, placed;
|
||||
|
||||
for (i=0; i < scope.assignedGroups.length; i++){
|
||||
for (j=0 ; j < scope.host_groups.length; j++) {
|
||||
if (scope.host_groups[j].id === scope.assignedGroups[i].id) {
|
||||
scope.host_groups.splice(j,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
var found, placed;
|
||||
for (var i=0; i < scope.assignedGroups.length; i++){
|
||||
for (i=0; i < scope.assignedGroups.length; i++){
|
||||
found = false;
|
||||
for (var j=0; j < scope.available_groups.length && !found; j++){
|
||||
if (scope.available_groups[j].id == scope.assignedGroups[i].id) {
|
||||
for (j=0; j < scope.available_groups.length && !found; j++){
|
||||
if (scope.available_groups[j].id === scope.assignedGroups[i].id) {
|
||||
found=true;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
placed = false;
|
||||
for (var j=0; j < scope.available_groups.length && !placed; j++){
|
||||
if (j == 0 && scope.assignedGroups[i].name.toLowerCase() < scope.available_groups[j].name.toLowerCase()) {
|
||||
for (j=0; j < scope.available_groups.length && !placed; j++){
|
||||
if (j === 0 && scope.assignedGroups[i].name.toLowerCase() < scope.available_groups[j].name.toLowerCase()) {
|
||||
// prepend to the beginning of the array
|
||||
placed=true;
|
||||
scope.available_groups.unshift(scope.assignedGroups[i]);
|
||||
@@ -939,30 +865,32 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
scope.leftButtonDisabled = true;
|
||||
scope.rightButtonDisabled = true;
|
||||
scope.formModalActionDisabled = false;
|
||||
}
|
||||
};
|
||||
|
||||
scope.moveRight = function() {
|
||||
// Remove selected groups from list of available groups
|
||||
for (var i=0; i < scope.selectedGroups.length; i++){
|
||||
for (var j=0 ; j < scope.available_groups.length; j++) {
|
||||
if (scope.available_groups[j].id == scope.selectedGroups[i].id) {
|
||||
|
||||
var i, j, found, placed;
|
||||
|
||||
for (i=0; i < scope.selectedGroups.length; i++){
|
||||
for (j=0 ; j < scope.available_groups.length; j++) {
|
||||
if (scope.available_groups[j].id === scope.selectedGroups[i].id) {
|
||||
scope.available_groups.splice(j,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
var found, placed;
|
||||
for (var i=0; i < scope.selectedGroups.length; i++){
|
||||
for (i=0; i < scope.selectedGroups.length; i++){
|
||||
found = false;
|
||||
for (var j=0; j < scope.host_groups.length && !found; j++){
|
||||
if (scope.host_groups[j].id == scope.selectedGroups[i].id) {
|
||||
for (j=0; j < scope.host_groups.length && !found; j++){
|
||||
if (scope.host_groups[j].id === scope.selectedGroups[i].id) {
|
||||
found=true;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
placed = false;
|
||||
for (var j=0; j < scope.host_groups.length && !placed; j++){
|
||||
if (j == 0 && scope.selectedGroups[i].name.toLowerCase() < scope.host_groups[j].name.toLowerCase()) {
|
||||
for (j=0; j < scope.host_groups.length && !placed; j++) {
|
||||
if (j === 0 && scope.selectedGroups[i].name.toLowerCase() < scope.host_groups[j].name.toLowerCase()) {
|
||||
// prepend to the beginning of the array
|
||||
placed=true;
|
||||
scope.host_groups.unshift(scope.selectedGroups[i]);
|
||||
@@ -986,7 +914,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
scope.leftButtonDisabled = true;
|
||||
scope.rightButtonDisabled = true;
|
||||
scope.formModalActionDisabled = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Load the host's current list of groups
|
||||
@@ -995,8 +923,9 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
scope.available_groups = [];
|
||||
Rest.setUrl(scope.host.related.groups + '?order_by=name');
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
for (var i=0; i < data.results.length; i++) {
|
||||
.success( function(data) {
|
||||
var i, j, found;
|
||||
for (i=0; i < data.results.length; i++) {
|
||||
scope.host_groups.push({
|
||||
id: data.results[i].id,
|
||||
name: data.results[i].name,
|
||||
@@ -1008,11 +937,10 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
description: data.results[i].description
|
||||
});
|
||||
}
|
||||
var found;
|
||||
for (var i=0; i < scope.inventory_groups.length; i++) {
|
||||
for (i=0; i < scope.inventory_groups.length; i++) {
|
||||
found = false;
|
||||
for (var j=0; j < scope.host_groups.length; j++) {
|
||||
if (scope.inventory_groups[i].id == scope.host_groups[j].id) {
|
||||
for (j=0; j < scope.host_groups.length; j++) {
|
||||
if (scope.inventory_groups[i].id === scope.host_groups[j].id) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
@@ -1021,7 +949,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
}
|
||||
}
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
.error( function(data, status) {
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Failed to get current groups for host: ' + host_id + '. GET returned: ' + status });
|
||||
});
|
||||
@@ -1036,9 +964,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
if (!scope.$$phase) {
|
||||
scope.$digest();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
|
||||
|
||||
@@ -21,16 +21,17 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
function(Alert, Rest, Refresh, $location, GetBasePath, Empty, $timeout, Wait, Store) {
|
||||
return function(params) {
|
||||
|
||||
var scope = params.scope;
|
||||
var set = params.set;
|
||||
var defaultUrl = params.url;
|
||||
var list = params.list;
|
||||
var iterator = (params.iterator) ? params.iterator : list.iterator;
|
||||
var setWidgets = (params.setWidgets == false) ? false : true;
|
||||
var sort_order = params.sort_order || '';
|
||||
var expected_objects=0, found_objects=0;
|
||||
var scope = params.scope,
|
||||
set = params.set,
|
||||
defaultUrl = params.url,
|
||||
list = params.list,
|
||||
iterator = (params.iterator) ? params.iterator : list.iterator,
|
||||
setWidgets = (params.setWidgets === false) ? false : true,
|
||||
sort_order = params.sort_order || '',
|
||||
widgets, i, modifier, current_params;
|
||||
|
||||
var params = {
|
||||
/*
|
||||
current_params = {
|
||||
set: set,
|
||||
defaultUrl: defaultUrl,
|
||||
list: list,
|
||||
@@ -38,25 +39,26 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
sort_order: sort_order
|
||||
};
|
||||
|
||||
Store('CurrentSearchParams', params); // Save in case Activity Stream widget needs to restore
|
||||
Store('CurrentSearchParams', current_params); // Save in case Activity Stream widget needs to restore */
|
||||
|
||||
function setDefaults(widget) {
|
||||
// Set default values
|
||||
var modifier = (widget == undefined || widget == 1) ? '' : widget;
|
||||
var f, fld, fka, modifier;
|
||||
modifier = (widget === undefined || widget === 1) ? '' : widget;
|
||||
scope[iterator + 'SearchField' + modifier] = '';
|
||||
scope[iterator + 'SearchFieldLabel' + modifier] = '';
|
||||
for (fld in list.fields) {
|
||||
if (list.fields[fld].searchWidget == undefined && widget == 1 ||
|
||||
list.fields[fld].searchWidget == widget) {
|
||||
if (list.fields[fld].searchWidget === undefined && widget === 1 ||
|
||||
list.fields[fld].searchWidget === widget) {
|
||||
if (list.fields[fld].key) {
|
||||
if (list.fields[fld].sourceModel) {
|
||||
var fka = list.fields[fld].sourceModel + '__' + list.fields[fld].sourceField;
|
||||
fka = list.fields[fld].sourceModel + '__' + list.fields[fld].sourceField;
|
||||
sort_order = (list.fields[fld].desc) ? '-' + fka : fka;
|
||||
}
|
||||
else {
|
||||
sort_order = (list.fields[fld].desc) ? '-' + fld : fld;
|
||||
}
|
||||
if (list.fields[fld].searchable == undefined || list.fields[fld].searchable == true) {
|
||||
if (list.fields[fld].searchable === undefined || list.fields[fld].searchable === true) {
|
||||
scope[iterator + 'SearchField' + modifier] = fld;
|
||||
scope[iterator + 'SearchFieldLabel' + modifier] = list.fields[fld].label;
|
||||
}
|
||||
@@ -68,9 +70,9 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
if (Empty(scope[iterator + 'SearchField' + modifier])) {
|
||||
// A field marked as key may not be 'searchable'. Find the first searchable field.
|
||||
for (fld in list.fields) {
|
||||
if (list.fields[fld].searchWidget == undefined && widget == 1 ||
|
||||
list.fields[fld].searchWidget == widget) {
|
||||
if (list.fields[fld].searchable == undefined || list.fields[fld].searchable == true) {
|
||||
if (list.fields[fld].searchWidget === undefined && widget === 1 ||
|
||||
list.fields[fld].searchWidget === widget) {
|
||||
if (list.fields[fld].searchable === undefined || list.fields[fld].searchable === true) {
|
||||
scope[iterator + 'SearchField' + modifier] = fld;
|
||||
scope[iterator + 'SearchFieldLabel' + modifier] = list.fields[fld].label;
|
||||
break;
|
||||
@@ -108,19 +110,19 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
|
||||
scope[iterator + 'InputDisable' + modifier] =
|
||||
(list.fields[scope[iterator + 'SearchField' + modifier]] &&
|
||||
list.fields[scope[iterator + 'SearchField' + modifier]].searchObject == 'all') ? true : false;
|
||||
list.fields[scope[iterator + 'SearchField' + modifier]].searchObject === 'all') ? true : false;
|
||||
|
||||
var f = scope[iterator + 'SearchField' + modifier];
|
||||
f = scope[iterator + 'SearchField' + modifier];
|
||||
if (list.fields[f]) {
|
||||
if ( list.fields[f].searchType && (list.fields[f].searchType == 'boolean'
|
||||
|| list.fields[f].searchType == 'select') ) {
|
||||
if ( list.fields[f].searchType && (list.fields[f].searchType === 'boolean' ||
|
||||
list.fields[f].searchType === 'select') ) {
|
||||
scope[iterator + 'SelectShow' + modifier] = true;
|
||||
scope[iterator + 'SearchSelectOpts' + modifier] = list.fields[f].searchOptions;
|
||||
}
|
||||
if (list.fields[f].searchType && list.fields[f].searchType == 'int') {
|
||||
if (list.fields[f].searchType && list.fields[f].searchType === 'int') {
|
||||
scope[iterator + 'HideSearchType' + modifier] = true;
|
||||
}
|
||||
if (list.fields[f].searchType && list.fields[f].searchType == 'gtzero') {
|
||||
if (list.fields[f].searchType && list.fields[f].searchType === 'gtzero') {
|
||||
scope[iterator + 'InputHide' + modifier] = true;
|
||||
}
|
||||
}
|
||||
@@ -128,16 +130,16 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
|
||||
if (setWidgets) {
|
||||
// Set default values for each search widget on the page
|
||||
var widgets = (list.searchWidgets) ? list.searchWidgets : 1;
|
||||
for (var i=1; i <= widgets; i++) {
|
||||
var modifier = (i == 1) ? '' : i;
|
||||
widgets = (list.searchWidgets) ? list.searchWidgets : 1;
|
||||
for (i=1; i <= widgets; i++) {
|
||||
modifier = (i === 1) ? '' : i;
|
||||
if ( $('#search-widget-container' + modifier) ) {
|
||||
setDefaults(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var params = {
|
||||
current_params = {
|
||||
set: set,
|
||||
defaultUrl: defaultUrl,
|
||||
list: list,
|
||||
@@ -145,13 +147,13 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
sort_order: sort_order
|
||||
};
|
||||
|
||||
Store('CurrentSearchParams', params); // Save in case Activity Stream widget needs to restore
|
||||
Store('CurrentSearchParams', current_params); // Save in case Activity Stream widget needs to restore
|
||||
|
||||
|
||||
// Functions to handle search widget changes
|
||||
scope.setSearchField = function(iterator, fld, label, widget) {
|
||||
|
||||
var modifier = (widget == undefined || widget == 1) ? '' : widget;
|
||||
var modifier = (widget === undefined || widget === 1) ? '' : widget;
|
||||
scope[iterator + 'SearchFieldLabel' + modifier] = label;
|
||||
scope[iterator + 'SearchField' + modifier] = fld;
|
||||
scope[iterator + 'SearchValue' + modifier] = '';
|
||||
@@ -159,7 +161,7 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
scope[iterator + 'HideSearchType' + modifier] = false;
|
||||
scope[iterator + 'InputHide' + modifier] = false;
|
||||
scope[iterator + 'SearchType' + modifier] = 'icontains';
|
||||
scope[iterator + 'InputDisable' + modifier] = (list.fields[fld].searchObject == 'all') ? true : false;
|
||||
scope[iterator + 'InputDisable' + modifier] = (list.fields[fld].searchObject === 'all') ? true : false;
|
||||
scope[iterator + 'ShowStartBtn' + modifier] = true;
|
||||
|
||||
if (list.fields[scope[iterator + 'SearchField' + modifier]] &&
|
||||
@@ -178,7 +180,7 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
scope[iterator + 'SearchPlaceholder' + modifier] = 'Search';
|
||||
}
|
||||
|
||||
if (list.fields[fld].searchType && list.fields[fld].searchType == 'gtzero') {
|
||||
if (list.fields[fld].searchType && list.fields[fld].searchType === 'gtzero') {
|
||||
scope[iterator + "InputDisable" + modifier] = true;
|
||||
scope[iterator + 'ShowStartBtn' + modifier] = false;
|
||||
scope.search(iterator);
|
||||
@@ -191,10 +193,10 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
scope[iterator + 'InputDisable' + modifier] = true;
|
||||
scope[iterator + "SearchValue" + modifier] = list.fields[fld].searchValue;
|
||||
// For boolean type, SearchValue must be an object
|
||||
if (list.fields[fld].searchType == 'boolean' && list.fields[fld].searchValue == 'true') {
|
||||
if (list.fields[fld].searchType === 'boolean' && list.fields[fld].searchValue === 'true') {
|
||||
scope[iterator + "SearchSelectValue" + modifier] = { value: 1 };
|
||||
}
|
||||
else if (list.fields[fld].searchType == 'boolean' && list.fields[fld].searchValue == 'false') {
|
||||
else if (list.fields[fld].searchType === 'boolean' && list.fields[fld].searchValue === 'false') {
|
||||
scope[iterator + "SearchSelectValue" + modifier] = { value: 0 };
|
||||
}
|
||||
else {
|
||||
@@ -202,22 +204,22 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
}
|
||||
scope[iterator + 'ShowStartBtn' + modifier] = false;
|
||||
}
|
||||
else if (list.fields[fld].searchType == 'in') {
|
||||
else if (list.fields[fld].searchType === 'in') {
|
||||
scope[iterator + "SearchType" + modifier] = 'in';
|
||||
scope[iterator + "SearchValue" + modifier] = list.fields[fld].searchValue;
|
||||
scope[iterator + "InputDisable" + modifier] = true;
|
||||
scope[iterator + 'ShowStartBtn' + modifier] = false;
|
||||
}
|
||||
else if (list.fields[fld].searchType && (list.fields[fld].searchType == 'boolean'
|
||||
|| list.fields[fld].searchType == 'select' || list.fields[fld].searchType == 'select_or')) {
|
||||
else if (list.fields[fld].searchType && (list.fields[fld].searchType === 'boolean' ||
|
||||
list.fields[fld].searchType === 'select' || list.fields[fld].searchType === 'select_or')) {
|
||||
scope[iterator + 'SelectShow' + modifier] = true;
|
||||
scope[iterator + 'SearchSelectOpts' + modifier] = list.fields[fld].searchOptions;
|
||||
}
|
||||
else if (list.fields[fld].searchType && list.fields[fld].searchType == 'int') {
|
||||
else if (list.fields[fld].searchType && list.fields[fld].searchType === 'int') {
|
||||
//scope[iterator + 'HideSearchType' + modifier] = true;
|
||||
scope[iterator + 'SearchType' + modifier] = 'int';
|
||||
}
|
||||
else if (list.fields[fld].searchType && list.fields[fld].searchType == 'isnull') {
|
||||
else if (list.fields[fld].searchType && list.fields[fld].searchType === 'isnull') {
|
||||
scope[iterator + 'SearchType' + modifier] = 'isnull';
|
||||
scope[iterator + 'InputDisable' + modifier] = true;
|
||||
scope[iterator + 'SearchValue' + modifier] = 'true';
|
||||
@@ -226,19 +228,21 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
|
||||
scope.search(iterator);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
scope.resetSearch = function(iterator) {
|
||||
// Respdond to click of reset button
|
||||
var widgets = (list.searchWidgets) ? list.searchWidgets : 1;
|
||||
for (var i=1; i <= widgets; i++) {
|
||||
var i,
|
||||
widgets = (list.searchWidgets) ? list.searchWidgets : 1;
|
||||
|
||||
for (i=1; i <= widgets; i++) {
|
||||
// Clear each search widget
|
||||
setDefaults(i);
|
||||
}
|
||||
// Force removal of search keys from the URL
|
||||
window.location = '/#' + $location.path();
|
||||
scope.search(iterator);
|
||||
}
|
||||
};
|
||||
|
||||
if (scope.removeDoSearch) {
|
||||
scope.removeDoSearch();
|
||||
@@ -247,9 +251,8 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
//
|
||||
// Execute the search
|
||||
//
|
||||
scope[iterator + 'Loading'] = (load == undefined || load == true) ? true : false;
|
||||
var url = defaultUrl;
|
||||
var connect;
|
||||
scope[iterator + 'Loading'] = (load === undefined || load === true) ? true : false;
|
||||
var url = defaultUrl, connect;
|
||||
|
||||
//finalize and execute the query
|
||||
scope[iterator + 'Page'] = (page) ? parseInt(page) - 1 : 0;
|
||||
@@ -286,11 +289,11 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
//
|
||||
Wait('start');
|
||||
scope[iterator + 'SearchParams'] = '';
|
||||
var widgets = (list.searchWidgets) ? list.searchWidgets : 1;
|
||||
var modifier;
|
||||
var i, modifier,
|
||||
widgets = (list.searchWidgets) ? list.searchWidgets : 1;
|
||||
|
||||
for (var i=1; i <= widgets; i++) {
|
||||
var modifier = (i == 1) ? '' : i;
|
||||
for (i=1; i <= widgets; i++) {
|
||||
modifier = (i === 1) ? '' : i;
|
||||
if ( $('#search-widget-container' + modifier) ) {
|
||||
if (list.fields[scope[iterator + 'SearchField' + modifier]] &&
|
||||
list.fields[scope[iterator + 'SearchField' + modifier]].searchObject) {
|
||||
@@ -337,10 +340,11 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
scope.removePrepareSearch2 = scope.$on('prepareSearch2', function(e, iterator, page, load, spin) {
|
||||
// Continue building the search by examining the remaining search widgets. If we're looking at activity_stream,
|
||||
// there's more than one.
|
||||
var widgets = (list.searchWidgets) ? list.searchWidgets : 1;
|
||||
var modifier;
|
||||
for (var i=1; i <= widgets; i++) {
|
||||
modifier = (i == 1) ? '' : i;
|
||||
var i, modifier,
|
||||
widgets = (list.searchWidgets) ? list.searchWidgets : 1;
|
||||
|
||||
for (i=1; i <= widgets; i++) {
|
||||
modifier = (i === 1) ? '' : i;
|
||||
scope[iterator + 'HoldInput' + modifier] = true;
|
||||
if ($('#search-widget-container' + modifier) &&
|
||||
list.fields[scope[iterator + 'SearchField' + modifier]] &&
|
||||
@@ -352,11 +356,14 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
// if user typed a value in the input box, show the reset link
|
||||
scope[iterator + 'ShowStartBtn' + modifier] = false;
|
||||
}
|
||||
else {
|
||||
scope[iterator + 'ShowStartBtn' + modifier] = true;
|
||||
}
|
||||
|
||||
if ( (!scope[iterator + 'SelectShow' + modifier] && !Empty(scope[iterator + 'SearchValue' + modifier])) ||
|
||||
(scope[iterator + 'SelectShow' + modifier] && scope[iterator + 'SearchSelectValue' + modifier]) ||
|
||||
(list.fields[scope[iterator + 'SearchField' + modifier]] &&
|
||||
list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'gtzero') ) {
|
||||
list.fields[scope[iterator + 'SearchField' + modifier]].searchType === 'gtzero') ) {
|
||||
if (list.fields[scope[iterator + 'SearchField' + modifier]].searchField) {
|
||||
scope[iterator + 'SearchParams'] += '&' + list.fields[scope[iterator + 'SearchField' + modifier]].searchField + '__';
|
||||
}
|
||||
@@ -365,9 +372,9 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
scope[iterator + 'SearchParams'] += '&' + list.fields[scope[iterator + 'SearchField' + modifier]].sourceModel + '__' +
|
||||
list.fields[scope[iterator + 'SearchField' + modifier]].sourceField + '__';
|
||||
}
|
||||
else if ( (list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'select') &&
|
||||
(scope[iterator + 'SearchSelectValue' + modifier].value == '' ||
|
||||
scope[iterator + 'SearchSelectValue' + modifier].value == null) ) {
|
||||
else if ( (list.fields[scope[iterator + 'SearchField' + modifier]].searchType === 'select') &&
|
||||
(scope[iterator + 'SearchSelectValue' + modifier].value === '' ||
|
||||
scope[iterator + 'SearchSelectValue' + modifier].value === null) ) {
|
||||
scope[iterator + 'SearchParams'] += '&' + scope[iterator + 'SearchField' + modifier] + '__';
|
||||
}
|
||||
else {
|
||||
@@ -375,17 +382,17 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
}
|
||||
|
||||
if ( list.fields[scope[iterator + 'SearchField' + modifier]].searchType &&
|
||||
(list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'int' ||
|
||||
list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'boolean' ) ) {
|
||||
(list.fields[scope[iterator + 'SearchField' + modifier]].searchType === 'int' ||
|
||||
list.fields[scope[iterator + 'SearchField' + modifier]].searchType === 'boolean' ) ) {
|
||||
scope[iterator + 'SearchParams'] += 'int=';
|
||||
}
|
||||
else if ( list.fields[scope[iterator + 'SearchField' + modifier]].searchType &&
|
||||
list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'gtzero' ) {
|
||||
list.fields[scope[iterator + 'SearchField' + modifier]].searchType === 'gtzero' ) {
|
||||
scope[iterator + 'SearchParams'] += 'gt=0';
|
||||
}
|
||||
else if ( (list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'select') &&
|
||||
(scope[iterator + 'SearchSelectValue' + modifier].value == '' ||
|
||||
scope[iterator + 'SearchSelectValue' + modifier].value == null) ) {
|
||||
else if ( (list.fields[scope[iterator + 'SearchField' + modifier]].searchType === 'select') &&
|
||||
(scope[iterator + 'SearchSelectValue' + modifier].value === '' ||
|
||||
scope[iterator + 'SearchSelectValue' + modifier].value === null) ) {
|
||||
scope[iterator + 'SearchParams'] += 'iexact=';
|
||||
}
|
||||
else {
|
||||
@@ -393,8 +400,8 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
}
|
||||
|
||||
if ( list.fields[scope[iterator + 'SearchField' + modifier]].searchType &&
|
||||
(list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'boolean'
|
||||
|| list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'select') ) {
|
||||
(list.fields[scope[iterator + 'SearchField' + modifier]].searchType === 'boolean' ||
|
||||
list.fields[scope[iterator + 'SearchField' + modifier]].searchType === 'select') ) {
|
||||
scope[iterator + 'SearchParams'] += scope[iterator + 'SearchSelectValue' + modifier].value;
|
||||
}
|
||||
else {
|
||||
@@ -402,15 +409,15 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
(list.fields[scope[iterator + 'SearchField' + modifier]].searchType &&
|
||||
list.fields[scope[iterator + 'SearchField' + modifier]].searchType !== 'or' &&
|
||||
list.fields[scope[iterator + 'SearchField' + modifier]].searchType !== 'gtzero') ) {
|
||||
scope[iterator + 'SearchParams'] += escape(scope[iterator + 'SearchValue' + modifier]);
|
||||
scope[iterator + 'SearchParams'] += encodeURI(scope[iterator + 'SearchValue' + modifier]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( (iterator == 'inventory' && scope.inventoryFailureFilter) ||
|
||||
(iterator == 'host' && scope.hostFailureFilter) ) {
|
||||
if ( (iterator === 'inventory' && scope.inventoryFailureFilter) ||
|
||||
(iterator === 'host' && scope.hostFailureFilter) ) {
|
||||
//Things that bypass the search widget. Should go back and add a second widget possibly on
|
||||
//inventory pages and eliminate this
|
||||
scope[iterator + 'SearchParams'] += '&has_active_failures=true';
|
||||
@@ -418,7 +425,7 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
|
||||
if (sort_order) {
|
||||
scope[iterator + 'SearchParams'] += (scope[iterator + 'SearchParams']) ? '&' : '';
|
||||
scope[iterator + 'SearchParams'] += 'order_by=' + escape(sort_order);
|
||||
scope[iterator + 'SearchParams'] += 'order_by=' + encodeURI(sort_order);
|
||||
}
|
||||
|
||||
scope.$emit('doSearch', iterator, page, load, spin);
|
||||
@@ -426,29 +433,29 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
|
||||
scope.startSearch = function(e,iterator) {
|
||||
// If use clicks enter while on input field, start the search
|
||||
if (e.keyCode == 13) {
|
||||
if (e.keyCode === 13) {
|
||||
scope.search(iterator);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
scope.search = function(iterator, page, load) {
|
||||
// Called to initiate a searh.
|
||||
// Page is optional. Added to accomodate back function on Job Events detail.
|
||||
// Spin optional -set to false if spin not desired.
|
||||
// Load optional -set to false if loading message not desired
|
||||
var load = (load === undefined) ? true : false;
|
||||
load = (load === undefined) ? true : false;
|
||||
if (load) {
|
||||
scope[set] = [];
|
||||
}
|
||||
scope.$emit('prepareSearch', iterator, page, load);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
scope.sort = function(fld) {
|
||||
// reset sort icons back to 'icon-sort' on all columns
|
||||
// except the one clicked
|
||||
$('.list-header').each(function(index) {
|
||||
if ($(this).attr('id') != fld + '-header') {
|
||||
$('.list-header').each(function() {
|
||||
if ($(this).attr('id') !== fld + '-header') {
|
||||
var icon = $(this).find('i');
|
||||
icon.attr('class','fa fa-sort');
|
||||
}
|
||||
@@ -456,8 +463,8 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
|
||||
// Toggle the icon for the clicked column
|
||||
// and set the sort direction
|
||||
var icon = $('#' + fld + '-header i');
|
||||
var direction = '';
|
||||
var icon = $('#' + fld + '-header i'),
|
||||
direction = '';
|
||||
if (icon.hasClass('fa-sort')) {
|
||||
icon.removeClass('fa-sort');
|
||||
icon.addClass('fa-sort-up');
|
||||
@@ -488,14 +495,14 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
}
|
||||
}
|
||||
scope.search(list.iterator);
|
||||
}
|
||||
};
|
||||
|
||||
// Call after modal dialogs to remove any lingering callbacks
|
||||
scope.searchCleanup = function() {
|
||||
scope.removeDoSearch();
|
||||
scope.removePrepareSearch();
|
||||
scope.removePrepareSearch2();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
@@ -211,6 +211,12 @@ textarea {
|
||||
opacity: 1.0;
|
||||
}
|
||||
|
||||
/* Host flyout- uses popver */
|
||||
.popover-content .host-flyout {
|
||||
font-size: 12px;
|
||||
i, a { font-size: 12px; }
|
||||
}
|
||||
|
||||
.alert {
|
||||
margin-top: 15px;
|
||||
margin-bottom: 15px;
|
||||
|
||||
Reference in New Issue
Block a user