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