From 94c242c608aaea7aefce522f8b2d0634bb50f108 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Fri, 19 Jun 2015 12:01:57 -0400 Subject: [PATCH] Fix issue with schedulers editing/adding schedules in the related accordians for Projects and Job Templates were not working, where the action buttons for schedules not even showing up in the Schedule accordian. I've updated hte form objects as well as the form-generator to accept the list of action buttons and their icons. Also fixed a related issue where the scheduler titles were not showing up on the scheduler dialog --- awx/ui/static/js/controllers/JobTemplates.js | 21 ++--- awx/ui/static/js/forms/JobTemplates.js | 77 ++++++++++++++++- awx/ui/static/js/forms/Projects.js | 87 +++++++++++++++++--- awx/ui/static/js/helpers/Schedules.js | 10 ++- awx/ui/static/js/lists/Schedules.js | 8 +- awx/ui/static/js/shared/form-generator.js | 9 +- 6 files changed, 172 insertions(+), 40 deletions(-) diff --git a/awx/ui/static/js/controllers/JobTemplates.js b/awx/ui/static/js/controllers/JobTemplates.js index 201ca3ca4b..f2954baf4e 100644 --- a/awx/ui/static/js/controllers/JobTemplates.js +++ b/awx/ui/static/js/controllers/JobTemplates.js @@ -669,7 +669,6 @@ export function JobTemplatesEdit($filter, $scope, $rootScope, $compile, $locatio var defaultUrl = GetBasePath('job_templates'), generator = GenerateForm, form = JobTemplateForm(), - loadingFinishedCount = 0, base = $location.path().replace(/^\//, '').split('/')[0], master = {}, id = $routeParams.template_id, @@ -832,19 +831,15 @@ export function JobTemplatesEdit($filter, $scope, $rootScope, $compile, $locatio $scope.removeJobTemplateLoadFinished(); } $scope.removeJobTemplateLoadFinished = $scope.$on('jobTemplateLoadFinished', function () { - loadingFinishedCount++; - if (loadingFinishedCount >= 2) { - // The initial template load finished. Now load related jobs, which - // will turn off the 'working' spinner. - for (var set in relatedSets) { - $scope.search(relatedSets[set].iterator); - } - SchedulesControllerInit({ - scope: $scope, - parent_scope: $scope, - iterator: 'schedule' - }); + for (var set in relatedSets) { + $scope.search(relatedSets[set].iterator); } + SchedulesControllerInit({ + scope: $scope, + parent_scope: $scope, + iterator: 'schedule' + }); + }); // Set the status/badge for each related job diff --git a/awx/ui/static/js/forms/JobTemplates.js b/awx/ui/static/js/forms/JobTemplates.js index 9416a69881..c9e6fea4b9 100644 --- a/awx/ui/static/js/forms/JobTemplates.js +++ b/awx/ui/static/js/forms/JobTemplates.js @@ -266,7 +266,6 @@ export default control: ''+ ''+ ''+ - // '
A survey is enabled but it does not exist. Create a survey or disable the survey.
' '
A survey is enabled but it does not exist. Create a survey or uncheck the Enable Survey box to disable the survey.
' }, become_enabled: { @@ -336,9 +335,81 @@ export default }, related: { - schedules: { - include: "SchedulesList" + type: 'collection', + title: 'Schedules', + iterator: 'schedule', + index: false, + open: false, + + actions: { + add: { + mode: 'all', + ngClick: 'addSchedule()', + awToolTip: 'Add a new schedule' + }, + refresh: { + mode: 'all', + awToolTip: "Refresh the page", + ngClick: "refreshSchedules()" + }, + stream: { + ngClick: "showActivity()", + awToolTip: "View Activity Stream", + mode: 'edit', + awFeature: 'activity_streams' + } + }, + fields: { + name: { + key: true, + label: 'Name', + ngClick: "editSchedule(schedule.id)", + columnClass: "col-md-3 col-sm-3 col-xs-3" + }, + dtstart: { + label: 'First Run', + filter: "longDate", + searchable: false, + columnClass: "col-md-2 col-sm-3 hidden-xs" + }, + next_run: { + label: 'Next Run', + filter: "longDate", + searchable: false, + columnClass: "col-md-2 col-sm-3 col-xs-3" + }, + dtend: { + label: 'Final Run', + filter: "longDate", + searchable: false, + columnClass: "col-md-2 col-sm-3 hidden-xs" + } + }, + fieldActions: { + "play": { + mode: "all", + ngClick: "toggleSchedule($event, schedule.id)", + awToolTip: "{{ schedule.play_tip }}", + dataTipWatch: "schedule.play_tip", + iconClass: "{{ 'fa icon-schedule-enabled-' + schedule.enabled }}", + dataPlacement: "top" + }, + edit: { + label: 'Edit', + ngClick: "editSchedule(schedule.id)", + icon: 'icon-edit', + awToolTip: 'Edit schedule', + dataPlacement: 'top' + }, + "delete": { + label: 'Delete', + ngClick: "deleteSchedule(schedule.id)", + icon: 'icon-trash', + awToolTip: 'Delete schedule', + dataPlacement: 'top' + } + } }, "completed_jobs": { include: "CompletedJobsList" diff --git a/awx/ui/static/js/forms/Projects.js b/awx/ui/static/js/forms/Projects.js index d84fc4fbf5..19dcb21da8 100644 --- a/awx/ui/static/js/forms/Projects.js +++ b/awx/ui/static/js/forms/Projects.js @@ -3,7 +3,7 @@ * * All Rights Reserved *************************************************/ - + /** * @ngdoc function * @name forms.function:Projects @@ -25,15 +25,6 @@ angular.module('ProjectFormDefinition', ['SchedulesListDefinition']) collapseOpen: true, actions: { - // scm_update: { - // mode: 'edit', - // ngClick: 'SCMUpdate()', - // awToolTip: "{{ scm_update_tooltip }}", - // dataTipWatch: "scm_update_tooltip", - // ngClass: "scm_type_class", - // dataPlacement: 'top', - // ngDisabled: "scm_type.value === 'manual' " - // }, stream: { 'class': "btn-primary btn-xs activity-btn", ngClick: "showActivity()", @@ -296,8 +287,80 @@ angular.module('ProjectFormDefinition', ['SchedulesListDefinition']) }, schedules: { - include: "SchedulesList", - index: false + type: 'collection', + title: 'Schedules', + iterator: 'schedule', + index: false, + open: false, + + actions: { + add: { + mode: 'all', + ngClick: 'addSchedule()', + awToolTip: 'Add a new schedule' + }, + refresh: { + mode: 'all', + awToolTip: "Refresh the page", + ngClick: "refreshSchedules()" + }, + stream: { + ngClick: "showActivity()", + awToolTip: "View Activity Stream", + mode: 'edit', + awFeature: 'activity_streams' + } + }, + fields: { + name: { + key: true, + label: 'Name', + ngClick: "editSchedule(schedule.id)", + columnClass: "col-md-3 col-sm-3 col-xs-3" + }, + dtstart: { + label: 'First Run', + filter: "longDate", + searchable: false, + columnClass: "col-md-2 col-sm-3 hidden-xs" + }, + next_run: { + label: 'Next Run', + filter: "longDate", + searchable: false, + columnClass: "col-md-2 col-sm-3 col-xs-3" + }, + dtend: { + label: 'Final Run', + filter: "longDate", + searchable: false, + columnClass: "col-md-2 col-sm-3 hidden-xs" + } + }, + fieldActions: { + "play": { + mode: "all", + ngClick: "toggleSchedule($event, schedule.id)", + awToolTip: "{{ schedule.play_tip }}", + dataTipWatch: "schedule.play_tip", + iconClass: "{{ 'fa icon-schedule-enabled-' + schedule.enabled }}", + dataPlacement: "top" + }, + edit: { + label: 'Edit', + ngClick: "editSchedule(schedule.id)", + icon: 'icon-edit', + awToolTip: 'Edit schedule', + dataPlacement: 'top' + }, + "delete": { + label: 'Delete', + ngClick: "deleteSchedule(schedule.id)", + icon: 'icon-trash', + awToolTip: 'Delete schedule', + dataPlacement: 'top' + } + } } }, diff --git a/awx/ui/static/js/helpers/Schedules.js b/awx/ui/static/js/helpers/Schedules.js index 53e26d4def..6ca31f5ddd 100644 --- a/awx/ui/static/js/helpers/Schedules.js +++ b/awx/ui/static/js/helpers/Schedules.js @@ -3,7 +3,7 @@ * * All Rights Reserved *************************************************/ - + /** * @ngdoc function * @name helpers.function:Schedules @@ -26,7 +26,8 @@ export default var buttons, scope = params.scope, - callback = params.callback; + callback = params.callback, + title = params.title; buttons = [{ "label": "Cancel", @@ -54,6 +55,7 @@ export default id: 'scheduler-modal-dialog', scope: scope, buttons: buttons, + title: title, width: 700, height: 725, minWidth: 400, @@ -111,7 +113,7 @@ export default schedule.rrule = schedule.rrule.replace(/ RRULE:/,';'); schedule.rrule = schedule.rrule.replace(/DTSTART:/,'DTSTART='); - ShowSchedulerModal({ scope: scope, callback: 'DialogReady' }); + ShowSchedulerModal({ scope: scope, callback: 'DialogReady', title: 'Edit Schedule' }); scope.showRRuleDetail = false; }); @@ -194,7 +196,7 @@ export default scheduler.inject('form-container', false); scheduler.injectDetail('occurrences', false); scheduler.clear(); - ShowSchedulerModal({ scope: scope, callback: 'DialogReady' }); + ShowSchedulerModal({ scope: scope, callback: 'DialogReady', title: 'Add Schedule' }); scope.showRRuleDetail = false; if (scope.removeScheduleSaved) { diff --git a/awx/ui/static/js/lists/Schedules.js b/awx/ui/static/js/lists/Schedules.js index ba63031068..f3eb000bce 100644 --- a/awx/ui/static/js/lists/Schedules.js +++ b/awx/ui/static/js/lists/Schedules.js @@ -3,7 +3,7 @@ * * All Rights Reserved *************************************************/ - + export default angular.module('SchedulesListDefinition', []) @@ -42,12 +42,6 @@ export default searchable: false, columnClass: "col-md-2 col-sm-3 hidden-xs" } - /*, - id: { - label: 'ID', - searchType: 'int', - searchOnly: true - }*/ }, actions: { diff --git a/awx/ui/static/js/shared/form-generator.js b/awx/ui/static/js/shared/form-generator.js index f732f4f4f3..04d91bbb19 100644 --- a/awx/ui/static/js/shared/form-generator.js +++ b/awx/ui/static/js/shared/form-generator.js @@ -1818,7 +1818,14 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat html += (fAction.ngHref) ? this.attr(fAction, 'ngHref') : ""; html += (fAction.ngShow) ? this.attr(fAction, 'ngShow') : ""; html += ">"; - html += SelectIcon({ action: act }); + if (fAction.iconClass) { + html += ""; + } else { + html += SelectIcon({ + action: act + }); + } + // html += SelectIcon({ action: act }); //html += (fAction.label) ? " " + fAction.label + "": ""; html += ""; }