From 406771c1ebad63b29cf2d1d313bccc32734da09a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 3 Mar 2018 16:23:17 +0100 Subject: [PATCH] Working, but dont reacting when timePeriod changes at File Cursor --- .vs/AAWebPlatform/v15/.suo | Bin 74752 -> 74752 bytes FileCursor.js | 11 +++++------ FileCursorCache.js | 22 +++++++++++++++++++--- ProductCard.js | 37 +++++++++++++++++++++++++++++++++++-- TimelineChart.js | 25 +++++++++++++++++++------ 5 files changed, 78 insertions(+), 17 deletions(-) diff --git a/.vs/AAWebPlatform/v15/.suo b/.vs/AAWebPlatform/v15/.suo index 397fec305de8074223b0e57de2e98897a77a7031..16a92535ebdd807706df86af1d20a58ca9064e9e 100644 GIT binary patch delta 1209 zcmd5*Ur19?7{BLiyIyshcTTpsrn_4!XKrR_CI-@KmFY4C>#2wAVf0v_;9lB<2!meQ zC;61rO?nDiJFh}h!zSvJBSXbTZ%I8wBZw^fj&3sWCF-RQe*C`k{r}FnH%i3{r9zJWWHRX8j zM4Ur75junkVMCl`E?om58gNl(sqBls;60n!5WPh7GWvNu?+1O&9>|q=>OE+16iC5VfWUwLwowh9&G;I^Zj=9*)2F)2Qbjn*0te#5x6v`AwmL%O= zQBY}gQ|9(up(M;Ahr9Rh$#QjiQEj0Rv$~nPX+xvlrRp$M+bZMsVV-2~%6AouhsquB zF(s7MsH56szhZo$sKS#aC&+K_ zz{cE+DN^tw-{(4e`6f&(HAQCrc3gtb@|is#&s4(m`EOuY)R*z+urarAEf-_+`X-AnO8 z%Zi1?GBE;y={T&fc%XN_AN=VCxS5e5u_W(2&Eq8nxdaBL+x91ZS&l+<)kq3+njy9N tV=wIM+Qs;+2&dLla4S^{z781{*1T}_<0MSn7XPHHnib(+dZ?T2zX7bDjFkWY delta 1074 zcmb`FO-vI(6vubAA1?HRZA#jr1-7+7ON*jXPz*$*Dwcu}F~NgIJP<=@;sFxD#1`T~ zy(oPqoHVlGXd*IK0?Xoos5csj2(@@L;bbpH5Z^$XfEPVD$uIBC%YWX-%)}S9@kQ-a zgeQ7%@uhjs?gt{<(@Uh44(hKEqmkpdQe+1gjE#68qp7KC!9Y_s7|z<}thJ*(i_{^F zNC>WJ$B6+pwf5pmxW9<7ggV56IFR$m1?tlI2}F38aMfSVIyglK`51xBA&-xB;Y3&$ zWoWCj{$aGN0Wab~Y|tdw#RBw92vct(a7XZ(Sj_-ZiB!Q0!Cok$7ep!$Kk|!77lm8o z#8~H18p+$z2?r)0C`dw!V~d6?JH$lTX$``Pu#2Gs)}$6%#4QLF%_PG2NIxA4hqFTc zJ|SdU15|RRi5%b)PKioVnoO5SJe54%Jc-hw@>XJGS#u-oX3ta@^}A{}&r^4GN+TcR z6Au^YLT!UJ;dH}fp_4Xts3ak|sXLO=OxL{IdptI8u16iaqsR0|XN5?mM=a6p6oC=1 zb=)BkGj;WTvBf%*Y1^oCPuhP#8ikVe z(-2${X*?Mxpr|)NoHN6lSuaefub?k!gY;52C`vwbr~>pYN1(@73U`&Fg9pvaU68-x zhuEr_uog~&vifsZviZ3U&aElXv*5w~Wl|3t^FH)MQVA35*I{10@wbw4S`YtPU`_s3 F{~LQpTj~G+ diff --git a/FileCursor.js b/FileCursor.js index 5fa883888..d59188a28 100644 --- a/FileCursor.js +++ b/FileCursor.js @@ -36,13 +36,11 @@ function newFileCursor() { cursorDate = pCursorDate; timePeriod = pTimePeriod; - setTimePeriod(pCurrentTimePeriod); - - getFiles(callBackFunction); + setTimePeriod(pCurrentTimePeriod, callBackFunction); } - function setTimePeriod(pTimePeriod) { + function setTimePeriod(pTimePeriod, callBackFunction) { /* @@ -86,6 +84,9 @@ function newFileCursor() { } + getFiles(callBackFunction); + + collectGarbage(); function enterSavingMode() { @@ -234,8 +235,6 @@ function newFileCursor() { default: } } - - } diff --git a/FileCursorCache.js b/FileCursorCache.js index d7e908eb3..9667d630e 100644 --- a/FileCursorCache.js +++ b/FileCursorCache.js @@ -1,6 +1,8 @@  function newFileCursorCache() { + const CONSOLE_LOG = true; + let fileCursorCache = { getFileCursor: getFileCursor, setDatetime: setDatetime, @@ -86,16 +88,30 @@ function newFileCursorCache() { } - console.log("FileCursorCache -> setDatetime -> expectedFiles = " + expectedFiles) + if (CONSOLE_LOG === true) { + + console.log("FileCursorCache -> setDatetime -> expectedFiles = " + expectedFiles); + + } } function setTimePeriod(pTimePeriod) { + filesLoaded = 0; + expectedFiles = 0; + fileCursors.forEach(setTimePeriodToEach) - function setTimePeriodToEach(value, key, map) { + function setTimePeriodToEach(fileCursor, key, map) { - value.setTimePeriod(pTimePeriod); + fileCursor.setTimePeriod(pTimePeriod, onFileReceived); + expectedFiles = expectedFiles + fileCursor.getExpectedFiles(); + + } + + if (CONSOLE_LOG === true) { + + console.log("FileCursorCache -> setTimePeriod -> expectedFiles = " + expectedFiles); } } diff --git a/ProductCard.js b/ProductCard.js index ea23d9d35..f8ee628eb 100644 --- a/ProductCard.js +++ b/ProductCard.js @@ -14,6 +14,7 @@ onDailyFileLoaded: onDailyFileLoaded, onSingleFileLoaded: onSingleFileLoaded, onDayChanged: onDayChanged, + onTimePeriodChanged: onTimePeriodChanged, getContainer: getContainer, // returns the inner most container that holds the point received by parameter. initialize: initialize }; @@ -119,11 +120,37 @@ function onDayChanged() { + /* + + When the datetime changes from one day to another, this forces cursors to potentially load more files, thus we reset this counter and + get ready to receive events on files loaded. + + */ + dailyFileProgressBar.animatedValue = 0; if (CONSOLE_LOG === true) { - console.log("ProductCard -> onDayChanged"); + console.log("ProductCard -> onDayChanged -> dailyFileProgressBar.animatedValue = " + dailyFileProgressBar.animatedValue); + + } + + } + + function onTimePeriodChanged() { + + /* + + When the time period below or equal to 1 hour changes, this forces cursors to potentially load more files, thus we reset this counter and + get ready to receive events on files loaded. + + */ + + dailyFileProgressBar.animatedValue = 0; + + if (CONSOLE_LOG === true) { + + console.log("ProductCard -> onTimePeriodChanged -> dailyFileProgressBar.animatedValue = " + dailyFileProgressBar.animatedValue); } @@ -351,7 +378,7 @@ /* ------------------- Progress Bars -------------------------- */ - const ANIMATED_INCREMENT = 3; + const ANIMATED_INCREMENT = 5; let point1; let point2; @@ -370,6 +397,8 @@ if (marketFileProgressBar.animatedValue >= 100) { + marketFileProgressBar.animatedValue = 100; + marketFileProgressBar.fillStyle = LOADED_FILL_STYLE; marketFileProgressBar.strokeStyle = LOADED_STROKE_STYLE; @@ -429,6 +458,8 @@ if (dailyFileProgressBar.animatedValue >= 100) { + dailyFileProgressBar.animatedValue = 100; + dailyFileProgressBar.fillStyle = LOADED_FILL_STYLE; dailyFileProgressBar.strokeStyle = LOADED_STROKE_STYLE; @@ -488,6 +519,8 @@ if (singleFileProgressBar.animatedValue >= 100) { + singleFileProgressBar.animatedValue = 100; + singleFileProgressBar.fillStyle = LOADED_FILL_STYLE; singleFileProgressBar.strokeStyle = LOADED_STROKE_STYLE; diff --git a/TimelineChart.js b/TimelineChart.js index defe0c5e8..67c313407 100644 --- a/TimelineChart.js +++ b/TimelineChart.js @@ -251,6 +251,14 @@ function newTimelineChart() { let activePlotter = activePlotters[i]; activePlotter.plotter.setTimePeriod(timePeriod); + if (timePeriod <= _1_HOUR_IN_MILISECONDS) { + + for (var i = 0; i < activePlotters.length; i++) { + + activePlotter.productCard.onTimePeriodChanged(); + + } + } } } @@ -303,6 +311,8 @@ function newTimelineChart() { let newDate = new Date(0); newDate.setUTCSeconds(center.x / 1000); + tellProductCardsWhenDayChanges(newDate); + datetime = newDate; for (var i = 0; i < activePlotters.length; i++) { @@ -335,16 +345,14 @@ function newTimelineChart() { } - function setDatetime(pDatetime) { + function tellProductCardsWhenDayChanges(pDatetime) { /* If there is a change in the day, then we tell it to the Product Card so that it can represent the activity of the daily cursors on the UI. */ let currentDate = Math.trunc(datetime.valueOf() / ONE_DAY_IN_MILISECONDS); - let newDate = Math.trunc(newDatetime.valueOf() / ONE_DAY_IN_MILISECONDS); + let newDate = Math.trunc(pDatetime.valueOf() / ONE_DAY_IN_MILISECONDS); - datetime = pDatetime; - - if (currentDate !== pDatetime) { + if (currentDate !== newDate) { if (timePeriod <= _1_HOUR_IN_MILISECONDS) { @@ -354,9 +362,14 @@ function newTimelineChart() { activePlotter.productCard.onDayChanged(); } - } } + } + + + function setDatetime(pDatetime) { + + tellProductCardsWhenDayChanges(pDatetime); /* No matter if the day changed or not, we need to inform all visible Plotters. */