person-details-dialog.component.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 { Component } from '../../component';
  21. import {IPeopleSearchConfigService, IPersonDetailsConfig} from '../../services/peoplesearch-config.service';
  22. import { IPeopleService } from '../../services/people.service';
  23. import {IAugmentedJQuery, ITimeoutService, noop} from 'angular';
  24. import { IPerson } from '../../models/person.model';
  25. import {IChangePasswordSuccess} from '../../components/changepassword/success-change-password.controller';
  26. let orgchartExportTemplateUrl = require('./orgchart-export.component.html');
  27. let orgchartEmailTemplateUrl = require('./orgchart-email.component.html');
  28. @Component({
  29. stylesheetUrl: require('./person-details-dialog.component.scss'),
  30. templateUrl: require('./person-details-dialog.component.html')
  31. })
  32. export default class PersonDetailsDialogComponent {
  33. person: IPerson;
  34. photosEnabled: boolean;
  35. orgChartEnabled: boolean;
  36. exportEnabled: boolean;
  37. emailTeamEnabled: boolean;
  38. maxExportDepth: number;
  39. maxEmailDepth: number;
  40. static $inject = [
  41. '$element',
  42. '$state',
  43. '$stateParams',
  44. '$timeout',
  45. 'ConfigService',
  46. 'PeopleService',
  47. 'IasDialogService'
  48. ];
  49. constructor(private $element: IAugmentedJQuery,
  50. private $state: angular.ui.IStateService,
  51. private $stateParams: angular.ui.IStateParamsService,
  52. private $timeout: ITimeoutService,
  53. private configService: IPeopleSearchConfigService,
  54. private peopleService: IPeopleService,
  55. private IasDialogService: any) {
  56. }
  57. $onInit(): void {
  58. const personId = this.$stateParams['personId'];
  59. this.configService.orgChartEnabled().then((orgChartEnabled: boolean) => {
  60. this.orgChartEnabled = orgChartEnabled;
  61. });
  62. this.configService.photosEnabled().then((photosEnabled: boolean) => {
  63. this.photosEnabled = photosEnabled;
  64. });
  65. this.configService.personDetailsConfig().then((personDetailsConfig: IPersonDetailsConfig) => {
  66. this.photosEnabled = personDetailsConfig.photosEnabled;
  67. this.orgChartEnabled = personDetailsConfig.orgChartEnabled;
  68. this.exportEnabled = personDetailsConfig.exportEnabled;
  69. this.emailTeamEnabled = personDetailsConfig.emailTeamEnabled;
  70. this.maxExportDepth = personDetailsConfig.maxExportDepth;
  71. this.maxEmailDepth = personDetailsConfig.maxEmailDepth;
  72. });
  73. this.peopleService
  74. .getPerson(personId)
  75. .then(
  76. (person: IPerson) => {
  77. this.person = person;
  78. },
  79. (error) => {
  80. // TODO: Handle error. NOOP for now will not assign person
  81. });
  82. }
  83. $postLink() {
  84. const self = this;
  85. this.$timeout(() => {
  86. self.$element.find('button')[0].focus();
  87. }, 100);
  88. }
  89. closeDialog(): void {
  90. this.$state.go('^', { query: this.$stateParams['query'] });
  91. }
  92. getAvatarStyle(): any {
  93. if (!this.person || !this.person.photoURL || !this.photosEnabled) {
  94. return null;
  95. }
  96. return { 'background-image': 'url(' + this.person.photoURL + ')' };
  97. }
  98. gotoOrgChart(): void {
  99. this.$state.go('orgchart.search', { personId: this.person.userKey });
  100. }
  101. getPersonDetailsUrl(personId: string): string {
  102. return this.$state.href('.', { personId: personId }, { inherit: true, });
  103. }
  104. searchText(text: string): void {
  105. this.$state.go('search.table', { query: text });
  106. }
  107. beginExport() {
  108. this.IasDialogService
  109. .open({
  110. controller: 'OrgchartExportController as $ctrl',
  111. templateUrl: orgchartExportTemplateUrl,
  112. locals: {
  113. peopleService: this.peopleService,
  114. maxDepth: this.maxExportDepth,
  115. personName: this.person.displayNames[0],
  116. userKey: this.person.userKey
  117. }
  118. });
  119. }
  120. beginEmail() {
  121. this.IasDialogService
  122. .open({
  123. controller: 'OrgchartEmailController as $ctrl',
  124. templateUrl: orgchartEmailTemplateUrl,
  125. locals: {
  126. peopleService: this.peopleService,
  127. maxDepth: this.maxEmailDepth,
  128. personName: this.person.displayNames[0],
  129. userKey: this.person.userKey
  130. }
  131. });
  132. }
  133. }