@sunbird-cb/utils 1.0.15 → 1.0.16

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.
@@ -12,8 +12,8 @@ import { HttpClient } from '@angular/common/http';
12
12
  import { KeycloakEventType, KeycloakService } from 'keycloak-angular';
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 () {
@@ -2754,6 +2754,7 @@ var PipeListFilterModule = (function () {
2754
2754
  return PipeListFilterModule;
2755
2755
  }());
2756
2756
 
2757
+ var moment = _moment;
2757
2758
  var PipeRelativeTimePipe = (function () {
2758
2759
  function PipeRelativeTimePipe() {
2759
2760
  }
@@ -3988,19 +3989,38 @@ var WsEvents;
3988
3989
  EnumInteractSubTypes["DISCUSS_TAB"] = "discuss-tab";
3989
3990
  EnumInteractSubTypes["EVENTS_TAB"] = "events-tab";
3990
3991
  EnumInteractSubTypes["SIDE_MENU"] = "side-menu";
3992
+ EnumInteractSubTypes["HOME_PAGE_STRIP_TABS"] = "home-page-strip-tabs";
3991
3993
  })(EnumInteractSubTypes = WsEvents.EnumInteractSubTypes || (WsEvents.EnumInteractSubTypes = {}));
3992
3994
  })(WsEvents || (WsEvents = {}));
3993
3995
 
3996
+ var moment$1 = _moment;
3994
3997
  var EventService = (function () {
3995
- function EventService(utilitySvc) {
3998
+ function EventService(utilitySvc, environment) {
3996
3999
  this.utilitySvc = utilitySvc;
4000
+ this.todaysEvents = [];
3997
4001
  this.eventsSubject = new Subject();
3998
4002
  this.events$ = this.eventsSubject.asObservable();
4003
+ this.eventsChatbotSubject = new Subject();
4004
+ this.chatbotEvents$ = this.eventsChatbotSubject.asObservable();
4005
+ this.eventsGetStartSubject = new Subject();
4006
+ this.getStartEvents$ = this.eventsGetStartSubject.asObservable();
4007
+ this.eventsPRSubject = new Subject();
4008
+ this.getPREvents$ = this.eventsPRSubject.asObservable();
4009
+ this.environment = environment;
3999
4010
  }
4000
4011
  EventService.prototype.dispatchEvent = function (event) {
4001
4012
  event.pageContext = this.getContext(event.pageContext);
4002
4013
  this.eventsSubject.next(event);
4003
4014
  };
4015
+ EventService.prototype.dispatchChatbotEvent = function (event) {
4016
+ this.eventsChatbotSubject.next(event);
4017
+ };
4018
+ EventService.prototype.dispatchGetStartedEvent = function (event) {
4019
+ this.eventsGetStartSubject.next(event);
4020
+ };
4021
+ EventService.prototype.dispatchPlatformRatingEvent = function (event) {
4022
+ this.eventsPRSubject.next(event);
4023
+ };
4004
4024
  EventService.prototype.raiseInteractTelemetry = function (edata, object, pageContext) {
4005
4025
  this.dispatchEvent({
4006
4026
  eventType: WsEvents.WsEventType.Telemetry,
@@ -4064,28 +4084,118 @@ var EventService = (function () {
4064
4084
  this.raiseInteractTelemetry({
4065
4085
  subType: subType,
4066
4086
  type: WsEvents.EnumInteractTypes.CLICK,
4067
- id: _.camelCase(data.label) + "-tab",
4087
+ id: camelCase(data.label) + "-tab",
4068
4088
  }, __assign({}, object), {
4069
- pageIdExt: _.camelCase(data.label) + "-tab",
4089
+ pageIdExt: camelCase(data.label) + "-tab",
4070
4090
  });
4071
- this.raiseCustomImpression(__assign({}, object), {
4072
- pageIdExt: _.camelCase(data.label) + "-tab",
4091
+ this.raiseCustomImpression(__assign({ context: {
4092
+ position: data.index,
4093
+ } }, object), {
4094
+ pageIdExt: camelCase(data.label) + "-tab",
4073
4095
  });
4074
4096
  };
4097
+ EventService.prototype.getPublicUrl = function (url) {
4098
+ var mainUrl = url.split('/content').pop() || '';
4099
+ return this.environment.contentHost + "/" + this.environment.contentBucket + "/content" + mainUrl;
4100
+ };
4101
+ EventService.prototype.allEventDateFormat = function (datetime) {
4102
+ var date = new Date(datetime).getDate();
4103
+ var year = new Date(datetime).getFullYear();
4104
+ var month = new Date(datetime).getMonth();
4105
+ var hours = new Date(datetime).getHours();
4106
+ var minutes = new Date(datetime).getMinutes();
4107
+ var seconds = new Date(datetime).getSeconds();
4108
+ var formatedDate = new Date(year, month, date, hours, minutes, seconds, 0);
4109
+ var format = 'YYYY-MM-DD';
4110
+ var readableDateMonth = moment$1(formatedDate).format(format);
4111
+ var finalDateTimeValue = "" + readableDateMonth;
4112
+ return finalDateTimeValue;
4113
+ };
4114
+ EventService.prototype.compareDate = function (startDate) {
4115
+ var now = new Date();
4116
+ var day = ('0' + (new Date().getDate())).slice(-2);
4117
+ var year = new Date().getFullYear();
4118
+ var month = ('0' + (now.getMonth() + 1)).slice(-2);
4119
+ var todaysdate = year + "-" + month + "-" + day;
4120
+ if (startDate === todaysdate) {
4121
+ return true;
4122
+ }
4123
+ return false;
4124
+ };
4125
+ EventService.prototype.customDateFormat = function (date, time) {
4126
+ var stime = time.split('+')[0];
4127
+ var hour = stime.substr(0, 2);
4128
+ var min = stime.substr(2, 3);
4129
+ return date + " " + hour + min;
4130
+ };
4131
+ EventService.prototype.setEventListData = function (eventObj) {
4132
+ var _this = this;
4133
+ if (eventObj !== undefined) {
4134
+ this.todaysEvents = [];
4135
+ var data_1 = eventObj;
4136
+ Object.keys(data_1).forEach((function (index) {
4137
+ var obj = data_1[index];
4138
+ var floor = Math.floor;
4139
+ var hours = floor(obj.duration / 60);
4140
+ var minutes = obj.duration % 60;
4141
+ var duration = (hours === 0) ? ((minutes === 0) ? '---' : minutes + " minutes") : (minutes === 0) ? (hours === 1) ?
4142
+ hours + " hour" : hours + " hours" : (hours === 1) ? hours + " hour " + minutes + " minutes" :
4143
+ hours + " hours " + minutes + " minutes";
4144
+ var creatordata = obj.creatorDetails !== undefined ? obj.creatorDetails : [];
4145
+ var str = creatordata && creatordata.length > 0 ? creatordata.replace(/\\/g, '') : [];
4146
+ var creatorDetails = str && str.length > 0 ? JSON.parse(str) : creatordata;
4147
+ var stime = obj.startTime.split('+')[0];
4148
+ var hour = stime.substr(0, 2);
4149
+ var min = stime.substr(2, 3);
4150
+ var starttime = "" + hour + min;
4151
+ var etime = obj.endTime.split('+')[0];
4152
+ var ehour = etime.substr(0, 2);
4153
+ var emin = etime.substr(2, 3);
4154
+ var endtime = "" + ehour + emin;
4155
+ var eventDataObj = {
4156
+ event: obj,
4157
+ eventName: obj.name,
4158
+ eventStartTime: starttime,
4159
+ eventEndTime: endtime,
4160
+ eventStartDate: obj.startDate,
4161
+ eventCreatedOn: _this.allEventDateFormat(obj.createdOn),
4162
+ eventDuration: duration,
4163
+ eventjoined: creatorDetails.length,
4164
+ eventThumbnail: obj.appIcon && (obj.appIcon !== null || obj.appIcon !== undefined) ?
4165
+ _this.getPublicUrl(obj.appIcon) :
4166
+ '/assets/icons/Events_default.png',
4167
+ pastevent: false,
4168
+ };
4169
+ var isToday = _this.compareDate(obj.startDate);
4170
+ if (isToday) {
4171
+ _this.todaysEvents.push(eventDataObj);
4172
+ }
4173
+ }));
4174
+ }
4175
+ };
4075
4176
  EventService.decorators = [
4076
4177
  { type: Injectable, args: [{
4077
4178
  providedIn: 'root',
4078
4179
  },] }
4079
4180
  ];
4080
4181
  EventService.ctorParameters = function () { return [
4081
- { type: UtilityService }
4182
+ { type: UtilityService },
4183
+ { type: undefined, decorators: [{ type: Inject, args: ['environment',] }] }
4082
4184
  ]; };
4083
- /** @nocollapse */ EventService.ngInjectableDef = ɵɵdefineInjectable({ factory: function EventService_Factory() { return new EventService(ɵɵinject(UtilityService)); }, token: EventService, providedIn: "root" });
4185
+ /** @nocollapse */ EventService.ngInjectableDef = ɵɵdefineInjectable({ factory: function EventService_Factory() { return new EventService(ɵɵinject(UtilityService), ɵɵinject("environment")); }, token: EventService, providedIn: "root" });
4084
4186
  return EventService;
4085
4187
  }());
4086
4188
  if (false) {
4189
+ EventService.prototype.todaysEvents;
4087
4190
  EventService.prototype.eventsSubject;
4088
4191
  EventService.prototype.events$;
4192
+ EventService.prototype.eventsChatbotSubject;
4193
+ EventService.prototype.chatbotEvents$;
4194
+ EventService.prototype.eventsGetStartSubject;
4195
+ EventService.prototype.getStartEvents$;
4196
+ EventService.prototype.eventsPRSubject;
4197
+ EventService.prototype.getPREvents$;
4198
+ EventService.prototype.environment;
4089
4199
  EventService.prototype.utilitySvc;
4090
4200
  }
4091
4201
 
@@ -5013,6 +5123,15 @@ if (false) {
5013
5123
  IProfile.prototype.showBlogs;
5014
5124
  IProfile.prototype.showQnA;
5015
5125
  }
5126
+ function IPortalUrls() { }
5127
+ if (false) {
5128
+ IPortalUrls.prototype.igot;
5129
+ IPortalUrls.prototype.spv;
5130
+ IPortalUrls.prototype.mdo;
5131
+ IPortalUrls.prototype.cbc;
5132
+ IPortalUrls.prototype.cbp;
5133
+ IPortalUrls.prototype.frac;
5134
+ }
5016
5135
 
5017
5136
  var endpoints = {
5018
5137
  userPref: '/apis/protected/v8/user/preference',
@@ -5467,5 +5586,5 @@ if (false) {
5467
5586
  IRatingInfo.prototype.count;
5468
5587
  }
5469
5588
 
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 };
5589
+ 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
5590
  //# sourceMappingURL=sunbird-cb-utils.js.map