my_identity.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 {u8aToHex} from '../helpers';
  18. export default [
  19. '$mdDialog',
  20. function($mdDialog) {
  21. return {
  22. restrict: 'EA',
  23. scope: {},
  24. bindToController: {
  25. identity: '=eeeIdentity',
  26. },
  27. controllerAs: 'ctrl',
  28. controller: [function() {
  29. this.showQRCode = () => {
  30. let identity: threema.Identity = this.identity;
  31. $mdDialog.show({
  32. controllerAs: 'ctrl',
  33. controller: [function() {
  34. this.cancel = () => {
  35. $mdDialog.cancel();
  36. };
  37. this.identity = identity;
  38. this.qrCode = {
  39. errorCorrectionLevel: 'L',
  40. size: '400px',
  41. data: '3mid:'
  42. + identity.identity
  43. + ','
  44. + u8aToHex(new Uint8Array(identity.publicKey)),
  45. };
  46. }],
  47. templateUrl: 'partials/dialog.myidentity.html',
  48. parent: angular.element(document.body),
  49. clickOutsideToClose: true,
  50. fullscreen: true,
  51. });
  52. };
  53. }],
  54. template: `
  55. <div class="my-threema-information" ng-click="ctrl.showQRCode()">
  56. <div class="nickname" ng-cloak
  57. ng-bind-html="ctrl.identity.publicNickname | emojify | emptyToPlaceholder: '-'">
  58. </div>
  59. </div>
  60. `,
  61. };
  62. },
  63. ];