diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index 531b3ac0ae..bb6db4b189 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -30,9 +30,11 @@ import {JobsListController} from './controllers/Jobs'; import {PortalController} from './controllers/Portal'; import systemTracking from './system-tracking/main'; import inventoryScripts from './inventory-scripts/main'; +import managementJobs from './management-jobs/main'; import routeExtensions from './shared/route-extensions/main'; import breadcrumbs from './shared/breadcrumbs/main'; + // modules import setupMenu from './setup-menu/main'; import mainMenu from './main-menu/main'; @@ -84,6 +86,7 @@ var tower = angular.module('Tower', [ breadcrumbs.name, systemTracking.name, inventoryScripts.name, + managementJobs.name, setupMenu.name, mainMenu.name, dashboard.name, @@ -183,8 +186,8 @@ var tower = angular.module('Tower', [ 'AboutAnsibleHelpModal', 'SurveyQuestionFormDefinition', 'PortalJobsListDefinition', - 'ConfigureTowerHelper', - 'ConfigureTowerJobsListDefinition', + + 'AdhocHelper', 'features', 'longDateFilter' @@ -944,9 +947,9 @@ var tower = angular.module('Tower', [ }]) .run(['$compile', '$cookieStore', '$rootScope', '$log', 'CheckLicense', '$location', 'Authorization', 'LoadBasePaths', 'Timer', 'ClearScope', 'HideStream', 'Socket', - 'LoadConfig', 'Store', 'ShowSocketHelp', 'AboutAnsibleHelp', 'ConfigureTower', + 'LoadConfig', 'Store', 'ShowSocketHelp', 'AboutAnsibleHelp', function ($compile, $cookieStore, $rootScope, $log, CheckLicense, $location, Authorization, LoadBasePaths, Timer, ClearScope, HideStream, Socket, - LoadConfig, Store, ShowSocketHelp, AboutAnsibleHelp, ConfigureTower) { + LoadConfig, Store, ShowSocketHelp, AboutAnsibleHelp) { var sock; @@ -1154,13 +1157,6 @@ var tower = angular.module('Tower', [ $location.path('/home/'); }; - $rootScope.configureTower = function(){ - ConfigureTower({ - scope: $rootScope, - parent_scope: $rootScope - }); - }; - }); // end of 'ConfigReady' diff --git a/awx/ui/client/src/helpers/ConfigureTower.js b/awx/ui/client/src/helpers/ConfigureTower.js deleted file mode 100644 index bc517c6490..0000000000 --- a/awx/ui/client/src/helpers/ConfigureTower.js +++ /dev/null @@ -1,657 +0,0 @@ -/************************************************* - * Copyright (c) 2015 Ansible, Inc. - * - * All Rights Reserved - *************************************************/ - -/** - * @ngdoc function - * @name helpers.function:ConfigureTower - * @description - * Schedules Helper - * - * Display the scheduler widget in a dialog - * - */ - -import listGenerator from '../shared/list-generator/main'; - -export default - angular.module('ConfigureTowerHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', 'SearchHelper', 'PaginationHelpers', listGenerator.name, 'ModalDialog', - 'GeneratorHelpers']) - - .factory('ConfigureTower', ['Wait', '$location' , '$compile', 'CreateDialog', 'ConfigureTowerJobsList', 'generateList', 'GetBasePath' , 'SearchInit' , 'PaginateInit', 'PlaybookRun', 'LoadSchedulesScope', - 'SchedulesList', 'SchedulesControllerInit' , 'ConfigureTowerSchedule', 'Rest' , 'ProcessErrors', - function(Wait, $location, $compile, CreateDialog, ConfigureTowerJobsList, GenerateList, GetBasePath, SearchInit, PaginateInit, PlaybookRun, LoadSchedulesScope, - SchedulesList, SchedulesControllerInit, ConfigureTowerSchedule, Rest, ProcessErrors) { - return function(params) { - // Set modal dimensions based on viewport width - - var scope = params.scope.$new(), - parent_scope = params.scope, - callback = 'OpenConfig', - defaultUrl = GetBasePath('system_job_templates'), - list = ConfigureTowerJobsList, - view = GenerateList, e, - scheduleUrl = GetBasePath('system_job_templates'), - buttons = [ - { - "label": "Close", - "onClick": function() { - // $(this).dialog('close'); - scope.cancelConfigure(); - }, - "icon": "fa-times", - "class": "btn btn-default", - "id": "configure-close-button" - } - ]; - - scope.cleanupJob = true; - - if(scope.removeOpenConfig) { - scope.removeOpenConfig(); - } - scope.removeOpenConfig = scope.$on('OpenConfig', function() { - $('#configure-tower-dialog').dialog('open'); - $('#configure-close-button').focus(); - $('#configure-close-button').blur(); - }); - - view.inject( list, { - id : 'configure-jobs', - mode: 'edit', - scope: scope, - breadCrumbs: false, - showSearch: false - }); - - SearchInit({ - scope: scope, - set: 'configure_jobs', - list: list, - url: defaultUrl - }); - PaginateInit({ - scope: scope, - list: list, - url: defaultUrl - }); - - scope.search(list.iterator); - - SchedulesControllerInit({ - scope: scope, - parent_scope: parent_scope, - // list: list - }); - - - CreateDialog({ - id: 'configure-tower-dialog', - title: 'Management Jobs', - target: 'configure-tower-dialog', - scope: scope, - buttons: buttons, - width: 670, - height: 800, - minWidth: 400, - callback: callback, - onClose: function () { - // Destroy on close - $('.tooltip').each(function () { - // Remove any lingering tooltip
elements - $(this).remove(); - }); - $('.popover').each(function () { - // remove lingering popover
elements - $(this).remove(); - }); - $("#configure-jobs").show(); - $("#configure-schedules-form-container").hide(); - $('#configure-schedules-list').empty(); - $('#configure-schedules-form').empty(); - $('#configure-schedules-detail').empty(); - $('#configure-tower-dialog').hide(); - $(this).dialog('destroy'); - scope.cancelConfigure(); - }, - }); - - - - // Cancel - scope.cancelConfigure = function () { - try { - $('#configure-tower-dialog').dialog('close'); - $("#configure-save-button").remove(); - } - catch(e) { - //ignore - } - if (scope.searchCleanup) { - scope.searchCleanup(); - } - // if (!Empty(parent_scope) && parent_scope.restoreSearch) { - // parent_scope.restoreSearch(); - // } - else { - Wait('stop'); - } - }; - - scope.submitCleanupJob = function(id, name){ - defaultUrl = GetBasePath('system_job_templates')+id+'/launch/'; - CreateDialog({ - id: 'prompt-for-days-facts', - title: name, - scope: scope, - width: 500, - height: 470, - minWidth: 200, - callback: 'PromptForDaysFacts', - onOpen: function(){ - scope.keep_unit_choices = [{ - "label" : "Days", - "value" : "d" - }, - { - "label": "Weeks", - "value" : "w" - }, - { - "label" : "Years", - "value" : "y" - }]; - scope.granularity_keep_unit_choices = [{ - "label" : "Days", - "value" : "d" - }, - { - "label": "Weeks", - "value" : "w" - }, - { - "label" : "Years", - "value" : "y" - }]; - e = angular.element(document.getElementById('prompt_for_days_facts_form')); - scope.prompt_for_days_facts_form.keep_amount.$setViewValue(30); - scope.prompt_for_days_facts_form.granularity_keep_amount.$setViewValue(1); - $compile(e)(scope); - scope.keep_unit = scope.keep_unit_choices[0]; - scope.granularity_keep_unit = scope.granularity_keep_unit_choices[1]; - - // this is a work-around for getting awMax to work (without - // clearing out the form) - scope.$watch('keep_amount', function(newVal) { - if (!newVal && newVal !== 0) { - $('#prompt-for-days-facts-launch').prop("disabled", true); - } else if (isNaN(newVal)) { - $('#prompt-for-days-facts-launch').prop("disabled", true); - } else if (newVal < 0) { - $('#prompt-for-days-facts-launch').prop("disabled", true); - } else if (newVal > 9999) { - $('#prompt-for-days-facts-launch').prop("disabled", true); - } else { - $('#prompt-for-days-facts-launch').prop("disabled", false); - } - }); - scope.$watch('granularity_keep_amount', function(newVal2) { - if (!newVal2 && newVal2 !== 0) { - $('#prompt-for-days-facts-launch').prop("disabled", true); - } else if (isNaN(newVal2)) { - $('#prompt-for-days-facts-launch').prop("disabled", true); - } else if (newVal2 < 0) { - $('#prompt-for-days-facts-launch').prop("disabled", true); - } else if (newVal2 > 9999) { - $('#prompt-for-days-facts-launch').prop("disabled", true); - } else { - $('#prompt-for-days-facts-launch').prop("disabled", false); - } - }); - }, - buttons: [{ - "label": "Cancel", - "onClick": function() { - $(this).dialog('close'); - - }, - "icon": "fa-times", - "class": "btn btn-default", - "id": "prompt-for-days-facts-cancel" - },{ - "label": "Launch", - "onClick": function() { - var extra_vars = { - "older_than": scope.keep_amount+scope.keep_unit.value, - "granularity": scope.granularity_keep_amount+scope.granularity_keep_unit.value - }, - data = {}; - data.extra_vars = JSON.stringify(extra_vars); - - Rest.setUrl(defaultUrl); - Rest.post(data) - .success(function() { - Wait('stop'); - $("#prompt-for-days-facts").dialog("close"); - $("#configure-tower-dialog").dialog('close'); - $location.path('/jobs/'); - }) - .error(function(data, status) { - ProcessErrors(scope, data, status, null, { hdr: 'Error!', - msg: 'Failed updating job ' + scope.job_template_id + ' with variables. POST returned: ' + status }); - }); - }, - "icon": "fa-rocket", - "class": "btn btn-primary", - "id": "prompt-for-days-facts-launch" - }] - }); - - if (scope.removePromptForDays) { - scope.removePromptForDays(); - } - scope.removePromptForDays = scope.$on('PromptForDaysFacts', function() { - // $('#configure-tower-dialog').dialog('close'); - $('#prompt-for-days-facts').show(); - $('#prompt-for-days-facts').dialog('open'); - Wait('stop'); - }); - }; - - scope.submitJob = function (id, name) { - Wait('start'); - if(this.configure_job.job_type === "cleanup_facts"){ - scope.submitCleanupJob(id, name); - } - else { - defaultUrl = GetBasePath('system_job_templates')+id+'/launch/'; - CreateDialog({ - id: 'prompt-for-days' , - title: name, - scope: scope, - width: 500, - height: 300, - minWidth: 200, - callback: 'PromptForDays', - onOpen: function(){ - e = angular.element(document.getElementById('prompt_for_days_form')); - scope.prompt_for_days_form.days_to_keep.$setViewValue(30); - $compile(e)(scope); - - // this is a work-around for getting awMax to work (without - // clearing out the form) - scope.$watch('days_to_keep', function(newVal) { // oldVal, scope) { // unused params get caught by jshint - if (!newVal && newVal !== 0) { - $('#prompt-for-days-launch').prop("disabled", true); - } else if (isNaN(newVal)) { - $('#prompt-for-days-launch').prop("disabled", true); - } else if (newVal < 0) { - $('#prompt-for-days-launch').prop("disabled", true); - } else if (newVal > 9999) { - $('#prompt-for-days-launch').prop("disabled", true); - } else { - $('#prompt-for-days-launch').prop("disabled", false); - } - }); - }, - buttons: [{ - "label": "Cancel", - "onClick": function() { - $(this).dialog('close'); - - }, - "icon": "fa-times", - "class": "btn btn-default", - "id": "prompt-for-days-cancel" - },{ - "label": "Launch", - "onClick": function() { - var extra_vars = {"days": scope.days_to_keep }, - data = {}; - data.extra_vars = JSON.stringify(extra_vars); - - Rest.setUrl(defaultUrl); - Rest.post(data) - .success(function() { - Wait('stop'); - $("#prompt-for-days").dialog("close"); - $("#configure-tower-dialog").dialog('close'); - $location.path('/jobs/'); - }) - .error(function(data, status) { - ProcessErrors(scope, data, status, null, { hdr: 'Error!', - msg: 'Failed updating job ' + scope.job_template_id + ' with variables. POST returned: ' + status }); - }); - }, - "icon": "fa-rocket", - "class": "btn btn-primary", - "id": "prompt-for-days-launch" - }] - }); - - if (scope.removePromptForDays) { - scope.removePromptForDays(); - } - scope.removePromptForDays = scope.$on('PromptForDays', function() { - // $('#configure-tower-dialog').dialog('close'); - $('#prompt-for-days').show(); - $('#prompt-for-days').dialog('open'); - Wait('stop'); - }); - } - }; - - scope.configureSchedule = function(id, name) { - if (id === 4) { - scope.isFactCleanup = true; - scope.keep_unit_choices = [{ - "label" : "Days", - "value" : "d" - }, - { - "label": "Weeks", - "value" : "w" - }, - { - "label" : "Years", - "value" : "y" - }]; - scope.granularity_keep_unit_choices = [{ - "label" : "Days", - "value" : "d" - }, - { - "label": "Weeks", - "value" : "w" - }, - { - "label" : "Years", - "value" : "y" - }]; - scope.prompt_for_days_facts_form.keep_amount.$setViewValue(30); - scope.prompt_for_days_facts_form.granularity_keep_amount.$setViewValue(1); - scope.keep_unit = scope.keep_unit_choices[0]; - scope.granularity_keep_unit = scope.granularity_keep_unit_choices[1]; - } else { - scope.isFactCleanup = false; - } - - Rest.setUrl(scheduleUrl+id+'/schedules/'); - Rest.get() - .success(function(data) { - if(data.count>0){ - scope.days=data.results[0].extra_data.days; - ConfigureTowerSchedule({ - scope: scope, - mode: 'edit', - url: scheduleUrl+id+'/schedules/' - }); - } else { - ConfigureTowerSchedule({ - scope: scope, - mode: 'add', - url: scheduleUrl+id+'/schedules/', - name: name - }); - } - }) - .error(function(data, status) { - ProcessErrors(scope, data, status, null, { hdr: 'Error!', - msg: 'Failed getting schedule information' }); - }); - - }; - - parent_scope.refreshJobs = function(){ - scope.search(SchedulesList.iterator); - }; - - }; - }]) - - - .factory('ConfigureTowerSchedule', ['$compile','SchedulerInit', 'Rest', 'Wait', 'SetSchedulesInnerDialogSize', 'SchedulePost', 'ProcessErrors', 'GetBasePath', 'Empty', 'Prompt', - function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, ProcessErrors, GetBasePath, Empty, Prompt) { - return function(params) { - var parent_scope = params.scope, - mode = params.mode, // 'add' or 'edit' - url = params.url, - scope = parent_scope.$new(), - id = params.id || undefined, - name = params.name || undefined, - schedule = {}, - scheduler, - target, - showForm, - list, - detail, - restoreList, - container, - elem; - - Wait('start'); - // $('#configure-jobs').hide(); - detail = $('#configure-schedules-detail').hide(); - list = $('#configure-schedules-list'); - target = $('#configure-schedules-form'); - container = $('#configure-schedules-form-container'); - $("#configure-jobs").show(); - $("#configure-schedules-form-container").hide(); - scope.mode = mode; - // Clean up any lingering stuff - container.hide(); - target.empty(); - $('.tooltip').each(function () { - $(this).remove(); - }); - $('.popover').each(function () { - $(this).remove(); - }); - - $("#configure-cancel-button").after(''); - elem = angular.element(document.getElementById('configure-schedules-form-container')); - $compile(elem)(scope); - - if (scope.removeScheduleReady) { - scope.removeScheduleReady(); - } - scope.removeScheduleReady = scope.$on('ScheduleReady', function() { - // Insert the scheduler widget into the hidden div - scheduler = SchedulerInit({ scope: scope, requireFutureStartTime: false }); - scheduler.inject('configure-schedules-form', false); - scheduler.injectDetail('configure-schedules-detail', false); - scheduler.clear(); - scope.formShowing = true; - scope.showRRuleDetail = false; - scope.schedulesTitle = (mode === 'edit') ? 'Edit Schedule' : 'Create Schedule'; - - - // display the scheduler widget - showForm = function() { - $('#configure-jobs').show('slide', { direction: 'left' }, 500); - $('#configure-jobs').hide(); - Wait('stop'); - $('#configure-schedules-overlay').width($('#configure-schedules-tab') - .width()).height($('#configure-schedules-tab').height()).show(); - container.width($('#configure-schedules-tab').width() - 18); - SetSchedulesInnerDialogSize(); - container.show('slide', { direction: 'right' }, 300); - // scope.schedulerPurgeDays = (!Empty(scope.days)) ? Number(scope.days) : 30; - target.show(); - if (scope.isFactCleanup) { - scope.$watch('scheduler_form.keep_amount.$modelValue', function(newVal) { - if (!newVal && newVal !== 0) { - $('#configure-save-button').prop("disabled", true); - } else if (isNaN(newVal)) { - $('#configure-save-button').prop("disabled", true); - } else if (newVal < 0) { - $('#configure-save-button').prop("disabled", true); - } else if (newVal > 9999) { - $('#configure-save-button').prop("disabled", true); - } else { - $('#configure-save-button').prop("disabled", false); - } - }); - scope.$watch('scheduler_form.granularity_keep_amount.$modelValue', function(newVal2) { - if (!newVal2 && newVal2 !== 0) { - $('#configure-save-button').prop("disabled", true); - } else if (isNaN(newVal2)) { - $('#configure-save-button').prop("disabled", true); - } else if (newVal2 < 0) { - $('#configure-save-button').prop("disabled", true); - } else if (newVal2 > 9999) { - $('#configure-save-button').prop("disabled", true); - } else { - $('#configure-save-button').prop("disabled", false); - } - }); - } - if(mode==="add"){ - scope.$apply(function(){ - scope.schedulerPurgeDays = 30; - scope.schedulerName = name+' Schedule'; - }); - } - if (mode === 'edit') { - scope.$apply(function() { - scheduler.setRRule(schedule.rrule); - scheduler.setName(schedule.name); - scope.schedulerPurgeDays = (!Empty(scope.days)) ? Number(scope.days) : 30; - }); - } - }; - setTimeout(function() { showForm(); }, 1000); - }); - - restoreList = function() { - // $('#group-save-button').prop('disabled', false); - $('#configure-jobs').show('slide', { direction: 'right' }, 500); - // $('#configure-jobs').width($('#configure-jobs').width()).height($('#configure-jobs').height()).hide(); - // parent_scope.refreshSchedules(); - list.show('slide', { direction: 'right' }, 500); - $('#configure-schedules-overlay').width($('#configure-schedules-tab').width()).height($('#configure-schedules-tab').height()).hide(); - parent_scope.refreshSchedules(); - - }; - - scope.showScheduleDetail = function() { - if (scope.formShowing) { - if (scheduler.isValid()) { - detail.width($('#configure-schedules-form').width()).height($('#configure-schedules-form').height()); - target.hide(); - detail.show(); - scope.formShowing = false; - } - } - else { - detail.hide(); - target.show(); - scope.formShowing = true; - } - }; - - if (scope.removeScheduleSaved) { - scope.removeScheduleSaved(); - } - scope.removeScheduleSaved = scope.$on('ScheduleSaved', function() { - Wait('stop'); - $("#configure-save-button").remove(); - container.hide('slide', { direction: 'left' }, 500, restoreList); - scope.$destroy(); - }); - - scope.saveScheduleForm = function() { - var extra_vars; - if (scheduler.isValid()) { - scope.schedulerIsValid = true; - url = (mode==="edit") ? GetBasePath('schedules')+id+'/' : url; - if (scope.isFactCleanup) { - extra_vars = { - "older_than": scope.scheduler_form.keep_amount.$viewValue + scope.scheduler_form.keep_unit.$viewValue.value, - "granularity": scope.scheduler_form.granularity_keep_amount.$viewValue + scope.scheduler_form.granularity_keep_unit.$viewValue.value - }; - } else { - extra_vars = { - "days" : scope.scheduler_form.schedulerPurgeDays.$viewValue - }; - } - schedule.extra_data = JSON.stringify(extra_vars); - - SchedulePost({ - scope: scope, - url: url, - scheduler: scheduler, - callback: 'ScheduleSaved', - mode: mode, - schedule: schedule - }); - } - else { - scope.schedulerIsValid = false; - } - }; - - scope.deleteSystemSchedule = function(){ - var hdr = 'Delete Schedule', - action = function () { - Wait('start'); - Rest.setUrl(schedule.url); - Rest.destroy() - .success(function () { - $('#prompt-modal').modal('hide'); - Wait('stop'); - // scope.$emit(callback, id); - scope.cancelScheduleForm(); - }) - .error(function (data, status) { - try { - $('#prompt-modal').modal('hide'); - } - catch(e) { - // ignore - } - ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + - ' failed. DELETE returned: ' + status }); - }); - }; - - Prompt({ - hdr: hdr, - body: "
Are you sure you want to delete the " + scope.schedulerName + " schedule?
", - action: action, - backdrop: false - }); - }; - - scope.cancelScheduleForm = function() { - container.hide('slide', { direction: 'right' }, 500, restoreList); - $("#configure-save-button").remove(); - scope.$destroy(); - }; - - if (mode === 'edit') { - // Get the existing record - Rest.setUrl(url); //GetBasePath('schedules')+id+'/'); - Rest.get() - .success(function(data) { - schedule = data.results[0]; - id = schedule.id; - if (!/DTSTART/.test(schedule.rrule)) { - schedule.rrule += ";DTSTART=" + schedule.dtstart.replace(/\.\d+Z$/,'Z'); - } - schedule.rrule = schedule.rrule.replace(/ RRULE:/,';'); - schedule.rrule = schedule.rrule.replace(/DTSTART:/,'DTSTART='); - scope.$emit('ScheduleReady'); - }) - .error(function(data,status){ - ProcessErrors(scope, data, status, null, { hdr: 'Error!', - msg: 'Failed to get: ' + url + ' GET returned: ' + status }); - }); - } - else { - scope.$emit('ScheduleReady'); - } - }; - }]); diff --git a/awx/ui/client/src/helpers/Schedules.js b/awx/ui/client/src/helpers/Schedules.js index 0aa0f2e6fe..bc8219eb7a 100644 --- a/awx/ui/client/src/helpers/Schedules.js +++ b/awx/ui/client/src/helpers/Schedules.js @@ -75,8 +75,10 @@ export default }; }]) - .factory('EditSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait', 'Rest', 'ProcessErrors', 'GetBasePath', 'SchedulePost', - function(SchedulerInit, ShowSchedulerModal, Wait, Rest, ProcessErrors, GetBasePath, SchedulePost) { + .factory('EditSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait', + 'Rest', 'ProcessErrors', 'GetBasePath', 'SchedulePost', 'Empty', '$routeParams', + function(SchedulerInit, ShowSchedulerModal, Wait, Rest, ProcessErrors, + GetBasePath, SchedulePost, Empty, $routeParams) { return function(params) { var scope = params.scope, id = params.id, @@ -84,6 +86,68 @@ export default schedule, scheduler, url = GetBasePath('schedules') + id + '/'; + function setGranularity(){ + var a,b, prompt_for_days, + keep_unit, + granularity, + granularity_keep_unit; + + if(scope.cleanupJob){ + scope.schedulerPurgeDays = Number(schedule.extra_data.days); + // scope.scheduler_form.schedulerPurgeDays.$setViewValue( Number(schedule.extra_data.days)); + } + else if(scope.isFactCleanup){ + scope.keep_unit_choices = [{ + "label" : "Days", + "value" : "d" + }, + { + "label": "Weeks", + "value" : "w" + }, + { + "label" : "Years", + "value" : "y" + }]; + scope.granularity_keep_unit_choices = [{ + "label" : "Days", + "value" : "d" + }, + { + "label": "Weeks", + "value" : "w" + }, + { + "label" : "Years", + "value" : "y" + }]; + // the API returns something like 20w or 1y + a = schedule.extra_data.older_than; // "20y" + b = schedule.extra_data.granularity; // "1w" + prompt_for_days = Number(_.initial(a,1).join('')); + keep_unit = _.last(a); // "y" + granularity = Number(_.initial(b,1).join('')); + granularity_keep_unit = _.last(b); // "w" + + scope.prompt_for_days_facts_form.keep_amount.$setViewValue(prompt_for_days); + scope.prompt_for_days_facts_form.granularity_keep_amount.$setViewValue(granularity); + scope.keep_unit = _.find(scope.keep_unit_choices, function(i){ + return i.value === keep_unit; + }); + scope.granularity_keep_unit =_.find(scope.granularity_keep_unit_choices, function(i){ + return i.value === granularity_keep_unit; + }); + } + } + + if(!Empty($routeParams.management_job)) { + if(scope.management_job.id === 4){ + scope.isFactCleanup = true; + } else { + scope.cleanupJob = true; + } + } + if (scope.removeDialogReady) { scope.removeDialogReady(); } @@ -94,6 +158,10 @@ export default scope.$apply(function() { scheduler.setRRule(schedule.rrule); scheduler.setName(schedule.name); + if(!Empty(scope.management_job)){ + setGranularity(); + } + }); }, 300); }); @@ -112,7 +180,6 @@ export default } schedule.rrule = schedule.rrule.replace(/ RRULE:/,';'); schedule.rrule = schedule.rrule.replace(/DTSTART:/,'DTSTART='); - ShowSchedulerModal({ scope: scope, callback: 'DialogReady', title: 'Edit Schedule' }); scope.showRRuleDetail = false; }); @@ -141,6 +208,8 @@ export default }); }; + + $('#scheduler-tabs li a').on('shown.bs.tab', function(e) { if ($(e.target).text() === 'Details') { if (!scheduler.isValid()) { @@ -181,6 +250,43 @@ export default else if (!Empty($routeParams.id)) { url += $routeParams.id + '/schedules/'; } + else if (!Empty($routeParams.management_job)) { + url += $routeParams.management_job + '/schedules/'; + if(scope.management_job.id === 4){ + scope.isFactCleanup = true; + scope.keep_unit_choices = [{ + "label" : "Days", + "value" : "d" + }, + { + "label": "Weeks", + "value" : "w" + }, + { + "label" : "Years", + "value" : "y" + }]; + scope.granularity_keep_unit_choices = [{ + "label" : "Days", + "value" : "d" + }, + { + "label": "Weeks", + "value" : "w" + }, + { + "label" : "Years", + "value" : "y" + }]; + scope.prompt_for_days_facts_form.keep_amount.$setViewValue(30); + scope.prompt_for_days_facts_form.granularity_keep_amount.$setViewValue(1); + scope.keep_unit = scope.keep_unit_choices[0]; + scope.granularity_keep_unit = scope.granularity_keep_unit_choices[1]; + } + else { + scope.cleanupJob = true; + } + } if (scope.removeDialogReady) { scope.removeDialogReady(); @@ -239,7 +345,7 @@ export default mode = params.mode, schedule = (params.schedule) ? params.schedule : {}, callback = params.callback, - newSchedule, rrule; + newSchedule, rrule, extra_vars; if (scheduler.isValid()) { Wait('start'); @@ -248,6 +354,20 @@ export default schedule.name = newSchedule.name; schedule.rrule = RRuleToAPI(rrule.toString()); schedule.description = (/error/.test(rrule.toText())) ? '' : rrule.toText(); + + if (scope.isFactCleanup) { + extra_vars = { + "older_than": scope.scheduler_form.keep_amount.$viewValue + scope.scheduler_form.keep_unit.$viewValue.value, + "granularity": scope.scheduler_form.granularity_keep_amount.$viewValue + scope.scheduler_form.granularity_keep_unit.$viewValue.value + }; + } else if (scope.cleanupJob) { + extra_vars = { + "days" : scope.scheduler_form.schedulerPurgeDays.$viewValue + }; + } + schedule.extra_data = JSON.stringify(extra_vars); + + Rest.setUrl(url); if (mode === 'add') { Rest.post(schedule) @@ -442,8 +562,10 @@ export default }]) - .factory('SchedulesControllerInit', ['$location', 'ToggleSchedule', 'DeleteSchedule', 'EditSchedule', 'AddSchedule', - function($location, ToggleSchedule, DeleteSchedule, EditSchedule, AddSchedule) { + .factory('SchedulesControllerInit', ['$location', 'ToggleSchedule', + 'DeleteSchedule', 'EditSchedule', 'AddSchedule', + function($location, ToggleSchedule, DeleteSchedule, EditSchedule, + AddSchedule) { return function(params) { var scope = params.scope, parent_scope = params.parent_scope, diff --git a/awx/ui/client/src/inventory-scripts/edit/edit.route.js b/awx/ui/client/src/inventory-scripts/edit/edit.route.js index 8290da615c..7a5c801856 100644 --- a/awx/ui/client/src/inventory-scripts/edit/edit.route.js +++ b/awx/ui/client/src/inventory-scripts/edit/edit.route.js @@ -39,6 +39,6 @@ export default { }); }); } - ], + ] } }; diff --git a/awx/ui/client/src/inventory-scripts/inventory-scripts.list.js b/awx/ui/client/src/inventory-scripts/inventory-scripts.list.js index 9553db26a7..76630be07e 100644 --- a/awx/ui/client/src/inventory-scripts/inventory-scripts.list.js +++ b/awx/ui/client/src/inventory-scripts/inventory-scripts.list.js @@ -41,6 +41,13 @@ export default function(){ ngClick: 'addCustomInv()', awToolTip: 'Create a new credential' }, + stream: { + ngClick: "showActivity()", + awToolTip: "View Activity Stream", + icon: "icon-comments-alt", + mode: 'edit', + awFeature: 'activity_streams' + } }, fieldActions: { diff --git a/awx/ui/client/src/inventory-scripts/list/list.controller.js b/awx/ui/client/src/inventory-scripts/list/list.controller.js index 1869a57b0e..c84d824b46 100644 --- a/awx/ui/client/src/inventory-scripts/list/list.controller.js +++ b/awx/ui/client/src/inventory-scripts/list/list.controller.js @@ -7,11 +7,11 @@ export default [ '$rootScope','Wait', 'generateList', 'inventoryScriptsListObject', 'GetBasePath' , 'SearchInit' , 'PaginateInit', - 'Rest' , 'ProcessErrors', 'Prompt', 'transitionTo', + 'Rest' , 'ProcessErrors', 'Prompt', 'transitionTo', 'Stream', function( $rootScope,Wait, GenerateList, inventoryScriptsListObject, GetBasePath, SearchInit, PaginateInit, - Rest, ProcessErrors, Prompt, transitionTo + Rest, ProcessErrors, Prompt, transitionTo, Stream ) { var scope = $rootScope.$new(), defaultUrl = GetBasePath('inventory_scripts'), @@ -19,12 +19,8 @@ export default view = GenerateList; view.inject( list, { - id : 'inventory_scripts', mode: 'edit', - scope: scope, - breadCrumbs: false, - activityStream: false, - showSearch: true + scope: scope }); SearchInit({ @@ -46,6 +42,11 @@ export default inventory_script: this.inventory_script }); }; + + scope.showActivity = function () { + Stream({ scope: scope }); + }; + scope.deleteCustomInv = function(id, name){ var action = function () { diff --git a/awx/ui/client/src/inventory-scripts/list/list.partial.html b/awx/ui/client/src/inventory-scripts/list/list.partial.html index 5968714002..6adbbb27e6 100644 --- a/awx/ui/client/src/inventory-scripts/list/list.partial.html +++ b/awx/ui/client/src/inventory-scripts/list/list.partial.html @@ -1,16 +1,6 @@ - - - -
diff --git a/awx/ui/client/src/inventory-scripts/list/list.route.js b/awx/ui/client/src/inventory-scripts/list/list.route.js index 62a4046af9..23090b8c94 100644 --- a/awx/ui/client/src/inventory-scripts/list/list.route.js +++ b/awx/ui/client/src/inventory-scripts/list/list.route.js @@ -8,7 +8,7 @@ export default { name: 'inventoryScriptsList', route: '/inventory_scripts', templateUrl: '/static/js/inventory-scripts/list/list.partial.html', - controller: 'listController', + controller: 'inventoryScriptsListController', resolve: { features: ['FeaturesService', function(FeaturesService) { return FeaturesService.get(); diff --git a/awx/ui/client/src/inventory-scripts/list/list.service.js b/awx/ui/client/src/inventory-scripts/list/list.service.js deleted file mode 100644 index 81b631bbe9..0000000000 --- a/awx/ui/client/src/inventory-scripts/list/list.service.js +++ /dev/null @@ -1,25 +0,0 @@ -/************************************************* - * Copyright (c) 2015 Ansible, Inc. - * - * All Rights Reserved - *************************************************/ - - var rest, getBasePath; - -export default - [ 'Rest', - 'GetBasePath', - function(_rest, _getBasePath) { - rest = _rest; - getBasePath = _getBasePath; - return deleteInventoryScript; - } - ]; - -function deleteInventoryScript(id) { - var url = getBasePath('inventory_scripts'); - - url = url + id; - rest.setUrl(url); - return rest.destroy(); -} diff --git a/awx/ui/client/src/inventory-scripts/list/main.js b/awx/ui/client/src/inventory-scripts/list/main.js index 2f4a8e5f79..b1f23354cb 100644 --- a/awx/ui/client/src/inventory-scripts/list/main.js +++ b/awx/ui/client/src/inventory-scripts/list/main.js @@ -9,7 +9,7 @@ import controller from './list.controller'; export default angular.module('inventoryScriptsList', []) - .controller('listController', controller) + .controller('inventoryScriptsListController', controller) .config(['$routeProvider', function($routeProvider) { var url = route.route; delete route.route; diff --git a/awx/ui/client/src/management-jobs/list/list.controller.js b/awx/ui/client/src/management-jobs/list/list.controller.js new file mode 100644 index 0000000000..9190b0a940 --- /dev/null +++ b/awx/ui/client/src/management-jobs/list/list.controller.js @@ -0,0 +1,287 @@ +/************************************************* + * Copyright (c) 2015 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + +// import listGenerator from 'tower/shared/list-generator/main'; + +export default + [ 'Wait', '$location' , '$compile', 'CreateDialog', 'generateList', + 'GetBasePath' , 'SearchInit' , 'PaginateInit', + 'SchedulesList', + 'Rest' , 'ProcessErrors', 'managementJobsListObject', '$rootScope', + 'transitionTo', 'Stream', + function( Wait, $location, $compile, CreateDialog, GenerateList, + GetBasePath, SearchInit, PaginateInit, + SchedulesList, + Rest, ProcessErrors, managementJobsListObject, $rootScope, + transitionTo, Stream) { + + var scope = $rootScope.$new(), + parent_scope = scope, + defaultUrl = GetBasePath('system_job_templates'), + list = managementJobsListObject, + view = GenerateList, e; + + scope.cleanupJob = true; + + view.inject( list, { + mode: 'edit', + scope: scope, + showSearch: true + }); + + SearchInit({ + scope: scope, + set: 'configure_jobs', + list: list, + url: defaultUrl + }); + + PaginateInit({ + scope: scope, + list: list, + url: defaultUrl + }); + + scope.search(list.iterator); + + scope.showActivity = function () { + Stream({ scope: scope }); + }; + + // Cancel + scope.cancelConfigure = function () { + try { + $('#configure-tower-dialog').dialog('close'); + $("#configure-save-button").remove(); + } + catch(e) { + //ignore + } + if (scope.searchCleanup) { + scope.searchCleanup(); + } + // if (!Empty(parent_scope) && parent_scope.restoreSearch) { + // parent_scope.restoreSearch(); + // } + else { + Wait('stop'); + } + }; + + scope.submitCleanupJob = function(id, name){ + defaultUrl = GetBasePath('system_job_templates')+id+'/launch/'; + CreateDialog({ + id: 'prompt-for-days-facts', + title: name, + scope: scope, + width: 500, + height: 470, + minWidth: 200, + callback: 'PromptForDaysFacts', + onOpen: function(){ + scope.keep_unit_choices = [{ + "label" : "Days", + "value" : "d" + }, + { + "label": "Weeks", + "value" : "w" + }, + { + "label" : "Years", + "value" : "y" + }]; + scope.granularity_keep_unit_choices = [{ + "label" : "Days", + "value" : "d" + }, + { + "label": "Weeks", + "value" : "w" + }, + { + "label" : "Years", + "value" : "y" + }]; + e = angular.element(document.getElementById('prompt_for_days_facts_form')); + scope.prompt_for_days_facts_form.keep_amount.$setViewValue(30); + scope.prompt_for_days_facts_form.granularity_keep_amount.$setViewValue(1); + $compile(e)(scope); + scope.keep_unit = scope.keep_unit_choices[0]; + scope.granularity_keep_unit = scope.granularity_keep_unit_choices[1]; + + // this is a work-around for getting awMax to work (without + // clearing out the form) + scope.$watch('keep_amount', function(newVal) { + if (!newVal && newVal !== 0) { + $('#prompt-for-days-facts-launch').prop("disabled", true); + } else if (isNaN(newVal)) { + $('#prompt-for-days-facts-launch').prop("disabled", true); + } else if (newVal < 0) { + $('#prompt-for-days-facts-launch').prop("disabled", true); + } else if (newVal > 9999) { + $('#prompt-for-days-facts-launch').prop("disabled", true); + } else { + $('#prompt-for-days-facts-launch').prop("disabled", false); + } + }); + scope.$watch('granularity_keep_amount', function(newVal2) { + if (!newVal2 && newVal2 !== 0) { + $('#prompt-for-days-facts-launch').prop("disabled", true); + } else if (isNaN(newVal2)) { + $('#prompt-for-days-facts-launch').prop("disabled", true); + } else if (newVal2 < 0) { + $('#prompt-for-days-facts-launch').prop("disabled", true); + } else if (newVal2 > 9999) { + $('#prompt-for-days-facts-launch').prop("disabled", true); + } else { + $('#prompt-for-days-facts-launch').prop("disabled", false); + } + }); + }, + buttons: [{ + "label": "Cancel", + "onClick": function() { + $(this).dialog('close'); + + }, + "icon": "fa-times", + "class": "btn btn-default", + "id": "prompt-for-days-facts-cancel" + },{ + "label": "Launch", + "onClick": function() { + var extra_vars = { + "older_than": scope.keep_amount+scope.keep_unit.value, + "granularity": scope.granularity_keep_amount+scope.granularity_keep_unit.value + }, + data = {}; + data.extra_vars = JSON.stringify(extra_vars); + + Rest.setUrl(defaultUrl); + Rest.post(data) + .success(function() { + Wait('stop'); + $("#prompt-for-days-facts").dialog("close"); + $("#configure-tower-dialog").dialog('close'); + $location.path('/jobs/'); + }) + .error(function(data, status) { + ProcessErrors(scope, data, status, null, { hdr: 'Error!', + msg: 'Failed updating job ' + scope.job_template_id + ' with variables. POST returned: ' + status }); + }); + }, + "icon": "fa-rocket", + "class": "btn btn-primary", + "id": "prompt-for-days-facts-launch" + }] + }); + + if (scope.removePromptForDays) { + scope.removePromptForDays(); + } + scope.removePromptForDays = scope.$on('PromptForDaysFacts', function() { + // $('#configure-tower-dialog').dialog('close'); + $('#prompt-for-days-facts').show(); + $('#prompt-for-days-facts').dialog('open'); + Wait('stop'); + }); + }; + + scope.submitJob = function (id, name) { + Wait('start'); + if(this.configure_job.job_type === "cleanup_facts"){ + scope.submitCleanupJob(id, name); + } + else { + defaultUrl = GetBasePath('system_job_templates')+id+'/launch/'; + CreateDialog({ + id: 'prompt-for-days' , + title: name, + scope: scope, + width: 500, + height: 300, + minWidth: 200, + callback: 'PromptForDays', + onOpen: function(){ + e = angular.element(document.getElementById('prompt_for_days_form')); + scope.prompt_for_days_form.days_to_keep.$setViewValue(30); + $compile(e)(scope); + + // this is a work-around for getting awMax to work (without + // clearing out the form) + scope.$watch('days_to_keep', function(newVal) { // oldVal, scope) { // unused params get caught by jshint + if (!newVal && newVal !== 0) { + $('#prompt-for-days-launch').prop("disabled", true); + } else if (isNaN(newVal)) { + $('#prompt-for-days-launch').prop("disabled", true); + } else if (newVal < 0) { + $('#prompt-for-days-launch').prop("disabled", true); + } else if (newVal > 9999) { + $('#prompt-for-days-launch').prop("disabled", true); + } else { + $('#prompt-for-days-launch').prop("disabled", false); + } + }); + }, + buttons: [{ + "label": "Cancel", + "onClick": function() { + $(this).dialog('close'); + + }, + "icon": "fa-times", + "class": "btn btn-default", + "id": "prompt-for-days-cancel" + },{ + "label": "Launch", + "onClick": function() { + var extra_vars = {"days": scope.days_to_keep }, + data = {}; + data.extra_vars = JSON.stringify(extra_vars); + + Rest.setUrl(defaultUrl); + Rest.post(data) + .success(function() { + Wait('stop'); + $("#prompt-for-days").dialog("close"); + // $("#configure-tower-dialog").dialog('close'); + $location.path('/jobs/'); + }) + .error(function(data, status) { + ProcessErrors(scope, data, status, null, { hdr: 'Error!', + msg: 'Failed updating job ' + scope.job_template_id + ' with variables. POST returned: ' + status }); + }); + }, + "icon": "fa-rocket", + "class": "btn btn-primary", + "id": "prompt-for-days-launch" + }] + }); + + if (scope.removePromptForDays) { + scope.removePromptForDays(); + } + scope.removePromptForDays = scope.$on('PromptForDays', function() { + // $('#configure-tower-dialog').dialog('close'); + $('#prompt-for-days').show(); + $('#prompt-for-days').dialog('open'); + Wait('stop'); + }); + } + }; + + scope.configureSchedule = function() { + transitionTo('managementJobsSchedule', { + management_job: this.configure_job + }); + }; + + parent_scope.refreshJobs = function(){ + scope.search(SchedulesList.iterator); + }; + } + ]; diff --git a/awx/ui/client/src/management-jobs/list/list.partial.html b/awx/ui/client/src/management-jobs/list/list.partial.html new file mode 100644 index 0000000000..01e12151f9 --- /dev/null +++ b/awx/ui/client/src/management-jobs/list/list.partial.html @@ -0,0 +1,8 @@ + + + + + +
+
+
diff --git a/awx/ui/client/src/management-jobs/list/list.route.js b/awx/ui/client/src/management-jobs/list/list.route.js new file mode 100644 index 0000000000..39c1d1a8bc --- /dev/null +++ b/awx/ui/client/src/management-jobs/list/list.route.js @@ -0,0 +1,17 @@ +/************************************************* + * Copyright (c) 2015 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + +export default { + name: 'managementJobsList', + route: '/management_jobs', + templateUrl: '/static/js/management-jobs/list/list.partial.html', + controller: 'listController', + resolve: { + features: ['FeaturesService', function(FeaturesService) { + return FeaturesService.get(); + }] + } +}; diff --git a/awx/ui/client/src/management-jobs/list/main.js b/awx/ui/client/src/management-jobs/list/main.js new file mode 100644 index 0000000000..06aa5c0b3f --- /dev/null +++ b/awx/ui/client/src/management-jobs/list/main.js @@ -0,0 +1,17 @@ +/************************************************* + * Copyright (c) 2015 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + +import route from './list.route'; +import controller from './list.controller'; + +export default + angular.module('managementJobsList', []) + .controller('listController', controller) + .config(['$routeProvider', function($routeProvider) { + var url = route.route; + delete route.route; + $routeProvider.when(url, route); + }]); diff --git a/awx/ui/client/src/management-jobs/main.js b/awx/ui/client/src/management-jobs/main.js new file mode 100644 index 0000000000..392e5edd41 --- /dev/null +++ b/awx/ui/client/src/management-jobs/main.js @@ -0,0 +1,16 @@ +/************************************************* + * Copyright (c) 2015 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + +import managementJobsList from './list/main'; +import managementJobsSchedule from './schedule/main'; +import list from './management-jobs.list'; + +export default + angular.module('managementJobs', [ + managementJobsList.name, + managementJobsSchedule.name + ]) + .factory('managementJobsListObject', list); diff --git a/awx/ui/client/src/lists/ConfigureTowerJobs.js b/awx/ui/client/src/management-jobs/management-jobs.list.js similarity index 59% rename from awx/ui/client/src/lists/ConfigureTowerJobs.js rename to awx/ui/client/src/management-jobs/management-jobs.list.js index cbb5150168..1a2f16e766 100644 --- a/awx/ui/client/src/lists/ConfigureTowerJobs.js +++ b/awx/ui/client/src/management-jobs/management-jobs.list.js @@ -3,24 +3,16 @@ * * All Rights Reserved *************************************************/ - - - - -export default - angular.module('ConfigureTowerJobsListDefinition', []) - .value('ConfigureTowerJobsList', { +export default function(){ + return { name: 'configure_jobs', iterator: 'configure_job', - selectTitle: 'Configure Tower Jobs', - editTitle: 'Configure Tower Jobs', index: false, hover: true, fields: { name: { - // key: true, label: 'Name', columnClass: 'col-sm-4 col-xs-4' }, @@ -29,6 +21,15 @@ export default columnClass: 'col-sm-6 col-xs-6 hidden-sm hidden-xs' } }, + actions: { + stream: { + ngClick: "showActivity()", + awToolTip: "View Activity Stream", + icon: "icon-comments-alt", + mode: 'edit', + awFeature: 'activity_streams' + } + }, fieldActions: { submit: { label: 'Launch', @@ -40,16 +41,10 @@ export default schedule: { label: 'Schedule', mode: 'all', - ngClick: 'configureSchedule(configure_job.id, configure_job.name)', // '#/job_templates/{{ configure_job.id }}/schedules', + ngClick: 'configureSchedule()', awToolTip: 'Schedule future job template runs', dataPlacement: 'top', } - // delete: { - // label: 'Delete Schedule', - // mode: 'all', - // ngClick: 'deleteSystemSchedule(configure_job.id)', // '#/job_templates/{{ configure_job.id }}/schedules', - // awToolTip: 'Delete the schedule ', - // dataPlacement: 'top' - // } } - }); + }; +} diff --git a/awx/ui/client/src/management-jobs/schedule/main.js b/awx/ui/client/src/management-jobs/schedule/main.js new file mode 100644 index 0000000000..822ecd63dd --- /dev/null +++ b/awx/ui/client/src/management-jobs/schedule/main.js @@ -0,0 +1,17 @@ +/************************************************* + * Copyright (c) 2015 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + +import route from './schedule.route'; +import controller from './schedule.controller'; + +export default + angular.module('managementJobsSchedule', []) + .controller('scheduleController', controller) + .config(['$routeProvider', function($routeProvider) { + var url = route.route; + delete route.route; + $routeProvider.when(url, route); + }]); diff --git a/awx/ui/client/src/management-jobs/schedule/schedule.controller.js b/awx/ui/client/src/management-jobs/schedule/schedule.controller.js new file mode 100644 index 0000000000..8abdc80bf6 --- /dev/null +++ b/awx/ui/client/src/management-jobs/schedule/schedule.controller.js @@ -0,0 +1,93 @@ +/************************************************* + * Copyright (c) 2015 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + +/** + * @ngdoc function + * @name controllers.function:Schedules + * @description This controller's for schedules +*/ + +export default [ + '$scope', '$location', '$routeParams', 'SchedulesList', 'Rest', + 'ProcessErrors', 'GetBasePath', 'Wait','LoadSchedulesScope', 'GetChoices', + 'Stream', 'management_job', '$rootScope', + function($scope, $location, $routeParams, SchedulesList, Rest, + ProcessErrors, GetBasePath, Wait, LoadSchedulesScope, GetChoices, + Stream, management_job, $rootScope) { + var base, id, url, parentObject; + $scope.management_job = management_job; + base = $location.path().replace(/^\//, '').split('/')[0]; + + // GetBasePath('management_job') must map to 'system_job_templates' + // to match the api syntax + $rootScope.defaultUrls.management_jobs = 'api/v1/system_job_templates/'; + + if ($scope.removePostRefresh) { + $scope.removePostRefresh(); + } + $scope.removePostRefresh = $scope.$on('PostRefresh', function() { + var list = $scope.schedules; + list.forEach(function(element, idx) { + list[idx].play_tip = (element.enabled) ? 'Schedule is Active.'+ + ' Click to temporarily stop.' : 'Schedule is temporarily '+ + 'stopped. Click to activate.'; + }); + }); + + if ($scope.removeParentLoaded) { + $scope.removeParentLoaded(); + } + $scope.removeParentLoaded = $scope.$on('ParentLoaded', function() { + url += "schedules/"; + SchedulesList.well = true; + LoadSchedulesScope({ + parent_scope: $scope, + scope: $scope, + list: SchedulesList, + id: 'management_jobs_schedule', + url: url, + pageSize: 20 + }); + }); + + if ($scope.removeChoicesReady) { + $scope.removeChocesReady(); + } + $scope.removeChoicesReady = $scope.$on('choicesReady', function() { + // Load the parent object + id = $routeParams.management_job; + url = GetBasePath('system_job_templates') + id + '/'; + Rest.setUrl(url); + Rest.get() + .success(function(data) { + parentObject = data; + $scope.$emit('ParentLoaded'); + }) + .error(function(data, status) { + ProcessErrors($scope, data, status, null, { hdr: 'Error!', + msg: 'Call to ' + url + ' failed. GET returned: ' + status }); + }); + }); + + $scope.refreshJobs = function() { + $scope.search(SchedulesList.iterator); + }; + + $scope.showActivity = function () { + Stream({ scope: $scope }); + }; + + Wait('start'); + + GetChoices({ + scope: $scope, + url: GetBasePath('system_jobs'), + field: 'type', + variable: 'type_choices', + callback: 'choicesReady' + }); + } +]; diff --git a/awx/ui/client/src/management-jobs/schedule/schedule.partial.html b/awx/ui/client/src/management-jobs/schedule/schedule.partial.html new file mode 100644 index 0000000000..2374f050c5 --- /dev/null +++ b/awx/ui/client/src/management-jobs/schedule/schedule.partial.html @@ -0,0 +1,12 @@ + + + + + + +
+
+
+ +
+
diff --git a/awx/ui/client/src/management-jobs/schedule/schedule.route.js b/awx/ui/client/src/management-jobs/schedule/schedule.route.js new file mode 100644 index 0000000000..f4896846b9 --- /dev/null +++ b/awx/ui/client/src/management-jobs/schedule/schedule.route.js @@ -0,0 +1,44 @@ +/************************************************* + * Copyright (c) 2015 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + +export default { + name: 'managementJobsSchedule', + route: '/management_jobs/:management_job/schedules', + templateUrl: '/static/js/management-jobs/schedule/schedule.partial.html', + controller: 'scheduleController', + resolve: { + features: ['FeaturesService', function(FeaturesService) { + return FeaturesService.get(); + }], + management_job: + [ '$route', + '$q', + 'Rest', + 'GetBasePath', + 'ProcessErrors', + function($route, $q, rest, getBasePath, ProcessErrors) { + if ($route.current.hasModelKey('management_job')) { + return $q.when($route.current.params.model.management_job); + } + + var managementJobId = $route.current.params.management_job; + + var url = getBasePath('system_job_templates') + managementJobId + '/'; + rest.setUrl(url); + return rest.get() + .then(function(data) { + return data.data; + }).catch(function (response) { + ProcessErrors(null, response.data, response.status, null, { + hdr: 'Error!', + msg: 'Failed to get inventory script info. GET returned status: ' + + response.status + }); + }); + } + ] + } +}; diff --git a/awx/ui/client/src/partials/configure_tower.html b/awx/ui/client/src/partials/configure_tower.html deleted file mode 100644 index 6b4d64532f..0000000000 --- a/awx/ui/client/src/partials/configure_tower.html +++ /dev/null @@ -1,31 +0,0 @@ - -
-
-
-
-
-
-

- -
-
-
-
-
-
- View Details - Back to options - - - -
-
-
- - diff --git a/awx/ui/client/src/setup-menu/main.js b/awx/ui/client/src/setup-menu/main.js index 87a3985c7e..fcc98ac4fa 100644 --- a/awx/ui/client/src/setup-menu/main.js +++ b/awx/ui/client/src/setup-menu/main.js @@ -4,7 +4,6 @@ import icon from '../shared/icon/main'; export default angular.module('setupMenu', [ 'AboutAnsibleHelpModal', - 'ConfigureTowerHelper', icon.name ]) .config(['$routeProvider', function($routeProvider) { diff --git a/awx/ui/client/src/setup-menu/setup-menu.partial.html b/awx/ui/client/src/setup-menu/setup-menu.partial.html index 0d467f1c5e..a07d50a3e8 100644 --- a/awx/ui/client/src/setup-menu/setup-menu.partial.html +++ b/awx/ui/client/src/setup-menu/setup-menu.partial.html @@ -53,19 +53,16 @@

- + diff --git a/awx/ui/client/src/setup-menu/setup.controller.js b/awx/ui/client/src/setup-menu/setup.controller.js index 75c28b0727..31ca9f7fe8 100644 --- a/awx/ui/client/src/setup-menu/setup.controller.js +++ b/awx/ui/client/src/setup-menu/setup.controller.js @@ -2,20 +2,11 @@ export default [ '$scope', '$rootScope', 'AboutAnsibleHelp', - 'ConfigureTower', function( $scope, $rootScope, - showAboutModal, - configureTower + showAboutModal ) { $scope.showAboutModal = showAboutModal; - - $scope.showManagementJobsModal = - configureTower.bind(null, - { scope: $rootScope, - parent_scope: $rootScope - }); - } ]; diff --git a/awx/ui/templates/ui/index.html b/awx/ui/templates/ui/index.html index 17b4129bd7..b85c11a3a4 100644 --- a/awx/ui/templates/ui/index.html +++ b/awx/ui/templates/ui/index.html @@ -155,30 +155,6 @@ -