@sunbird-cb/utils 1.0.15 → 1.0.17

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.
Files changed (33) hide show
  1. package/bundles/sunbird-cb-utils.umd.js +155 -43
  2. package/bundles/sunbird-cb-utils.umd.js.map +1 -1
  3. package/bundles/sunbird-cb-utils.umd.min.js +2 -2
  4. package/bundles/sunbird-cb-utils.umd.min.js.map +1 -1
  5. package/esm2015/lib/pipes/pipe-relative-time/pipe-relative-time.pipe.js +3 -2
  6. package/esm2015/lib/services/auth-keycloak.service.js +18 -19
  7. package/esm2015/lib/services/card-content.model.js +2 -1
  8. package/esm2015/lib/services/event.model.js +2 -1
  9. package/esm2015/lib/services/event.service.js +115 -7
  10. package/esm2015/lib/services/user-preference.model.js +10 -1
  11. package/esm2015/public-api.js +2 -1
  12. package/esm2015/sunbird-cb-utils.js +6 -7
  13. package/esm5/lib/pipes/pipe-relative-time/pipe-relative-time.pipe.js +3 -2
  14. package/esm5/lib/services/auth-keycloak.service.js +23 -29
  15. package/esm5/lib/services/card-content.model.js +2 -1
  16. package/esm5/lib/services/event.model.js +2 -1
  17. package/esm5/lib/services/event.service.js +116 -7
  18. package/esm5/lib/services/user-preference.model.js +10 -1
  19. package/esm5/public-api.js +2 -1
  20. package/esm5/sunbird-cb-utils.js +6 -7
  21. package/fesm2015/sunbird-cb-utils.js +143 -24
  22. package/fesm2015/sunbird-cb-utils.js.map +1 -1
  23. package/fesm5/sunbird-cb-utils.js +149 -34
  24. package/fesm5/sunbird-cb-utils.js.map +1 -1
  25. package/lib/services/auth-keycloak.service.d.ts +1 -3
  26. package/lib/services/card-content.model.d.ts +2 -1
  27. package/lib/services/event.model.d.ts +2 -1
  28. package/lib/services/event.service.d.ts +17 -1
  29. package/lib/services/user-preference.model.d.ts +8 -0
  30. package/package.json +1 -1
  31. package/public-api.d.ts +1 -0
  32. package/sunbird-cb-utils.d.ts +4 -5
  33. package/sunbird-cb-utils.metadata.json +1 -1
@@ -8,12 +8,12 @@ import { map, debounceTime, distinctUntilChanged, throttleTime, filter, catchErr
8
8
  import { CommonModule } from '@angular/common';
9
9
  import { MatIconModule, MatButtonModule, MatDialogModule, MatToolbarModule, MatCardModule, MatTooltipModule, MatSliderModule, MatProgressSpinnerModule, MatDialogRef as MatDialogRef$1 } from '@angular/material';
10
10
  import { ImageCropperModule } from 'ngx-image-cropper';
11
- import { HttpClient } from '@angular/common/http';
12
11
  import { KeycloakEventType, KeycloakService } from 'keycloak-angular';
12
+ import { HttpClient } from '@angular/common/http';
13
13
  import { Platform } from '@angular/cdk/platform';
14
14
  import { NavigationEnd, Router, ActivatedRoute } from '@angular/router';
15
- import moment from 'moment';
16
- import _, { orderBy } from 'lodash';
15
+ import * as _moment from 'moment';
16
+ import { orderBy, camelCase } from 'lodash';
17
17
  import { DomSanitizer } from '@angular/platform-browser';
18
18
 
19
19
  var ConfigurationsService = (function () {
@@ -1807,9 +1807,8 @@ if (false) {
1807
1807
  var storage$1 = localStorage;
1808
1808
  var storageKey$1 = 'kc';
1809
1809
  var AuthKeycloakService = (function () {
1810
- function AuthKeycloakService(http, configSvc, keycloakSvc, msAuthSvc) {
1810
+ function AuthKeycloakService(configSvc, keycloakSvc, msAuthSvc) {
1811
1811
  var _this = this;
1812
- this.http = http;
1813
1812
  this.configSvc = configSvc;
1814
1813
  this.keycloakSvc = keycloakSvc;
1815
1814
  this.msAuthSvc = msAuthSvc;
@@ -1952,7 +1951,7 @@ var AuthKeycloakService = (function () {
1952
1951
  if (_redirectUrl === void 0) { _redirectUrl = this.defaultRedirectUrl; }
1953
1952
  return __awaiter(this, void 0, void 0, function () {
1954
1953
  return __generator(this, function (_a) {
1955
- window.location.href = _redirectUrl + "apis/reset";
1954
+ window.location.href = _redirectUrl + "public/logout";
1956
1955
  return [2];
1957
1956
  });
1958
1957
  });
@@ -1960,24 +1959,23 @@ var AuthKeycloakService = (function () {
1960
1959
  AuthKeycloakService.prototype.force_logout = function () {
1961
1960
  return __awaiter(this, void 0, void 0, function () {
1962
1961
  return __generator(this, function (_a) {
1963
- switch (_a.label) {
1964
- case 0:
1965
- if (storage$1.getItem('telemetrySessionId')) {
1966
- storage$1.removeItem('telemetrySessionId');
1967
- }
1968
- try {
1969
- sessionStorage.clear();
1970
- localStorage.clear();
1971
- }
1972
- catch (_b) {
1973
- }
1974
- storage$1.removeItem(storageKey$1);
1975
- window.location.href = '/public/logout';
1976
- return [4, this.http.get('/apis/reset').toPromise()];
1977
- case 1:
1978
- _a.sent();
1979
- return [2];
1962
+ if (storage$1.getItem('telemetrySessionId')) {
1963
+ storage$1.removeItem('telemetrySessionId');
1964
+ }
1965
+ storage$1.removeItem(storageKey$1);
1966
+ if (localStorage.getItem('login') === 'true') {
1967
+ try {
1968
+ sessionStorage.clear();
1969
+ localStorage.clear();
1970
+ }
1971
+ catch (_b) {
1972
+ }
1973
+ window.location.href = this.defaultRedirectUrl + "apis/reset";
1980
1974
  }
1975
+ else {
1976
+ window.location.href = this.defaultRedirectUrl + "public/logout";
1977
+ }
1978
+ return [2];
1981
1979
  });
1982
1980
  });
1983
1981
  };
@@ -2089,17 +2087,15 @@ var AuthKeycloakService = (function () {
2089
2087
  },] }
2090
2088
  ];
2091
2089
  AuthKeycloakService.ctorParameters = function () { return [
2092
- { type: HttpClient },
2093
2090
  { type: ConfigurationsService },
2094
2091
  { type: KeycloakService },
2095
2092
  { type: AuthMicrosoftService }
2096
2093
  ]; };
2097
- /** @nocollapse */ AuthKeycloakService.ngInjectableDef = ɵɵdefineInjectable({ factory: function AuthKeycloakService_Factory() { return new AuthKeycloakService(ɵɵinject(HttpClient), ɵɵinject(ConfigurationsService), ɵɵinject(KeycloakService), ɵɵinject(AuthMicrosoftService)); }, token: AuthKeycloakService, providedIn: "root" });
2094
+ /** @nocollapse */ AuthKeycloakService.ngInjectableDef = ɵɵdefineInjectable({ factory: function AuthKeycloakService_Factory() { return new AuthKeycloakService(ɵɵinject(ConfigurationsService), ɵɵinject(KeycloakService), ɵɵinject(AuthMicrosoftService)); }, token: AuthKeycloakService, providedIn: "root" });
2098
2095
  return AuthKeycloakService;
2099
2096
  }());
2100
2097
  if (false) {
2101
2098
  AuthKeycloakService.prototype.loginChangeSubject;
2102
- AuthKeycloakService.prototype.http;
2103
2099
  AuthKeycloakService.prototype.configSvc;
2104
2100
  AuthKeycloakService.prototype.keycloakSvc;
2105
2101
  AuthKeycloakService.prototype.msAuthSvc;
@@ -2754,6 +2750,7 @@ var PipeListFilterModule = (function () {
2754
2750
  return PipeListFilterModule;
2755
2751
  }());
2756
2752
 
2753
+ var moment = _moment;
2757
2754
  var PipeRelativeTimePipe = (function () {
2758
2755
  function PipeRelativeTimePipe() {
2759
2756
  }
@@ -3988,19 +3985,38 @@ var WsEvents;
3988
3985
  EnumInteractSubTypes["DISCUSS_TAB"] = "discuss-tab";
3989
3986
  EnumInteractSubTypes["EVENTS_TAB"] = "events-tab";
3990
3987
  EnumInteractSubTypes["SIDE_MENU"] = "side-menu";
3988
+ EnumInteractSubTypes["HOME_PAGE_STRIP_TABS"] = "home-page-strip-tabs";
3991
3989
  })(EnumInteractSubTypes = WsEvents.EnumInteractSubTypes || (WsEvents.EnumInteractSubTypes = {}));
3992
3990
  })(WsEvents || (WsEvents = {}));
3993
3991
 
3992
+ var moment$1 = _moment;
3994
3993
  var EventService = (function () {
3995
- function EventService(utilitySvc) {
3994
+ function EventService(utilitySvc, environment) {
3996
3995
  this.utilitySvc = utilitySvc;
3996
+ this.todaysEvents = [];
3997
3997
  this.eventsSubject = new Subject();
3998
3998
  this.events$ = this.eventsSubject.asObservable();
3999
+ this.eventsChatbotSubject = new Subject();
4000
+ this.chatbotEvents$ = this.eventsChatbotSubject.asObservable();
4001
+ this.eventsGetStartSubject = new Subject();
4002
+ this.getStartEvents$ = this.eventsGetStartSubject.asObservable();
4003
+ this.eventsPRSubject = new Subject();
4004
+ this.getPREvents$ = this.eventsPRSubject.asObservable();
4005
+ this.environment = environment;
3999
4006
  }
4000
4007
  EventService.prototype.dispatchEvent = function (event) {
4001
4008
  event.pageContext = this.getContext(event.pageContext);
4002
4009
  this.eventsSubject.next(event);
4003
4010
  };
4011
+ EventService.prototype.dispatchChatbotEvent = function (event) {
4012
+ this.eventsChatbotSubject.next(event);
4013
+ };
4014
+ EventService.prototype.dispatchGetStartedEvent = function (event) {
4015
+ this.eventsGetStartSubject.next(event);
4016
+ };
4017
+ EventService.prototype.dispatchPlatformRatingEvent = function (event) {
4018
+ this.eventsPRSubject.next(event);
4019
+ };
4004
4020
  EventService.prototype.raiseInteractTelemetry = function (edata, object, pageContext) {
4005
4021
  this.dispatchEvent({
4006
4022
  eventType: WsEvents.WsEventType.Telemetry,
@@ -4064,28 +4080,118 @@ var EventService = (function () {
4064
4080
  this.raiseInteractTelemetry({
4065
4081
  subType: subType,
4066
4082
  type: WsEvents.EnumInteractTypes.CLICK,
4067
- id: _.camelCase(data.label) + "-tab",
4083
+ id: camelCase(data.label) + "-tab",
4068
4084
  }, __assign({}, object), {
4069
- pageIdExt: _.camelCase(data.label) + "-tab",
4085
+ pageIdExt: camelCase(data.label) + "-tab",
4070
4086
  });
4071
- this.raiseCustomImpression(__assign({}, object), {
4072
- pageIdExt: _.camelCase(data.label) + "-tab",
4087
+ this.raiseCustomImpression(__assign({ context: {
4088
+ position: data.index,
4089
+ } }, object), {
4090
+ pageIdExt: camelCase(data.label) + "-tab",
4073
4091
  });
4074
4092
  };
4093
+ EventService.prototype.getPublicUrl = function (url) {
4094
+ var mainUrl = url.split('/content').pop() || '';
4095
+ return this.environment.contentHost + "/" + this.environment.contentBucket + "/content" + mainUrl;
4096
+ };
4097
+ EventService.prototype.allEventDateFormat = function (datetime) {
4098
+ var date = new Date(datetime).getDate();
4099
+ var year = new Date(datetime).getFullYear();
4100
+ var month = new Date(datetime).getMonth();
4101
+ var hours = new Date(datetime).getHours();
4102
+ var minutes = new Date(datetime).getMinutes();
4103
+ var seconds = new Date(datetime).getSeconds();
4104
+ var formatedDate = new Date(year, month, date, hours, minutes, seconds, 0);
4105
+ var format = 'YYYY-MM-DD';
4106
+ var readableDateMonth = moment$1(formatedDate).format(format);
4107
+ var finalDateTimeValue = "" + readableDateMonth;
4108
+ return finalDateTimeValue;
4109
+ };
4110
+ EventService.prototype.compareDate = function (startDate) {
4111
+ var now = new Date();
4112
+ var day = ('0' + (new Date().getDate())).slice(-2);
4113
+ var year = new Date().getFullYear();
4114
+ var month = ('0' + (now.getMonth() + 1)).slice(-2);
4115
+ var todaysdate = year + "-" + month + "-" + day;
4116
+ if (startDate === todaysdate) {
4117
+ return true;
4118
+ }
4119
+ return false;
4120
+ };
4121
+ EventService.prototype.customDateFormat = function (date, time) {
4122
+ var stime = time.split('+')[0];
4123
+ var hour = stime.substr(0, 2);
4124
+ var min = stime.substr(2, 3);
4125
+ return date + " " + hour + min;
4126
+ };
4127
+ EventService.prototype.setEventListData = function (eventObj) {
4128
+ var _this = this;
4129
+ if (eventObj !== undefined) {
4130
+ this.todaysEvents = [];
4131
+ var data_1 = eventObj;
4132
+ Object.keys(data_1).forEach((function (index) {
4133
+ var obj = data_1[index];
4134
+ var floor = Math.floor;
4135
+ var hours = floor(obj.duration / 60);
4136
+ var minutes = obj.duration % 60;
4137
+ var duration = (hours === 0) ? ((minutes === 0) ? '---' : minutes + " minutes") : (minutes === 0) ? (hours === 1) ?
4138
+ hours + " hour" : hours + " hours" : (hours === 1) ? hours + " hour " + minutes + " minutes" :
4139
+ hours + " hours " + minutes + " minutes";
4140
+ var creatordata = obj.creatorDetails !== undefined ? obj.creatorDetails : [];
4141
+ var str = creatordata && creatordata.length > 0 ? creatordata.replace(/\\/g, '') : [];
4142
+ var creatorDetails = str && str.length > 0 ? JSON.parse(str) : creatordata;
4143
+ var stime = obj.startTime.split('+')[0];
4144
+ var hour = stime.substr(0, 2);
4145
+ var min = stime.substr(2, 3);
4146
+ var starttime = "" + hour + min;
4147
+ var etime = obj.endTime.split('+')[0];
4148
+ var ehour = etime.substr(0, 2);
4149
+ var emin = etime.substr(2, 3);
4150
+ var endtime = "" + ehour + emin;
4151
+ var eventDataObj = {
4152
+ event: obj,
4153
+ eventName: obj.name,
4154
+ eventStartTime: starttime,
4155
+ eventEndTime: endtime,
4156
+ eventStartDate: obj.startDate,
4157
+ eventCreatedOn: _this.allEventDateFormat(obj.createdOn),
4158
+ eventDuration: duration,
4159
+ eventjoined: creatorDetails.length,
4160
+ eventThumbnail: obj.appIcon && (obj.appIcon !== null || obj.appIcon !== undefined) ?
4161
+ _this.getPublicUrl(obj.appIcon) :
4162
+ '/assets/icons/Events_default.png',
4163
+ pastevent: false,
4164
+ };
4165
+ var isToday = _this.compareDate(obj.startDate);
4166
+ if (isToday) {
4167
+ _this.todaysEvents.push(eventDataObj);
4168
+ }
4169
+ }));
4170
+ }
4171
+ };
4075
4172
  EventService.decorators = [
4076
4173
  { type: Injectable, args: [{
4077
4174
  providedIn: 'root',
4078
4175
  },] }
4079
4176
  ];
4080
4177
  EventService.ctorParameters = function () { return [
4081
- { type: UtilityService }
4178
+ { type: UtilityService },
4179
+ { type: undefined, decorators: [{ type: Inject, args: ['environment',] }] }
4082
4180
  ]; };
4083
- /** @nocollapse */ EventService.ngInjectableDef = ɵɵdefineInjectable({ factory: function EventService_Factory() { return new EventService(ɵɵinject(UtilityService)); }, token: EventService, providedIn: "root" });
4181
+ /** @nocollapse */ EventService.ngInjectableDef = ɵɵdefineInjectable({ factory: function EventService_Factory() { return new EventService(ɵɵinject(UtilityService), ɵɵinject("environment")); }, token: EventService, providedIn: "root" });
4084
4182
  return EventService;
4085
4183
  }());
4086
4184
  if (false) {
4185
+ EventService.prototype.todaysEvents;
4087
4186
  EventService.prototype.eventsSubject;
4088
4187
  EventService.prototype.events$;
4188
+ EventService.prototype.eventsChatbotSubject;
4189
+ EventService.prototype.chatbotEvents$;
4190
+ EventService.prototype.eventsGetStartSubject;
4191
+ EventService.prototype.getStartEvents$;
4192
+ EventService.prototype.eventsPRSubject;
4193
+ EventService.prototype.getPREvents$;
4194
+ EventService.prototype.environment;
4089
4195
  EventService.prototype.utilitySvc;
4090
4196
  }
4091
4197
 
@@ -5013,6 +5119,15 @@ if (false) {
5013
5119
  IProfile.prototype.showBlogs;
5014
5120
  IProfile.prototype.showQnA;
5015
5121
  }
5122
+ function IPortalUrls() { }
5123
+ if (false) {
5124
+ IPortalUrls.prototype.igot;
5125
+ IPortalUrls.prototype.spv;
5126
+ IPortalUrls.prototype.mdo;
5127
+ IPortalUrls.prototype.cbc;
5128
+ IPortalUrls.prototype.cbp;
5129
+ IPortalUrls.prototype.frac;
5130
+ }
5016
5131
 
5017
5132
  var endpoints = {
5018
5133
  userPref: '/apis/protected/v8/user/preference',
@@ -5467,5 +5582,5 @@ if (false) {
5467
5582
  IRatingInfo.prototype.count;
5468
5583
  }
5469
5584
 
5470
- export { AuthKeycloakService, AuthMicrosoftService, ClassChangeOnScrollModule, ConfigurationsService, DefaultThumbnailModule, EFeatures, EInstance, EventService, ExploreDetailResolve, HorizontalScrollerModule, ImageCropComponent, ImageCropModule, ImageResponsiveModule, InViewPortModule, LoggerService, LogoutComponent, LogoutModule, MarketingOfferingResolve, NavigationModule, NsContent, OrderByPipe, PageResolve, PermissionModule, PipeConciseDateRangeModule, PipeConciseDateRangePipe, PipeCountTransformModule, PipeCountTransformPipe, PipeDateConcatModule, PipeDateConcatPipe, PipeDurationTransformModule, PipeDurationTransformPipe, PipeFilterModule, PipeFilterPipe, PipeFilterSearchModule, PipeFilterSearchPipe, PipeHtmlTagRemovalModule, PipeHtmlTagRemovalPipe, PipeLimitToModule, PipeLimitToPipe, PipeListFilterModule, PipeListFilterPipe, PipeNameTransformModule, PipeNameTransformPipe, PipeOrderByModule, PipePartialContentModule, PipePartialContentPipe, PipeRelativeTimeModule, PipeRelativeTimePipe, PipeSafeSanitizerModule, PipeSafeSanitizerPipe, SubapplicationRespondService, TelemetryService, UserPreferenceService, UtilityService, ValueService, WidgetContentService, WsEvents, getStringifiedQueryParams, ClassChangeOnScrollDirective as ɵa, DefaultThumbnailDirective as ɵb, ImageResponsiveDirective as ɵc, InViewPortDirective as ɵd, NavigationDirective as ɵe, PermissionDirective as ɵf, HorizontalScrollerComponent as ɵg };
5585
+ export { AuthKeycloakService, AuthMicrosoftService, ClassChangeOnScrollModule, ConfigurationsService, DefaultThumbnailModule, EFeatures, EInstance, EventService, ExploreDetailResolve, HorizontalScrollerModule, ImageCropComponent, ImageCropModule, ImageResponsiveDirective, ImageResponsiveModule, InViewPortModule, LoggerService, LogoutComponent, LogoutModule, MarketingOfferingResolve, NavigationModule, NsContent, OrderByPipe, PageResolve, PermissionModule, PipeConciseDateRangeModule, PipeConciseDateRangePipe, PipeCountTransformModule, PipeCountTransformPipe, PipeDateConcatModule, PipeDateConcatPipe, PipeDurationTransformModule, PipeDurationTransformPipe, PipeFilterModule, PipeFilterPipe, PipeFilterSearchModule, PipeFilterSearchPipe, PipeHtmlTagRemovalModule, PipeHtmlTagRemovalPipe, PipeLimitToModule, PipeLimitToPipe, PipeListFilterModule, PipeListFilterPipe, PipeNameTransformModule, PipeNameTransformPipe, PipeOrderByModule, PipePartialContentModule, PipePartialContentPipe, PipeRelativeTimeModule, PipeRelativeTimePipe, PipeSafeSanitizerModule, PipeSafeSanitizerPipe, SubapplicationRespondService, TelemetryService, UserPreferenceService, UtilityService, ValueService, WidgetContentService, WsEvents, getStringifiedQueryParams, ClassChangeOnScrollDirective as ɵa, DefaultThumbnailDirective as ɵb, InViewPortDirective as ɵc, NavigationDirective as ɵd, PermissionDirective as ɵe, HorizontalScrollerComponent as ɵf };
5471
5586
  //# sourceMappingURL=sunbird-cb-utils.js.map