diff --git a/client-base/src/main/webapp/html/GeneView/summary-legend.js b/client-base/src/main/webapp/html/GeneView/summary-legend.js
index ed969b1eb..6bcbfcdeb 100644
--- a/client-base/src/main/webapp/html/GeneView/summary-legend.js
+++ b/client-base/src/main/webapp/html/GeneView/summary-legend.js
@@ -58,11 +58,15 @@ function filterGeneTableByType ( event, conceptType )
if ( !conceptEvidences ) return false // just in case
// Splits the gene evidences string in the gene table into an array of evidences.
// See the API for details about this format
+
+ /* TODO: remove, use the available facilities for these
+ operations
let evidences = []
for(let evidence in conceptEvidences){
evidences.push(evidence)
- }
- return selectedTypes.every ( t => evidences.includes ( t ) )
+ } */
+ const rowEvidences = Object.keys ( conceptEvidences )
+ return selectedTypes.every ( t => rowEvidences.includes ( t ) )
}
_filterKnetTableByType (
@@ -74,8 +78,7 @@ function filterGeneTableByType ( event, conceptType )
function filterEvidenceTableByType ( event, conceptType )
{
const rowFilterPred = ( selectedTypes, tableRow ) => {
- const rowEvidencesString = tableRow.conceptType
- return selectedTypes.some ( t => t == rowEvidencesString )
+ return selectedTypes.some ( t => t == tableRow.conceptType )
}
_filterKnetTableByType (
@@ -84,7 +87,7 @@ function filterEvidenceTableByType ( event, conceptType )
)
}
-// function updates, store and checks for non-active legend keys
+// function updates, store and checks for non-active legend keys
function updateLegendsKeys(key, location, event) {
const currentTable = $(`#${location}`)
diff --git a/client-base/src/main/webapp/html/javascript/data-utils.js b/client-base/src/main/webapp/html/javascript/data-utils.js
index 151397b3d..32a8aeca5 100644
--- a/client-base/src/main/webapp/html/javascript/data-utils.js
+++ b/client-base/src/main/webapp/html/javascript/data-utils.js
@@ -55,7 +55,7 @@ function searchKeyword() {
// api request
var request = "/" + searchMode;
-
+ // TODO: possibly related to #768
//if(geneList_size > freegenelist_limit) {
// check if user logged in and if yes, get user_id
@@ -81,6 +81,31 @@ function searchKeyword() {
* checks user login status and, in case of success, calls the API specified in searchMode and
* requestParams.
*
+ * TODO: (when we have time, don't remove this commnt until completed, possubly move it to a GH issue)
+ * This is a callback hell (google for it), checkUserPlan() receives
+ * parameters it shouldn't deal with at all, just to pass them along.
+ *
+ * The modern, cleaner way to do the same is to use promises, althogh in this case, checkUserPlan()
+ * needs to do some wrapping around the call back to be chained after success. So, it needs to become
+ * like:
+ *
+ * function checkUserPlan ( onComplete ) // pass the callback, not its details or parameters
+ * {
+ * $.ajax({
+ * ...
+ * complete: function () {
+ * ... // the same current pre-processing
+ * onComplete() // in place of the current requestGenomeData()
+ * ... // the same current post-procesding
+ * }
+ * })
+ * }
+ *
+ * // This would be the invocation in searchKeyword() above
+ * // don't give the requestGenomeData() params to checkUserPlan(), it doesn't really need
+ * // to know them.
+ * checkUserPlan( () => requestGenomeData(...) )
+ *
*/
function checkUserPlan() {
var login_check_url = knetspace_api_host + "/api/v1/me";
@@ -934,18 +959,25 @@ class GenesListManager {
* Converts genetable JSON format data to TSV format removing conceptEvidences and qtlEvidence properties.
*/
function geneTableToTsv(data) {
+
+ /* TODO: remove. Stop coding these transformations this way.
const genesArrayExclEvidences = []
data.forEach(genes => {
const { conceptEvidences, qtlEvidences, ...genesWithoutEvidence } = genes
genesArrayExclEvidences.push(genesWithoutEvidence)
})
+ */
+ const genesArrayExclEvidences = data.map ( geneTableRow => {
+ // TODO: remove WHAT SORT OF NAME IS genesWithoutEvidence?!?
+ // const { conceptEvidences, qtlEvidences, ...genesWithoutEvidence } = genes
+ const { conceptEvidences, qtlEvidences, ...filteredFields} = geneTableRow
+ return filteredFields
+ })
const tsvFormat = formatJsonToTsv(genesArrayExclEvidences);
return tsvFormat;
-
-
}
/**
@@ -972,9 +1004,25 @@ function formatJsonToTsv(data) {
}
+// function replace gene and evidence genome data ondexId key with nodeId
+function replaceOndexId(tableData) {
-// TODO: see init-utils.js
-//
+ const refinedTableData = tableData.map(({
+ ondexId: nodeId,
+ ...data
+ }) => ({
+ nodeId,
+ ...data
+ }))
+
+ return refinedTableData
+}
+
+
+/*
+ * TODO: see init-utils.js
+ * Keep this test/provisional code ad the end of files.
+ */
if (TEST_MODE) {
function testGeneTable2OldString() {
let testTableJs = [
@@ -1120,18 +1168,3 @@ if (TEST_MODE) {
testEvidenceTable2OldString()
} // if TEST_MODE
-
-
-// function replace gene and evidence genome data ondexId key with nodeId
-function replaceOndexId(tableData) {
-
- const refinedTableData = tableData.map(({
- ondexId: nodeId,
- ...data
- }) => ({
- nodeId,
- ...data
- }))
-
- return refinedTableData
-}
\ No newline at end of file
diff --git a/client-base/src/main/webapp/html/javascript/evidence-table.js b/client-base/src/main/webapp/html/javascript/evidence-table.js
index 80360ddc8..d914f7051 100644
--- a/client-base/src/main/webapp/html/javascript/evidence-table.js
+++ b/client-base/src/main/webapp/html/javascript/evidence-table.js
@@ -343,7 +343,7 @@ function triggerAccessionToolTips() {
var downloadToolTip = createAccessionToolTips('.accession-downloadicon', 'Download full table.', 'download');
- // TODO: too much repition
+ // TODO: too much repeatition
$(".accession-clipboard").mouseover(function (e) {
e.preventDefault();
@@ -417,7 +417,16 @@ function createEvidenceTableBody ( tableData, doAppend = false )
const fromRow = evidenceTableScroller.getPageStart ()
const toRow = evidenceTableScroller.getPageEnd ()
- tableData.forEach( (evidence,index) =>
+ /**
+ * TODO: how can this work, if before we were looping on the fromRow/toRow window?
+ *
+ * Is it because it now gets the rendered window only? If yes, remove fromRow, toRow declarations,
+ * but then what's evidenceTableScroller for?
+ *
+ * if it's a bug, fix it with a loop over the right window
+ */
+
+ tableData.forEach( (evidence,index) =>
{
let {conceptType, name, pvalue, totalGenesSize, geneList, nodeId, userGenesSize, userGeneAccessions } = evidence
diff --git a/client-base/src/main/webapp/html/javascript/web-cache-new.js b/client-base/src/main/webapp/html/javascript/web-cache-new.js
new file mode 100644
index 000000000..881fb477e
--- /dev/null
+++ b/client-base/src/main/webapp/html/javascript/web-cache-new.js
@@ -0,0 +1,105 @@
+/**
+ * Manages the caching for web requests, with a specific new entry handler that
+ * make URL calls and deals with possible errors.
+ *
+ * Currently, we're only using the subclass EvidenceAccessionCache in openGeneListPopup()/evidence-table.js
+ *
+ */
+class WebCacheWrapper
+{
+ #cacheName = null
+
+ constructor ( cacheName ) {
+ this.#cacheName = cacheName
+ }
+
+
+ /**
+ * Entry getter that uses the cache-through approach, ie, if the entry is already cached,
+ * returns it, if not, uses #apiHandler() to get data, caches the result and then return them.
+ *
+ * This is the main method to access the cache, it is used like:
+ *
+ * let data = cacheWrapper.get ( "http://foo.url?param=" + param ) // options can be omitted
+ * let data = cacheWrapper.get ( "http://foo.url?param=" + param, { timeout: 1000 } )
+ *
+ *