From 61c0355f77595eba3822eae63a9a791b2cdaaf7d Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Wed, 2 Apr 2014 16:43:07 -0400 Subject: [PATCH] AC-1120. Fixed log viewer issues. Display 'Group' and group name rather than 'Inv Source'. Always display variables/source variables tabs when data present. Translate source value to a proper label using an OPTIONS request. --- awx/ui/static/js/forms/LogViewerOptions.js | 11 ++++-- awx/ui/static/js/helpers/LogViewer.js | 44 ++++++++++++++++++---- awx/ui/static/js/lists/ScheduledJobs.js | 3 +- 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/awx/ui/static/js/forms/LogViewerOptions.js b/awx/ui/static/js/forms/LogViewerOptions.js index a3d94b06ef..680168e73b 100644 --- a/awx/ui/static/js/forms/LogViewerOptions.js +++ b/awx/ui/static/js/forms/LogViewerOptions.js @@ -63,6 +63,11 @@ angular.module('LogViewerOptionsDefinition', []) type: "text", readonly: true }, + "inventory_source": { + label: "Group", + type: "text", + readonly: true + }, "source": { label: "Source", type: "text", @@ -79,12 +84,12 @@ angular.module('LogViewerOptionsDefinition', []) readonly: true }, "overwrite": { - label: "Overwrite Vars", + label: "Overwrite", type: "text", readonly: true }, - "inventory_source": { - label: "Inv Source", + "overwrite_vars": { + label: "Overwrite Vars", type: "text", readonly: true } diff --git a/awx/ui/static/js/helpers/LogViewer.js b/awx/ui/static/js/helpers/LogViewer.js index 3fe457be17..c81c197265 100644 --- a/awx/ui/static/js/helpers/LogViewer.js +++ b/awx/ui/static/js/helpers/LogViewer.js @@ -10,9 +10,9 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator', 'VariablesHelper']) .factory('LogViewer', ['$compile', 'CreateDialog', 'GetJob', 'Wait', 'GenerateForm', 'LogViewerStatusForm', 'AddTable', 'AddTextarea', - 'LogViewerOptionsForm', 'EnvTable', 'GetBasePath', 'LookUpName', 'Empty', 'AddPreFormattedText', 'ParseVariableString', + 'LogViewerOptionsForm', 'EnvTable', 'GetBasePath', 'LookUpName', 'Empty', 'AddPreFormattedText', 'ParseVariableString', 'GetChoices', function($compile, CreateDialog, GetJob, Wait, GenerateForm, LogViewerStatusForm, AddTable, AddTextarea, LogViewerOptionsForm, EnvTable, - GetBasePath, LookUpName, Empty, AddPreFormattedText, ParseVariableString) { + GetBasePath, LookUpName, Empty, AddPreFormattedText, ParseVariableString, GetChoices) { return function(params) { var parent_scope = params.scope, url = params.url, @@ -70,6 +70,7 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator', }*/ if (data.extra_vars) { + $('#logview-tabs li:eq(4)').show(); AddTextarea({ container_id: 'variables-container', fld_id: 'variables', @@ -81,6 +82,7 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator', } if (data.source_vars) { + $('#logview-tabs li:eq(5)').show(); AddTextarea({ container_id: 'source-container', fld_id: 'source-variables', @@ -91,6 +93,29 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator', $('#logview-tabs li:eq(5)').hide(); } + if (!Empty(scope.source)) { + if (scope.removeChoicesReady) { + scope.removeChoicesReady(); + } + scope.removeChoicesReady = scope.$on('ChoicesReady', function() { + scope.source_choices.every(function(e) { + if (e.value === scope.source) { + scope.source = e.label; + return false; + } + return true; + }); + }); + GetChoices({ + scope: scope, + url: GetBasePath('inventory_sources'), + field: 'source', + variable: 'source_choices', + choice_name: 'choices', + callback: 'ChoicesReady' + }); + } + if (!Empty(scope.credential)) { LookUpName({ scope: scope, @@ -194,7 +219,10 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator', Rest.setUrl(url); Rest.get() .success(function(data) { - if (!Empty(data.name)) { + if (scope_var === 'inventory_source') { + scope[scope_var + '_name'] = data.summary_fields.group.name; + } + else if (!Empty(data.name)) { scope[scope_var + '_name'] = data.name; } if (!Empty(data.group)) { @@ -209,13 +237,13 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator', }; }]) - .factory('AddTable', ['Empty', 'Find', function(Empty, Find) { + .factory('AddTable', ['$compile', 'Empty', 'Find', function($compile, Empty, Find) { return function(params) { var form = params.form, id = params.id, scope = params.scope, getIcon = params.getIcon, - fld, html, url, + fld, html, url, e, urls = [ { "variable": "credential", "url": "/#/credentials/" }, { "variable": "project", "url": "/#/projects/" }, @@ -250,13 +278,15 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator', } } else { - html += scope[fld]; + html += "{{ " + fld + " }}"; } html += "\n"; } } html += "\n"; - $('#' + id).empty().html(html); + e = angular.element(document.getElementById(id)); + e.empty().html(html); + $compile(e)(scope); }; }]) diff --git a/awx/ui/static/js/lists/ScheduledJobs.js b/awx/ui/static/js/lists/ScheduledJobs.js index f9a8e80b59..336036b4b9 100644 --- a/awx/ui/static/js/lists/ScheduledJobs.js +++ b/awx/ui/static/js/lists/ScheduledJobs.js @@ -37,8 +37,7 @@ angular.module('ScheduledJobsDefinition', []) searchable: false, columnClass: "col-md-2 hidden-xs", filter: "date:'MM/dd/yy HH:mm:ss'", - key: true, - desc: true + key: true }, type: { label: 'Type',