From d2f267c34c32998609e97ac6d65ca8d178ccfc2f Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Mon, 12 Dec 2016 18:21:35 -0800 Subject: [PATCH 01/10] fixing options request for template list --- .../list/templates-list.controller.js | 56 +++++++++---------- .../templates/list/templates-list.route.js | 14 +++++ 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/awx/ui/client/src/templates/list/templates-list.controller.js b/awx/ui/client/src/templates/list/templates-list.controller.js index 93f32807ea..ff75f8f79b 100644 --- a/awx/ui/client/src/templates/list/templates-list.controller.js +++ b/awx/ui/client/src/templates/list/templates-list.controller.js @@ -4,15 +4,16 @@ * All Rights Reserved *************************************************/ -export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest', 'Alert', - 'TemplateList', 'Prompt', 'ClearScope', 'ProcessErrors', 'GetBasePath', - 'InitiatePlaybookRun', 'Wait', '$state', '$filter', 'Dataset', 'rbacUiControlService', 'TemplatesService', - 'QuerySet', 'GetChoices', 'TemplateCopyService', +export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest', + 'Alert','TemplateList', 'Prompt', 'ClearScope', 'ProcessErrors', + 'GetBasePath', 'InitiatePlaybookRun', 'Wait', '$state', '$filter', + 'Dataset', 'rbacUiControlService', 'TemplatesService','QuerySet', + 'GetChoices', 'TemplateCopyService', 'DataOptions', function( $scope, $rootScope, $location, $stateParams, Rest, Alert, TemplateList, Prompt, ClearScope, ProcessErrors, GetBasePath, InitiatePlaybookRun, Wait, $state, $filter, Dataset, rbacUiControlService, TemplatesService, - qs, GetChoices, TemplateCopyService + qs, GetChoices, TemplateCopyService, DataOptions ) { ClearScope(); @@ -36,38 +37,31 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest', 'Al $scope.list = list; $scope[`${list.iterator}_dataset`] = Dataset.data; $scope[list.name] = $scope[`${list.iterator}_dataset`].results; + $scope.options = DataOptions; $rootScope.flashMessage = null; - if ($scope.removeChoicesReady) { - $scope.removeChoicesReady(); - } - $scope.removeChoicesReady = $scope.$on('choicesReady', function() { - $scope[list.name].forEach(function(item, item_idx) { - var itm = $scope[list.name][item_idx]; + $scope.$watchCollection('templates', function() { + $scope[list.name].forEach(function(item, item_idx) { + var itm = $scope[list.name][item_idx]; - // Set the item type label - if (list.fields.type) { - $scope.type_choices.every(function(choice) { - if (choice.value === item.type) { - itm.type_label = choice.label; - return false; - } - return true; - }); - } - }); - }); - - GetChoices({ - scope: $scope, - url: GetBasePath('unified_job_templates'), - field: 'type', - variable: 'type_choices', - callback: 'choicesReady' - }); + // Set the item type label + if (list.fields.type) { + $scope.options.type.choices.every(function(choice) { + if (choice[0] === item.type) { + itm.type_label = choice[1]; + return false; + } + return true; + }); + } + }); + } + ); } + + $scope.$on(`ws-jobs`, function () { // @issue - this is no longer quite as ham-fisted but I'd like for someone else to take a peek // calling $state.reload(); here was problematic when launching a job because job launch also diff --git a/awx/ui/client/src/templates/list/templates-list.route.js b/awx/ui/client/src/templates/list/templates-list.route.js index e615e52db1..5a79700bdb 100644 --- a/awx/ui/client/src/templates/list/templates-list.route.js +++ b/awx/ui/client/src/templates/list/templates-list.route.js @@ -46,6 +46,20 @@ export default { let path = GetBasePath(list.basePath) || GetBasePath(list.name); return qs.search(path, $stateParams[`${list.iterator}_search`]); } + ], + DataOptions: ['Rest', 'GetBasePath', '$stateParams', '$q', 'TemplateList', + function(Rest, GetBasePath, $stateParams, $q, list) { + let path = GetBasePath(list.basePath) || GetBasePath(list.name); + Rest.setUrl(path); + var val = $q.defer(); + Rest.options() + .then(function(data) { + val.resolve(data.data.actions.GET); + }, function(data) { + val.reject(data); + }); + return val.promise; + } ] } }; From 976e9bfe82a51ee60c4a92ac036a19a87bf99f96 Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Wed, 14 Dec 2016 14:58:40 -0800 Subject: [PATCH 02/10] adding callback for when options are received --- .../shared/smart-search/queryset.service.js | 18 ++++++++++++++---- .../smart-search/smart-search.controller.js | 9 +++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/awx/ui/client/src/shared/smart-search/queryset.service.js b/awx/ui/client/src/shared/smart-search/queryset.service.js index a45f8af74f..359245bed4 100644 --- a/awx/ui/client/src/shared/smart-search/queryset.service.js +++ b/awx/ui/client/src/shared/smart-search/queryset.service.js @@ -18,13 +18,23 @@ export default ['$q', 'Rest', 'ProcessErrors', '$rootScope', 'Wait', 'DjangoSear // grab a single model from the cache, if present if (cache.get(path)) { - defer.resolve({[name] : new DjangoSearchModel(name, path, cache.get(path), relations)}); + defer.resolve({ + models: { + [name] : new DjangoSearchModel(name, path, cache.get(path), relations) + }, + options: cache.get(path) + }); } else { this.url = path; resolve = this.options(path) .then((res) => { base = res.data.actions.GET; - defer.resolve({[name]: new DjangoSearchModel(name, path, base, relations)}); + defer.resolve({ + models: { + [name]: new DjangoSearchModel(name, path, base, relations) + }, + options: res + }); }); } return defer.promise; @@ -76,9 +86,9 @@ export default ['$q', 'Rest', 'ProcessErrors', '$rootScope', 'Wait', 'DjangoSear if (Array.isArray(value)){ return _.map(value, (item) => { return `${key.split('__').join(':')}:${item}`; - }); + }); } - else { + else { return `${key.split('__').join(':')}:${value}`; } }, diff --git a/awx/ui/client/src/shared/smart-search/smart-search.controller.js b/awx/ui/client/src/shared/smart-search/smart-search.controller.js index 87dc33198a..3352cb5495 100644 --- a/awx/ui/client/src/shared/smart-search/smart-search.controller.js +++ b/awx/ui/client/src/shared/smart-search/smart-search.controller.js @@ -15,8 +15,9 @@ export default ['$stateParams', '$scope', '$state', 'QuerySet', 'GetBasePath', ' path = GetBasePath($scope.basePath) || $scope.basePath; relations = getRelationshipFields($scope.dataset.results); $scope.searchTags = stripDefaultParams($state.params[`${$scope.iterator}_search`]); - qs.initFieldset(path, $scope.djangoModel, relations).then((models) => { - $scope.models = models; + qs.initFieldset(path, $scope.djangoModel, relations).then((data) => { + $scope.models = data.models; + $scope.$emit(`${$scope.list.iterator}_options`, data.options); }); } @@ -102,12 +103,12 @@ export default ['$stateParams', '$scope', '$state', 'QuerySet', 'GetBasePath', ' params.page = '1'; queryset = _.merge(queryset, params, (objectValue, sourceValue, key, object) => { if (object[key] && object[key] !== sourceValue){ - return [object[key], sourceValue]; + return [object[key], sourceValue]; } else { // // https://lodash.com/docs/3.10.1#merge // If customizer fn returns undefined merging is handled by default _.merge algorithm - return undefined; + return undefined; } }); // https://ui-router.github.io/docs/latest/interfaces/params.paramdeclaration.html#dynamic From c4ce68b4de8c1393fbade3ff191f14141ffe1686 Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Wed, 14 Dec 2016 14:59:05 -0800 Subject: [PATCH 03/10] applying callback mechanism to job tmeplate list --- .../list/templates-list.controller.js | 52 +++++++++++-------- .../templates/list/templates-list.route.js | 14 ----- 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/awx/ui/client/src/templates/list/templates-list.controller.js b/awx/ui/client/src/templates/list/templates-list.controller.js index ff75f8f79b..51b353a51a 100644 --- a/awx/ui/client/src/templates/list/templates-list.controller.js +++ b/awx/ui/client/src/templates/list/templates-list.controller.js @@ -8,12 +8,12 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest', 'Alert','TemplateList', 'Prompt', 'ClearScope', 'ProcessErrors', 'GetBasePath', 'InitiatePlaybookRun', 'Wait', '$state', '$filter', 'Dataset', 'rbacUiControlService', 'TemplatesService','QuerySet', - 'GetChoices', 'TemplateCopyService', 'DataOptions', + 'GetChoices', 'TemplateCopyService', function( $scope, $rootScope, $location, $stateParams, Rest, Alert, TemplateList, Prompt, ClearScope, ProcessErrors, GetBasePath, InitiatePlaybookRun, Wait, $state, $filter, Dataset, rbacUiControlService, TemplatesService, - qs, GetChoices, TemplateCopyService, DataOptions + qs, GetChoices, TemplateCopyService ) { ClearScope(); @@ -37,29 +37,39 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest', $scope.list = list; $scope[`${list.iterator}_dataset`] = Dataset.data; $scope[list.name] = $scope[`${list.iterator}_dataset`].results; - $scope.options = DataOptions; + $scope.options = {}; $rootScope.flashMessage = null; - - $scope.$watchCollection('templates', function() { - $scope[list.name].forEach(function(item, item_idx) { - var itm = $scope[list.name][item_idx]; - - // Set the item type label - if (list.fields.type) { - $scope.options.type.choices.every(function(choice) { - if (choice[0] === item.type) { - itm.type_label = choice[1]; - return false; - } - return true; - }); - } - }); - } - ); } + $scope.$on(`${list.iterator}_options`, function(event, data){ + debugger; + $scope.options = data.data.actions.GET; + optionsRequestDataProcessing(); + }); + + $scope.$watchCollection('templates', function() { + optionsRequestDataProcessing(); + } + ); + // iterate over the list and add fields like type label, after the + // OPTIONS request returns, or the list is sorted/paginated/searched + function optionsRequestDataProcessing(){ + $scope[list.name].forEach(function(item, item_idx) { + var itm = $scope[list.name][item_idx]; + + // Set the item type label + if (list.fields.type && $scope.options.hasOwnProperty('type')) { + $scope.options.type.choices.every(function(choice) { + if (choice[0] === item.type) { + itm.type_label = choice[1]; + return false; + } + return true; + }); + } + }); + } $scope.$on(`ws-jobs`, function () { diff --git a/awx/ui/client/src/templates/list/templates-list.route.js b/awx/ui/client/src/templates/list/templates-list.route.js index 5a79700bdb..e615e52db1 100644 --- a/awx/ui/client/src/templates/list/templates-list.route.js +++ b/awx/ui/client/src/templates/list/templates-list.route.js @@ -46,20 +46,6 @@ export default { let path = GetBasePath(list.basePath) || GetBasePath(list.name); return qs.search(path, $stateParams[`${list.iterator}_search`]); } - ], - DataOptions: ['Rest', 'GetBasePath', '$stateParams', '$q', 'TemplateList', - function(Rest, GetBasePath, $stateParams, $q, list) { - let path = GetBasePath(list.basePath) || GetBasePath(list.name); - Rest.setUrl(path); - var val = $q.defer(); - Rest.options() - .then(function(data) { - val.resolve(data.data.actions.GET); - }, function(data) { - val.reject(data); - }); - return val.promise; - } ] } }; From 9e3b5abc37623711aab6bad99f1bd73cd3cb7f2e Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Wed, 14 Dec 2016 17:05:15 -0800 Subject: [PATCH 04/10] fixing post-processing for projects list --- awx/ui/client/src/controllers/Projects.js | 38 +++++++++++++++++-- awx/ui/client/src/lists/Projects.js | 1 + .../list/templates-list.controller.js | 1 - 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/awx/ui/client/src/controllers/Projects.js b/awx/ui/client/src/controllers/Projects.js index 17076a2a73..1eb8fbb2df 100644 --- a/awx/ui/client/src/controllers/Projects.js +++ b/awx/ui/client/src/controllers/Projects.js @@ -37,11 +37,43 @@ export function ProjectsList($scope, $rootScope, $location, $log, $stateParams, _.forEach($scope[list.name], buildTooltips); $rootScope.flashMessage = null; } - - $scope.$watch(`${list.name}`, function() { - _.forEach($scope[list.name], buildTooltips); + + $scope.$on(`${list.iterator}_options`, function(event, data){ + $scope.options = data.data.actions.GET; + optionsRequestDataProcessing(); }); + $scope.$watchCollection(`${$scope.list.name}`, function() { + optionsRequestDataProcessing(); + } + ); + + // iterate over the list and add fields like type label, after the + // OPTIONS request returns, or the list is sorted/paginated/searched + function optionsRequestDataProcessing(){ + $scope[list.name].forEach(function(item, item_idx) { + var itm = $scope[list.name][item_idx]; + + // Set the item type label + if (list.fields.scm_type && $scope.options && + $scope.options.hasOwnProperty('scm_type')) { + $scope.options.scm_type.choices.every(function(choice) { + if (choice[0] === item.scm_type) { + itm.type_label = choice[1]; + return false; + } + return true; + }); + } + + _.forEach($scope[list.name], buildTooltips); + + }); + } + // $scope.$watch(`${list.name}`, function() { + // _.forEach($scope[list.name], buildTooltips); + // }); + function buildTooltips(project) { project.statusIcon = GetProjectIcon(project.status); project.statusTip = GetProjectToolTip(project.status); diff --git a/awx/ui/client/src/lists/Projects.js b/awx/ui/client/src/lists/Projects.js index 83cb2eb7e7..5115b0d662 100644 --- a/awx/ui/client/src/lists/Projects.js +++ b/awx/ui/client/src/lists/Projects.js @@ -46,6 +46,7 @@ export default }, scm_type: { label: i18n._('Type'), + ngBind: 'project.type_label', excludeModal: true, columnClass: 'col-lg-3 col-md-2 col-sm-3 hidden-xs' }, diff --git a/awx/ui/client/src/templates/list/templates-list.controller.js b/awx/ui/client/src/templates/list/templates-list.controller.js index 51b353a51a..5bcd659a38 100644 --- a/awx/ui/client/src/templates/list/templates-list.controller.js +++ b/awx/ui/client/src/templates/list/templates-list.controller.js @@ -43,7 +43,6 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest', } $scope.$on(`${list.iterator}_options`, function(event, data){ - debugger; $scope.options = data.data.actions.GET; optionsRequestDataProcessing(); }); From db4bb50976cff6a60e292e2a4f32fee8b6e3ca8d Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Wed, 14 Dec 2016 17:24:21 -0800 Subject: [PATCH 05/10] adding post-processing for jobs list --- awx/ui/client/src/controllers/Jobs.js | 83 +++++++++++++++-------- awx/ui/client/src/controllers/Projects.js | 7 +- 2 files changed, 58 insertions(+), 32 deletions(-) diff --git a/awx/ui/client/src/controllers/Jobs.js b/awx/ui/client/src/controllers/Jobs.js index c68c6c5826..3ea53d3191 100644 --- a/awx/ui/client/src/controllers/Jobs.js +++ b/awx/ui/client/src/controllers/Jobs.js @@ -13,7 +13,7 @@ export function JobsListController($state, $rootScope, $log, $scope, $compile, $stateParams, - ClearScope, Find, DeleteJob, RelaunchJob, AllJobsList, ScheduledJobsList, GetBasePath, Dataset, GetChoices) { + ClearScope, Find, DeleteJob, RelaunchJob, AllJobsList, ScheduledJobsList, GetBasePath, Dataset) { ClearScope(); @@ -29,39 +29,68 @@ export function JobsListController($state, $rootScope, $log, $scope, $compile, $ $scope.showJobType = true; - _.forEach($scope[list.name], buildTooltips); - if ($scope.removeChoicesReady) { - $scope.removeChoicesReady(); + // _.forEach($scope[list.name], buildTooltips); + // if ($scope.removeChoicesReady) { + // $scope.removeChoicesReady(); + // } + // $scope.removeChoicesReady = $scope.$on('choicesReady', function() { + // $scope[list.name].forEach(function(item, item_idx) { + // var itm = $scope[list.name][item_idx]; + // if(item.summary_fields && item.summary_fields.source_workflow_job && + // item.summary_fields.source_workflow_job.id){ + // item.workflow_result_link = `/#/workflows/${item.summary_fields.source_workflow_job.id}`; + // } + // // Set the item type label + // if (list.fields.type) { + // $scope.type_choices.every(function(choice) { + // if (choice.value === item.type) { + // itm.type_label = choice.label; + // return false; + // } + // return true; + // }); + // } + // }); + // }); + + + } + $scope.$on(`${list.iterator}_options`, function(event, data){ + $scope.options = data.data.actions.GET; + optionsRequestDataProcessing(); + }); + + $scope.$watchCollection(`${$scope.list.name}`, function() { + optionsRequestDataProcessing(); } - $scope.removeChoicesReady = $scope.$on('choicesReady', function() { - $scope[list.name].forEach(function(item, item_idx) { - var itm = $scope[list.name][item_idx]; - if(item.summary_fields && item.summary_fields.source_workflow_job && - item.summary_fields.source_workflow_job.id){ - item.workflow_result_link = `/#/workflows/${item.summary_fields.source_workflow_job.id}`; - } - // Set the item type label - if (list.fields.type) { - $scope.type_choices.every(function(choice) { - if (choice.value === item.type) { - itm.type_label = choice.label; + ); + + // iterate over the list and add fields like type label, after the + // OPTIONS request returns, or the list is sorted/paginated/searched + function optionsRequestDataProcessing(){ + + $scope[list.name].forEach(function(item, item_idx) { + var itm = $scope[list.name][item_idx]; + + if(item.summary_fields && item.summary_fields.source_workflow_job && + item.summary_fields.source_workflow_job.id){ + item.workflow_result_link = `/#/workflows/${item.summary_fields.source_workflow_job.id}`; + } + + // Set the item type label + if (list.fields.type && $scope.options && + $scope.options.hasOwnProperty('type')) { + $scope.options.type.choices.every(function(choice) { + if (choice[0] === item.type) { + itm.type_label = choice[1]; return false; } return true; }); } - }); - }); - - GetChoices({ - scope: $scope, - url: GetBasePath('unified_jobs'), - field: 'type', - variable: 'type_choices', - callback: 'choicesReady' + buildTooltips(itm); }); } - function buildTooltips(job) { job.status_tip = 'Job ' + job.status + ". Click for details."; } @@ -131,5 +160,5 @@ export function JobsListController($state, $rootScope, $log, $scope, $compile, $ } JobsListController.$inject = ['$state', '$rootScope', '$log', '$scope', '$compile', '$stateParams', - 'ClearScope', 'Find', 'DeleteJob', 'RelaunchJob', 'AllJobsList', 'ScheduledJobsList', 'GetBasePath', 'Dataset', 'GetChoices' + 'ClearScope', 'Find', 'DeleteJob', 'RelaunchJob', 'AllJobsList', 'ScheduledJobsList', 'GetBasePath', 'Dataset' ]; diff --git a/awx/ui/client/src/controllers/Projects.js b/awx/ui/client/src/controllers/Projects.js index 1eb8fbb2df..d0c845a058 100644 --- a/awx/ui/client/src/controllers/Projects.js +++ b/awx/ui/client/src/controllers/Projects.js @@ -37,7 +37,7 @@ export function ProjectsList($scope, $rootScope, $location, $log, $stateParams, _.forEach($scope[list.name], buildTooltips); $rootScope.flashMessage = null; } - + $scope.$on(`${list.iterator}_options`, function(event, data){ $scope.options = data.data.actions.GET; optionsRequestDataProcessing(); @@ -66,13 +66,10 @@ export function ProjectsList($scope, $rootScope, $location, $log, $stateParams, }); } - _.forEach($scope[list.name], buildTooltips); + buildTooltips(itm); }); } - // $scope.$watch(`${list.name}`, function() { - // _.forEach($scope[list.name], buildTooltips); - // }); function buildTooltips(project) { project.statusIcon = GetProjectIcon(project.status); From 8c55eaec99dde23c9e8ee66f377d47276edf04d5 Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Wed, 14 Dec 2016 17:38:09 -0800 Subject: [PATCH 06/10] post processing for credentials list --- awx/ui/client/src/controllers/Credentials.js | 30 ++++++++++++++++++++ awx/ui/client/src/controllers/Jobs.js | 27 +----------------- awx/ui/client/src/lists/Credentials.js | 1 + 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/awx/ui/client/src/controllers/Credentials.js b/awx/ui/client/src/controllers/Credentials.js index 1681205992..8ccc5afd78 100644 --- a/awx/ui/client/src/controllers/Credentials.js +++ b/awx/ui/client/src/controllers/Credentials.js @@ -36,6 +36,36 @@ export function CredentialsList($scope, $rootScope, $location, $log, $scope.selected = []; } + $scope.$on(`${list.iterator}_options`, function(event, data){ + $scope.options = data.data.actions.GET; + optionsRequestDataProcessing(); + }); + + $scope.$watchCollection(`${$scope.list.name}`, function() { + optionsRequestDataProcessing(); + } + ); + // iterate over the list and add fields like type label, after the + // OPTIONS request returns, or the list is sorted/paginated/searched + function optionsRequestDataProcessing(){ + $scope[list.name].forEach(function(item, item_idx) { + var itm = $scope[list.name][item_idx]; + + // Set the item type label + debugger; + if (list.fields.kind && $scope.options && + $scope.options.hasOwnProperty('kind')) { + $scope.options.kind.choices.every(function(choice) { + if (choice[0] === item.kind) { + itm.kind_label = choice[1]; + return false; + } + return true; + }); + } + }); + } + $scope.addCredential = function() { $state.go('credentials.add'); }; diff --git a/awx/ui/client/src/controllers/Jobs.js b/awx/ui/client/src/controllers/Jobs.js index 3ea53d3191..cbf588200c 100644 --- a/awx/ui/client/src/controllers/Jobs.js +++ b/awx/ui/client/src/controllers/Jobs.js @@ -28,33 +28,8 @@ export function JobsListController($state, $rootScope, $log, $scope, $compile, $ $scope[list.name] = $scope[`${list.iterator}_dataset`].results; $scope.showJobType = true; - - // _.forEach($scope[list.name], buildTooltips); - // if ($scope.removeChoicesReady) { - // $scope.removeChoicesReady(); - // } - // $scope.removeChoicesReady = $scope.$on('choicesReady', function() { - // $scope[list.name].forEach(function(item, item_idx) { - // var itm = $scope[list.name][item_idx]; - // if(item.summary_fields && item.summary_fields.source_workflow_job && - // item.summary_fields.source_workflow_job.id){ - // item.workflow_result_link = `/#/workflows/${item.summary_fields.source_workflow_job.id}`; - // } - // // Set the item type label - // if (list.fields.type) { - // $scope.type_choices.every(function(choice) { - // if (choice.value === item.type) { - // itm.type_label = choice.label; - // return false; - // } - // return true; - // }); - // } - // }); - // }); - - } + $scope.$on(`${list.iterator}_options`, function(event, data){ $scope.options = data.data.actions.GET; optionsRequestDataProcessing(); diff --git a/awx/ui/client/src/lists/Credentials.js b/awx/ui/client/src/lists/Credentials.js index d099f2826e..c6e8d6bbae 100644 --- a/awx/ui/client/src/lists/Credentials.js +++ b/awx/ui/client/src/lists/Credentials.js @@ -37,6 +37,7 @@ export default }, kind: { label: i18n._('Type'), + ngBind: 'credential.kind_label', excludeModal: true, nosort: true, columnClass: 'col-md-2 hidden-sm hidden-xs' From 7d90a5205f27787d8f6a99d449d0c9255370aeff Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Wed, 14 Dec 2016 20:12:04 -0800 Subject: [PATCH 07/10] removing debugger statement --- awx/ui/client/src/controllers/Credentials.js | 1 - 1 file changed, 1 deletion(-) diff --git a/awx/ui/client/src/controllers/Credentials.js b/awx/ui/client/src/controllers/Credentials.js index 8ccc5afd78..a64056ccd4 100644 --- a/awx/ui/client/src/controllers/Credentials.js +++ b/awx/ui/client/src/controllers/Credentials.js @@ -52,7 +52,6 @@ export function CredentialsList($scope, $rootScope, $location, $log, var itm = $scope[list.name][item_idx]; // Set the item type label - debugger; if (list.fields.kind && $scope.options && $scope.options.hasOwnProperty('kind')) { $scope.options.kind.choices.every(function(choice) { From 817a57267462802ea38bf51b3dbe118df0a7c09d Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Wed, 14 Dec 2016 22:00:20 -0800 Subject: [PATCH 08/10] adding post processing for notification template list --- .../list.controller.js | 54 ++++++++++--------- .../notificationTemplates.list.js | 1 + 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/awx/ui/client/src/notifications/notification-templates-list/list.controller.js b/awx/ui/client/src/notifications/notification-templates-list/list.controller.js index e82cc8219e..208c4a3b8d 100644 --- a/awx/ui/client/src/notifications/notification-templates-list/list.controller.js +++ b/awx/ui/client/src/notifications/notification-templates-list/list.controller.js @@ -29,34 +29,38 @@ $scope.list = list; $scope[`${list.iterator}_dataset`] = Dataset.data; $scope[list.name] = $scope[`${list.iterator}_dataset`].results; - - GetChoices({ - scope: $scope, - url: defaultUrl, - field: 'notification_type', - variable: 'notification_type_options', - callback: 'choicesReadyNotifierList' - }); } - $scope.removeChoicesHere = $scope.$on('choicesReadyNotifierList', function() { - list.fields.notification_type.searchOptions = $scope.notification_type_options; - - if ($rootScope.addedItem) { - $scope.addedItem = $rootScope.addedItem; - delete $rootScope.addedItem; - } - $scope.notification_templates.forEach(function(notification_template, i) { - setStatus(notification_template); - $scope.notification_type_options.forEach(function(type) { - if (type.value === notification_template.notification_type) { - $scope.notification_templates[i].notification_type = type.label; - var recent_notifications = notification_template.summary_fields.recent_notifications; - $scope.notification_templates[i].status = recent_notifications && recent_notifications.length > 0 ? recent_notifications[0].status : "none"; - } - }); + $scope.$on(`notification_template_options`, function(event, data){ + $scope.options = data.data.actions.GET; + optionsRequestDataProcessing(); }); - }); + + $scope.$watchCollection("notification_templates", function() { + optionsRequestDataProcessing(); + } + ); + // iterate over the list and add fields like type label, after the + // OPTIONS request returns, or the list is sorted/paginated/searched. + function optionsRequestDataProcessing(){ + $scope[list.name].forEach(function(item, item_idx) { + var itm = $scope[list.name][item_idx]; + // Set the item type label + if (list.fields.notification_type && $scope.options && + $scope.options.hasOwnProperty('notification_type')) { + $scope.options.notification_type.choices.every(function(choice) { + if (choice[0] === item.notification_type) { + itm.type_label = choice[1]; + var recent_notifications = itm.summary_fields.recent_notifications; + itm.status = recent_notifications && recent_notifications.length > 0 ? recent_notifications[0].status : "none"; + return false; + } + return true; + }); + } + setStatus(itm); + }); + } function setStatus(notification_template) { var html, recent_notifications = notification_template.summary_fields.recent_notifications; diff --git a/awx/ui/client/src/notifications/notificationTemplates.list.js b/awx/ui/client/src/notifications/notificationTemplates.list.js index f0e1d527d5..0987e5fcab 100644 --- a/awx/ui/client/src/notifications/notificationTemplates.list.js +++ b/awx/ui/client/src/notifications/notificationTemplates.list.js @@ -36,6 +36,7 @@ export default ['i18n', function(i18n){ }, notification_type: { label: i18n._('Type'), + ngBind: "notification_template.type_label", searchType: 'select', searchOptions: [], excludeModal: true, From b78ed36abf3e9e05cb56517bdb57408a5ca49be5 Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Thu, 15 Dec 2016 13:47:12 -0800 Subject: [PATCH 09/10] post processing for scheduled jobs list --- awx/ui/client/src/controllers/Schedules.js | 2 +- awx/ui/client/src/lists/ScheduledJobs.js | 3 +- awx/ui/client/src/scheduler/main.js | 54 +++++++++++++- .../src/scheduler/schedulerList.controller.js | 72 ++++++++++++++----- 4 files changed, 106 insertions(+), 25 deletions(-) diff --git a/awx/ui/client/src/controllers/Schedules.js b/awx/ui/client/src/controllers/Schedules.js index edebf66a84..5a29150215 100644 --- a/awx/ui/client/src/controllers/Schedules.js +++ b/awx/ui/client/src/controllers/Schedules.js @@ -65,7 +65,7 @@ GetBasePath, Wait, Find, LoadSchedulesScope, GetChoices) { msg: 'Call to ' + url + ' failed. GET returned: ' + status }); }); }); - + debugger; $scope.refreshJobs = function() { // @issue: OLD SEARCH // $scope.search(SchedulesList.iterator); diff --git a/awx/ui/client/src/lists/ScheduledJobs.js b/awx/ui/client/src/lists/ScheduledJobs.js index e4a17496c6..a771a75b8f 100644 --- a/awx/ui/client/src/lists/ScheduledJobs.js +++ b/awx/ui/client/src/lists/ScheduledJobs.js @@ -31,8 +31,7 @@ export default name: { label: i18n._('Name'), columnClass: 'col-lg-4 col-md-5 col-sm-5 col-xs-7 List-staticColumnAdjacent', - sourceModel: 'unified_job_template', - sourceField: 'name', + ngBind: 'schedule.summary_fields.unified_job_template.name', ngClick: "editSchedule(schedule)", awToolTip: "{{ schedule.nameTip | sanitize}}", dataTipWatch: 'schedule.nameTip', diff --git a/awx/ui/client/src/scheduler/main.js b/awx/ui/client/src/scheduler/main.js index 840197d944..f8620c880e 100644 --- a/awx/ui/client/src/scheduler/main.js +++ b/awx/ui/client/src/scheduler/main.js @@ -45,7 +45,19 @@ export default let path = `${GetBasePath('job_templates')}${$stateParams.id}`; Rest.setUrl(path); return Rest.get(path).then((res) => res.data); - }] + }], + UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q', + function(Rest, GetBasePath, $stateParams, $q) { + Rest.setUrl(GetBasePath('unified_jobs')); + var val = $q.defer(); + Rest.options() + .then(function(data) { + val.resolve(data.data); + }, function(data) { + val.reject(data); + }); + return val.promise; + }] }, views: { '@': { @@ -119,7 +131,19 @@ export default let path = `${GetBasePath('workflow_job_templates')}${$stateParams.id}`; Rest.setUrl(path); return Rest.get(path).then((res) => res.data); - }] + }], + UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q', + function(Rest, GetBasePath, $stateParams, $q) { + Rest.setUrl(GetBasePath('unified_jobs')); + var val = $q.defer(); + Rest.options() + .then(function(data) { + val.resolve(data.data); + }, function(data) { + val.reject(data); + }); + return val.promise; + }] }, views: { '@': { @@ -190,7 +214,19 @@ export default let path = `${GetBasePath('projects')}${$stateParams.id}`; Rest.setUrl(path); return Rest.get(path).then((res) => res.data); - }] + }], + UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q', + function(Rest, GetBasePath, $stateParams, $q) { + Rest.setUrl(GetBasePath('unified_jobs')); + var val = $q.defer(); + Rest.options() + .then(function(data) { + val.resolve(data.data); + }, function(data) { + val.reject(data); + }); + return val.promise; + }] }, views: { '@': { @@ -268,6 +304,18 @@ export default } ], ParentObject: [() =>{return {endpoint:'/api/v1/schedules'}; }], + UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q', + function(Rest, GetBasePath, $stateParams, $q) { + Rest.setUrl(GetBasePath('unified_jobs')); + var val = $q.defer(); + Rest.options() + .then(function(data) { + val.resolve(data.data); + }, function(data) { + val.reject(data); + }); + return val.promise; + }] }, views: { 'list@jobs': { diff --git a/awx/ui/client/src/scheduler/schedulerList.controller.js b/awx/ui/client/src/scheduler/schedulerList.controller.js index e003ea1fd2..4f9e9809d3 100644 --- a/awx/ui/client/src/scheduler/schedulerList.controller.js +++ b/awx/ui/client/src/scheduler/schedulerList.controller.js @@ -14,12 +14,12 @@ export default [ '$scope', '$compile', '$location', '$stateParams', 'SchedulesList', 'Rest', 'ProcessErrors', 'ReturnToCaller', 'ClearScope', 'GetBasePath', 'Wait', 'rbacUiControlService', - 'Find', 'ToggleSchedule', 'DeleteSchedule', 'GetChoices', '$q', '$state', 'Dataset', 'ParentObject', + 'Find', 'ToggleSchedule', 'DeleteSchedule', 'GetChoices', '$q', '$state', 'Dataset', 'ParentObject', 'UnifiedJobsOptions', function($scope, $compile, $location, $stateParams, SchedulesList, Rest, ProcessErrors, ReturnToCaller, ClearScope, GetBasePath, Wait, rbacUiControlService, Find, ToggleSchedule, DeleteSchedule, GetChoices, - $q, $state, Dataset, ParentObject) { + $q, $state, Dataset, ParentObject, UnifiedJobsOptions) { ClearScope(); @@ -43,11 +43,45 @@ export default [ $scope.list = list; $scope[`${list.iterator}_dataset`] = Dataset.data; $scope[list.name] = $scope[`${list.iterator}_dataset`].results; + $scope.unified_job_options = UnifiedJobsOptions.actions.GET; - _.forEach($scope[list.name], buildTooltips); + // _.forEach($scope[list.name], buildTooltips); + } + + $scope.$on(`${list.iterator}_options`, function(event, data){ + $scope.options = data.data.actions.GET; + optionsRequestDataProcessing(); + }); + + $scope.$watchCollection(`${$scope.list.name}`, function() { + optionsRequestDataProcessing(); + } + ); + + // iterate over the list and add fields like type label, after the + // OPTIONS request returns, or the list is sorted/paginated/searched + function optionsRequestDataProcessing(){ + $scope[list.name].forEach(function(item, item_idx) { + var itm = $scope[list.name][item_idx]; + + // Set the item type label + if (list.fields.type && $scope.unified_job_options && + $scope.unified_job_options.hasOwnProperty('type')) { + $scope.unified_job_options.type.choices.every(function(choice) { + if (choice[0] === itm.summary_fields.unified_job_template.unified_job_type) { + itm.type_label = choice[1]; + return false; + } + return true; + }); + } + buildTooltips(itm); + + }); } function buildTooltips(schedule) { + var job = schedule.summary_fields.unified_job_template; if (schedule.enabled) { schedule.play_tip = 'Schedule is active. Click to stop.'; schedule.status = 'active'; @@ -57,6 +91,18 @@ export default [ schedule.status = 'stopped'; schedule.status_tip = 'Schedule is stopped. Click to activate.'; } + + schedule.nameTip = schedule.name; + // include the word schedule if the schedule name does not include the word schedule + if (schedule.name.indexOf("schedule") === -1 && schedule.name.indexOf("Schedule") === -1) { + schedule.nameTip += " schedule"; + } + schedule.nameTip += " for "; + if (job.name.indexOf("job") === -1 && job.name.indexOf("Job") === -1) { + schedule.nameTip += "job "; + } + schedule.nameTip += job.name; + schedule.nameTip += ". Click to edit schedule."; } $scope.refreshSchedules = function() { @@ -99,7 +145,7 @@ export default [ name: 'projectSchedules.edit', params: { id: schedule.unified_job_template, - schedule_id: schedule.id + schedule_id: schedule.id } }); break; @@ -109,7 +155,7 @@ export default [ name: 'managementJobSchedules.edit', params: { id: schedule.unified_job_template, - schedule_id: schedule.id + schedule_id: schedule.id } }); break; @@ -136,7 +182,7 @@ export default [ throw err; } }); - }); + }); } }; @@ -160,7 +206,7 @@ export default [ }; base = $location.path().replace(/^\//, '').split('/')[0]; - + if (base === 'management_jobs') { $scope.base = base = 'system_job_templates'; } @@ -175,17 +221,5 @@ export default [ $scope.formCancel = function() { $state.go('^', null, { reload: true }); }; - - // @issue - believe this is no longer necessary now that parent object is resolved prior to controller initilizing - - // Wait('start'); - - // GetChoices({ - // scope: $scope, - // url: GetBasePath('unified_jobs'), //'/static/sample/data/types/data.json' - // field: 'type', - // variable: 'type_choices', - // callback: 'choicesReady' - // }); } ]; From 2b5d64d7468a518c64120758c575aef7654b7e87 Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Thu, 15 Dec 2016 15:16:25 -0800 Subject: [PATCH 10/10] removing debugger statements --- awx/ui/client/src/controllers/Schedules.js | 2 +- awx/ui/client/src/templates/main.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/src/controllers/Schedules.js b/awx/ui/client/src/controllers/Schedules.js index 5a29150215..edebf66a84 100644 --- a/awx/ui/client/src/controllers/Schedules.js +++ b/awx/ui/client/src/controllers/Schedules.js @@ -65,7 +65,7 @@ GetBasePath, Wait, Find, LoadSchedulesScope, GetChoices) { msg: 'Call to ' + url + ' failed. GET returned: ' + status }); }); }); - debugger; + $scope.refreshJobs = function() { // @issue: OLD SEARCH // $scope.search(SchedulesList.iterator); diff --git a/awx/ui/client/src/templates/main.js b/awx/ui/client/src/templates/main.js index b458121def..03b380bd58 100644 --- a/awx/ui/client/src/templates/main.js +++ b/awx/ui/client/src/templates/main.js @@ -115,7 +115,7 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA }, 'jobTemplateList@templates.editWorkflowJobTemplate.workflowMaker': { templateProvider: function(WorkflowMakerJobTemplateList, generateList) { - //debugger; + let html = generateList.build({ list: WorkflowMakerJobTemplateList, input_type: 'radio',