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

Copy/move groups/host route config and search init (#4396)

* beginning of fixing copy-move-groups

* Configure copy-move group route, initialize search in copy-move-group controller, fix stateExtender squashing

* Hook up copy-move-hosts route/controller, use generic "copy_search" as search parameter name

* lint

* fixes 400 error on copy group route
This commit is contained in:
Leigh Johnson 2016-12-15 14:53:38 -05:00 committed by GitHub
parent f77949b4b0
commit f8d75554b3
6 changed files with 72 additions and 61 deletions

View File

@ -5,10 +5,10 @@
*************************************************/
export default
['$scope', '$state', '$stateParams', 'generateList', 'GroupManageService', 'GetBasePath', 'CopyMoveGroupList', 'group',
function($scope, $state, $stateParams, GenerateList, GroupManageService, GetBasePath, CopyMoveGroupList, group){
var list = CopyMoveGroupList,
view = GenerateList;
['$scope', '$state', '$stateParams', 'GroupManageService', 'GetBasePath', 'CopyMoveGroupList', 'group', 'Dataset',
function($scope, $state, $stateParams, GroupManageService, GetBasePath, CopyMoveGroupList, group, Dataset){
var list = CopyMoveGroupList;
$scope.item = group;
$scope.submitMode = $stateParams.groups === undefined ? 'move' : 'copy';
$scope['toggle_'+ list.iterator] = function(id){
@ -58,33 +58,18 @@
$(el).prop('disabled', (idx, value) => !value);
});
};
var init = function(){
var url = GetBasePath('inventory') + $stateParams.inventory_id + '/groups/';
url += $stateParams.group ? '?not__id__in=' + group.id + ',' + _.last($stateParams.group) : '?not__id=' + group.id;
list.basePath = url;
$scope.atRootLevel = $stateParams.group ? false : true;
view.inject(list, {
mode: 'lookup',
id: 'copyMove-list',
scope: $scope,
input_type: 'radio'
});
// @issue: OLD SEARCH
// SearchInit({
// scope: $scope,
// set: list.name,
// list: list,
// url: url
// });
// PaginateInit({
// scope: $scope,
// list: list,
// url : url,
// mode: 'lookup'
// });
// $scope.search(list.iterator, null, true, false);
// remove the current group from list
};
function init(){
var url = GetBasePath('inventory') + $stateParams.inventory_id + '/groups/';
url += $stateParams.group ? '?not__id__in=' + group.id + ',' + _.last($stateParams.group) : '?not__id=' + group.id;
list.basePath = url;
$scope.atRootLevel = $stateParams.group ? false : true;
// search init
$scope.list = list;
$scope[`${list.iterator}_dataset`] = Dataset.data;
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
}
init();
}];

View File

@ -5,10 +5,10 @@
*************************************************/
export default
['$scope', '$state', '$stateParams', 'generateList', 'HostManageService', 'GetBasePath', 'CopyMoveGroupList', 'host',
function($scope, $state, $stateParams, GenerateList, HostManageService, GetBasePath, CopyMoveGroupList, host){
var list = CopyMoveGroupList,
view = GenerateList;
['$scope', '$state', '$stateParams', 'generateList', 'HostManageService', 'GetBasePath', 'CopyMoveGroupList', 'host', 'Dataset',
function($scope, $state, $stateParams, GenerateList, HostManageService, GetBasePath, CopyMoveGroupList, host, Dataset){
var list = CopyMoveGroupList;
$scope.item = host;
$scope.submitMode = 'copy';
$scope['toggle_'+ list.iterator] = function(id){
@ -40,29 +40,11 @@
}
};
var init = function(){
var url = GetBasePath('inventory') + $stateParams.inventory_id + '/groups/';
list.basePath = url;
view.inject(list, {
mode: 'lookup',
id: 'copyMove-list',
scope: $scope,
input_type: 'radio'
});
// search init
$scope.list = list;
$scope[`${list.iterator}_dataset`] = Dataset.data;
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
// @issue: OLD SEARCH
// SearchInit({
// scope: $scope,
// set: list.name,
// list: list,
// url: url
// });
// PaginateInit({
// scope: $scope,
// list: list,
// url : url,
// mode: 'lookup'
// });
// $scope.search(list.iterator, null, true, false);
};
init();
}];

View File

@ -10,7 +10,7 @@
<input type="radio" ng-model="submitMode" value="move" class="ng-pristine ng-untouched ng-valid"> Move
</label>
</div>
<div id="copyMove-list"></div>
<div id="copyMove-list" ui-view="copyMoveList"></div>
<div class="copyMove-root form-group pull-left" ng-hide="atRootLevel">
<span><input type="checkbox" ng-model="targetRootGroup" ng-change="toggleTargetRootGroup()"> Use the inventory root</span>
</div>

View File

@ -10,14 +10,31 @@ import CopyMoveHostsController from './copy-move-hosts.controller';
var copyMoveGroupRoute = {
name: 'inventoryManage.copyMoveGroup',
url: '/copy-move-group/{group_id}',
url: '/copy-move-group/{group_id:int}',
searchPrefix: 'copy',
data: {
group_id: 'group_id',
},
params: {
copy_search: {
value: {
not__id__in: null
},
dynamic: true,
squash: ''
}
},
ncyBreadcrumb: {
label: "COPY OR MOVE {{item.name}}"
},
resolve: {
Dataset: ['CopyMoveGroupList', 'QuerySet', '$stateParams', 'GetBasePath', 'group',
function(list, qs, $stateParams, GetBasePath, group) {
$stateParams.copy_search.not__id__in = ($stateParams.group.length > 0 ? group.id + ',' + _.last($stateParams.group) : group.id);
let path = GetBasePath(list.name);
return qs.search(path, $stateParams.copy_search);
}
],
group: ['GroupManageService', '$stateParams', function(GroupManageService, $stateParams){
return GroupManageService.get({id: $stateParams.group_id}).then(res => res.data.results[0]);
}]
@ -26,16 +43,33 @@ var copyMoveGroupRoute = {
'form@inventoryManage' : {
controller: CopyMoveGroupsController,
templateUrl: templateUrl('inventories/manage/copy-move/copy-move'),
},
'copyMoveList@inventoryManage.copyMoveGroup': {
templateProvider: function(CopyMoveGroupList, generateList) {
let html = generateList.build({
list: CopyMoveGroupList,
mode: 'lookup',
input_type: 'radio'
});
return html;
}
}
}
};
var copyMoveHostRoute = {
name: 'inventoryManage.copyMoveHost',
url: '/copy-move-host/{host_id}',
searchPrefix: 'copy',
ncyBreadcrumb: {
label: "COPY OR MOVE {{item.name}}"
},
resolve: {
Dataset: ['CopyMoveGroupList', 'QuerySet', '$stateParams', 'GetBasePath',
function(list, qs, $stateParams, GetBasePath) {
let path = GetBasePath(list.name);
return qs.search(path, $stateParams.copy_search);
}
],
host: ['HostManageService', '$stateParams', function(HostManageService, $stateParams){
return HostManageService.get({id: $stateParams.host_id}).then(res => res.data.results[0]);
}]
@ -44,6 +78,16 @@ var copyMoveHostRoute = {
'form@inventoryManage': {
templateUrl: templateUrl('inventories/manage/copy-move/copy-move'),
controller: CopyMoveHostsController,
},
'copyMoveList@inventoryManage.copyMoveHost': {
templateProvider: function(CopyMoveGroupList, generateList) {
let html = generateList.build({
list: CopyMoveGroupList,
mode: 'lookup',
input_type: 'radio'
});
return html;
}
}
}
};

View File

@ -12,7 +12,7 @@ export default
.value('CopyMoveGroupList', {
name: 'groups',
iterator: 'group',
iterator: 'copy',
selectTitle: 'Copy Groups',
index: false,
well: false,

View File

@ -31,7 +31,7 @@ export default function($stateProvider) {
order_by: "name"
},
dynamic: true,
squash: true
squash: ''
}
}
};