diff --git a/control/content/controllers/content.home.controller.js b/control/content/controllers/content.home.controller.js index 14f91eb..78fdf94 100644 --- a/control/content/controllers/content.home.controller.js +++ b/control/content/controllers/content.home.controller.js @@ -25,6 +25,7 @@ ContentHome.validLinkSuccess = false; ContentHome.validLinkFailure = false; ContentHome.validLinkNoEvents = false; + ContentHome.largePayload = false; var tmrDelay = null; var updateMasterItem = function (data) { @@ -111,6 +112,7 @@ ContentHome.validateCalUrl = function () { function successCallback(resp) { Buildfire.spinner.hide(); + ContentHome.largePayload = false; if (resp && resp.events) { ContentHome.validLinkSuccess = true; $timeout(function () { @@ -158,6 +160,18 @@ * */ init(); + buildfire.messaging.onReceivedMessage = function(message) { + switch(message.cmd) { + case "PAYLOAD_TOO_LARGE": + $timeout(function () { + ContentHome.largePayload = true; + },0); + return; + default: + return; + } + } + /* * watch for changes in data and trigger the saveDataWithDelay function on change * */ diff --git a/control/content/templates/home.html b/control/content/templates/home.html index fec90ba..fb2e573 100644 --- a/control/content/templates/home.html +++ b/control/content/templates/home.html @@ -9,7 +9,7 @@ ng-change="ContentHome.clearData()"/>
- @@ -29,5 +29,8 @@ >There is an error with this feed. Please check and try again.
+
+ Warning: Your calendar feed seems to be very large and will load slowly for your users. Please consider deleting old and redundant events to prevent longer load times +
\ No newline at end of file diff --git a/widget/app.services.js b/widget/app.services.js index bb03606..3db9a3d 100644 --- a/widget/app.services.js +++ b/widget/app.services.js @@ -74,6 +74,7 @@ }; var getFeedEvents = function (url, date, offset, refreshData, requestType) { console.log("start getFeedEvents: " + new Date()); + var requestStart = +new Date(); var deferred = $q.defer(); if (!url) { deferred.reject(new Error('Undefined feed url')); @@ -102,6 +103,7 @@ return e; }).then(function (r) { postObj.offset = i; + buildfire.spinner.show(); return $http({ method: "post", url: getProxyServerUrl() + '/events', @@ -134,6 +136,15 @@ //duplicated events - filter deferred.resolve(finalResults); + var requestEnd = +new Date() - requestStart; + buildfire.spinner.hide(); + + // if it took longer than 3s to load + if(requestEnd > 3000) { + buildfire.messaging.sendMessageToControl({ + cmd: "PAYLOAD_TOO_LARGE", + }); + } console.log("end getFeedEvents: " + new Date()); }); }); diff --git a/widget/controllers/widget.feed.controller.js b/widget/controllers/widget.feed.controller.js index 84b5f49..0df4c97 100644 --- a/widget/controllers/widget.feed.controller.js +++ b/widget/controllers/widget.feed.controller.js @@ -574,13 +574,15 @@ $scope.today(); $scope.getDayClass = function (date, mode) { - var dayToCheck = new Date(date).setHours(0, 0, 0, 0); + var dayToCheck = new Date(date ? date : new Date()).setHours(0, 0, 0, 0); var currentDay; - for (var i = 0; i < WidgetFeed.eventsAll.length; i++) { - currentDay = new Date(WidgetFeed.eventsAll[i].startDate).setHours(0, 0, 0, 0); - if (dayToCheck === currentDay) { - return 'eventDate avoid-clicks-none'; - } + if(WidgetFeed.eventsAll) { + for (var i = 0; i < WidgetFeed.eventsAll.length; i++) { + currentDay = new Date(WidgetFeed.eventsAll[i].startDate).setHours(0, 0, 0, 0); + if (dayToCheck === currentDay) { + return 'eventDate avoid-clicks-none'; + } + } } }; diff --git a/widget/index.html b/widget/index.html index 8f7a24a..731d0c2 100644 --- a/widget/index.html +++ b/widget/index.html @@ -52,7 +52,6 @@