mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 03:10:42 -03:30
Fixed schedules list on Projects page and Job Templates page.
This commit is contained in:
parent
7bc7362299
commit
6b3d5da500
@ -337,7 +337,7 @@ JobTemplatesAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$lo
|
||||
function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeParams, JobTemplateForm, GenerateForm, Rest,
|
||||
Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList,
|
||||
CredentialList, ProjectList, LookUpInit, GetBasePath, md5Setup, ParseTypeChange, JobStatusToolTip, FormatDate,
|
||||
Wait, Stream, Empty, Prompt, ParseVariableString, ToJSON) {
|
||||
Wait, Stream, Empty, Prompt, ParseVariableString, ToJSON, SchedulesControllerInit) {
|
||||
|
||||
ClearScope();
|
||||
|
||||
@ -466,7 +466,11 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
||||
for (var set in relatedSets) {
|
||||
$scope.search(relatedSets[set].iterator);
|
||||
}
|
||||
|
||||
SchedulesControllerInit({
|
||||
scope: $scope,
|
||||
parent_scope: $scope,
|
||||
iterator: 'schedule'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -753,5 +757,5 @@ JobTemplatesEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$l
|
||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit',
|
||||
'ReturnToCaller', 'ClearScope', 'InventoryList', 'CredentialList', 'ProjectList', 'LookUpInit',
|
||||
'GetBasePath', 'md5Setup', 'ParseTypeChange', 'JobStatusToolTip', 'FormatDate', 'Wait', 'Stream', 'Empty', 'Prompt',
|
||||
'ParseVariableString', 'ToJSON'
|
||||
'ParseVariableString', 'ToJSON', 'SchedulesControllerInit'
|
||||
];
|
||||
@ -373,7 +373,7 @@ function ProjectsAdd($scope, $rootScope, $compile, $location, $log, $routeParams
|
||||
ClearScope();
|
||||
|
||||
// Inject dynamic view
|
||||
var form = ProjectsForm,
|
||||
var form = ProjectsForm(),
|
||||
generator = GenerateForm,
|
||||
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||
defaultUrl = GetBasePath('projects'),
|
||||
@ -510,12 +510,12 @@ ProjectsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log',
|
||||
function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm,
|
||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, Prompt,
|
||||
ClearScope, GetBasePath, ReturnToCaller, GetProjectPath, Authorization, CredentialList, LookUpInit, GetChoices,
|
||||
Empty, DebugForm, Wait, Stream) {
|
||||
Empty, DebugForm, Wait, Stream, SchedulesControllerInit) {
|
||||
|
||||
ClearScope('htmlTemplate');
|
||||
|
||||
// Inject dynamic view
|
||||
var form = ProjectsForm,
|
||||
var form = ProjectsForm(),
|
||||
generator = GenerateForm,
|
||||
defaultUrl = GetBasePath('projects') + $routeParams.id + '/',
|
||||
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||
@ -540,6 +540,12 @@ function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParam
|
||||
$scope.search(relatedSets[set].iterator);
|
||||
}
|
||||
|
||||
SchedulesControllerInit({
|
||||
scope: $scope,
|
||||
parent_scope: $scope,
|
||||
iterator: 'schedule'
|
||||
});
|
||||
|
||||
if (Authorization.getUserInfo('is_superuser') === true) {
|
||||
GetProjectPath({ scope: $scope, master: master });
|
||||
} else {
|
||||
@ -574,7 +580,7 @@ function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParam
|
||||
Rest.setUrl(defaultUrl);
|
||||
Rest.get({ params: { id: id } })
|
||||
.success(function (data) {
|
||||
var related, set, fld, i;
|
||||
var fld, i;
|
||||
LoadBreadCrumbs({ path: '/projects/' + id, title: data.name });
|
||||
for (fld in form.fields) {
|
||||
if (form.fields[fld].type === 'checkbox_group') {
|
||||
@ -596,15 +602,8 @@ function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParam
|
||||
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
|
||||
}
|
||||
}
|
||||
related = data.related;
|
||||
for (set in form.related) {
|
||||
if (related[set]) {
|
||||
relatedSets[set] = {
|
||||
url: related[set],
|
||||
iterator: form.related[set].iterator
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
relatedSets = form.relatedSets(data.related);
|
||||
|
||||
data.scm_type = (Empty(data.scm_type)) ? '' : data.scm_type;
|
||||
|
||||
@ -639,8 +638,7 @@ function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParam
|
||||
$scope.$emit('projectLoaded');
|
||||
})
|
||||
.error(function (data, status) {
|
||||
ProcessErrors($scope, data, status, form, {
|
||||
hdr: 'Error!',
|
||||
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
||||
msg: 'Failed to retrieve project: ' + id + '. GET status: ' + status
|
||||
});
|
||||
});
|
||||
@ -756,5 +754,5 @@ function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParam
|
||||
ProjectsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'ProjectsForm', 'GenerateForm',
|
||||
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit', 'Prompt', 'ClearScope',
|
||||
'GetBasePath', 'ReturnToCaller', 'GetProjectPath', 'Authorization', 'CredentialList', 'LookUpInit', 'GetChoices', 'Empty',
|
||||
'DebugForm', 'Wait', 'Stream'
|
||||
'DebugForm', 'Wait', 'Stream', 'SchedulesControllerInit'
|
||||
];
|
||||
@ -15,8 +15,7 @@ GetBasePath, Wait, Breadcrumbs, Find, LoadDialogPartial, LoadSchedulesScope, Get
|
||||
|
||||
ClearScope();
|
||||
|
||||
var base, e, id, url, parentObject,
|
||||
schedules_scope = $scope.$new();
|
||||
var base, e, id, url, parentObject;
|
||||
|
||||
base = $location.path().replace(/^\//, '').split('/')[0];
|
||||
|
||||
@ -47,7 +46,7 @@ GetBasePath, Wait, Breadcrumbs, Find, LoadDialogPartial, LoadSchedulesScope, Get
|
||||
|
||||
LoadSchedulesScope({
|
||||
parent_scope: $scope,
|
||||
scope: schedules_scope,
|
||||
scope: $scope,
|
||||
list: SchedulesList,
|
||||
id: 'schedule-list-target',
|
||||
url: url
|
||||
@ -75,7 +74,7 @@ GetBasePath, Wait, Breadcrumbs, Find, LoadDialogPartial, LoadSchedulesScope, Get
|
||||
});
|
||||
|
||||
$scope.refreshJobs = function() {
|
||||
schedules_scope.search(SchedulesList.iterator);
|
||||
$scope.search(SchedulesList.iterator);
|
||||
};
|
||||
|
||||
Wait('start');
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
*
|
||||
*
|
||||
*/
|
||||
angular.module('ProjectFormDefinition', [])
|
||||
.value('ProjectsForm', {
|
||||
angular.module('ProjectFormDefinition', ['SchedulesListDefinition'])
|
||||
.value('ProjectsFormObject', {
|
||||
|
||||
addTitle: 'Create Project',
|
||||
editTitle: '{{ name }}',
|
||||
@ -282,53 +282,36 @@ angular.module('ProjectFormDefinition', [])
|
||||
}
|
||||
},
|
||||
|
||||
schedules: {
|
||||
type: 'collection',
|
||||
title: 'Schedules',
|
||||
iterator: 'schedule',
|
||||
index: true,
|
||||
open: false,
|
||||
|
||||
fields: {
|
||||
name: {
|
||||
key: true,
|
||||
label: 'Name'
|
||||
},
|
||||
dtstart: {
|
||||
label: 'Start'
|
||||
},
|
||||
dtend: {
|
||||
label: 'End'
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
add: {
|
||||
mode: 'all',
|
||||
ngClick: 'addSchedule()',
|
||||
awToolTip: 'Add a new schedule'
|
||||
}
|
||||
},
|
||||
|
||||
fieldActions: {
|
||||
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'
|
||||
}
|
||||
}
|
||||
|
||||
schedules: {
|
||||
include: "SchedulesList"
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
relatedSets: function(urls) {
|
||||
return {
|
||||
organizations: {
|
||||
iterator: 'organization',
|
||||
url: urls.organizations
|
||||
},
|
||||
schedules: {
|
||||
iterator: 'schedule',
|
||||
url: urls.schedules
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}); // Form
|
||||
})
|
||||
|
||||
.factory('ProjectsForm', ['ProjectsFormObject', 'SchedulesList', function(ProjectsFormObject, ScheduleList) {
|
||||
return function() {
|
||||
var itm;
|
||||
for (itm in ProjectsFormObject.related) {
|
||||
if (ProjectsFormObject.related[itm].include === "SchedulesList") {
|
||||
ProjectsFormObject.related[itm] = ScheduleList;
|
||||
ProjectsFormObject.related[itm].generateList = true; // tell form generator to call list generator and inject a list
|
||||
}
|
||||
}
|
||||
return ProjectsFormObject;
|
||||
};
|
||||
}]);
|
||||
@ -69,6 +69,7 @@ angular.module('SchedulesHelper', [ 'Utilities', 'RestServices', 'SchedulesHelpe
|
||||
return function(params) {
|
||||
var scope = params.scope,
|
||||
id = params.id,
|
||||
callback = params.callback,
|
||||
schedule, scheduler,
|
||||
url = GetBasePath('schedules') + id + '/';
|
||||
|
||||
@ -118,8 +119,13 @@ angular.module('SchedulesHelper', [ 'Utilities', 'RestServices', 'SchedulesHelpe
|
||||
Rest.setUrl(url);
|
||||
Rest.put(schedule)
|
||||
.success(function(){
|
||||
Wait('stop');
|
||||
$('#scheduler-modal-dialog').dialog('close');
|
||||
if (callback) {
|
||||
scope.$emit(callback);
|
||||
}
|
||||
else {
|
||||
Wait('stop');
|
||||
}
|
||||
})
|
||||
.error(function(data, status){
|
||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||
@ -368,11 +374,13 @@ angular.module('SchedulesHelper', [ 'Utilities', 'RestServices', 'SchedulesHelpe
|
||||
}])
|
||||
|
||||
|
||||
.factory('SchedulesControllerInit', ['ToggleSchedule', 'DeleteSchedule', 'EditSchedule', 'AddSchedule',
|
||||
function(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;
|
||||
parent_scope = params.parent_scope,
|
||||
iterator = (params.iterator) ? params.iterator : scope.iterator,
|
||||
base = $location.path().replace(/^\//, '').split('/')[0];
|
||||
|
||||
scope.toggleSchedule = function(event, id) {
|
||||
try {
|
||||
@ -412,11 +420,19 @@ angular.module('SchedulesHelper', [ 'Utilities', 'RestServices', 'SchedulesHelpe
|
||||
};
|
||||
|
||||
scope.refreshJobs = function() {
|
||||
parent_scope.refreshJobs();
|
||||
if (base === 'jobs') {
|
||||
parent_scope.refreshJobs();
|
||||
}
|
||||
else {
|
||||
scope.search(iterator);
|
||||
}
|
||||
};
|
||||
|
||||
if (scope.removeSchedulesRefresh) {
|
||||
scope.removeSchedulesRefresh();
|
||||
}
|
||||
scope.$on('SchedulesRefresh', function() {
|
||||
parent_scope.refreshJobs();
|
||||
scope.refreshJobs();
|
||||
});
|
||||
};
|
||||
}])
|
||||
|
||||
@ -446,11 +446,11 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
};
|
||||
|
||||
|
||||
scope.sort = function (fld) {
|
||||
scope.sort = function (iterator, fld) {
|
||||
// Reset sort icons back to 'icon-sort' on all columns
|
||||
// except the one clicked.
|
||||
$('.list-header').each(function () {
|
||||
if ($(this).attr('id') !== fld + '-header') {
|
||||
if ($(this).attr('id') !== iterator + '-' + fld + '-header') {
|
||||
var icon = $(this).find('i');
|
||||
icon.attr('class', 'fa fa-sort');
|
||||
}
|
||||
@ -458,7 +458,7 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
|
||||
// Toggle the icon for the clicked column
|
||||
// and set the sort direction
|
||||
var icon = $('#' + fld + '-header i'),
|
||||
var icon = $('#' + iterator + '-' + fld + '-header i'),
|
||||
direction = '';
|
||||
if (icon.hasClass('fa-sort')) {
|
||||
icon.removeClass('fa-sort');
|
||||
|
||||
@ -300,11 +300,9 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
|
||||
!(options.mode === 'lookup' && list.fields[fld].excludeModal !== undefined && list.fields[fld].excludeModal === true)) {
|
||||
html += "<th class=\"list-header";
|
||||
html += (list.fields[fld].columnClass) ? " " + list.fields[fld].columnClass : "";
|
||||
html += "\" id=\"";
|
||||
html += (list.fields[fld].id) ? list.fields[fld].id : fld + "-header";
|
||||
html += "\"";
|
||||
html += "\" id=\"" + list.iterator + "-" + fld + "-header\"";
|
||||
html += (list.fields[fld].columnShow) ? " ng-show=\"" + list.fields[fld].columnShow + "\" " : "";
|
||||
html += (list.fields[fld].nosort === undefined || list.fields[fld].nosort !== true) ? " ng-click=\"sort('" + fld + "')\"" : "";
|
||||
html += (list.fields[fld].nosort === undefined || list.fields[fld].nosort !== true) ? " ng-click=\"sort('" + list.iterator + "','" + fld + "')\"" : "";
|
||||
html += ">";
|
||||
html += list.fields[fld].label;
|
||||
if (list.fields[fld].nosort === undefined || list.fields[fld].nosort !== true) {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
<div class="tab-pane" id="job_templates">
|
||||
<div ng-cloak id="htmlTemplate"></div>
|
||||
<div ng-include="'/static/partials/schedule_dialog.html'"></div>
|
||||
</div>
|
||||
@ -1,4 +1,5 @@
|
||||
<div class="tab-pane" id="projects">
|
||||
<div ng-cloak id="htmlTemplate"></div>
|
||||
<div ng-include="'/static/partials/logviewer.html'"></div>
|
||||
<div ng-include="'/static/partials/schedule_dialog.html'"></div>
|
||||
</div>
|
||||
Loading…
x
Reference in New Issue
Block a user