routes.ts 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Password Management Servlets (PWM)
  3. * http://www.pwm-project.org
  4. *
  5. * Copyright (c) 2006-2009 Novell, Inc.
  6. * Copyright (c) 2009-2021 The PWM Project
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. */
  20. import { IPeopleSearchConfigService } from './services/peoplesearch-config.service';
  21. import { IQService } from 'angular';
  22. import LocalStorageService from './services/local-storage.service';
  23. export default [
  24. '$stateProvider',
  25. '$urlRouterProvider',
  26. (
  27. $stateProvider: angular.ui.IStateProvider,
  28. $urlRouterProvider: angular.ui.IUrlRouterProvider
  29. ) => {
  30. $urlRouterProvider.otherwise(
  31. ($injector: angular.auto.IInjectorService, $location: angular.ILocationService) => {
  32. let $state: angular.ui.IStateService = <angular.ui.IStateService>$injector.get('$state');
  33. let localStorageService: LocalStorageService =
  34. <LocalStorageService>$injector.get('LocalStorageService');
  35. let storedView = localStorageService.getItem(localStorageService.keys.SEARCH_VIEW);
  36. if (storedView) {
  37. $state.go(storedView);
  38. }
  39. else {
  40. $location.url('search/cards');
  41. }
  42. });
  43. $stateProvider.state('search', {
  44. url: '/search?query',
  45. abstract: true,
  46. template: '<div class="people-search-component"><ui-view/></div>',
  47. });
  48. $stateProvider.state('search.table', { url: '/table', component: 'peopleSearchTable' });
  49. $stateProvider.state('search.cards', { url: '/cards', component: 'peopleSearchCards' });
  50. $stateProvider.state('search.table.details', {
  51. url: '/details/{personId}',
  52. component: 'personDetailsDialogComponent'
  53. });
  54. $stateProvider.state('search.cards.details', {
  55. url: '/details/{personId}',
  56. component: 'personDetailsDialogComponent'
  57. });
  58. $stateProvider.state('orgchart', { url: '/orgchart?query',
  59. abstract: true,
  60. template: '<ui-view/>',
  61. resolve: {
  62. enabled: [
  63. '$q',
  64. 'ConfigService',
  65. ($q: IQService, configService: IPeopleSearchConfigService) => {
  66. let deferred = $q.defer();
  67. configService
  68. .orgChartEnabled()
  69. .then((orgChartEnabled: boolean) => {
  70. if (!orgChartEnabled) {
  71. deferred.reject('OrgChart disabled');
  72. }
  73. else {
  74. deferred.resolve();
  75. }
  76. });
  77. return deferred.promise;
  78. }]
  79. }
  80. });
  81. $stateProvider.state('orgchart.index', { url: '', component: 'orgChartSearch' });
  82. $stateProvider.state('orgchart.search', { url: '/{personId}', component: 'orgChartSearch' });
  83. $stateProvider.state('orgchart.search.details', { url: '/details', component: 'personDetailsDialogComponent' });
  84. }];