mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 19:37:38 -02:30
Added schedule delete support to Inventory group edit dialog, schedules controller and jobs controller.
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBreadCrumbs, LoadScope, RunningJobsList, CompletedJobsList, QueuedJobsList,
|
function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBreadCrumbs, LoadScope, RunningJobsList, CompletedJobsList, QueuedJobsList,
|
||||||
ScheduledJobsList, GetChoices, GetBasePath, Wait, DeleteJob, ToggleScheduleEnabled, Find) {
|
ScheduledJobsList, GetChoices, GetBasePath, Wait, DeleteJob, Find, DeleteSchedule, ToggleSchedule) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -75,14 +75,12 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea
|
|||||||
url: GetBasePath('schedules')
|
url: GetBasePath('schedules')
|
||||||
});
|
});
|
||||||
|
|
||||||
if (scheduled_scope.removeScheduleToggled) {
|
if (scheduled_scope.removeSchedulesRefresh) {
|
||||||
scheduled_scope.removeScheduleToggled();
|
scheduled_scope.removeSchedulesRefresh();
|
||||||
}
|
}
|
||||||
scheduled_scope.removeScheduleToggled = function(e, id) {
|
scheduled_scope.removeSchedulesRefresh = scheduled_scope.$on('SchedulesRefresh', function() {
|
||||||
//scheduled_scope.search(ScheduledJobsList.iterator);
|
scheduled_scope.search(ScheduledJobsList.iterator);
|
||||||
var schedule = Find({ list: scheduled_scope[ScheduledJobsList.name], key: 'id', val: id});
|
});
|
||||||
schedule.enabled = (schedule.enabled) ? false : true;
|
|
||||||
};
|
|
||||||
|
|
||||||
completed_scope.deleteJob = function(id) {
|
completed_scope.deleteJob = function(id) {
|
||||||
DeleteJob({ scope: completed_scope, id: id });
|
DeleteJob({ scope: completed_scope, id: id });
|
||||||
@@ -97,9 +95,18 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea
|
|||||||
};
|
};
|
||||||
|
|
||||||
scheduled_scope.toggleSchedule = function(id) {
|
scheduled_scope.toggleSchedule = function(id) {
|
||||||
ToggleScheduleEnabled({
|
ToggleSchedule({
|
||||||
scope: scheduled_scope,
|
scope: scheduled_scope,
|
||||||
id: id
|
id: id,
|
||||||
|
callback: 'SchedulesRefresh'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
scheduled_scope.deleteSchedule = function(id) {
|
||||||
|
DeleteSchedule({
|
||||||
|
scope: scheduled_scope,
|
||||||
|
id: id,
|
||||||
|
callback: 'SchedulesRefresh'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -136,7 +143,7 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea
|
|||||||
}
|
}
|
||||||
|
|
||||||
JobsListController.$inject = ['$scope', '$compile', 'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'LoadScope', 'RunningJobsList', 'CompletedJobsList',
|
JobsListController.$inject = ['$scope', '$compile', 'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'LoadScope', 'RunningJobsList', 'CompletedJobsList',
|
||||||
'QueuedJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', 'Wait', 'DeleteJob', 'ToggleScheduleEnabled', 'Find'];
|
'QueuedJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', 'Wait', 'DeleteJob', 'Find', 'DeleteSchedule', 'ToggleSchedule'];
|
||||||
|
|
||||||
function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, JobForm, JobTemplateForm, GenerateForm, Rest,
|
function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, JobForm, JobTemplateForm, GenerateForm, Rest,
|
||||||
Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList,
|
Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function ScheduleEdit($scope, $compile, $location, $routeParams, SchedulesList, GenerateList, Rest, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
function ScheduleEdit($scope, $compile, $location, $routeParams, SchedulesList, GenerateList, Rest, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
||||||
GetBasePath, LookUpInit, Wait, SchedulerInit, Breadcrumbs, SearchInit, PaginateInit, PageRangeSetup, EditSchedule, AddSchedule, Find, ToggleSchedule) {
|
GetBasePath, LookUpInit, Wait, SchedulerInit, Breadcrumbs, SearchInit, PaginateInit, PageRangeSetup, EditSchedule, AddSchedule, Find, ToggleSchedule, DeleteSchedule) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -125,12 +125,12 @@ GetBasePath, LookUpInit, Wait, SchedulerInit, Breadcrumbs, SearchInit, PaginateI
|
|||||||
AddSchedule({ scope: $scope, schedule: schedule, url: url });
|
AddSchedule({ scope: $scope, schedule: schedule, url: url });
|
||||||
};
|
};
|
||||||
|
|
||||||
if ($scope.removeScheduleToggled) {
|
if ($scope.removeScheduleRefresh) {
|
||||||
$scope.removeScheduleToggled();
|
$scope.removeScheduleRefresh();
|
||||||
}
|
}
|
||||||
$scope.removeScheduleToggled = function() {
|
$scope.removeScheduleToggled = $scope.$on('ScheduleRefresh', function() {
|
||||||
$scope.search(SchedulesList.iterator);
|
$scope.search(SchedulesList.iterator);
|
||||||
};
|
});
|
||||||
|
|
||||||
$scope.toggleSchedule = function(id) {
|
$scope.toggleSchedule = function(id) {
|
||||||
ToggleSchedule({
|
ToggleSchedule({
|
||||||
@@ -140,6 +140,22 @@ GetBasePath, LookUpInit, Wait, SchedulerInit, Breadcrumbs, SearchInit, PaginateI
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.toggleSchedule = function(id) {
|
||||||
|
ToggleSchedule({
|
||||||
|
scope: $scope,
|
||||||
|
id: id,
|
||||||
|
callback: 'SchedulesRefresh'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.deleteSchedule = function(id) {
|
||||||
|
DeleteSchedule({
|
||||||
|
scope: $scope,
|
||||||
|
id: id,
|
||||||
|
callback: 'SchedulesRefresh'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Load the parent object
|
// Load the parent object
|
||||||
id = $routeParams.id;
|
id = $routeParams.id;
|
||||||
Rest.setUrl(GetBasePath(base) + id);
|
Rest.setUrl(GetBasePath(base) + id);
|
||||||
@@ -156,5 +172,5 @@ GetBasePath, LookUpInit, Wait, SchedulerInit, Breadcrumbs, SearchInit, PaginateI
|
|||||||
|
|
||||||
ScheduleEdit.$inject = ['$scope', '$compile', '$location', '$routeParams', 'SchedulesList', 'GenerateList', 'Rest', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
|
ScheduleEdit.$inject = ['$scope', '$compile', '$location', '$routeParams', 'SchedulesList', 'GenerateList', 'Rest', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
|
||||||
'ClearScope', 'GetBasePath', 'LookUpInit', 'Wait', 'SchedulerInit', 'Breadcrumbs', 'SearchInit', 'PaginateInit', 'PageRangeSetup', 'EditSchedule', 'AddSchedule',
|
'ClearScope', 'GetBasePath', 'LookUpInit', 'Wait', 'SchedulerInit', 'Breadcrumbs', 'SearchInit', 'PaginateInit', 'PageRangeSetup', 'EditSchedule', 'AddSchedule',
|
||||||
'Find', 'ToggleSchedule'
|
'Find', 'ToggleSchedule', 'DeleteSchedule'
|
||||||
];
|
];
|
||||||
@@ -326,8 +326,9 @@ angular.module('GroupsHelper', ['RestServices', 'Utilities', 'ListGenerator', 'G
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
.factory('ScheduleList', ['ScheduleEdit', 'SchedulesList', 'GenerateList', 'SearchInit', 'PaginateInit', 'Rest', 'PageRangeSetup',
|
.factory('ScheduleList', ['ScheduleEdit', 'SchedulesList', 'GenerateList', 'SearchInit', 'PaginateInit', 'Rest', 'PageRangeSetup',
|
||||||
'Wait', 'ProcessErrors', 'Find',
|
'Wait', 'ProcessErrors', 'Find', 'ToggleSchedule', 'DeleteSchedule',
|
||||||
function(ScheduleEdit, SchedulesList, GenerateList, SearchInit, PaginateInit, Rest, PageRangeSetup, Wait, ProcessErrors, Find) {
|
function(ScheduleEdit, SchedulesList, GenerateList, SearchInit, PaginateInit, Rest, PageRangeSetup, Wait, ProcessErrors, Find,
|
||||||
|
ToggleSchedule, DeleteSchedule) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
var parent_scope = params.scope,
|
var parent_scope = params.scope,
|
||||||
schedule_scope = parent_scope.$new(),
|
schedule_scope = parent_scope.$new(),
|
||||||
@@ -406,6 +407,30 @@ function(ScheduleEdit, SchedulesList, GenerateList, SearchInit, PaginateInit, Re
|
|||||||
schedule_scope.addSchedule = function() {
|
schedule_scope.addSchedule = function() {
|
||||||
ScheduleEdit({ scope: parent_scope, schedule: {}, mode: 'add'});
|
ScheduleEdit({ scope: parent_scope, schedule: {}, mode: 'add'});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (schedule_scope.removeSchedulesRefresh) {
|
||||||
|
schedule_scope.removeSchedulesRefresh();
|
||||||
|
}
|
||||||
|
schedule_scope.removeSchedulesRefresh = schedule_scope.$on('SchedulesRefresh', function() {
|
||||||
|
schedule_scope.search(SchedulesList.iterator);
|
||||||
|
});
|
||||||
|
|
||||||
|
schedule_scope.toggleSchedule = function(id) {
|
||||||
|
ToggleSchedule({
|
||||||
|
scope: schedule_scope,
|
||||||
|
id: id,
|
||||||
|
callback: 'SchedulesRefresh'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
schedule_scope.deleteSchedule = function(id) {
|
||||||
|
DeleteSchedule({
|
||||||
|
scope: schedule_scope,
|
||||||
|
id: id,
|
||||||
|
callback: 'SchedulesRefresh'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('JobsHelper', ['Utilities', 'FormGenerator', 'JobSummaryDefinition', 'InventoryHelper', 'GeneratorHelpers', 'SchedulesHelper'])
|
angular.module('JobsHelper', ['Utilities', 'FormGenerator', 'JobSummaryDefinition', 'InventoryHelper', 'GeneratorHelpers'])
|
||||||
|
|
||||||
.factory('JobStatusToolTip', [
|
.factory('JobStatusToolTip', [
|
||||||
function () {
|
function () {
|
||||||
@@ -326,17 +326,4 @@ function(Find, GetBasePath, Rest, Wait, ProcessErrors, Prompt){
|
|||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
}])
|
|
||||||
|
|
||||||
.factory('ToggleScheduleEnabled', ['ToggleSchedule', function(ToggleSchedule) {
|
|
||||||
return function(params) {
|
|
||||||
var scope = params.scope,
|
|
||||||
id = params.id;
|
|
||||||
ToggleSchedule({
|
|
||||||
scope: scope,
|
|
||||||
id: id,
|
|
||||||
callback: 'ScheduleToggled'
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|||||||
@@ -262,6 +262,60 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
|||||||
msg: 'Failed to retrieve schedule ' + id + ' GET returned: ' + status });
|
msg: 'Failed to retrieve schedule ' + id + ' GET returned: ' + status });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
}])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a schedule. Prompts user to confirm delete
|
||||||
|
*
|
||||||
|
* DeleteSchedule({
|
||||||
|
* scope: $scope containing list of schedules
|
||||||
|
* id: id of schedule to delete
|
||||||
|
* callback: $scope.$emit label to call when delete is completed
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
.factory('DeleteSchedule', ['GetBasePath','Rest', 'Wait', 'ProcessErrors', 'Prompt', 'Find',
|
||||||
|
function(GetBasePath, Rest, Wait, ProcessErrors, Prompt, Find) {
|
||||||
|
return function(params) {
|
||||||
|
|
||||||
|
var scope = params.scope,
|
||||||
|
id = params.id,
|
||||||
|
callback = params.callback,
|
||||||
|
action, schedule, list, url, hdr;
|
||||||
|
|
||||||
|
if (scope.schedules) {
|
||||||
|
list = scope.schedules;
|
||||||
|
}
|
||||||
|
else if (scope.scheduled_jobs) {
|
||||||
|
list = scope.scheduled_jobs;
|
||||||
|
}
|
||||||
|
|
||||||
|
url = GetBasePath('schedules') + id + '/';
|
||||||
|
schedule = Find({list: list, key: 'id', val: id });
|
||||||
|
hdr = 'Delete Schedule';
|
||||||
|
|
||||||
|
action = function () {
|
||||||
|
Wait('start');
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.destroy()
|
||||||
|
.success(function () {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
scope.$emit(callback, id);
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url +
|
||||||
|
' failed. DELETE returned: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Prompt({
|
||||||
|
hdr: hdr,
|
||||||
|
body: "<div class=\"alert alert-info\">Are you sure you want to delete the <em>" + schedule.name + "</em> schedule?</div>",
|
||||||
|
action: action
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
||||||
@@ -278,3 +332,54 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -67,13 +67,13 @@ angular.module('ScheduledJobsDefinition', [])
|
|||||||
},
|
},
|
||||||
"edit": {
|
"edit": {
|
||||||
mode: "all",
|
mode: "all",
|
||||||
ngClick: "edit(scheduled_job.id)",
|
ngClick: "editSchedule(scheduled_job.id)",
|
||||||
awToolTip: "Edit the schedule",
|
awToolTip: "Edit the schedule",
|
||||||
dataPlacement: "top"
|
dataPlacement: "top"
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
mode: 'all',
|
mode: 'all',
|
||||||
ngClick: 'deleteJob(completed_job.id)',
|
ngClick: 'deleteSchedule(scheduled_job.id)',
|
||||||
awToolTip: 'Delete the schedule',
|
awToolTip: 'Delete the schedule',
|
||||||
dataPlacement: 'top'
|
dataPlacement: 'top'
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user