From 3638ff8f6ead22d7e697a9814a0fb754cb638c20 Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Tue, 25 Mar 2014 10:53:23 -0400 Subject: [PATCH] Added schedule.enabled support to job_template.schedules and projects.schedules. --- awx/ui/static/js/controllers/Schedules.js | 45 ++++++++++++++----- awx/ui/static/js/lists/Schedules.js | 18 ++++++-- awx/ui/static/sample/data/schedules/data.json | 3 ++ .../sample/data/schedules/inventory/data.json | 3 ++ .../sample/data/schedules/projects/data.json | 3 ++ 5 files changed, 58 insertions(+), 14 deletions(-) diff --git a/awx/ui/static/js/controllers/Schedules.js b/awx/ui/static/js/controllers/Schedules.js index 0177f46d6b..4334dbc133 100644 --- a/awx/ui/static/js/controllers/Schedules.js +++ b/awx/ui/static/js/controllers/Schedules.js @@ -11,19 +11,32 @@ 'use strict'; function ScheduleEdit($scope, $compile, $location, $routeParams, SchedulesList, GenerateList, Rest, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, -GetBasePath, LookUpInit, Wait, SchedulerInit, Breadcrumbs, SearchInit, PaginateInit, PageRangeSetup, EditSchedule, AddSchedule, Find) { +GetBasePath, LookUpInit, Wait, SchedulerInit, Breadcrumbs, SearchInit, PaginateInit, PageRangeSetup, EditSchedule, AddSchedule, Find, ToggleSchedule) { ClearScope(); - var base, e, id, job_template, url; + var base, e, id, parentObject, url; base = $location.path().replace(/^\//, '').split('/')[0]; - - $scope.$on('job_template_ready', function() { + + 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.removeScheduledLoaded = $scope.$on('ParentLoaded', function() { // Add breadcrumbs LoadBreadCrumbs({ path: $location.path().replace(/\/schedules$/,''), - title: job_template.name + title: parentObject.name }); e = angular.element(document.getElementById('breadcrumbs')); e.html(Breadcrumbs({ list: SchedulesList, mode: 'edit' })); @@ -112,16 +125,28 @@ GetBasePath, LookUpInit, Wait, SchedulerInit, Breadcrumbs, SearchInit, PaginateI AddSchedule({ scope: $scope, schedule: schedule, url: url }); }; + if ($scope.removeScheduleToggled) { + $scope.removeScheduleToggled(); + } + $scope.removeScheduleToggled = function() { + $scope.search(SchedulesList.iterator); + }; - //scheduler = SchedulerInit({ scope: $scope }); - //scheduler.inject('scheduler-target', true); + $scope.toggleSchedule = function(id) { + ToggleSchedule({ + scope: $scope, + id: id, + callback: 'ScheduleToggled' + }); + }; + // Load the parent object id = $routeParams.id; Rest.setUrl(GetBasePath(base) + id); Rest.get() .success(function(data) { - job_template = data; - $scope.$emit('job_template_ready'); + parentObject = data; + $scope.$emit('ParentLoaded'); }) .error(function(status) { ProcessErrors($scope, null, status, null, { hdr: 'Error!', @@ -131,5 +156,5 @@ GetBasePath, LookUpInit, Wait, SchedulerInit, Breadcrumbs, SearchInit, PaginateI ScheduleEdit.$inject = ['$scope', '$compile', '$location', '$routeParams', 'SchedulesList', 'GenerateList', 'Rest', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GetBasePath', 'LookUpInit', 'Wait', 'SchedulerInit', 'Breadcrumbs', 'SearchInit', 'PaginateInit', 'PageRangeSetup', 'EditSchedule', 'AddSchedule', -'Find' +'Find', 'ToggleSchedule' ]; \ No newline at end of file diff --git a/awx/ui/static/js/lists/Schedules.js b/awx/ui/static/js/lists/Schedules.js index 5f490b2070..328b8dc80c 100644 --- a/awx/ui/static/js/lists/Schedules.js +++ b/awx/ui/static/js/lists/Schedules.js @@ -22,13 +22,16 @@ angular.module('SchedulesListDefinition', []) fields: { name: { key: true, - label: 'Name' + label: 'Name', + ngClick: "editSchedule(schedule.id)" }, dtstart: { - label: 'Start' + label: 'Start', + searchable: false }, dtend: { - label: 'End' + label: 'End', + searchable: false } }, @@ -46,6 +49,14 @@ angular.module('SchedulesListDefinition', []) }, fieldActions: { + "play": { + mode: "all", + ngClick: "toggleSchedule(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)", @@ -53,7 +64,6 @@ angular.module('SchedulesListDefinition', []) awToolTip: 'Edit schedule', dataPlacement: 'top' }, - "delete": { label: 'Delete', ngClick: "deleteSchedule(schedule.id)", diff --git a/awx/ui/static/sample/data/schedules/data.json b/awx/ui/static/sample/data/schedules/data.json index 9d95725650..18d450b748 100644 --- a/awx/ui/static/sample/data/schedules/data.json +++ b/awx/ui/static/sample/data/schedules/data.json @@ -10,6 +10,7 @@ "project": null, "job_class": "ansible:playbook", "name": "Hourly", + "enabled": true, "dtstart": "2014-03-10T17:00:00.000Z" , "dtend": null, "rrule": "FREQ=HOURLY;DTSTART=20140310T170000Z;INTERVAL=1" @@ -21,6 +22,7 @@ "project": null, "job_class": "ansible:playbook", "name": "Weekly", + "enabled": true, "dtstart": "2014-03-17T13:00:00.000Z", "dtend": null, "rrule": "FREQ=WEEKLY;DTSTART=20140317T130000Z;INTERVAL=1;COUNT=10;BYDAY=MO" @@ -32,6 +34,7 @@ "project": null, "job_class": "ansible:playbook", "name": "Monthly", + "enabled": false, "dtstart": "2014-04-06T01:00:00.000Z", "dtend": "2020-03-01T01:00:00.000Z", "rrule": "FREQ=MONTHLY;DTSTART=20140406T010000Z;INTERVAL=1;UNTIL=20200301T010000Z;BYMONTHDAY=1" diff --git a/awx/ui/static/sample/data/schedules/inventory/data.json b/awx/ui/static/sample/data/schedules/inventory/data.json index e377db960f..f13b6353d6 100644 --- a/awx/ui/static/sample/data/schedules/inventory/data.json +++ b/awx/ui/static/sample/data/schedules/inventory/data.json @@ -11,6 +11,7 @@ "job_class": "inventory:sync", "job_type": "inventory_sync", "name": "Hourly", + "enabled": true, "dtstart": "2014-03-10T17:00:00.000Z" , "dtend": null, "rrule": "FREQ=HOURLY;DTSTART=20140310T170000Z;INTERVAL=1" @@ -23,6 +24,7 @@ "job_class": "inventory:sync", "job_type": "inventory_sync", "name": "Weekly", + "enabled": true, "dtstart": "2014-03-17T13:00:00.000Z", "dtend": null, "rrule": "FREQ=WEEKLY;DTSTART=20140317T130000Z;INTERVAL=1;COUNT=10;BYDAY=MO" @@ -35,6 +37,7 @@ "job_class": "inventory:sync", "job_type": "inventory_sync", "name": "Monthly", + "enabled": false, "dtstart": "2014-04-06T01:00:00.000Z", "dtend": "2020-03-01T01:00:00.000Z", "rrule": "FREQ=MONTHLY;DTSTART=20140406T010000Z;INTERVAL=1;UNTIL=20200301T010000Z;BYMONTHDAY=1" diff --git a/awx/ui/static/sample/data/schedules/projects/data.json b/awx/ui/static/sample/data/schedules/projects/data.json index c9c7031ab2..3229635198 100644 --- a/awx/ui/static/sample/data/schedules/projects/data.json +++ b/awx/ui/static/sample/data/schedules/projects/data.json @@ -11,6 +11,7 @@ "job_class": "project:sync", "job_type": "project_sync", "name": "Hourly", + "enabled": false, "dtstart": "2014-03-10T17:00:00.000Z" , "dtend": null, "rrule": "FREQ=HOURLY;DTSTART=20140310T170000Z;INTERVAL=1" @@ -23,6 +24,7 @@ "job_class": "project:sync", "job_type": "project_sync", "name": "Weekly", + "enabled": true, "dtstart": "2014-03-17T13:00:00.000Z", "dtend": null, "rrule": "FREQ=WEEKLY;DTSTART=20140317T130000Z;INTERVAL=1;COUNT=10;BYDAY=MO" @@ -35,6 +37,7 @@ "job_class": "project:sync", "job_type": "project_sync", "name": "Monthly", + "enabled": true, "dtstart": "2014-04-06T01:00:00.000Z", "dtend": "2020-03-01T01:00:00.000Z", "rrule": "FREQ=MONTHLY;DTSTART=20140406T010000Z;INTERVAL=1;UNTIL=20200301T010000Z;BYMONTHDAY=1"