diff --git a/awx/ui/static/js/widgets/InventorySyncStatus.js b/awx/ui/static/js/widgets/InventorySyncStatus.js index d45a888163..ae302cf6cb 100644 --- a/awx/ui/static/js/widgets/InventorySyncStatus.js +++ b/awx/ui/static/js/widgets/InventorySyncStatus.js @@ -30,7 +30,9 @@ angular.module('InventorySyncStatusWidget', ['RestServices', 'Utilities']) function makeRow(label, count, fail) { var html = "\n"; - html += "" + label + "\n"; + html += "\n"; html += ""; html += (fail > 0) ? "" + fail + "" : ""; html += "\n"; @@ -141,25 +143,31 @@ angular.module('InventorySyncStatusWidget', ['RestServices', 'Utilities']) ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get ' + url + '. GET status: ' + status }); }); - + + if (scope.removeTypesReady) { + scope.removeTypesReady(); + } scope.removeTypesReady = scope.$on('TypesReady', function (e, label, count, fail) { results.push({ label: label, count: count, fail: fail }); if (results.length == expected) { scope.$emit('CountReceived'); } }); - - scope.removeCountProjects = scope.$on('CountTypes', function(e, choices) { + + if (scope.CountProjects) { + scope.CountProjects(); + } + scope.removeCountProjects = scope.$on('CountTypes', function() { - scm_choices = choices; + var choices = scope['inventorySources']; function getLabel(config) { var url = config.url; var type = url.match(/source=.*\&/)[0].replace(/source=/,'').replace(/\&/,''); var label; for (var i=0; i < choices.length; i++) { - if (choices[i][0] == type) { - label = choices[i][1]; + if (choices[i].value == type) { + label = choices[i].label; break; } } @@ -168,24 +176,24 @@ angular.module('InventorySyncStatusWidget', ['RestServices', 'Utilities']) // Remove ---- option from list of choices for (var i=0; i < choices.length; i++) { - if (choices[i][1].match(/^---/)) { + if (choices[i].label.match(/^---/)) { choices.splice(i,1); break; } } for (var i=0; i < choices.length; i++) { - if (choices[i][1].match(/^Local/)) { + if (choices[i].label.match(/^Local/)) { choices.splice(i,1); break; } } expected = choices.length; - + for (var i=0; i < choices.length; i++) { - if (!choices[i][1].match(/^---/)) { - var url = GetBasePath('inventory_sources') + '?source=' + choices[i][0] + '&page=1'; + if (!choices[i].label.match(/^---/)) { + var url = GetBasePath('inventory_sources') + '?source=' + choices[i].value + '&page=1'; Rest.setUrl(url); Rest.get() .success( function(data, status, headers, config) { @@ -210,8 +218,9 @@ angular.module('InventorySyncStatusWidget', ['RestServices', 'Utilities']) GetChoices({ scope: scope, url: GetBasePath('inventory_sources'), + variable: 'inventorySources', field: 'source', - emit: 'CountTypes' }); + callback: 'CountTypes' }); } }]); \ No newline at end of file diff --git a/awx/ui/static/js/widgets/JobStatus.js b/awx/ui/static/js/widgets/JobStatus.js index 4fd87ce43e..e8d015ba3d 100644 --- a/awx/ui/static/js/widgets/JobStatus.js +++ b/awx/ui/static/js/widgets/JobStatus.js @@ -28,7 +28,9 @@ angular.module('JobStatusWidget', ['RestServices', 'Utilities']) function makeRow(label, count, fail) { var html = ''; html += "\n"; - html += "" + label + "\n"; + html += "\n"; html += ""; html += (fail > 0) ? "" + fail + "" : ""; html += "\n"; diff --git a/awx/ui/static/js/widgets/SCMSyncStatus.js b/awx/ui/static/js/widgets/SCMSyncStatus.js index f9012ab0b3..7fce1a0275 100644 --- a/awx/ui/static/js/widgets/SCMSyncStatus.js +++ b/awx/ui/static/js/widgets/SCMSyncStatus.js @@ -27,9 +27,9 @@ angular.module('SCMSyncStatusWidget', ['RestServices', 'Utilities']) function makeRow(label, count, fail) { var value; - for (var i=0; i < scm_choices.length; i++) { - if (scm_choices[i][1] == label) { - value = scm_choices[i][0]; + for (var i=0; i < scope['projectChoices'].length; i++) { + if (scope['projectChoices'][i].label == label) { + value = scope['projectChoices'][i].value; break; } } @@ -87,17 +87,17 @@ angular.module('SCMSyncStatusWidget', ['RestServices', 'Utilities']) }); - scope.removeCountProjects = scope.$on('CountProjects', function(e, choices) { + scope.removeCountProjects = scope.$on('CountProjects', function() { - scm_choices = choices; + var choices = scope['projectChoices']; function getScmLabel(config) { var url = config.url; var scm_type = url.match(/scm_type=.*\&/)[0].replace(/scm_type=/,'').replace(/\&/,''); var label; for (var i=0; i < choices.length; i++) { - if (choices[i][0] == scm_type) { - label = choices[i][1]; + if (choices[i].value == scm_type) { + label = choices[i].label; break; } } @@ -106,14 +106,14 @@ angular.module('SCMSyncStatusWidget', ['RestServices', 'Utilities']) // Remove ---- option from list of choices for (var i=0; i < choices.length; i++) { - if (choices[i][1].match(/^---/)) { + if (choices[i].value.match(/^---/)) { choices.splice(i,1); break; } } // Remove Manual option from list of choices for (var i=0; i < choices.length; i++) { - if (choices[i][1].match(/Manual/)) { + if (choices[i].label.match(/Manual/)) { choices.splice(i,1); break; } @@ -122,8 +122,8 @@ angular.module('SCMSyncStatusWidget', ['RestServices', 'Utilities']) expected = choices.length; for (var i=0; i < choices.length; i++) { - if (!choices[i][1].match(/^---/)) { - var url = GetBasePath('projects') + '?scm_type=' + choices[i][0] + '&page=1'; + if (!choices[i].label.match(/^---/)) { + var url = GetBasePath('projects') + '?scm_type=' + choices[i].value + '&page=1'; Rest.setUrl(url); Rest.get() .success( function(data, status, headers, config) { @@ -146,7 +146,13 @@ angular.module('SCMSyncStatusWidget', ['RestServices', 'Utilities']) } }); - GetChoices({ scope: scope, url: GetBasePath('projects'), field: 'scm_type', emit: 'CountProjects'}); + GetChoices({ + scope: scope, + url: GetBasePath('projects'), + variable: 'projectChoices', + field: 'scm_type', + callback: 'CountProjects' + }); } }]); \ No newline at end of file