From f891c30ebbbed05fbedfe05ef2086b3a1caa597d Mon Sep 17 00:00:00 2001
From: Chris Houseknecht
/g,' ');
- for (var opt in list.fields['status'].searchOptions) {
- if (list.fields['status'].searchOptions[opt].value == $routeParams['status']) {
- scope[list.iterator + 'SearchSelectValue'] = list.fields['status'].searchOptions[opt];
- break;
- }
+ scope[list.iterator + 'SearchSelectOpts'] = list.fields.status.searchOptions;
+ scope[list.iterator + 'SearchFieldLabel'] = list.fields.status.label.replace(/
/g, ' ');
+ for (opt in list.fields.status.searchOptions) {
+ if (list.fields.status.searchOptions[opt].value === $routeParams.status) {
+ scope[list.iterator + 'SearchSelectValue'] = list.fields.status.searchOptions[opt];
+ break;
+ }
}
}
- if ($routeParams['source']) {
+ if ($routeParams.source) {
scope[list.iterator + 'SearchField'] = 'source';
scope[list.iterator + 'SelectShow'] = true;
- scope[list.iterator + 'SearchSelectOpts'] = list.fields['source'].searchOptions;
- scope[list.iterator + 'SearchFieldLabel'] = list.fields['source'].label.replace(/\
/g,' ');
- for (var opt in list.fields['source'].searchOptions) {
- if (list.fields['source'].searchOptions[opt].value == $routeParams['source']) {
- scope[list.iterator + 'SearchSelectValue'] = list.fields['source'].searchOptions[opt];
- break;
- }
+ scope[list.iterator + 'SearchSelectOpts'] = list.fields.source.searchOptions;
+ scope[list.iterator + 'SearchFieldLabel'] = list.fields.source.label.replace(/
/g, ' ');
+ for (opt in list.fields.source.searchOptions) {
+ if (list.fields.source.searchOptions[opt].value === $routeParams.source) {
+ scope[list.iterator + 'SearchSelectValue'] = list.fields.source.searchOptions[opt];
+ break;
+ }
}
- if ($routeParams['status']) {
- scope[list.iterator + 'ExtraParms'] = '&inventory_source__status__icontains=' + $routeParams['status'];
+ if ($routeParams.status) {
+ scope[list.iterator + 'ExtraParms'] = '&inventory_source__status__icontains=' + $routeParams.status;
}
}
- if ($routeParams['has_external_source']) {
+ if ($routeParams.has_external_source) {
scope[list.iterator + 'SearchField'] = 'has_external_source';
- scope[list.iterator + 'SearchValue'] = list.fields['has_external_source'].searchValue;
+ scope[list.iterator + 'SearchValue'] = list.fields.has_external_source.searchValue;
scope[list.iterator + 'InputDisable'] = true;
scope[list.iterator + 'SearchType'] = 'in';
- scope[list.iterator + 'SearchFieldLabel'] = list.fields['has_external_source'].label;
+ scope[list.iterator + 'SearchFieldLabel'] = list.fields.has_external_source.label;
}
-
- scope.search(list.iterator);
-
- LoadBreadCrumbs();
-
- scope.showActivity = function() { Stream({ scope: scope }); }
- scope.editGroup = function(group_id, inventory_id) {
- GroupsEdit({ scope: scope, group_id: group_id, inventory_id: inventory_id, groups_reload: false });
- }
-
- scope.viewUpdateStatus = function(id) {
+ scope.search(list.iterator);
+
+ LoadBreadCrumbs();
+
+ scope.showActivity = function () {
+ Stream({
+ scope: scope
+ });
+ };
+
+ scope.editGroup = function (group_id, inventory_id) {
+ GroupsEdit({
+ scope: scope,
+ group_id: group_id,
+ inventory_id: inventory_id,
+ groups_reload: false
+ });
+ };
+
+ scope.viewUpdateStatus = function (id) {
scope.groups = scope.home_groups;
- ViewUpdateStatus({ scope: scope, tree_id: id })
- };
+ ViewUpdateStatus({
+ scope: scope,
+ tree_id: id
+ });
+ };
// Launch inventory sync
- scope.updateGroup = function(id) {
- var group = Find({ list: scope.home_groups, key: 'id', val: id});
+ scope.updateGroup = function (id) {
+ var group = Find({ list: scope.home_groups, key: 'id', val: id });
if (group) {
if (Empty(group.source)) {
// if no source, do nothing.
- }
- else if (group.status == 'updating') {
+ } else if (group.status === 'updating') {
Alert('Update in Progress', 'The inventory update process is currently running for group ' +
- scope.home_groups[i].name + '. Use the Refresh button to monitor the status.', 'alert-info');
- }
- else {
+ group.name + '. Use the Refresh button to monitor the status.', 'alert-info');
+ } else {
Wait('start');
Rest.setUrl(group.related.inventory_source);
Rest.get()
- .success( function(data, status, headers, config) {
+ .success(function (data) {
InventoryUpdate({
- scope: scope,
+ scope: scope,
url: data.related.update,
- group_name: data.summary_fields.group.name,
+ group_name: data.summary_fields.group.name,
group_source: data.source,
tree_id: group.id,
group_id: group.id
- });
- })
- .error( function(data, status, headers, config) {
- ProcessErrors(scope, data, status, form,
- { hdr: 'Error!', msg: 'Failed to retrieve inventory source: ' + group.related.inventory_source +
- ' POST returned status: ' + status });
});
+ })
+ .error(function (data, status) {
+ ProcessErrors(scope, data, status, null, { hdr: 'Error!',
+ msg: 'Failed to retrieve inventory source: ' + group.related.inventory_source + ' POST returned status: ' + status
+ });
+ });
}
- }
}
+ };
- scope.refresh = function() { scope.search(list.iterator, null, false, true); }
+ scope.refresh = function () {
+ scope.search(list.iterator, null, false, true);
+ };
- }
+}
-HomeGroups.$inject = [ '$location', '$routeParams', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
+HomeGroups.$inject = ['$location', '$routeParams', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'GetHostsStatusMsg', 'GetSyncStatusMsg', 'ViewUpdateStatus',
'Stream', 'GroupsEdit', 'Wait', 'Alert', 'Rest', 'Empty', 'InventoryUpdate', 'Find'
- ];
+];
-function HomeHosts ($location, $routeParams, HomeHostList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
+function HomeHosts($location, $routeParams, HomeHostList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
GetBasePath, SearchInit, PaginateInit, FormatDate, SetStatus, ToggleHostEnabled, HostsEdit, Stream, Find, ShowJobSummary) {
- ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
- //scope.
+ ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
+ //scope.
- var generator = GenerateList;
- var list = HomeHostList;
- var defaultUrl=GetBasePath('hosts');
-
- var scope = generator.inject(list, { mode: 'edit' });
- var base = $location.path().replace(/^\//,'').split('/')[0];
+ var generator = GenerateList,
+ list = HomeHostList,
+ defaultUrl = GetBasePath('hosts'),
+ scope = generator.inject(list, { mode: 'edit' });
if (scope.removePostRefresh) {
- scope.removePostRefresh();
+ scope.removePostRefresh();
}
- scope.removePostRefresh = scope.$on('PostRefresh', function() {
- for (var i=0; i < scope.hosts.length; i++) {
- scope['hosts'][i]['inventory_name'] = scope['hosts'][i]['summary_fields']['inventory']['name'];
+ scope.removePostRefresh = scope.$on('PostRefresh', function () {
+ for (var i = 0; i < scope.hosts.length; i++) {
+ scope.hosts[i].inventory_name = scope.hosts[i].summary_fields.inventory.name;
//SetHostStatus(scope['hosts'][i]);
- SetStatus({ scope: scope, host: scope['hosts'][i] });
+ SetStatus({
+ scope: scope,
+ host: scope.hosts[i]
+ });
}
- });
+ });
+
+ SearchInit({
+ scope: scope,
+ set: 'hosts',
+ list: list,
+ url: defaultUrl
+ });
+ PaginateInit({
+ scope: scope,
+ list: list,
+ url: defaultUrl
+ });
- SearchInit({ scope: scope, set: 'hosts', list: list, url: defaultUrl });
- PaginateInit({ scope: scope, list: list, url: defaultUrl });
-
// Process search params
- if ($routeParams['name']) {
+ if ($routeParams.name) {
scope[HomeHostList.iterator + 'InputDisable'] = false;
- scope[HomeHostList.iterator + 'SearchValue'] = $routeParams['name'];
+ scope[HomeHostList.iterator + 'SearchValue'] = $routeParams.name;
scope[HomeHostList.iterator + 'SearchField'] = 'name';
- scope[HomeHostList.iterator + 'SearchFieldLabel'] = list.fields['name'].label;
+ scope[HomeHostList.iterator + 'SearchFieldLabel'] = list.fields.name.label;
}
-
- if ($routeParams['id']) {
+
+ if ($routeParams.id) {
scope[HomeHostList.iterator + 'InputDisable'] = false;
- scope[HomeHostList.iterator + 'SearchValue'] = $routeParams['id'];
+ scope[HomeHostList.iterator + 'SearchValue'] = $routeParams.id;
scope[HomeHostList.iterator + 'SearchField'] = 'id';
- scope[HomeHostList.iterator + 'SearchFieldLabel'] = list.fields['id'].label;
+ scope[HomeHostList.iterator + 'SearchFieldLabel'] = list.fields.id.label;
scope[HomeHostList.iterator + 'SearchSelectValue'] = null;
}
- if ($routeParams['has_active_failures']) {
+ if ($routeParams.has_active_failures) {
scope[HomeHostList.iterator + 'InputDisable'] = true;
- scope[HomeHostList.iterator + 'SearchValue'] = $routeParams['has_active_failures'];
+ scope[HomeHostList.iterator + 'SearchValue'] = $routeParams.has_active_failures;
scope[HomeHostList.iterator + 'SearchField'] = 'has_active_failures';
- scope[HomeHostList.iterator + 'SearchFieldLabel'] = HomeHostList.fields['has_active_failures'].label;
- scope[HomeHostList.iterator + 'SearchSelectValue'] = ($routeParams['has_active_failures'] == 'true') ? { value: 1 } : { value: 0 };
+ scope[HomeHostList.iterator + 'SearchFieldLabel'] = HomeHostList.fields.has_active_failures.label;
+ scope[HomeHostList.iterator + 'SearchSelectValue'] = ($routeParams.has_active_failures === 'true') ? { value: 1 } : { value: 0 };
}
-
+
scope.search(list.iterator);
-
+
LoadBreadCrumbs();
-
- scope.showActivity = function() { Stream({ scope: scope }); }
- scope.toggle_host_enabled = function(id, sources) { ToggleHostEnabled({ host_id: id, external_source: sources, scope: scope }); }
+ scope.showActivity = function () {
+ Stream({
+ scope: scope
+ });
+ };
- scope.editHost = function(host_id, host_name) {
- var host = Find({ list: scope.hosts, key: 'id', val: host_id });
+ scope.toggle_host_enabled = function (id, sources) {
+ ToggleHostEnabled({
+ host_id: id,
+ external_source: sources,
+ scope: scope
+ });
+ };
+
+ scope.editHost = function (host_id) {
+ var host = Find({
+ list: scope.hosts,
+ key: 'id',
+ val: host_id
+ });
if (host) {
- HostsEdit({ scope: scope, host_id: host_id, inventory_id: host.inventory, group_id: null, hostsReload: false });
- }
+ HostsEdit({
+ scope: scope,
+ host_id: host_id,
+ inventory_id: host.inventory,
+ group_id: null,
+ hostsReload: false
+ });
}
+ };
- scope.showJobSummary = function(job_id) {
- ShowJobSummary({ job_id: job_id });
- }
+ scope.showJobSummary = function (job_id) {
+ ShowJobSummary({
+ job_id: job_id
+ });
+ };
- }
+}
-HomeHosts.$inject = [ '$location', '$routeParams', 'HomeHostList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
+HomeHosts.$inject = ['$location', '$routeParams', 'HomeHostList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'SetStatus', 'ToggleHostEnabled', 'HostsEdit', 'Stream',
'Find', 'ShowJobSummary'
- ];
+];
\ No newline at end of file
diff --git a/awx/ui/static/js/controllers/Inventories.js b/awx/ui/static/js/controllers/Inventories.js
index 64de7d27ac..35cf1f183e 100644
--- a/awx/ui/static/js/controllers/Inventories.js
+++ b/awx/ui/static/js/controllers/Inventories.js
@@ -3,61 +3,78 @@
*
*
* Inventories.js
- *
+ *
* Controller functions for the Inventory model.
*
*/
-
+
'use strict';
-function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, InventoryList,
- GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
- ClearScope, ProcessErrors, GetBasePath, Wait, Stream, EditInventoryProperties)
-{
- ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
- //scope.
- var list = InventoryList;
- var defaultUrl = GetBasePath('inventory');
- var view = GenerateList;
- var paths = $location.path().replace(/^\//,'').split('/');
- var mode = (paths[0] == 'inventories') ? 'edit' : 'select'; // if base path 'users', we're here to add/edit users
- var scope = view.inject(InventoryList, { mode: mode }); // Inject our view
+function InventoriesList($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, InventoryList,
+ GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors,
+ GetBasePath, Wait, Stream, EditInventoryProperties) {
+ ClearScope('htmlTemplate');
+
+ var list = InventoryList,
+ defaultUrl = GetBasePath('inventory'),
+ view = GenerateList,
+ paths = $location.path().replace(/^\//, '').split('/'),
+ mode = (paths[0] === 'inventories') ? 'edit' : 'select', // if base path 'users', we're here to add/edit users
+ scope = view.inject(InventoryList, { mode: mode });
+
$rootScope.flashMessage = null;
- SearchInit({ scope: scope, set: 'inventories', list: list, url: defaultUrl });
- PaginateInit({ scope: scope, list: list, url: defaultUrl });
-
- if ($routeParams['name']) {
+ SearchInit({
+ scope: scope,
+ set: 'inventories',
+ list: list,
+ url: defaultUrl
+ });
+ PaginateInit({
+ scope: scope,
+ list: list,
+ url: defaultUrl
+ });
+
+ if ($routeParams.name) {
scope[InventoryList.iterator + 'InputDisable'] = false;
- scope[InventoryList.iterator + 'SearchValue'] = $routeParams['name'];
+ scope[InventoryList.iterator + 'SearchValue'] = $routeParams.name;
scope[InventoryList.iterator + 'SearchField'] = 'name';
- scope[InventoryList.iterator + 'SearchFieldLabel'] = InventoryList.fields['name'].label;
+ scope[InventoryList.iterator + 'SearchFieldLabel'] = InventoryList.fields.name.label;
scope[InventoryList.iterator + 'SearchSelectValue'] = null;
}
- if ($routeParams['has_active_failures']) {
+ if ($routeParams.has_active_failures) {
scope[InventoryList.iterator + 'InputDisable'] = true;
- scope[InventoryList.iterator + 'SearchValue'] = $routeParams['has_active_failures'];
+ scope[InventoryList.iterator + 'SearchValue'] = $routeParams.has_active_failures;
scope[InventoryList.iterator + 'SearchField'] = 'has_active_failures';
- scope[InventoryList.iterator + 'SearchFieldLabel'] = InventoryList.fields['has_active_failures'].label;
- scope[InventoryList.iterator + 'SearchSelectValue'] = ($routeParams['has_active_failures'] == 'true') ? { value: 1 } : { value: 0 };
+ scope[InventoryList.iterator + 'SearchFieldLabel'] = InventoryList.fields.has_active_failures.label;
+ scope[InventoryList.iterator + 'SearchSelectValue'] = ($routeParams.has_active_failures === 'true') ? {
+ value: 1
+ } : {
+ value: 0
+ };
}
- if ($routeParams['has_inventory_sources']) {
+ if ($routeParams.has_inventory_sources) {
scope[InventoryList.iterator + 'InputDisable'] = true;
- scope[InventoryList.iterator + 'SearchValue'] = $routeParams['has_inventory_sources'];
+ scope[InventoryList.iterator + 'SearchValue'] = $routeParams.has_inventory_sources;
scope[InventoryList.iterator + 'SearchField'] = 'has_inventory_sources';
- scope[InventoryList.iterator + 'SearchFieldLabel'] = InventoryList.fields['has_inventory_sources'].label;
- scope[InventoryList.iterator + 'SearchSelectValue'] = ($routeParams['has_inventory_sources'] == 'true') ? { value: 1 } : { value: 0 };
+ scope[InventoryList.iterator + 'SearchFieldLabel'] = InventoryList.fields.has_inventory_sources.label;
+ scope[InventoryList.iterator + 'SearchSelectValue'] = ($routeParams.has_inventory_sources === 'true') ? {
+ value: 1
+ } : {
+ value: 0
+ };
}
- if ($routeParams['inventory_sources_with_failures']) {
+ if ($routeParams.inventory_sources_with_failures) {
// pass a value of true, however this field actually contains an integer value
scope[InventoryList.iterator + 'InputDisable'] = true;
- scope[InventoryList.iterator + 'SearchValue'] = $routeParams['inventory_sources_with_failures'];
+ scope[InventoryList.iterator + 'SearchValue'] = $routeParams.inventory_sources_with_failures;
scope[InventoryList.iterator + 'SearchField'] = 'inventory_sources_with_failures';
- scope[InventoryList.iterator + 'SearchFieldLabel'] = InventoryList.fields['inventory_sources_with_failures'].label;
+ scope[InventoryList.iterator + 'SearchFieldLabel'] = InventoryList.fields.inventory_sources_with_failures.label;
scope[InventoryList.iterator + 'SearchType'] = 'gtzero';
}
@@ -66,282 +83,300 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res
LoadBreadCrumbs();
if (scope.removePostRefresh) {
- scope.removePostRefresh();
+ scope.removePostRefresh();
}
- scope.removePostRefresh = scope.$on('PostRefresh', function() {
+ scope.removePostRefresh = scope.$on('PostRefresh', function () {
//If we got here by deleting an inventory, stop the spinner and cleanup events
Wait('stop');
$('#prompt-modal').off();
- for (var i=0; i < scope.inventories.length; i++) {
-
+ for (var i = 0; i < scope.inventories.length; i++) {
+
// Set values for Failed Hosts column
//scope.inventories[i].failed_hosts = scope.inventories[i].hosts_with_active_failures + ' / ' + scope.inventories[i].total_hosts;
-
+
if (scope.inventories[i].hosts_with_active_failures > 0) {
- scope.inventories[i].failed_hosts_tip = scope.inventories[i].hosts_with_active_failures +
- ( (scope.inventories[i].hosts_with_active_failures == 1) ? ' host' : ' hosts' ) + ' with job failures. Click to view details.';
- scope.inventories[i].failed_hosts_link = '/#/inventories/' + scope.inventories[i].id + '/';
- scope.inventories[i].failed_hosts_class = 'true';
- }
- else {
- if (scope.inventories[i].total_hosts == 0) {
- // no hosts
- scope.inventories[i].failed_hosts_tip = "No hosts defined. Click to add.";
- scope.inventories[i].failed_hosts_link = '/#/inventories/' + scope.inventories[i].id + '/';
- scope.inventories[i].failed_hosts_class = 'na';
- }
- else {
- // many hosts with 0 failures
- scope.inventories[i].failed_hosts_tip = scope.inventories[i].total_hosts +
- ( (scope.inventories[i].total_hosts > 1) ? ' hosts' : ' host' ) + " with no job failures. Click to view details.";
- scope.inventories[i].failed_hosts_link = '/#/inventories/' + scope.inventories[i].id + '/';
- scope.inventories[i].failed_hosts_class = 'false';
- }
+ scope.inventories[i].failed_hosts_tip = scope.inventories[i].hosts_with_active_failures +
+ ((scope.inventories[i].hosts_with_active_failures === 1) ? ' host' : ' hosts') + ' with job failures. Click to view details.';
+ scope.inventories[i].failed_hosts_link = '/#/inventories/' + scope.inventories[i].id + '/';
+ scope.inventories[i].failed_hosts_class = 'true';
+ } else {
+ if (scope.inventories[i].total_hosts === 0) {
+ // no hosts
+ scope.inventories[i].failed_hosts_tip = "No hosts defined. Click to add.";
+ scope.inventories[i].failed_hosts_link = '/#/inventories/' + scope.inventories[i].id + '/';
+ scope.inventories[i].failed_hosts_class = 'na';
+ } else {
+ // many hosts with 0 failures
+ scope.inventories[i].failed_hosts_tip = scope.inventories[i].total_hosts +
+ ((scope.inventories[i].total_hosts > 1) ? ' hosts' : ' host') + " with no job failures. Click to view details.";
+ scope.inventories[i].failed_hosts_link = '/#/inventories/' + scope.inventories[i].id + '/';
+ scope.inventories[i].failed_hosts_class = 'false';
+ }
}
// Set values for Status column
- scope.inventories[i].status = scope.inventories[i].inventory_sources_with_failures + ' / ' + scope.inventories[i].total_inventory_sources;
+ scope.inventories[i].status = scope.inventories[i].inventory_sources_with_failures + ' / ' + scope.inventories[i].total_inventory_sources;
if (scope.inventories[i].inventory_sources_with_failures > 0) {
- scope.inventories[i].status_tip = scope.inventories[i].inventory_sources_with_failures + ' cloud ' +
- ( (scope.inventories[i].inventory_sources_with_failures == 1) ? 'source' : 'sources' ) +
- ' with failures. Click to view details.';
- scope.inventories[i].status_link = '/#/inventories/' + scope.inventories[i].id + '/';
- scope.inventories[i].status_class = 'failed';
- }
- else {
- if (scope.inventories[i].total_inventory_sources == 0) {
- // no groups are reporting a source
- scope.inventories[i].status_tip = "Not synced with a cloud source. Click to edit.";
- scope.inventories[i].status_link = '/#/inventories/' + scope.inventories[i].id + '/';
- scope.inventories[i].status_class = 'na';
- }
- else {
- // many hosts with 0 failures
- scope.inventories[i].status_tip = scope.inventories[i].total_inventory_sources +
- ' cloud ' + ( (scope.inventories[i].total_inventory_sources > 1) ? 'sources' : 'source' ) +
- ' with no failures. Click to view details.';
- scope.inventories[i].status_link = '/#/inventories/' + scope.inventories[i].id + '/';
- scope.inventories[i].status_class = 'successful';
- }
+ scope.inventories[i].status_tip = scope.inventories[i].inventory_sources_with_failures + ' cloud ' +
+ ((scope.inventories[i].inventory_sources_with_failures === 1) ? 'source' : 'sources') +
+ ' with failures. Click to view details.';
+ scope.inventories[i].status_link = '/#/inventories/' + scope.inventories[i].id + '/';
+ scope.inventories[i].status_class = 'failed';
+ } else {
+ if (scope.inventories[i].total_inventory_sources === 0) {
+ // no groups are reporting a source
+ scope.inventories[i].status_tip = "Not synced with a cloud source. Click to edit.";
+ scope.inventories[i].status_link = '/#/inventories/' + scope.inventories[i].id + '/';
+ scope.inventories[i].status_class = 'na';
+ } else {
+ // many hosts with 0 failures
+ scope.inventories[i].status_tip = scope.inventories[i].total_inventory_sources +
+ ' cloud ' + ((scope.inventories[i].total_inventory_sources > 1) ? 'sources' : 'source') +
+ ' with no failures. Click to view details.';
+ scope.inventories[i].status_link = '/#/inventories/' + scope.inventories[i].id + '/';
+ scope.inventories[i].status_class = 'successful';
+ }
}
}
- });
+ });
if (scope.removeRefreshInventories) {
scope.removeRefreshInventories();
}
- scope.removeRefreshInventories = scope.$on('RefreshInventories', function() {
+ scope.removeRefreshInventories = scope.$on('RefreshInventories', function () {
// Reflect changes after inventory properties edit completes
scope.search(list.iterator);
+ });
+
+ scope.showActivity = function () {
+ Stream({
+ scope: scope
});
-
- scope.showActivity = function() { Stream({ scope: scope }); }
+ };
- scope.editInventoryProperties = function(inventory_id) {
- EditInventoryProperties({ scope: scope, inventory_id: inventory_id });
- }
+ scope.editInventoryProperties = function (inventory_id) {
+ EditInventoryProperties({
+ scope: scope,
+ inventory_id: inventory_id
+ });
+ };
- scope.addInventory = function() {
+ scope.addInventory = function () {
$location.path($location.path() + '/add');
- }
+ };
- scope.editInventory = function(id) {
+ scope.editInventory = function (id) {
$location.path($location.path() + '/' + id);
- }
-
- scope.deleteInventory = function(id, name) {
-
- var action = function() {
+ };
+
+ scope.deleteInventory = function (id, name) {
+
+ var action = function () {
var url = defaultUrl + id + '/';
- $('#prompt-modal').on('hidden.bs.modal', function() {
+ $('#prompt-modal').on('hidden.bs.modal', function () {
Wait('start');
- });
+ });
$('#prompt-modal').modal('hide');
Rest.setUrl(url);
Rest.destroy()
- .success( function(data, status, headers, config) {
- scope.search(list.iterator);
- })
- .error( function(data, status, headers, config) {
+ .success(function () {
+ scope.search(list.iterator);
+ })
+ .error(function (data, status) {
Wait('stop');
- ProcessErrors(scope, data, status, null,
- { hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
- });
- };
+ ProcessErrors(scope, data, status, null, {
+ hdr: 'Error!',
+ msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status
+ });
+ });
+ };
- Prompt({ hdr: 'Delete',
- body: 'Are you sure you want to delete ' + name + '?',
- action: action
- });
- }
-
- scope.lookupOrganization = function(organization_id) {
+ Prompt({
+ hdr: 'Delete',
+ body: 'Are you sure you want to delete ' + name + '?',
+ action: action
+ });
+ };
+
+ scope.lookupOrganization = function (organization_id) {
Rest.setUrl(GetBasePath('organizations') + organization_id + '/');
Rest.get()
- .success( function(data, status, headers, config) {
+ .success(function (data) {
return data.name;
- });
- }
+ });
+ };
- // Failed jobs link. Go to the jobs tabs, find all jobs for the inventory and sort by status
- scope.viewJobs = function(id) {
+ // Failed jobs link. Go to the jobs tabs, find all jobs for the inventory and sort by status
+ scope.viewJobs = function (id) {
$location.url('/jobs/?inventory__int=' + id);
- }
+ };
- scope.viewFailedJobs = function(id) {
+ scope.viewFailedJobs = function (id) {
$location.url('/jobs/?inventory__int=' + id + '&status=failed');
+ };
+}
+
+InventoriesList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'InventoryList', 'GenerateList',
+ 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors',
+ 'GetBasePath', 'Wait', 'Stream', 'EditInventoryProperties'
+];
+
+
+function InventoriesAdd($scope, $rootScope, $compile, $location, $log, $routeParams, InventoryForm,
+ GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
+ GenerateList, OrganizationList, SearchInit, PaginateInit, LookUpInit, GetBasePath,
+ ParseTypeChange, Wait) {
+ ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
+ //scope.
+
+ // Inject dynamic view
+ var defaultUrl = GetBasePath('inventory'),
+ form = InventoryForm,
+ generator = GenerateForm,
+ scope;
+
+ form.well = true;
+ form.formLabelSize = null;
+ form.formFieldSize = null;
+
+ scope = generator.inject(form, {
+ mode: 'add',
+ related: false
+ });
+ scope.inventoryParseType = 'yaml';
+
+ generator.reset();
+ LoadBreadCrumbs();
+ ParseTypeChange(scope, 'inventory_variables', 'inventoryParseType');
+
+ LookUpInit({
+ scope: scope,
+ form: form,
+ current_item: ($routeParams.organization_id) ? $routeParams.organization_id : null,
+ list: OrganizationList,
+ field: 'organization'
+ });
+
+ // Save
+ scope.formSave = function () {
+ generator.clearApiErrors();
+ Wait('start');
+ try {
+ var fld, json_data, data;
+
+ // Make sure we have valid variable data
+ if (scope.inventoryParseType === 'json') {
+ json_data = JSON.parse(scope.inventory_variables); //make sure JSON parses
+ } else {
+ json_data = jsyaml.load(scope.inventory_variables); //parse yaml
+ }
+
+ // Make sure our JSON is actually an object
+ if (typeof json_data !== 'object') {
+ throw "failed to return an object!";
+ }
+
+ data = {};
+ for (fld in form.fields) {
+ if (fld !== 'inventory_variables') {
+ if (form.fields[fld].realName) {
+ data[form.fields[fld].realName] = scope[fld];
+ } else {
+ data[fld] = scope[fld];
+ }
+ }
+ }
+
+ Rest.setUrl(defaultUrl);
+ Rest.post(data)
+ .success(function (data) {
+ var inventory_id = data.id;
+ if (scope.inventory_variables) {
+ Rest.setUrl(data.related.variable_data);
+ Rest.put(json_data)
+ .success(function () {
+ Wait('stop');
+ $location.path('/inventories/' + inventory_id + '/');
+ })
+ .error(function (data, status) {
+ Wait('stop');
+ ProcessErrors(scope, data, status, null, { hdr: 'Error!',
+ msg: 'Failed to add inventory varaibles. PUT returned status: ' + status
+ });
+ });
+ } else {
+ Wait('stop');
+ $location.path('/inventories/' + inventory_id + '/');
+ }
+ })
+ .error(function (data, status) {
+ Wait('stop');
+ ProcessErrors(scope, data, status, form, {
+ hdr: 'Error!',
+ msg: 'Failed to add new inventory. Post returned status: ' + status
+ });
+ });
+ } catch (err) {
+ Wait('stop');
+ Alert("Error", "Error parsing inventory variables. Parser returned: " + err);
}
+
+ };
+
+ // Reset
+ scope.formReset = function () {
+ // Defaults
+ generator.reset();
+ };
}
-InventoriesList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'InventoryList', 'GenerateList',
- 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors',
- 'GetBasePath', 'Wait', 'Stream', 'EditInventoryProperties'];
-
-
-function InventoriesAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, InventoryForm,
- GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
- GenerateList, OrganizationList, SearchInit, PaginateInit, LookUpInit, GetBasePath,
- ParseTypeChange, Wait)
-{
- ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
- //scope.
-
- // Inject dynamic view
- var defaultUrl = GetBasePath('inventory');
- var form = InventoryForm;
- var generator = GenerateForm;
-
- form.well = true,
- form.formLabelSize = null;
- form.formFieldSize = null;
-
- var scope = generator.inject(form, {mode: 'add', related: false});
- scope.inventoryParseType = 'yaml';
-
- generator.reset();
- LoadBreadCrumbs();
- ParseTypeChange(scope,'inventory_variables', 'inventoryParseType');
-
- LookUpInit({
- scope: scope,
- form: form,
- current_item: ($routeParams.organization_id) ? $routeParams.organization_id : null,
- list: OrganizationList,
- field: 'organization'
- });
-
- // Save
- scope.formSave = function() {
- generator.clearApiErrors();
- Wait('start');
- try {
- // Make sure we have valid variable data
- if (scope.inventoryParseType == 'json') {
- var json_data = JSON.parse(scope.inventory_variables); //make sure JSON parses
- }
- else {
- var json_data = jsyaml.load(scope.inventory_variables); //parse yaml
- }
-
- // Make sure our JSON is actually an object
- if (typeof json_data !== 'object') {
- throw "failed to return an object!";
- }
-
- var data = {}
- for (var fld in form.fields) {
- if (fld != 'inventory_variables') {
- if (form.fields[fld].realName) {
- data[form.fields[fld].realName] = scope[fld];
- }
- else {
- data[fld] = scope[fld];
- }
- }
- }
-
- Rest.setUrl(defaultUrl);
- Rest.post(data)
- .success( function(data, status, headers, config) {
- var inventory_id = data.id;
- if (scope.inventory_variables) {
- Rest.setUrl(data.related.variable_data);
- Rest.put(json_data)
- .success( function(data, status, headers, config) {
- Wait('stop');
- $location.path('/inventories/' + inventory_id + '/');
- })
- .error( function(data, status, headers, config) {
- Wait('stop');
- ProcessErrors(scope, data, status, form,
- { hdr: 'Error!', msg: 'Failed to add inventory varaibles. PUT returned status: ' + status });
- });
- }
- else {
- Wait('stop');
- $location.path('/inventories/' + inventory_id + '/');
- }
- })
- .error( function(data, status, headers, config) {
- Wait('stop');
- ProcessErrors(scope, data, status, form,
- { hdr: 'Error!', msg: 'Failed to add new inventory. Post returned status: ' + status });
- });
- }
- catch(err) {
- Wait('stop');
- Alert("Error", "Error parsing inventory variables. Parser returned: " + err);
- }
-
- };
-
- // Reset
- scope.formReset = function() {
- // Defaults
- generator.reset();
- };
-}
-
-InventoriesAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'InventoryForm', 'GenerateForm',
- 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GenerateList',
- 'OrganizationList', 'SearchInit', 'PaginateInit', 'LookUpInit', 'GetBasePath', 'ParseTypeChange', 'Wait'
- ];
+InventoriesAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'InventoryForm', 'GenerateForm',
+ 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GenerateList',
+ 'OrganizationList', 'SearchInit', 'PaginateInit', 'LookUpInit', 'GetBasePath', 'ParseTypeChange', 'Wait'
+];
-function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateList, ClearScope, InventoryGroups, InventoryHosts, BuildTree, Wait,
- GetSyncStatusMsg, InjectHosts, HostsReload, GroupsAdd, GroupsEdit, GroupsDelete, Breadcrumbs, LoadBreadCrumbs, Empty,
- Rest, ProcessErrors, InventoryUpdate, Alert, ToggleChildren, ViewUpdateStatus, GroupsCancelUpdate, Find,
- HostsCreate, EditInventoryProperties, HostsEdit, HostsDelete, ToggleHostEnabled, CopyMoveGroup, CopyMoveHost,
- Stream, GetBasePath, ShowJobSummary, ApplyEllipsis, WatchInventoryWindowResize, HelpDialog, InventoryGroupsHelp,
- Store)
-{
- ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
- //scope.
+function InventoriesEdit($scope, $location, $routeParams, $compile, GenerateList, ClearScope, InventoryGroups, InventoryHosts, BuildTree, Wait,
+ GetSyncStatusMsg, InjectHosts, HostsReload, GroupsAdd, GroupsEdit, GroupsDelete, Breadcrumbs, LoadBreadCrumbs, Empty,
+ Rest, ProcessErrors, InventoryUpdate, Alert, ToggleChildren, ViewUpdateStatus, GroupsCancelUpdate, Find,
+ HostsCreate, EditInventoryProperties, HostsEdit, HostsDelete, ToggleHostEnabled, CopyMoveGroup, CopyMoveHost,
+ Stream, GetBasePath, ShowJobSummary, ApplyEllipsis, WatchInventoryWindowResize, HelpDialog, InventoryGroupsHelp,
+ Store) {
+ ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
+ //scope.
+
+ var generator = GenerateList,
+ list = InventoryGroups;
- var generator = GenerateList;
- var list = InventoryGroups;
- var base = $location.path().replace(/^\//,'').split('/')[0];
-
$scope.inventory_id = $routeParams.inventory_id;
-
- LoadBreadCrumbs({ path: $location.path(), title: '{{ inventory_name }}' });
+
+ LoadBreadCrumbs({
+ path: $location.path(),
+ title: '{{ inventory_name }}'
+ });
// After the tree data loads for the first time, generate the groups and hosts lists
if ($scope.removeGroupTreeLoaded) {
$scope.removeGroupTreeLoaded();
}
- $scope.removeGroupTreeLoaded = $scope.$on('GroupTreeLoaded', function(e, inventory_name, groups) {
+ $scope.removeGroupTreeLoaded = $scope.$on('GroupTreeLoaded', function (event, inventory_name, groups) {
// Add breadcrumbs
- var e = angular.element(document.getElementById('breadcrumbs'));
+ var e, inventoryAutoHelp;
+ e = angular.element(document.getElementById('breadcrumbs'));
e.html(Breadcrumbs({ list: list, mode: 'edit' }));
$compile(e)($scope);
-
+
// Add groups view
- generator.inject(list, { mode: 'edit', id: 'groups-container', breadCrumbs: false, searchSize: 'col-lg-5 col-md-5 col-sm-5' });
+ generator.inject(list, {
+ mode: 'edit',
+ id: 'groups-container',
+ breadCrumbs: false,
+ searchSize: 'col-lg-5 col-md-5 col-sm-5'
+ });
$scope.groups = groups;
$scope.inventory_name = inventory_name;
@@ -352,235 +387,324 @@ function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateLis
$scope.groups[0].selected_class = 'selected';
$scope.groups[0].active_class = 'active-row';
$scope.selected_group_name = $scope.groups[0].name;
- }
- else {
+ } else {
$scope.selected_tree_id = null;
$scope.selected_group_id = null;
- }
+ }
// Add hosts view
$scope.show_failures = false;
- InjectHosts({ scope: $scope, inventory_id: $scope.inventory_id, tree_id: $scope.selected_tree_id, group_id: $scope.selected_group_id });
-
+ InjectHosts({
+ scope: $scope,
+ inventory_id: $scope.inventory_id,
+ tree_id: $scope.selected_tree_id,
+ group_id: $scope.selected_group_id
+ });
+
// As the window shrinks and expands, apply ellipsis
- setTimeout(function() {
+ setTimeout(function () {
// Hack to keep group name from slipping to a new line
- $('#groups_table .name-column').each( function() {
- var td_width = $(this).width();
- var level_width = $(this).find('.level').width();
- var level_padding = parseInt($(this).find('.level').css('padding-left').replace(/px/,''));
- var level = level_width + level_padding;
- var pct = ( 100 - Math.ceil((level / td_width)*100) ) + '%';
- $(this).find('.group-name').css({ width: pct });
+ $('#groups_table .name-column').each(function () {
+ var td_width, level_width, level_padding, level, pct;
+ td_width = $(this).width();
+ level_width = $(this).find('.level').width();
+ level_padding = parseInt($(this).find('.level').css('padding-left').replace(/px/, ''));
+ level = level_width + level_padding;
+ pct = (100 - Math.ceil((level / td_width) * 100)) + '%';
+ $(this).find('.group-name').css({
+ width: pct
});
+ });
ApplyEllipsis('#groups_table .group-name a');
ApplyEllipsis('#hosts_table .host-name a');
- }, 2500); //give the window time to display
+ }, 2500); //give the window time to display
WatchInventoryWindowResize();
-
- var inventoryAutoHelp = Store('inventoryAutoHelp');
+
+ inventoryAutoHelp = Store('inventoryAutoHelp');
if (inventoryAutoHelp !== 'off' && $scope.autoShowGroupHelp) {
- $scope.showGroupHelp({ autoShow: true });
+ $scope.showGroupHelp({
+ autoShow: true
+ });
}
- });
-
+ });
+
// Called after tree data is reloaded on refresh button click.
if ($scope.removeGroupTreeRefreshed) {
$scope.removeGroupTreeRefreshed();
}
- $scope.removeGroupTreeRefreshed = $scope.$on('GroupTreeRefreshed', function(e, inventory_name, groups) {
+ $scope.removeGroupTreeRefreshed = $scope.$on('GroupTreeRefreshed', function () {
// Reapply ellipsis to groups
- setTimeout(function() { ApplyEllipsis('#groups_table .group-name a'); }, 2500);
+ setTimeout(function () {
+ ApplyEllipsis('#groups_table .group-name a');
+ }, 2500);
// Reselect the preveiously selected group node, causing host view to refresh.
$scope.showHosts($scope.selected_tree_id, $scope.selected_group_id, false);
- });
-
+ });
+
// Group was deleted. Now we need to refresh the group view.
if ($scope.removeGroupDeleteCompleted) {
$scope.removeGroupDeleteCompleted();
}
- $scope.removeGroupDeleteCompleted = $scope.$on('GroupDeleteCompleted', function(e) {
+ $scope.removeGroupDeleteCompleted = $scope.$on('GroupDeleteCompleted', function () {
$scope.selected_tree_id = 1;
$scope.selected_group_id = null;
- BuildTree({ scope: $scope, inventory_id: $scope.inventory_id, refresh: true });
+ BuildTree({
+ scope: $scope,
+ inventory_id: $scope.inventory_id,
+ refresh: true
});
+ });
// Respond to a group drag-n-drop
if ($scope.removeCopMoveGroup) {
$scope.removeCopyMoveGroup();
}
- $scope.removeCopyMoveGroup = $scope.$on('CopyMoveGroup', function(e, inbound_tree_id, target_tree_id) {
- CopyMoveGroup({ scope: $scope, target_tree_id: target_tree_id, inbound_tree_id: inbound_tree_id });
+ $scope.removeCopyMoveGroup = $scope.$on('CopyMoveGroup', function (e, inbound_tree_id, target_tree_id) {
+ CopyMoveGroup({
+ scope: $scope,
+ target_tree_id: target_tree_id,
+ inbound_tree_id: inbound_tree_id
});
+ });
// Respond to a host drag-n-drop
if ($scope.removeCopMoveHost) {
$scope.removeCopyMoveHost();
}
- $scope.removeCopyMoveHost = $scope.$on('CopyMoveHost', function(e, target_tree_id, host_id) {
- CopyMoveHost({ scope: $scope, target_tree_id: target_tree_id, host_id: host_id });
+ $scope.removeCopyMoveHost = $scope.$on('CopyMoveHost', function (e, target_tree_id, host_id) {
+ CopyMoveHost({
+ scope: $scope,
+ target_tree_id: target_tree_id,
+ host_id: host_id
});
+ });
- $scope.showHosts = function(tree_id, group_id, show_failures) {
+ $scope.showHosts = function (tree_id, group_id, show_failures) {
// Clicked on group
if (tree_id !== null) {
Wait('start');
- $scope.selected_tree_id = tree_id;
+ $scope.selected_tree_id = tree_id;
$scope.selected_group_id = group_id;
$scope.hosts = [];
- $scope.show_failures = show_failures; // turn on failed hosts filter in hosts view
- for (var i=0; i < $scope.groups.length; i++) {
- if ($scope.groups[i].id == tree_id) {
+ $scope.show_failures = show_failures; // turn on failed hosts filter in hosts view
+ for (var i = 0; i < $scope.groups.length; i++) {
+ if ($scope.groups[i].id === tree_id) {
$scope.groups[i].selected_class = 'selected';
$scope.groups[i].active_class = 'active-row';
$scope.selected_group_name = $scope.groups[i].name;
- }
- else {
+ } else {
$scope.groups[i].selected_class = '';
$scope.groups[i].active_class = '';
}
}
- HostsReload({ scope: $scope, group_id: group_id, tree_id: tree_id, inventory_id: $scope.inventory_id });
- }
- else {
+ HostsReload({
+ scope: $scope,
+ group_id: group_id,
+ tree_id: tree_id,
+ inventory_id: $scope.inventory_id
+ });
+ } else {
Wait('stop');
}
- }
+ };
- $scope.createGroup = function() {
- GroupsAdd({ scope: $scope, inventory_id: $scope.inventory_id, group_id: $scope.selected_group_id });
- }
-
- $scope.editGroup = function(group_id, tree_id) {
- GroupsEdit({ scope: $scope, inventory_id: $scope.inventory_id, group_id: group_id, tree_id: tree_id, groups_reload: true });
- }
+ $scope.createGroup = function () {
+ GroupsAdd({
+ scope: $scope,
+ inventory_id: $scope.inventory_id,
+ group_id: $scope.selected_group_id
+ });
+ };
+
+ $scope.editGroup = function (group_id, tree_id) {
+ GroupsEdit({
+ scope: $scope,
+ inventory_id: $scope.inventory_id,
+ group_id: group_id,
+ tree_id: tree_id,
+ groups_reload: true
+ });
+ };
// Launch inventory sync
- $scope.updateGroup = function(id) {
- var group = Find({ list: $scope.groups, key: 'id', val: id});
+ $scope.updateGroup = function (id) {
+ var group = Find({ list: $scope.groups, key: 'id', val: id });
if (group) {
if (Empty(group.source)) {
// if no source, do nothing.
- }
- else if (group.status == 'updating') {
+ } else if (group.status === 'updating') {
Alert('Update in Progress', 'The inventory update process is currently running for group ' +
- $scope.groups[i].name + '. Use the Refresh button to monitor the status.', 'alert-info');
- }
- else {
+ group.name + '. Use the Refresh button to monitor the status.', 'alert-info');
+ } else {
Wait('start');
Rest.setUrl(group.related.inventory_source);
Rest.get()
- .success( function(data, status, headers, config) {
+ .success(function (data) {
InventoryUpdate({
- scope: $scope,
+ scope: $scope,
url: data.related.update,
- group_name: data.summary_fields.group.name,
+ group_name: data.summary_fields.group.name,
group_source: data.source,
tree_id: group.id,
group_id: group.group_id
- });
- })
- .error( function(data, status, headers, config) {
- Wait('stop');
- ProcessErrors(scope, data, status, form,
- { hdr: 'Error!', msg: 'Failed to retrieve inventory source: ' + group.related.inventory_source +
- ' POST returned status: ' + status });
});
+ })
+ .error(function (data, status) {
+ Wait('stop');
+ ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to retrieve inventory source: ' +
+ group.related.inventory_source + ' POST returned status: ' + status });
+ });
}
- }
}
+ };
- $scope.cancelUpdate = function(tree_id) {
- GroupsCancelUpdate({ scope: $scope, tree_id: tree_id });
- }
-
- $scope.toggle = function(tree_id) {
+ $scope.cancelUpdate = function (tree_id) {
+ GroupsCancelUpdate({
+ scope: $scope,
+ tree_id: tree_id
+ });
+ };
+
+ $scope.toggle = function (tree_id) {
// Expand/collapse nodes
- ToggleChildren({ scope: $scope, list: list, id: tree_id });
- }
+ ToggleChildren({
+ scope: $scope,
+ list: list,
+ id: tree_id
+ });
+ };
- $scope.refreshGroups = function(tree_id, group_id) {
+ $scope.refreshGroups = function (tree_id, group_id) {
// Refresh the tree data when refresh button cicked
if (tree_id) {
$scope.selected_tree_id = tree_id;
$scope.selected_group_id = group_id;
}
- BuildTree({ scope: $scope, inventory_id: $scope.inventory_id, refresh: true });
- }
+ BuildTree({
+ scope: $scope,
+ inventory_id: $scope.inventory_id,
+ refresh: true
+ });
+ };
- $scope.viewUpdateStatus = function(tree_id, group_id) {
- ViewUpdateStatus({ scope: $scope, tree_id: tree_id, group_id: group_id });
- }
+ $scope.viewUpdateStatus = function (tree_id, group_id) {
+ ViewUpdateStatus({
+ scope: $scope,
+ tree_id: tree_id,
+ group_id: group_id
+ });
+ };
- $scope.deleteGroup = function(tree_id, group_id) {
- GroupsDelete({ scope: $scope, tree_id: tree_id, group_id: group_id, inventory_id: $scope.inventory_id });
- }
+ $scope.deleteGroup = function (tree_id, group_id) {
+ GroupsDelete({
+ scope: $scope,
+ tree_id: tree_id,
+ group_id: group_id,
+ inventory_id: $scope.inventory_id
+ });
+ };
- $scope.createHost = function() {
- HostsCreate({ scope: $scope });
- }
-
- $scope.editInventoryProperties = function() {
- EditInventoryProperties({ scope: $scope, inventory_id: $scope.inventory_id });
- }
+ $scope.createHost = function () {
+ HostsCreate({
+ scope: $scope
+ });
+ };
- $scope.editHost = function(host_id) {
- HostsEdit({ scope: $scope, host_id: host_id, inventory_id: $scope.inventory_id });
- }
+ $scope.editInventoryProperties = function () {
+ EditInventoryProperties({
+ scope: $scope,
+ inventory_id: $scope.inventory_id
+ });
+ };
- $scope.deleteHost = function(host_id, host_name) {
- HostsDelete({ scope: $scope, host_id: host_id, host_name: host_name });
- }
+ $scope.editHost = function (host_id) {
+ HostsEdit({
+ scope: $scope,
+ host_id: host_id,
+ inventory_id: $scope.inventory_id
+ });
+ };
- $scope.toggleHostEnabled = function(host_id, external_source) {
- ToggleHostEnabled({ scope: $scope, host_id: host_id, external_source: external_source });
- }
+ $scope.deleteHost = function (host_id, host_name) {
+ HostsDelete({
+ scope: $scope,
+ host_id: host_id,
+ host_name: host_name
+ });
+ };
- $scope.showGroupActivity = function() {
+ $scope.toggleHostEnabled = function (host_id, external_source) {
+ ToggleHostEnabled({
+ scope: $scope,
+ host_id: host_id,
+ external_source: external_source
+ });
+ };
+
+ $scope.showGroupActivity = function () {
var url, title, group;
if ($scope.selected_group_id) {
- group = Find({ list: $scope.groups, key: 'id', val: $scope.selected_tree_id });
+ group = Find({
+ list: $scope.groups,
+ key: 'id',
+ val: $scope.selected_tree_id
+ });
url = GetBasePath('activity_stream') + '?group__id=' + $scope.selected_group_id;
title = 'Showing all activities for group ' + group.name;
- }
- else {
+ } else {
title = 'Showing all activities for all ' + $scope.inventory_name + ' groups';
url = GetBasePath('activity_stream') + '?group__inventory__id=' + $scope.inventory_id;
}
- Stream({ scope: $scope, inventory_name: $scope.inventory_name, url: url, title: title });
- }
-
- $scope.showHostActivity = function() {
+ Stream({
+ scope: $scope,
+ inventory_name: $scope.inventory_name,
+ url: url,
+ title: title
+ });
+ };
+
+ $scope.showHostActivity = function () {
var url, title;
title = 'Showing all activities for all ' + $scope.inventory_name + ' hosts';
url = GetBasePath('activity_stream') + '?host__inventory__id=' + $scope.inventory_id;
- Stream({ scope: $scope, inventory_name: $scope.inventory_name, url: url, title: title });
- }
+ Stream({
+ scope: $scope,
+ inventory_name: $scope.inventory_name,
+ url: url,
+ title: title
+ });
+ };
- $scope.showJobSummary = function(job_id) {
- ShowJobSummary({ job_id: job_id });
- }
+ $scope.showJobSummary = function (job_id) {
+ ShowJobSummary({
+ job_id: job_id
+ });
+ };
- $scope.showGroupHelp = function(params) {
- var opts = { defn: InventoryGroupsHelp };
+ $scope.showGroupHelp = function (params) {
+ var opts = {
+ defn: InventoryGroupsHelp
+ };
if (params) {
opts.autoShow = params.autoShow || false;
}
HelpDialog(opts);
- }
+ };
//Load tree data for the first time
- BuildTree({ scope: $scope, inventory_id: $scope.inventory_id, refresh: false });
+ BuildTree({
+ scope: $scope,
+ inventory_id: $scope.inventory_id,
+ refresh: false
+ });
- }
+}
-InventoriesEdit.$inject = [ '$scope', '$location', '$routeParams', '$compile', 'GenerateList', 'ClearScope', 'InventoryGroups', 'InventoryHosts',
- 'BuildTree', 'Wait', 'GetSyncStatusMsg', 'InjectHosts', 'HostsReload', 'GroupsAdd', 'GroupsEdit', 'GroupsDelete',
- 'Breadcrumbs', 'LoadBreadCrumbs', 'Empty', 'Rest', 'ProcessErrors', 'InventoryUpdate', 'Alert', 'ToggleChildren',
- 'ViewUpdateStatus', 'GroupsCancelUpdate', 'Find', 'HostsCreate', 'EditInventoryProperties', 'HostsEdit',
- 'HostsDelete', 'ToggleHostEnabled', 'CopyMoveGroup', 'CopyMoveHost', 'Stream', 'GetBasePath', 'ShowJobSummary',
- 'ApplyEllipsis', 'WatchInventoryWindowResize', 'HelpDialog', 'InventoryGroupsHelp', 'Store'
- ];
-
+InventoriesEdit.$inject = ['$scope', '$location', '$routeParams', '$compile', 'GenerateList', 'ClearScope', 'InventoryGroups', 'InventoryHosts',
+ 'BuildTree', 'Wait', 'GetSyncStatusMsg', 'InjectHosts', 'HostsReload', 'GroupsAdd', 'GroupsEdit', 'GroupsDelete', 'Breadcrumbs',
+ 'LoadBreadCrumbs', 'Empty', 'Rest', 'ProcessErrors', 'InventoryUpdate', 'Alert', 'ToggleChildren', 'ViewUpdateStatus', 'GroupsCancelUpdate',
+ 'Find', 'HostsCreate', 'EditInventoryProperties', 'HostsEdit', 'HostsDelete', 'ToggleHostEnabled', 'CopyMoveGroup', 'CopyMoveHost',
+ 'Stream', 'GetBasePath', 'ShowJobSummary', 'ApplyEllipsis', 'WatchInventoryWindowResize', 'HelpDialog', 'InventoryGroupsHelp', 'Store'
+];
\ No newline at end of file
diff --git a/awx/ui/static/js/controllers/JobEvents.js b/awx/ui/static/js/controllers/JobEvents.js
index 735fe2eaee..7c9406dd0d 100644
--- a/awx/ui/static/js/controllers/JobEvents.js
+++ b/awx/ui/static/js/controllers/JobEvents.js
@@ -3,180 +3,168 @@
*
*
* JobEvents.js
- *
+ *
* Controller functions for the Job Events model.
*
*/
'use strict';
-function JobEventsList ($filter, $scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobEventList,
- GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
- ClearScope, ProcessErrors, GetBasePath, LookUpInit, ToggleChildren,
- FormatDate, EventView, Refresh, Wait)
-{
+function JobEventsList($filter, $scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobEventList, GenerateList,
+ LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, LookUpInit, ToggleChildren,
+ FormatDate, EventView, Refresh, Wait) {
+
ClearScope('htmlTemplate');
- var list = JobEventList;
+
+ var list = JobEventList,
+ defaultUrl = GetBasePath('jobs') + $routeParams.id + '/job_events/', //?parent__isnull=1';
+ view = GenerateList,
+ scope = view.inject(list, { mode: 'edit' }),
+ page;
+
list.base = $location.path();
-
- var defaultUrl = GetBasePath('jobs') + $routeParams.id + '/job_events/'; //?parent__isnull=1';
-
- var view = GenerateList;
- var base = $location.path().replace(/^\//,'').split('/')[0];
- var scope = view.inject(list, { mode: 'edit' });
-
scope.job_id = $routeParams.id;
$rootScope.flashMessage = null;
scope.selected = [];
- scope.expand = true; //on load, automatically expand all nodes
+ scope.expand = true; //on load, automatically expand all nodes
+
+ scope.parentNode = 'parent-event'; // used in ngClass to dynamically set row level class and control
+ scope.childNode = 'child-event'; // link color and cursor
- scope.parentNode = 'parent-event'; // used in ngClass to dynamically set row level class and control
- scope.childNode = 'child-event'; // link color and cursor
-
if (scope.removeSetHostLinks) {
- scope.removeSetHostLinks();
+ scope.removeSetHostLinks();
}
- scope.removeSetHostLinks = scope.$on('SetHostLinks', function(e, inventory_id) {
- for (var i=0; i < scope.jobevents.length; i++) {
+ scope.removeSetHostLinks = scope.$on('SetHostLinks', function (e, inventory_id) {
+ for (var i = 0; i < scope.jobevents.length; i++) {
if (scope.jobevents[i].summary_fields.host) {
- scope.jobevents[i].hostLink = "/#/inventories/" + inventory_id + "/hosts/?name=" +
- escape(scope.jobevents[i].summary_fields.host.name);
+ scope.jobevents[i].hostLink = "/#/inventories/" + inventory_id + "/hosts/?name=" +
+ encodeURI(scope.jobevents[i].summary_fields.host.name);
}
}
- });
+ });
function formatJSON(eventData) {
//turn JSON event data into an html form
- var html = '';
- if (eventData['res']) {
- var n, rows;
- var found = false;
- if (typeof eventData.res == 'string') {
- n = eventData['res'].match(/\n/g);
- rows = (n) ? n.length : 1;
- rows = (rows > 10) ? 10 : rows;
- found = true;
- html += "
View YAML examples at docs.ansible.com
', dataContainer: 'body', tab: 'source' - }, + }, checkbox_group: { label: 'Update Options', type: 'checkbox_group', ngShow: "source && (source.value !== '' && source.value !== null)", tab: 'source', - fields: [ - { - name: 'overwrite', - label: 'Overwrite', - type: 'checkbox', - ngShow: "source.value !== '' && source.value !== null", - addRequired: false, - editRequired: false, - awPopOver: 'When checked all child groups and hosts not found on the remote source will be deleted from ' + - 'the local inventory.
Unchecked any local child hosts and groups not found on the external source will ' + - 'remain untouched by the inventory update process.
', - dataTitle: 'Overwrite', - dataContainer: 'body', - dataPlacement: 'right', - labelClass: 'checkbox-options' - }, - { - name: 'overwrite_vars', - label: 'Overwrite Variables', - type: 'checkbox', - ngShow: "source.value !== '' && source.value !== null", - addRequired: false, - editRequired: false, - awPopOver: 'If checked, all variables for child groups and hosts will be removed and replaced by those ' + - 'found on the external source.
When not checked a merge will be performed, combining local variables with ' + - 'those found on the external source.
', - dataTitle: 'Overwrite Variables', - dataContainer: 'body', - dataPlacement: 'right', - labelClass: 'checkbox-options' - }, - { - name: 'update_on_launch', - label: 'Update on Launch', - type: 'checkbox', - ngShow: "source.value !== '' && source.value !== null", - addRequired: false, - editRequired: false, - awPopOver: 'Each time a job runs using this inventory, refresh the inventory from the selected source before ' + - 'executing job tasks.
', - dataTitle: 'Update on Launch', - dataContainer: 'body', - dataPlacement: 'right', - labelClass: 'checkbox-options' - } - ] - } - }, + fields: [{ + name: 'overwrite', + label: 'Overwrite', + type: 'checkbox', + ngShow: "source.value !== '' && source.value !== null", + addRequired: false, + editRequired: false, + awPopOver: 'When checked all child groups and hosts not found on the remote source will be deleted from ' + + 'the local inventory.
Unchecked any local child hosts and groups not found on the external source will ' + + 'remain untouched by the inventory update process.
', + dataTitle: 'Overwrite', + dataContainer: 'body', + dataPlacement: 'right', + labelClass: 'checkbox-options' + }, { + name: 'overwrite_vars', + label: 'Overwrite Variables', + type: 'checkbox', + ngShow: "source.value !== '' && source.value !== null", + addRequired: false, + editRequired: false, + awPopOver: 'If checked, all variables for child groups and hosts will be removed and replaced by those ' + + 'found on the external source.
When not checked a merge will be performed, combining local variables with ' + + 'those found on the external source.
', + dataTitle: 'Overwrite Variables', + dataContainer: 'body', + dataPlacement: 'right', + labelClass: 'checkbox-options' + }, { + name: 'update_on_launch', + label: 'Update on Launch', + type: 'checkbox', + ngShow: "source.value !== '' && source.value !== null", + addRequired: false, + editRequired: false, + awPopOver: 'Each time a job runs using this inventory, refresh the inventory from the selected source before ' + + 'executing job tasks.
', + dataTitle: 'Update on Launch', + dataContainer: 'body', + dataPlacement: 'right', + labelClass: 'checkbox-options' + }] + } + }, + + buttons: { - buttons: { //for now always generates