CAUserProfile.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /**
  4. * Licensed Materials - Property of IBM
  5. * IBM Business Analytics (C) Copyright IBM Corp. 2020
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define(['../../../lib/@waca/dashboard-common/dist/core/APIFactory', '../../../features/dashboard/userProfile/UserProfileAPI'], function (APIFactory, UserProfileAPI) {
  9. /**
  10. * @class
  11. * @implements UserProfileAPI
  12. * @hideconstructor
  13. * @classdesc default implementation of the UserProfileAPI
  14. */
  15. var CAUserProfile = function () {
  16. function CAUserProfile() {
  17. _classCallCheck(this, CAUserProfile);
  18. this._api = APIFactory.createAPI(this, [UserProfileAPI]);
  19. }
  20. CAUserProfile.prototype.getAPI = function getAPI() {
  21. return this._api;
  22. };
  23. /**
  24. * Glass initialize method for services
  25. * @param {Object} glassContext
  26. */
  27. CAUserProfile.prototype.initialize = function initialize(glassContext) {
  28. var _this = this;
  29. this._userProfile = glassContext.getCoreSvc('.UserProfile');
  30. this._config = glassContext.getCoreSvc('.Config');
  31. return this._config.getConfigValue('ClientValidDomainList').then(function (list) {
  32. _this._validDomainList = list;
  33. });
  34. };
  35. /**
  36. *
  37. * @param {string} capabilityName
  38. * @returns {boolean} true/false based on CM capabilities
  39. */
  40. CAUserProfile.prototype.hasCapability = function hasCapability(capabilityName) {
  41. return this._userProfile.capabilities.indexOf(capabilityName) != -1;
  42. };
  43. CAUserProfile.prototype.getValidDomainList = function getValidDomainList() {
  44. return this._validDomainList;
  45. };
  46. /**
  47. * @returns {string} user content locale. Defaults to 'en'
  48. */
  49. CAUserProfile.prototype.getContentLocale = function getContentLocale() {
  50. var userPreferences = this._userProfile && this._userProfile.preferences;
  51. return userPreferences && userPreferences.contentLocale || 'en';
  52. };
  53. CAUserProfile.prototype.getAvailableContentLocales = function getAvailableContentLocales() {
  54. return this._config.getContentLocales();
  55. };
  56. CAUserProfile.prototype.getUserAccount = function getUserAccount() {
  57. var userAccount = this._userProfile.userAccount;
  58. return {
  59. defaultName: userAccount && userAccount.defaultName,
  60. userName: userAccount && userAccount.userName,
  61. id: userAccount && userAccount.id,
  62. email: userAccount && userAccount.email
  63. };
  64. };
  65. return CAUserProfile;
  66. }();
  67. return CAUserProfile;
  68. });
  69. //# sourceMappingURL=CAUserProfile.js.map