Improvements needed to deal correctly with Data Ranges

When outside the range, files are not requsted to the server, then there is no async operation as usual, and these modules where not expecting that. Now fixed.
This commit is contained in:
Luis Fernando Molina committed 2018-05-16 11:22:13 +02:00
1 parent cb17dc10dd
commit 2d51354a0c
3 files changed
+165 -29

No files matched your search

+32 -14
View File
@@ -11,6 +11,7 @@ function newFileCursor() {
let cursorDate;
let thisObject = {
reload: reload,
setDatetime: setDatetime,
setTimePeriod: setTimePeriod,
files: undefined,
@@ -85,10 +86,12 @@ function newFileCursor() {
beginDateRange = pBeginDateRange;
endDateRange = pEndDateRange;
setTimePeriod(pCurrentTimePeriod, pCursorDate, callBackFunction);
setTimePeriod(pCurrentTimePeriod, pCursorDate);
intervalHandle = setInterval(updateFiles , timePeriod);
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE);
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); }
@@ -197,7 +200,7 @@ function newFileCursor() {
}
}
function setTimePeriod(pTimePeriod, pDatetime, callBackFunction) {
function setTimePeriod(pTimePeriod, pDatetime) {
try {
@@ -237,20 +240,22 @@ function newFileCursor() {
if (Math.abs(positionB - positionA) <= 1) {
if (INFO_LOG === true) { logger.write("[INFO] setTimePeriod -> Will EXIT Saving Mode."); }
if (INFO_LOG === true) { logger.write("[INFO] setTimePeriod -> pTimePeriod = " + convertTimePeriodToName(pTimePeriod)); }
if (INFO_LOG === true) { logger.write("[INFO] setTimePeriod -> timePeriod = " + convertTimePeriodToName(timePeriod)); }
exitSavingMode();
//console.log("File Cursor with period " + periodName + " EXITED saving mode after being notified the user is at period " + convertTimePeriodToName(pTimePeriod));
} else {
if (INFO_LOG === true) { logger.write("[INFO] setTimePeriod -> Will ENTER Saving Mode."); }
if (INFO_LOG === true) { logger.write("[INFO] setTimePeriod -> pTimePeriod = " + convertTimePeriodToName(pTimePeriod)); }
if (INFO_LOG === true) { logger.write("[INFO] setTimePeriod -> timePeriod = " + convertTimePeriodToName(timePeriod)); }
enterSavingMode();
//console.log("File Cursor with period " + periodName + " ENTERED saving mode after being notified the user is at period " + convertTimePeriodToName(pTimePeriod));
}
getFiles(callBackFunction);
collectGarbage(callBackFunction);
function enterSavingMode() {
try {
@@ -331,7 +336,6 @@ function newFileCursor() {
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] setTimePeriod -> enterSavingMode -> err = " + err); }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
}
}
@@ -415,34 +419,48 @@ function newFileCursor() {
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] setTimePeriod -> exitSavingMode -> err = " + err); }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] setTimePeriod -> err = " + err); }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
}
}
function setDatetime(pDatetime, callBackFunction) {
function setDatetime(pDatetime) {
try {
if (INFO_LOG === true) { logger.write("[INFO] setDatetime -> Entering function."); }
if (pDatetime === undefined) { return; }
if (pDatetime === undefined) {
if (ERROR_LOG === true) { logger.write("[ERROR] setDatetime -> Received undefined datetime."); }
return;
}
cursorDate = pDatetime;
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] setDatetime -> err = " + err); }
}
}
function reload(callBackFunction) {
try {
if (INFO_LOG === true) { logger.write("[INFO] reload -> Entering function."); }
getFiles(callBackFunction);
collectGarbage(callBackFunction);
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] setDatetime -> err = " + err); }
if (ERROR_LOG === true) { logger.write("[ERROR] reload -> err = " + err); }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
}
}