mobicloud-core 1.0.93 → 1.0.94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -866,6 +866,27 @@
866
866
  return MobiUserProfile;
867
867
  }());
868
868
 
869
+ var ApplicationDetails = /** @class */ (function () {
870
+ function ApplicationDetails() {
871
+ }
872
+ return ApplicationDetails;
873
+ }());
874
+ var ProfileDetails = /** @class */ (function () {
875
+ function ProfileDetails() {
876
+ }
877
+ return ProfileDetails;
878
+ }());
879
+ var ProfileImage = /** @class */ (function () {
880
+ function ProfileImage() {
881
+ }
882
+ return ProfileImage;
883
+ }());
884
+ (function (MapProvider) {
885
+ MapProvider["None"] = "None";
886
+ MapProvider["Bing"] = "Bing";
887
+ MapProvider["Google"] = "Google";
888
+ })(exports.MapProvider || (exports.MapProvider = {}));
889
+
869
890
  var MobicloudCoreService = /** @class */ (function () {
870
891
  function MobicloudCoreService(httpClient, configService) {
871
892
  var _this = this;
@@ -879,6 +900,8 @@
879
900
  this.mobiUserProfileObservable = this.mobiUserProfileSource.asObservable();
880
901
  this.applicationDetailsSource = new rxjs.BehaviorSubject(undefined);
881
902
  this.applicationDetailsObservable = this.applicationDetailsSource.asObservable();
903
+ this.profileDetailsSource = new rxjs.BehaviorSubject(undefined);
904
+ this.profileDetailsObservable = this.profileDetailsSource.asObservable();
882
905
  this.countriesSource = new rxjs.BehaviorSubject(undefined);
883
906
  this.countriesObservable = this.countriesSource.asObservable();
884
907
  this.manager = new oidcClient.UserManager({
@@ -911,6 +934,8 @@
911
934
  this.mobiUserProfileSource.next(undefined);
912
935
  this.applicationDetailsSource.next(undefined);
913
936
  }
937
+ this.fetchProfileDetails().then(function (res) {
938
+ });
914
939
  };
915
940
  MobicloudCoreService.prototype.getApplicationDetails = function () {
916
941
  this.fetchApplicationDetails().then(function (appdetails) {
@@ -937,15 +962,14 @@
937
962
  _this.applicationDetails = appDetails;
938
963
  if (_this.applicationDetails) {
939
964
  _this.applicationDetailsSource.next(_this.applicationDetails);
940
- console.log("Current ApplicationDetails", _this.applicationDetails);
941
965
  }
942
966
  else {
943
967
  _this.applicationDetailsSource.next(undefined);
944
- console.log("An empty ApplicationDetails was returned");
945
968
  }
946
969
  return appDetails;
947
970
  }, function (err) {
948
971
  console.error("fetchApplicationDetails error:", err);
972
+ _this.applicationDetails = undefined;
949
973
  _this.applicationDetailsSource.next(undefined);
950
974
  return undefined;
951
975
  }));
@@ -953,12 +977,14 @@
953
977
  }
954
978
  else {
955
979
  console.warn("ApplicationDetails is null, MasterOrganization is not selected");
980
+ this.applicationDetails = undefined;
956
981
  this.applicationDetailsSource.next(undefined);
957
982
  return new Promise(function (resolve) { resolve(undefined); });
958
983
  }
959
984
  }
960
985
  else {
961
986
  console.warn("ApplicationDetails is null, user not authenticated");
987
+ this.applicationDetails = undefined;
962
988
  this.applicationDetailsSource.next(undefined);
963
989
  return new Promise(function (resolve) { resolve(undefined); });
964
990
  }
@@ -975,17 +1001,66 @@
975
1001
  console.error(err);
976
1002
  })).toPromise();
977
1003
  };
1004
+ MobicloudCoreService.prototype.fetchProfileDetails = function () {
1005
+ var _this = this;
1006
+ var _a;
1007
+ if (this.isAuthenticated() && ((_a = this.mobiUserProfile) === null || _a === void 0 ? void 0 : _a.user_id)) {
1008
+ var url;
1009
+ if (this.mobiUserProfile.isEmployeeUser) {
1010
+ url = this.configService.getMobiManagementDataUrl() + "employee(" + this.mobiUserProfile.user_id + ")?$expand=Image($select=StorageAccountName,BlobContainerName,BlobName)";
1011
+ }
1012
+ else if (this.mobiUserProfile.isCustomerUser) {
1013
+ url = this.configService.getMobiManagementDataUrl() + "customeruser(" + this.mobiUserProfile.user_id + ")?$expand=Image($select=StorageAccountName,BlobContainerName,BlobName)";
1014
+ }
1015
+ else if (this.mobiUserProfile.isVendorUser) {
1016
+ url = this.configService.getMobiManagementDataUrl() + "vendoruser(" + this.mobiUserProfile.user_id + ")?$expand=Image($select=StorageAccountName,BlobContainerName,BlobName)";
1017
+ }
1018
+ if (url) {
1019
+ var applicationDetail_Observable = this.httpClient.get(url)
1020
+ .pipe(operators.timeout(15000), operators.catchError(this.handleError)).pipe(operators.map(function (user_result) {
1021
+ var _a, _b, _c, _d;
1022
+ var profile_details;
1023
+ if (user_result.value) {
1024
+ _this.profileDetails = Object.assign(new ProfileDetails(), { Id: (_b = (_a = user_result.value[0]) === null || _a === void 0 ? void 0 : _a.Id) === null || _b === void 0 ? void 0 : _b.toString(), Name: (_c = user_result.value[0]) === null || _c === void 0 ? void 0 : _c.Name, Image: (_d = user_result.value[0]) === null || _d === void 0 ? void 0 : _d.Image });
1025
+ if (_this.profileDetails) {
1026
+ _this.profileDetailsSource.next(_this.profileDetails);
1027
+ }
1028
+ else {
1029
+ _this.profileDetailsSource.next(undefined);
1030
+ }
1031
+ }
1032
+ return profile_details;
1033
+ }, function (err) {
1034
+ console.error("fetchApplicationDetails error:", err);
1035
+ _this.profileDetails = undefined;
1036
+ _this.profileDetailsSource.next(undefined);
1037
+ return undefined;
1038
+ }));
1039
+ return applicationDetail_Observable.toPromise();
1040
+ }
1041
+ else {
1042
+ this.profileDetails = undefined;
1043
+ this.profileDetailsSource.next(undefined);
1044
+ return new Promise(function (resolve) { resolve(undefined); });
1045
+ }
1046
+ }
1047
+ else {
1048
+ this.profileDetails = undefined;
1049
+ this.profileDetailsSource.next(undefined);
1050
+ return new Promise(function (resolve) { resolve(undefined); });
1051
+ }
1052
+ };
978
1053
  MobicloudCoreService.prototype.signIn = function (redirectUrl) {
979
1054
  var _a;
980
1055
  return __awaiter(this, void 0, void 0, function () {
981
1056
  var _this = this;
982
- return __generator(this, function (_c) {
983
- switch (_c.label) {
1057
+ return __generator(this, function (_e) {
1058
+ switch (_e.label) {
984
1059
  case 0: return [4 /*yield*/, ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.signinRedirect({ data: { redirectUrl: redirectUrl } }).catch(function (reason) {
985
1060
  console.error("signIn failed:", reason, _this.mobiUserProfile);
986
1061
  return rxjs.throwError(reason);
987
1062
  }))];
988
- case 1: return [2 /*return*/, _c.sent()];
1063
+ case 1: return [2 /*return*/, _e.sent()];
989
1064
  }
990
1065
  });
991
1066
  });
@@ -993,14 +1068,14 @@
993
1068
  MobicloudCoreService.prototype.completeSignIn = function () {
994
1069
  var _a;
995
1070
  return __awaiter(this, void 0, void 0, function () {
996
- var _c;
997
- return __generator(this, function (_d) {
998
- switch (_d.label) {
1071
+ var _e;
1072
+ return __generator(this, function (_f) {
1073
+ switch (_f.label) {
999
1074
  case 0:
1000
- _c = this;
1075
+ _e = this;
1001
1076
  return [4 /*yield*/, ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.signinRedirectCallback())];
1002
1077
  case 1:
1003
- _c.user = _d.sent();
1078
+ _e.user = _f.sent();
1004
1079
  this.onUserChanged();
1005
1080
  return [2 /*return*/, this.user];
1006
1081
  }
@@ -1011,15 +1086,15 @@
1011
1086
  var _a;
1012
1087
  return __awaiter(this, void 0, void 0, function () {
1013
1088
  var _this = this;
1014
- return __generator(this, function (_c) {
1015
- switch (_c.label) {
1089
+ return __generator(this, function (_e) {
1090
+ switch (_e.label) {
1016
1091
  case 0: return [4 /*yield*/, ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.signinSilent().then(function (user) {
1017
1092
  _this.onSignedInSilent(user);
1018
1093
  }).catch(function (reason) {
1019
1094
  console.error("signInSilent failed:", reason, _this.mobiUserProfile);
1020
1095
  return rxjs.throwError(reason);
1021
1096
  }))];
1022
- case 1: return [2 /*return*/, _c.sent()];
1097
+ case 1: return [2 /*return*/, _e.sent()];
1023
1098
  }
1024
1099
  });
1025
1100
  });
@@ -1031,10 +1106,10 @@
1031
1106
  MobicloudCoreService.prototype.completeSilentSignIn = function () {
1032
1107
  var _a;
1033
1108
  return __awaiter(this, void 0, void 0, function () {
1034
- return __generator(this, function (_c) {
1035
- switch (_c.label) {
1109
+ return __generator(this, function (_e) {
1110
+ switch (_e.label) {
1036
1111
  case 0: return [4 /*yield*/, ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.signinSilentCallback())];
1037
- case 1: return [2 /*return*/, _c.sent()];
1112
+ case 1: return [2 /*return*/, _e.sent()];
1038
1113
  }
1039
1114
  });
1040
1115
  });
@@ -1042,17 +1117,17 @@
1042
1117
  MobicloudCoreService.prototype.signout = function () {
1043
1118
  var _a;
1044
1119
  return __awaiter(this, void 0, void 0, function () {
1045
- return __generator(this, function (_c) {
1046
- switch (_c.label) {
1120
+ return __generator(this, function (_e) {
1121
+ switch (_e.label) {
1047
1122
  case 0: return [4 /*yield*/, ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.signoutRedirect())];
1048
- case 1: return [2 /*return*/, _c.sent()];
1123
+ case 1: return [2 /*return*/, _e.sent()];
1049
1124
  }
1050
1125
  });
1051
1126
  });
1052
1127
  };
1053
1128
  MobicloudCoreService.prototype.completeSignout = function () {
1054
1129
  return __awaiter(this, void 0, void 0, function () {
1055
- return __generator(this, function (_c) {
1130
+ return __generator(this, function (_e) {
1056
1131
  this.onUserChanged();
1057
1132
  return [2 /*return*/];
1058
1133
  });
@@ -1798,6 +1873,16 @@
1798
1873
  filterExpression = column.defaultCalculateFilterExpression.apply(column, arguments);
1799
1874
  }
1800
1875
  return filterExpression;
1876
+ }
1877
+ function getBlobUrl(storageAccountName, blobPath) {
1878
+ var delim = blobPath.startsWith('/') ? '' : '/';
1879
+ return "https://" + storageAccountName + ".'blob.core.windows.net'" + delim + blobPath;
1880
+ }
1881
+ function getProfileImageUrl(storageAccountName, blobContainerName, blobName) {
1882
+ if (storageAccountName && blobContainerName && blobName) {
1883
+ return getBlobUrl(storageAccountName, blobContainerName + blobName);
1884
+ }
1885
+ return './assets/png/no-profile-img-32.png';
1801
1886
  }
1802
1887
 
1803
1888
  var LanguageInfo = /** @class */ (function () {
@@ -1829,17 +1914,6 @@
1829
1914
  return StorageAccountInfo;
1830
1915
  }());
1831
1916
 
1832
- var ApplicationDetails = /** @class */ (function () {
1833
- function ApplicationDetails() {
1834
- }
1835
- return ApplicationDetails;
1836
- }());
1837
- (function (MapProvider) {
1838
- MapProvider["None"] = "None";
1839
- MapProvider["Bing"] = "Bing";
1840
- MapProvider["Google"] = "Google";
1841
- })(exports.MapProvider || (exports.MapProvider = {}));
1842
-
1843
1917
  (function (MenuState) {
1844
1918
  MenuState["OpenedNormal"] = "OpenNormal";
1845
1919
  MenuState["OpenCollapsed"] = "OpenCollapsed";
@@ -1863,6 +1937,8 @@
1863
1937
  exports.MobicloudCoreModule = MobicloudCoreModule;
1864
1938
  exports.MobicloudCoreService = MobicloudCoreService;
1865
1939
  exports.OrganizationInfo = OrganizationInfo;
1940
+ exports.ProfileDetails = ProfileDetails;
1941
+ exports.ProfileImage = ProfileImage;
1866
1942
  exports.StorageAccountInfo = StorageAccountInfo;
1867
1943
  exports.ThemeInfo = ThemeInfo;
1868
1944
  exports.TokenHttpInterceptor = TokenHttpInterceptor;
@@ -1871,6 +1947,8 @@
1871
1947
  exports.dateFunctionFilterExpression = dateFunctionFilterExpression;
1872
1948
  exports.ensureDateEqual = ensureDateEqual;
1873
1949
  exports.fullNameFilterExpression_Employee = fullNameFilterExpression_Employee;
1950
+ exports.getBlobUrl = getBlobUrl;
1951
+ exports.getProfileImageUrl = getProfileImageUrl;
1874
1952
  exports.setZeroTime_ODataValues = setZeroTime_ODataValues;
1875
1953
 
1876
1954
  Object.defineProperty(exports, '__esModule', { value: true });