UI-Router: inventories manage, with nested groups

containing their own routes
This commit is contained in:
Jared Tabor
2015-12-16 15:53:33 -08:00
parent 5e777bd992
commit c06250fc57
9 changed files with 794 additions and 697 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -16,7 +16,7 @@ export function InventoriesList($scope, $rootScope, $location, $log,
$routeParams, $compile, $filter, sanitizeFilter, Rest, Alert, InventoryList, generateList, $routeParams, $compile, $filter, sanitizeFilter, Rest, Alert, InventoryList, generateList,
LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
ClearScope, ProcessErrors, GetBasePath, Wait, Stream, ClearScope, ProcessErrors, GetBasePath, Wait, Stream,
EditInventoryProperties, Find, Empty, LogViewer) { EditInventoryProperties, Find, Empty, LogViewer, $state) {
var list = InventoryList, var list = InventoryList,
defaultUrl = GetBasePath('inventory'), defaultUrl = GetBasePath('inventory'),
@@ -312,7 +312,8 @@ export function InventoriesList($scope, $rootScope, $location, $log,
}; };
$scope.addInventory = function () { $scope.addInventory = function () {
$location.path($location.path() + '/add'); // $location.path($location.path() + '/add');
$state.go('inventories.add');
}; };
$scope.editInventory = function (id) { $scope.editInventory = function (id) {
@@ -369,7 +370,7 @@ export function InventoriesList($scope, $rootScope, $location, $log,
InventoriesList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', '$compile', '$filter', 'sanitizeFilter', 'Rest', 'Alert', 'InventoryList', 'generateList', InventoriesList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', '$compile', '$filter', 'sanitizeFilter', 'Rest', 'Alert', 'InventoryList', 'generateList',
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors',
'GetBasePath', 'Wait', 'Stream', 'EditInventoryProperties', 'Find', 'Empty', 'LogViewer' 'GetBasePath', 'Wait', 'Stream', 'EditInventoryProperties', 'Find', 'Empty', 'LogViewer', '$state'
]; ];
@@ -792,14 +793,14 @@ InventoriesEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$lo
export function InventoriesManage ($log, $scope, $rootScope, $location, export function InventoriesManage ($log, $scope, $rootScope, $location,
$routeParams, $compile, generateList, ClearScope, Empty, Wait, Rest, Alert, $state, $compile, generateList, ClearScope, Empty, Wait, Rest, Alert,
LoadBreadCrumbs, GetBasePath, ProcessErrors, Breadcrumbs, InventoryGroups, LoadBreadCrumbs, GetBasePath, ProcessErrors, Breadcrumbs, InventoryGroups,
InjectHosts, Find, HostsReload, SearchInit, PaginateInit, GetSyncStatusMsg, InjectHosts, Find, HostsReload, SearchInit, PaginateInit, GetSyncStatusMsg,
GetHostsStatusMsg, GroupsEdit, InventoryUpdate, GroupsCancelUpdate, GetHostsStatusMsg, GroupsEdit, InventoryUpdate, GroupsCancelUpdate,
ViewUpdateStatus, GroupsDelete, Store, HostsEdit, HostsDelete, ViewUpdateStatus, GroupsDelete, Store, HostsEdit, HostsDelete,
EditInventoryProperties, ToggleHostEnabled, Stream, ShowJobSummary, EditInventoryProperties, ToggleHostEnabled, Stream, ShowJobSummary,
InventoryGroupsHelp, HelpDialog, ViewJob, InventoryGroupsHelp, HelpDialog, ViewJob,
GroupsCopy, HostsCopy, transitionTo) { GroupsCopy, HostsCopy, $stateParams) {
var PreviousSearchParams, var PreviousSearchParams,
url, url,
@@ -1040,7 +1041,7 @@ export function InventoriesManage ($log, $scope, $rootScope, $location,
}); });
// Load Inventory // Load Inventory
url = GetBasePath('inventory') + $routeParams.inventory_id + '/'; url = GetBasePath('inventory') + $stateParams.inventory_id + '/';
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function (data) { .success(function (data) {
@@ -1132,7 +1133,13 @@ export function InventoriesManage ($log, $scope, $rootScope, $location,
}; };
$scope.groupSelect = function(id) { $scope.groupSelect = function(id) {
var group = Find({ list: $scope.groups, key: 'id', val: id }); var groups = [], group = Find({ list: $scope.groups, key: 'id', val: id });
if($state.params.groups){
groups.push($state.params.groups);
}
groups.push(group.id);
groups = groups.join();
$state.transitionTo('inventoriesManage', {inventory_id: $state.params.inventory_id, groups: groups}, { notify: false });
$scope.group_breadcrumbs.push(group); $scope.group_breadcrumbs.push(group);
setActiveGroupBreadcrumb(); setActiveGroupBreadcrumb();
loadGroups(group.related.children, group.id); loadGroups(group.related.children, group.id);
@@ -1401,7 +1408,7 @@ export function InventoriesManage ($log, $scope, $rootScope, $location,
InventoriesManage.$inject = ['$log', '$scope', '$rootScope', '$location', InventoriesManage.$inject = ['$log', '$scope', '$rootScope', '$location',
'$routeParams', '$compile', 'generateList', 'ClearScope', 'Empty', 'Wait', '$state', '$compile', 'generateList', 'ClearScope', 'Empty', 'Wait',
'Rest', 'Alert', 'LoadBreadCrumbs', 'GetBasePath', 'ProcessErrors', 'Rest', 'Alert', 'LoadBreadCrumbs', 'GetBasePath', 'ProcessErrors',
'Breadcrumbs', 'InventoryGroups', 'InjectHosts', 'Find', 'HostsReload', 'Breadcrumbs', 'InventoryGroups', 'InjectHosts', 'Find', 'HostsReload',
'SearchInit', 'PaginateInit', 'GetSyncStatusMsg', 'GetHostsStatusMsg', 'SearchInit', 'PaginateInit', 'GetSyncStatusMsg', 'GetHostsStatusMsg',
@@ -1409,5 +1416,5 @@ InventoriesManage.$inject = ['$log', '$scope', '$rootScope', '$location',
'GroupsDelete', 'Store', 'HostsEdit', 'HostsDelete', 'GroupsDelete', 'Store', 'HostsEdit', 'HostsDelete',
'EditInventoryProperties', 'ToggleHostEnabled', 'Stream', 'ShowJobSummary', 'EditInventoryProperties', 'ToggleHostEnabled', 'Stream', 'ShowJobSummary',
'InventoryGroupsHelp', 'HelpDialog', 'ViewJob', 'GroupsCopy', 'InventoryGroupsHelp', 'HelpDialog', 'ViewJob', 'GroupsCopy',
'HostsCopy', 'transitionTo' 'HostsCopy', '$stateParams'
]; ];

View File

@@ -22,9 +22,9 @@
* @description * @description
*/ */
export default export default
['$rootScope', '$cookieStore', 'transitionTo', 'CreateDialog', 'Authorization', ['$rootScope', '$cookieStore', 'CreateDialog', 'Authorization',
'Store', '$interval', '$location', '$q', 'Store', '$interval', '$location', '$q',
function ($rootScope, $cookieStore, transitionTo, CreateDialog, Authorization, function ($rootScope, $cookieStore, CreateDialog, Authorization,
Store, $interval, $location, $q) { Store, $interval, $location, $q) {
return { return {

View File

@@ -16,4 +16,5 @@ export default {
} }
$(".LoginModal-dialog").remove(); $(".LoginModal-dialog").remove();
}] }]
}; };

View File

@@ -13,7 +13,7 @@ import logoutRoute from './logout.route';
export default export default
angular.module('login', [authentication.name, loginModal.name]) angular.module('login', [authentication.name, loginModal.name])
.config(['$routeProvider', function($routeProvider) { .config(['$routeProvider', function($routeProvider) {
var url = loginRoute.route; var url = loginRoute.url;
delete loginRoute.route; delete loginRoute.route;
$routeProvider.when(url, loginRoute); $routeProvider.when(url, loginRoute);
url = logoutRoute.route; url = logoutRoute.route;

View File

@@ -87,7 +87,7 @@
</a> </a>
<a class="MainMenu-item MainMenu-item--notMobile MainMenu-item--left" <a class="MainMenu-item MainMenu-item--notMobile MainMenu-item--left"
id="main_menu_inventories_link" id="main_menu_inventories_link"
href="/#/inventories" ui-sref="inventories"
ng-class="{'is-currentRoute' : isCurrentRoute('inventories'), 'is-loggedOut' : !$root.current_user.username}"> ng-class="{'is-currentRoute' : isCurrentRoute('inventories'), 'is-loggedOut' : !$root.current_user.username}">
<span class="MainMenu-itemText"> <span class="MainMenu-itemText">
INVENTORIES INVENTORIES

View File

@@ -1,4 +1,5 @@
<div class="tab-pane" id="inventories"> <div class="tab-pane" id="inventories">
<div ui-view></div>
<div ng-cloak id="htmlTemplate"></div> <div ng-cloak id="htmlTemplate"></div>
<div id="inventory-edit-modal-dialog"></div> <div id="inventory-edit-modal-dialog"></div>
<div id="scan-jobs-list" style="padding-top:40px"></div> <div id="scan-jobs-list" style="padding-top:40px"></div>

View File

@@ -0,0 +1,14 @@
<div class="tab-pane" id="inventories-add">
<div ng-cloak id="htmlTemplate"></div>
<div id="inventory-edit-modal-dialog"></div>
<div id="scan-jobs-list" style="padding-top:40px"></div>
<div ng-include="'/static/partials/logviewer.html'"></div>
<div id="copy-job-modal" style="display:none">
<form name="copy_form" id="copy_form">
What would you like to name the copy of job template <b><span id=job_name></span></b>?<br>
<input id="new_copy_name" name="new_copy_name" ng-model ="new_copy_name" ng-required="true" class="form-control ng-pristine ng-invalid-required ng-invalid" style="margin-top:10px;">
<div class="error survey_error ng-hide" ng-show="copy_form.new_copy_name.$dirty && copy_form.new_copy_name.$error.required">Please enter a name for this job template copy.</div></input>
</form>
</div>
</div>

View File

@@ -46,7 +46,8 @@
<div class="container-fluid" id="#content-container"> <div class="container-fluid" id="#content-container">
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<div ng-view id="main-view"></div> <!-- <div ng-view id="main-view"></div> -->
<div ui-view id="main-view"></div>
</div> </div>
</div> </div>
@@ -171,7 +172,8 @@
save one fact scan (snapshot) per time window (frequency). save one fact scan (snapshot) per time window (frequency).
For example, facts older than 30 days are purged, while one For example, facts older than 30 days are purged, while one
weekly fact scan is kept.<br> weekly fact scan is kept.<br>
Caution: Setting both numerical variables to "0" will delete all facts.<br></div> Caution: Setting both numerical variables to "0" will delete all facts.<br>
</div>
<div class="form-group "> <div class="form-group ">
<label for="description"> <label for="description">
<span class="label-text"> <span class="label-text">
@@ -211,7 +213,7 @@
prompt_for_days_facts_form.granularity_keep_amount.$error.min || prompt_for_days_facts_form.granularity_keep_amount.$error.min ||
prompt_for_days_facts_form.granularity_keep_amount.$error.max)">Please enter an integer<span ng-show="prompt_for_days_facts_form.granularity_keep_amount.$dirty && prompt_for_days_facts_form.granularity_keep_amount.$error.min"> that is not negative</span><span ng-show="prompt_for_days_facts_form.granularity_keep_amount.$dirty && prompt_for_days_facts_form.granularity_keep_amount.$error.max"> that is lower than 9999</span>.</div> prompt_for_days_facts_form.granularity_keep_amount.$error.max)">Please enter an integer<span ng-show="prompt_for_days_facts_form.granularity_keep_amount.$dirty && prompt_for_days_facts_form.granularity_keep_amount.$error.min"> that is not negative</span><span ng-show="prompt_for_days_facts_form.granularity_keep_amount.$dirty && prompt_for_days_facts_form.granularity_keep_amount.$error.max"> that is lower than 9999</span>.</div>
</div> </div>
</div>
</form> </form>
</div> </div>
@@ -220,7 +222,7 @@
<div class="overlay"></div> <div class="overlay"></div>
<div class="spinny"><i class="fa fa-cog fa-spin fa-2x"></i> <p>working...</p></div> <div class="spinny"><i class="fa fa-cog fa-spin fa-2x"></i> <p>working...</p></div>
<div class="site-footer"></div> <!-- <div class="site-footer"></div> -->
<tower-footer></tower-footer> <tower-footer></tower-footer>
<script> <script>
// HACK: Need this to support global-dependent // HACK: Need this to support global-dependent