Working, but dont reacting when timePeriod changes at File Cursor

This commit is contained in:
Luis Fernando Molina committed 2018-03-03 16:23:17 +01:00
1 parent 7dea1b0618
commit 406771c1eb
5 files changed
+78 -17

No files matched your search

Binary file not shown.
+5 -6
View File
@@ -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:
}
}
}
+19 -3
View File
@@ -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);
}
}
+35 -2
View File
@@ -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;
+19 -6
View File
@@ -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. */