group_badge.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * This file is part of Threema Web.
  3. *
  4. * Threema Web is free software: you can redistribute it and/or modify it
  5. * under the terms of the GNU Affero General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or (at
  7. * your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Affero General Public License
  15. * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. import {StateService as UiStateService} from '@uirouter/angularjs';
  18. /**
  19. * Show a contact receiver with small avatar, name and verification level
  20. */
  21. export default [
  22. '$translate',
  23. '$state',
  24. function($translate, $state: UiStateService) {
  25. return {
  26. restrict: 'EA',
  27. scope: {},
  28. bindToController: {
  29. groupReceiver: '=eeeGroupReceiver',
  30. contactReceiver: '=?eeeContactReceiver',
  31. },
  32. controllerAs: 'ctrl',
  33. controller: [function() {
  34. this.click = () => {
  35. $state.go('messenger.home.conversation', {
  36. type: 'group',
  37. id: this.groupReceiver.id,
  38. initParams: null,
  39. });
  40. };
  41. this.$onInit = function() {
  42. this.showRoleIcon = this.contactReceiver !== undefined;
  43. if (this.showRoleIcon) {
  44. if (this.contactReceiver.id === this.groupReceiver.administrator) {
  45. this.roleIcon = 'people';
  46. $translate('messenger.GROUP_ROLE_CREATOR')
  47. .then((label) => this.roleName = label);
  48. } else {
  49. this.roleIcon = 'people_outline';
  50. $translate('messenger.GROUP_ROLE_NORMAL')
  51. .then((label) => this.roleName = label);
  52. }
  53. }
  54. };
  55. }],
  56. template: `
  57. <div class="group-badge receiver-badge" ng-click="ctrl.click()">
  58. <section class="avatar-box">
  59. <eee-avatar eee-receiver="ctrl.groupReceiver"
  60. eee-resolution="'low'"></eee-avatar>
  61. </section>
  62. <div class="receiver-badge-name"
  63. ng-bind-html="ctrl.groupReceiver.displayName | escapeHtml | emojify">
  64. </div>
  65. <div class="receiver-role" ng-if="ctrl.showRoleIcon" title="{{ctrl.roleLabel}}">
  66. <md-icon aria-label="{{ctrl.roleLabel}}" class="material-icons md-24">
  67. {{ctrl.roleIcon}}
  68. </md-icon>
  69. </div>
  70. </div>
  71. `,
  72. };
  73. },
  74. ];