mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 02:50:02 -03:30
Adding scheduler for inventory syncs
which can be found in the groups panel on the left side of hte inventory manage page in the row for each group.
This commit is contained in:
parent
72b80457eb
commit
f1545860f0
@ -207,24 +207,47 @@ export default
|
||||
};
|
||||
}])
|
||||
|
||||
.factory('AddSchedule', ['$location', '$stateParams', 'SchedulerInit', 'ShowSchedulerModal', 'Wait', 'GetBasePath', 'Empty',
|
||||
'SchedulePost', '$state',
|
||||
function($location, $stateParams, SchedulerInit, ShowSchedulerModal, Wait, GetBasePath, Empty, SchedulePost, $state) {
|
||||
.factory('AddSchedule', ['$location', '$stateParams', 'SchedulerInit',
|
||||
'ShowSchedulerModal', 'Wait', 'GetBasePath', 'Empty',
|
||||
'SchedulePost', '$state', 'Rest', 'ProcessErrors',
|
||||
function($location, $stateParams, SchedulerInit, ShowSchedulerModal,
|
||||
Wait, GetBasePath, Empty, SchedulePost, $state, Rest,
|
||||
ProcessErrors) {
|
||||
return function(params) {
|
||||
var scope = params.scope,
|
||||
callback= params.callback,
|
||||
base = params.base || $location.path().replace(/^\//, '').split('/')[0],
|
||||
url = GetBasePath(base),
|
||||
url,
|
||||
scheduler;
|
||||
|
||||
if (!Empty($stateParams.template_id)) {
|
||||
url += $stateParams.template_id + '/schedules/';
|
||||
url = GetBasePath(base) + $stateParams.template_id + '/schedules/';
|
||||
}
|
||||
else if (!Empty($stateParams.id) && base !== 'system_job_templates') {
|
||||
url += $stateParams.id + '/schedules/';
|
||||
else if (!Empty($stateParams.id) && base !== 'system_job_templates' && base !== 'inventory') {
|
||||
url = GetBasePath(base) + $stateParams.id + '/schedules/';
|
||||
}
|
||||
else if (base === 'system_job_templates') {
|
||||
url += $stateParams.id + '/schedules/';
|
||||
if($stateParams.id === 4){
|
||||
else if(base === "inventory"){
|
||||
if (!params.url){
|
||||
url = GetBasePath('groups') + $stateParams.id + '/';
|
||||
Rest.setUrl(url);
|
||||
Rest.get().
|
||||
then(function (data) {
|
||||
url = data.data.related.inventory_source + 'schedules/';
|
||||
}).catch(function (response) {
|
||||
ProcessErrors(null, response.data, response.status, null, {
|
||||
hdr: 'Error!',
|
||||
msg: 'Failed to get inventory group info. GET returned status: ' +
|
||||
response.status
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
url = params.url;
|
||||
}
|
||||
}
|
||||
else if (base == 'system_job_templates') {
|
||||
url = GetBasePath(base) + $stateParams.id + '/schedules/';
|
||||
if($stateParams.id == 4){
|
||||
scope.isFactCleanup = true;
|
||||
scope.keep_unit_choices = [{
|
||||
"label" : "Days",
|
||||
@ -528,10 +551,10 @@ export default
|
||||
};
|
||||
}])
|
||||
|
||||
|
||||
.factory('SchedulesControllerInit', ['$state', '$location', 'ToggleSchedule',
|
||||
'DeleteSchedule',
|
||||
function($state, $location, ToggleSchedule, DeleteSchedule) {
|
||||
.factory('SchedulesControllerInit', ['$state', '$location',
|
||||
'ToggleSchedule', 'DeleteSchedule', 'ParamPass',
|
||||
function($state, $location, ToggleSchedule, DeleteSchedule,
|
||||
ParamPass) {
|
||||
return function(params) {
|
||||
var scope = params.scope,
|
||||
parent_scope = params.parent_scope,
|
||||
@ -567,7 +590,8 @@ export default
|
||||
|
||||
scope.addSchedule = function() {
|
||||
var base = $state.current.name.split(".")[0];
|
||||
$state.go(base + ".add", {passedScope: scope});
|
||||
ParamPass.set(scope.schedule_url);
|
||||
$state.go(base + ".add");
|
||||
};
|
||||
|
||||
scope.refreshSchedules = function() {
|
||||
|
||||
@ -400,6 +400,12 @@ function InventoriesManage($log, $scope, $rootScope, $location,
|
||||
});
|
||||
};
|
||||
|
||||
$scope.scheduleGroup = function(id) {
|
||||
$state.go('inventoryManageSchedules', {
|
||||
inventory_id: $scope.inventory.id, id: id
|
||||
});
|
||||
};
|
||||
|
||||
$scope.copyGroup = function(id) {
|
||||
PreviousSearchParams = Store('group_current_search_params');
|
||||
var params = {
|
||||
|
||||
@ -214,6 +214,7 @@ function manageGroupsDirectiveController($filter, $location, $log,
|
||||
master.source_regions = opts;
|
||||
CreateSelect2({
|
||||
element: "group_source_regions",
|
||||
multiple: true,
|
||||
opts: opts
|
||||
});
|
||||
|
||||
@ -241,7 +242,8 @@ function manageGroupsDirectiveController($filter, $location, $log,
|
||||
}
|
||||
master.group_by = opts;
|
||||
CreateSelect2({
|
||||
element: "#source_group_by",
|
||||
element: "#group_group_by",
|
||||
multiple: true,
|
||||
opts: opts
|
||||
});
|
||||
}
|
||||
@ -407,7 +409,7 @@ function manageGroupsDirectiveController($filter, $location, $log,
|
||||
if ($scope.source && ($scope.source.value === 'ec2')) {
|
||||
data.instance_filters = $scope.instance_filters;
|
||||
// Create a string out of selected list of regions
|
||||
group_by = $('#source_group_by').select2("data");
|
||||
group_by = $('#group_group_by').select2("data");
|
||||
r = [];
|
||||
for (i = 0; i < group_by.length; i++) {
|
||||
r.push(group_by[i].id);
|
||||
|
||||
@ -161,6 +161,14 @@ export default
|
||||
ngShow: "group.id > 0",
|
||||
dataPlacement: "top"
|
||||
},
|
||||
schedule: {
|
||||
mode: 'all',
|
||||
ngClick: "scheduleGroup(group.id)",
|
||||
awToolTip: "{{ group.group_schedule_tooltip }}",
|
||||
ngClass: "group.scm_type_class",
|
||||
dataPlacement: 'top',
|
||||
ngHide: "group.summary_fields.inventory_source.source === ''"
|
||||
},
|
||||
edit: {
|
||||
//label: 'Edit',
|
||||
mode: 'all',
|
||||
|
||||
@ -81,4 +81,37 @@ export default
|
||||
}]
|
||||
}
|
||||
});
|
||||
$stateExtender.addState({
|
||||
name: 'inventoryManageSchedules',
|
||||
route: '/inventory/:inventory_id/manage/:id/schedules',
|
||||
templateUrl: templateUrl("scheduler/scheduler"),
|
||||
controller: 'schedulerController',
|
||||
resolve: {
|
||||
features: ['FeaturesService', function(FeaturesService) {
|
||||
return FeaturesService.get();
|
||||
}]
|
||||
}
|
||||
});
|
||||
$stateExtender.addState({
|
||||
name: 'inventoryManageSchedules.add',
|
||||
route: '/add',
|
||||
templateUrl: templateUrl("scheduler/schedulerForm"),
|
||||
controller: 'schedulerAddController',
|
||||
resolve: {
|
||||
features: ['FeaturesService', function(FeaturesService) {
|
||||
return FeaturesService.get();
|
||||
}]
|
||||
}
|
||||
});
|
||||
$stateExtender.addState({
|
||||
name: 'inventoryManageSchedules.edit',
|
||||
route: '/:schedule_id',
|
||||
templateUrl: templateUrl("scheduler/schedulerForm"),
|
||||
controller: 'schedulerEditController',
|
||||
resolve: {
|
||||
features: ['FeaturesService', function(FeaturesService) {
|
||||
return FeaturesService.get();
|
||||
}]
|
||||
}
|
||||
});
|
||||
}]);
|
||||
|
||||
@ -12,15 +12,18 @@
|
||||
|
||||
|
||||
export default [
|
||||
'$scope', '$compile', '$location', '$stateParams', 'SchedulesList', 'Rest', 'ProcessErrors', 'ReturnToCaller', 'ClearScope',
|
||||
'GetBasePath', 'Wait', 'Find', 'LoadDialogPartial', 'LoadSchedulesScope', 'GetChoices',
|
||||
'$scope', '$compile', '$location', '$stateParams', 'SchedulesList', 'Rest',
|
||||
'ProcessErrors', 'ReturnToCaller', 'ClearScope', 'GetBasePath', 'Wait',
|
||||
'Find', 'LoadDialogPartial', 'LoadSchedulesScope', 'GetChoices', '$q',
|
||||
function ($scope, $compile, $location, $stateParams,
|
||||
SchedulesList, Rest, ProcessErrors, ReturnToCaller, ClearScope,
|
||||
GetBasePath, Wait, Find, LoadDialogPartial, LoadSchedulesScope, GetChoices) {
|
||||
GetBasePath, Wait, Find, LoadDialogPartial, LoadSchedulesScope, GetChoices,
|
||||
$q) {
|
||||
|
||||
ClearScope();
|
||||
|
||||
var base, id, url, parentObject;
|
||||
var base, id, url,parentObject, title;
|
||||
|
||||
base = $location.path().replace(/^\//, '').split('/')[0];
|
||||
if (base === 'management_jobs') {
|
||||
$scope.base = base = 'system_job_templates';
|
||||
@ -28,6 +31,7 @@ export default [
|
||||
if ($stateParams.job_type){
|
||||
$scope.job_type = $stateParams.job_type;
|
||||
}
|
||||
|
||||
if ($scope.removePostRefresh) {
|
||||
$scope.removePostRefresh();
|
||||
}
|
||||
@ -46,7 +50,8 @@ export default [
|
||||
SchedulesList.well = true;
|
||||
|
||||
// include name of item in listTitle
|
||||
SchedulesList.listTitle = parentObject.name + "<div class='List-titleLockup'></div>Schedules";
|
||||
SchedulesList.listTitle = title ? title : parentObject.name;
|
||||
SchedulesList.listTitle = `${SchedulesList.listTitle}<div class='List-titleLockup'></div>Schedules`;
|
||||
|
||||
LoadSchedulesScope({
|
||||
parent_scope: $scope,
|
||||
@ -58,6 +63,28 @@ export default [
|
||||
});
|
||||
});
|
||||
|
||||
function getUrl(){
|
||||
if($stateParams.inventory_id){
|
||||
url = GetBasePath('groups') + $stateParams.id + '/';
|
||||
Rest.setUrl(url);
|
||||
var promise;
|
||||
promise = Rest.get();
|
||||
return promise.then(function (data) {
|
||||
url = data.data.related.inventory_source;
|
||||
title = data.data.name;
|
||||
}).catch(function (response) {
|
||||
ProcessErrors(null, response.data, response.status, null, {
|
||||
hdr: 'Error!',
|
||||
msg: 'Failed to get inventory group info. GET returned status: ' +
|
||||
response.status
|
||||
});
|
||||
});
|
||||
}
|
||||
else{
|
||||
url = GetBasePath(base) + id + '/';
|
||||
return $q.when(url);
|
||||
}
|
||||
}
|
||||
|
||||
if ($scope.removeChoicesReady) {
|
||||
$scope.removeChocesReady();
|
||||
@ -65,17 +92,18 @@ export default [
|
||||
$scope.removeChoicesReady = $scope.$on('choicesReady', function() {
|
||||
// Load the parent object
|
||||
id = $stateParams.id;
|
||||
url = GetBasePath(base) + 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 });
|
||||
});
|
||||
getUrl().then(function(){
|
||||
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() {
|
||||
|
||||
@ -1,4 +1,15 @@
|
||||
export default ['$compile', '$state', '$stateParams', 'AddSchedule', 'Wait', '$scope', '$rootScope', 'CreateSelect2', 'ParseTypeChange', 'GetBasePath', 'Rest', function($compile, $state, $stateParams, AddSchedule, Wait, $scope, $rootScope, CreateSelect2, ParseTypeChange, GetBasePath, Rest) {
|
||||
/*************************************************
|
||||
* Copyright (c) 2016 Ansible, Inc.
|
||||
*
|
||||
* All Rights Reserved
|
||||
*************************************************/
|
||||
|
||||
export default ['$compile', '$state', '$stateParams', 'AddSchedule', 'Wait',
|
||||
'$scope', '$rootScope', 'CreateSelect2', 'ParseTypeChange', 'GetBasePath',
|
||||
'Rest', 'ParamPass',
|
||||
function($compile, $state, $stateParams, AddSchedule, Wait, $scope,
|
||||
$rootScope, CreateSelect2, ParseTypeChange, GetBasePath, Rest, ParamPass) {
|
||||
|
||||
$scope.$on("ScheduleFormCreated", function(e, scope) {
|
||||
$scope.hideForm = false;
|
||||
$scope = angular.extend($scope, scope);
|
||||
@ -40,6 +51,7 @@ export default ['$compile', '$state', '$stateParams', 'AddSchedule', 'Wait', '$s
|
||||
|
||||
$scope.hideForm = true;
|
||||
|
||||
var schedule_url = ParamPass.get();
|
||||
|
||||
$scope.formCancel = function() {
|
||||
$state.go("^");
|
||||
@ -79,18 +91,19 @@ export default ['$compile', '$state', '$stateParams', 'AddSchedule', 'Wait', '$s
|
||||
else if ($state.current.name === 'projectSchedules.add'){
|
||||
$scope.extraVars = '---';
|
||||
$scope.parseType = 'yaml';
|
||||
ParseTypeChange({
|
||||
scope: $scope,
|
||||
variable: 'extraVars',
|
||||
ParseTypeChange({
|
||||
scope: $scope,
|
||||
variable: 'extraVars',
|
||||
parse_variable: 'parseType',
|
||||
field_id: 'SchedulerForm-extraVars'
|
||||
field_id: 'SchedulerForm-extraVars'
|
||||
});
|
||||
}
|
||||
|
||||
AddSchedule({
|
||||
scope: $scope,
|
||||
callback: 'SchedulesRefresh',
|
||||
base: $scope.base ? $scope.base : null
|
||||
base: $scope.base ? $scope.base : null,
|
||||
url: schedule_url
|
||||
});
|
||||
|
||||
var callSelect2 = function() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user