1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

Moves schedules tab to related tab for sources form

This commit is contained in:
Jared Tabor 2018-05-11 14:44:38 -07:00
parent ce09ab446d
commit 77e195bbb9
9 changed files with 53 additions and 42 deletions

View File

@ -1,6 +1,7 @@
<div class="tab-pane" id="inventories-panel">
<aw-limit-panels max-panels="2" panel-container="inventories-panel"></aw-limit-panels>
<div ui-view="adhocForm"></div>
<div ui-view="scheduler"></div>
<div ui-view="hostForm"></div>
<div ui-view="nestedGroupForm"></div>
<div ui-view="groupForm"></div>

View File

@ -5,10 +5,11 @@ export default {
name: 'inventories.edit.inventory_sources.edit.schedules.add',
url: '/add',
ncyBreadcrumb: {
parent: 'inventories.edit.inventory_sources.edit.schedules',
label: N_("CREATE SCHEDULE")
},
views: {
'form': {
'scheduler@inventories': {
controller: 'schedulerAddController',
templateUrl: templateUrl("scheduler/schedulerForm")
}

View File

@ -1,15 +1,18 @@
import {templateUrl} from '../../../../../../shared/template-url/template-url.factory';
import editScheduleResolve from '../../../../../../scheduler/editSchedule.resolve';
export default {
name: 'inventories.edit.inventory_sources.edit.schedules.edit',
url: '/:schedule_id',
ncyBreadcrumb: {
parent: "inventories.edit.inventory_sources.edit.schedules",
label: "{{schedule_obj.name}}"
},
views: {
'form': {
'scheduler@inventories': {
templateUrl: templateUrl("scheduler/schedulerForm"),
controller: 'schedulerEditController',
}
}
},
resolve: editScheduleResolve()
};

View File

@ -1,21 +1,35 @@
import { N_ } from '../../../../../../i18n';
export default {
searchPrefix: 'schedule',
name: 'inventories.edit.inventory_sources.edit.schedules',
url: '/schedules',
searchPrefix: 'schedule',
ncyBreadcrumb: {
parent: 'inventories.edit.inventory_sources.edit',
label: N_('SCHEDULES')
},
views: {
'related': {
templateProvider: function(SchedulesList, generateList){
SchedulesList.title = false;
let html = generateList.build({
list: SchedulesList,
mode: 'edit'
});
return html;
},
controller: 'schedulerListController'
}
},
resolve: {
Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath', 'inventorySourceData',
function(list, qs, $stateParams, GetBasePath, inventorySourceData) {
let path = `${inventorySourceData.related.schedules}`;
Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath', 'inventorySource',
function(list, qs, $stateParams, GetBasePath, inventorySource) {
let path = `${inventorySource.get().related.schedules}`;
return qs.search(path, $stateParams[`${list.iterator}_search`]);
}
],
ParentObject: ['inventorySourceData', function(inventorySourceData) {
return inventorySourceData;
ParentObject: ['inventorySource', function(inventorySource) {
return inventorySource.get();
}],
UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',
function(Rest, GetBasePath, $stateParams, $q) {
@ -29,32 +43,12 @@ export default {
});
return val.promise;
}],
ScheduleList: ['SchedulesList', 'inventorySourceData',
(SchedulesList, inventorySourceData) => {
ScheduleList: ['SchedulesList', 'inventorySource',
(SchedulesList, inventorySource) => {
let list = _.cloneDeep(SchedulesList);
list.basePath = `${inventorySourceData.related.schedules}`;
list.basePath = `${inventorySource.get().related.schedules}`;
return list;
}
]
},
views: {
// clear form template when views render in this substate
'form': {
templateProvider: () => ''
},
// target the un-named ui-view @ root level
'@': {
templateProvider: function(ScheduleList, generateList, ParentObject, $filter) {
// include name of parent resource in listTitle
ScheduleList.listTitle = `${$filter('sanitize')(ParentObject.name)}<div class='List-titleLockup'></div>` + N_('SCHEDULES');
let html = generateList.build({
list: ScheduleList,
mode: 'edit'
});
html = generateList.wrapPanel(html);
return "<div class='InventoryManage-container'>" + generateList.insertFormView() + html + "</div>";
},
controller: 'schedulerListController'
}
}
};

View File

@ -222,7 +222,7 @@
$scope.scheduleSource = function(id) {
// Add this inv source's id to the array of inv source id's so that it gets
// added to the breadcrumb trail
$state.go('inventories.edit.inventory_sources.edit.schedules', {inventory_source_id: id}, {reload: true});
$state.go('inventories.edit.inventory_sources.edit.schedules',{inventory_source_id: id});
};
$scope.syncAllSources = function() {

View File

@ -411,8 +411,14 @@ return {
},
related: {
notifications: notifications_object
notifications: notifications_object,
schedules: {
title: i18n._('Schedules'),
skipGenerator: true,
ngClick: "$state.go('inventories.edit.inventory_sources.edit.schedules')"
}
}
};
}];

View File

@ -7,9 +7,7 @@
import listController from './schedulerList.controller';
import addController from './schedulerAdd.controller';
import editController from './schedulerEdit.controller';
import {templateUrl} from '../shared/template-url/template-url.factory';
import schedulerDatePicker from './schedulerDatePicker.directive';
import { N_ } from '../i18n';
import DeleteSchedule from './factories/delete-schedule.factory';
import RRuleToAPI from './factories/r-rule-to-api.factory';
import SchedulePost from './factories/schedule-post.factory';

View File

@ -8,12 +8,12 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
'$scope', '$rootScope', 'CreateSelect2', 'ParseTypeChange', 'GetBasePath',
'Rest', 'ParentObject', 'JobTemplateModel', '$q', 'Empty', 'SchedulePost',
'ProcessErrors', 'SchedulerInit', '$location', 'PromptService', 'RRuleToAPI', 'moment',
'WorkflowJobTemplateModel', 'TemplatesStrings',
'WorkflowJobTemplateModel', 'TemplatesStrings', 'rbacUiControlService',
function($filter, $state, $stateParams, $http, Wait,
$scope, $rootScope, CreateSelect2, ParseTypeChange, GetBasePath,
Rest, ParentObject, JobTemplate, $q, Empty, SchedulePost,
ProcessErrors, SchedulerInit, $location, PromptService, RRuleToAPI, moment,
WorkflowJobTemplate, TemplatesStrings
WorkflowJobTemplate, TemplatesStrings, rbacUiControlService
) {
var base = $scope.base || $location.path().replace(/^\//, '').split('/')[0],
@ -21,7 +21,15 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
job_type;
var schedule_url = ParentObject.related.schedules || `${ParentObject.related.inventory_source}schedules`;
if (ParentObject){
$scope.parentObject = ParentObject;
let scheduleEndpoint = ParentObject.endpoint|| ParentObject.related.schedules || `${ParentObject.related.inventory_source}schedules`;
$scope.canAdd = false;
rbacUiControlService.canAdd(scheduleEndpoint)
.then(function(params) {
$scope.canAdd = params.canAdd;
});
}
let processSchedulerEndDt = function(){
// set the schedulerEndDt to be equal to schedulerStartDt + 1 day @ midnight
var dt = new Date($scope.schedulerUTCTime);

View File

@ -49,7 +49,7 @@ const jobTemplatesSchedulesListRoute = {
},
views: {
related: {
templateProvider: function(ScheduleList, generateList, ParentObject, $filter){
templateProvider: function(ScheduleList, generateList){
ScheduleList.title = false;
let html = generateList.build({
list: ScheduleList,
@ -141,7 +141,7 @@ const workflowSchedulesRoute = {
},
views: {
related: {
templateProvider: function(ScheduleList, generateList, ParentObject, $filter){
templateProvider: function(ScheduleList, generateList){
ScheduleList.title = false;
let html = generateList.build({
list: ScheduleList,
@ -232,7 +232,7 @@ const projectsSchedulesListRoute = {
},
views: {
related: {
templateProvider: function(ScheduleList, generateList, ParentObject, $filter){
templateProvider: function(ScheduleList, generateList){
ScheduleList.title = false;
let html = generateList.build({
list: ScheduleList,