@sunbird-cb/utils-v2 0.0.19 → 0.0.21

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.
@@ -1,4 +1,4 @@
1
- import { __assign, __awaiter, __generator, __values, __read } from 'tslib';
1
+ import { __assign, __spread, __awaiter, __generator, __values, __read } from 'tslib';
2
2
  import { Injectable, ɵɵdefineInjectable, ɵɵinject, EventEmitter, Component, Inject, Output, NgModule, Directive, Input, HostBinding, HostListener, ElementRef, ViewChild, Pipe, LOCALE_ID } from '@angular/core';
3
3
  import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
4
4
  import { MatSnackBar } from '@angular/material/snack-bar';
@@ -1957,6 +1957,7 @@ var EventService = (function () {
1957
1957
  function EventService(environment, utilitySvc) {
1958
1958
  this.utilitySvc = utilitySvc;
1959
1959
  this.todaysEvents = [];
1960
+ this.todaysLiveEvents = [];
1960
1961
  this.eventsSubject = new Subject();
1961
1962
  this.events$ = this.eventsSubject.asObservable();
1962
1963
  this.eventsChatbotSubject = new Subject();
@@ -2087,16 +2088,35 @@ var EventService = (function () {
2087
2088
  var min = stime.substr(2, 3);
2088
2089
  return date + " " + hour + min;
2089
2090
  };
2091
+ EventService.prototype.sortItemByTime = function (eventsdata) {
2092
+ return eventsdata.sort((function (a, b) {
2093
+ var firstDate = new Date(a.eventDate);
2094
+ var secondDate = new Date(b.eventDate);
2095
+ return secondDate > firstDate ? 1 : -1;
2096
+ }));
2097
+ };
2098
+ EventService.prototype.sortItemByTimeAsc = function (eventsdata) {
2099
+ return eventsdata.sort((function (a, b) {
2100
+ var firstDate = new Date(a.eventDate);
2101
+ var secondDate = new Date(b.eventDate);
2102
+ return secondDate < firstDate ? 1 : -1;
2103
+ }));
2104
+ };
2090
2105
  EventService.prototype.setEventListData = function (eventObj) {
2091
2106
  var _this = this;
2092
2107
  if (eventObj !== undefined) {
2093
2108
  this.todaysEvents = [];
2109
+ this.todaysLiveEvents = [];
2094
2110
  var data_1 = eventObj;
2095
2111
  var isEventLive_1 = false;
2096
2112
  var isEventRecording_1 = false;
2113
+ var isEventPast_1 = false;
2114
+ var isEventFuture_1 = false;
2097
2115
  Object.keys(data_1).forEach((function (index) {
2098
2116
  isEventRecording_1 = false;
2099
2117
  isEventLive_1 = false;
2118
+ isEventPast_1 = false;
2119
+ isEventFuture_1 = false;
2100
2120
  var obj = data_1[index];
2101
2121
  var floor = Math.floor;
2102
2122
  var hours = floor(obj.duration / 60);
@@ -2132,9 +2152,21 @@ var EventService = (function () {
2132
2152
  else if (today >= eventendDate) {
2133
2153
  isEventRecording_1 = true;
2134
2154
  isEventLive_1 = false;
2155
+ if (moment(today).isAfter(eventendDate) && moment(today).isAfter(eventDate)) {
2156
+ isEventPast_1 = true;
2157
+ }
2158
+ }
2159
+ else {
2160
+ if (moment(today).isBefore(eventDate) && moment(today).isBefore(eventendDate)) {
2161
+ isEventFuture_1 = true;
2162
+ }
2135
2163
  }
2136
2164
  var eventDataObj = {
2165
+ eventDate: eventDate,
2166
+ eventendDate: eventendDate,
2137
2167
  isEventLive: isEventLive_1,
2168
+ isEventFuture: isEventFuture_1,
2169
+ isEventPast: isEventPast_1,
2138
2170
  isEventRecording: isEventRecording_1,
2139
2171
  event: obj,
2140
2172
  eventName: obj.name,
@@ -2150,14 +2182,29 @@ var EventService = (function () {
2150
2182
  pastevent: false,
2151
2183
  };
2152
2184
  var isToday = _this.compareDate(obj.startDate);
2153
- if (isToday && isEventLive_1) {
2185
+ if (isToday) {
2154
2186
  _this.todaysEvents.push(eventDataObj);
2155
2187
  }
2188
+ if (isToday && isEventLive_1) {
2189
+ _this.todaysLiveEvents.push(eventDataObj);
2190
+ }
2156
2191
  }));
2157
- this.todaysEvents = this.todaysEvents.sort((function (a, b) {
2158
- return (a.isEventLive === b.isEventLive) ? 0 : b.isEventLive ? -1 : 1;
2159
- }));
2160
- }
2192
+ this.todaysLiveEvents = this.sortItemByTime(this.todaysLiveEvents);
2193
+ this.todaysEvents = this.getTodaysEvents(this.todaysEvents);
2194
+ }
2195
+ };
2196
+ EventService.prototype.getTodaysEvents = function (eventData) {
2197
+ var liveEvents = [];
2198
+ var pastEvents = [];
2199
+ var futureEvents = [];
2200
+ liveEvents = this.todaysLiveEvents;
2201
+ pastEvents = eventData.filter((function (pastEvent) { return pastEvent.isEventPast; }));
2202
+ futureEvents = eventData.filter((function (futureEvent) { return futureEvent.isEventFuture; }));
2203
+ liveEvents = this.sortItemByTimeAsc(liveEvents);
2204
+ futureEvents = this.sortItemByTimeAsc(futureEvents);
2205
+ pastEvents = this.sortItemByTime(pastEvents);
2206
+ this.todaysEvents = __spread(liveEvents, futureEvents, pastEvents);
2207
+ return this.todaysEvents;
2161
2208
  };
2162
2209
  EventService.decorators = [
2163
2210
  { type: Injectable, args: [{
@@ -2173,6 +2220,7 @@ var EventService = (function () {
2173
2220
  }());
2174
2221
  if (false) {
2175
2222
  EventService.prototype.todaysEvents;
2223
+ EventService.prototype.todaysLiveEvents;
2176
2224
  EventService.prototype.eventsSubject;
2177
2225
  EventService.prototype.events$;
2178
2226
  EventService.prototype.eventsChatbotSubject;
@@ -2318,8 +2366,10 @@ var HorizontalScrollerV2Component = (function () {
2318
2366
  this.defaultMaxWidgets = this.defaultMaxWidgets ? this.widgetsLength < this.defaultMaxWidgets ?
2319
2367
  this.widgetsLength : this.defaultMaxWidgets : this.defaultMaxWidgets;
2320
2368
  arrLength_1 = this.defaultMaxWidgets / arrLength_1;
2321
- for (var i = 0; i < arrLength_1; i += 1) {
2322
- this.bottomDotsArray.push(i);
2369
+ if (arrLength_1 !== Infinity) {
2370
+ for (var i = 0; i < arrLength_1; i += 1) {
2371
+ this.bottomDotsArray.push(i);
2372
+ }
2323
2373
  }
2324
2374
  }
2325
2375
  }