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