@sjcrh/proteinpaint-server 2.138.1 → 2.138.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/routes/filterTermValues.js +25 -17
- package/src/app.js +27 -19
package/package.json
CHANGED
|
@@ -28,7 +28,29 @@ function init({ genomes }) {
|
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
async function getFilters(query, ds, res) {
|
|
32
|
+
if (!query.filterByUserSites)
|
|
33
|
+
authApi.mayAdjustFilter(query, ds, query.terms);
|
|
34
|
+
try {
|
|
35
|
+
const samplesPerFilter = await getSamplesPerFilter(query, ds);
|
|
36
|
+
const filtersData = await getData(
|
|
37
|
+
{
|
|
38
|
+
terms: query.terms,
|
|
39
|
+
__protected__: query.__protected__
|
|
40
|
+
},
|
|
41
|
+
ds
|
|
42
|
+
);
|
|
43
|
+
const tw2List = {};
|
|
44
|
+
for (const tw of query.terms) {
|
|
45
|
+
tw2List[tw.term.id] = getList(samplesPerFilter, filtersData, tw, query.showAll);
|
|
46
|
+
}
|
|
47
|
+
res.send({ ...tw2List });
|
|
48
|
+
} catch (e) {
|
|
49
|
+
console.log(e);
|
|
50
|
+
res.send({ error: e.message || e });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function getList(samplesPerFilter, filtersData, tw, showAll) {
|
|
32
54
|
const values = Object.values(tw.term.values);
|
|
33
55
|
values.sort((v1, v2) => v1.label.localeCompare(v2.label));
|
|
34
56
|
const twSamples = samplesPerFilter[tw.term.id];
|
|
@@ -42,28 +64,14 @@ function getList(samplesPerFilter, filtersData, tw) {
|
|
|
42
64
|
for (const value of values) {
|
|
43
65
|
const label = value.label.replace(/["']/g, "");
|
|
44
66
|
const disabled = !sampleValues.includes(value.key || value.label);
|
|
67
|
+
if (!showAll && disabled)
|
|
68
|
+
continue;
|
|
45
69
|
filteredValues.push({ value: value.key || value.label, label, disabled });
|
|
46
70
|
}
|
|
47
71
|
filteredValues.unshift({ label: "", value: "" });
|
|
48
72
|
filteredValues.sort((a, b) => a.label.localeCompare(b.label));
|
|
49
73
|
return filteredValues;
|
|
50
74
|
}
|
|
51
|
-
async function getFilters(query, ds, res) {
|
|
52
|
-
if (!query.filterByUserSites)
|
|
53
|
-
authApi.mayAdjustFilter(query, ds, query.terms);
|
|
54
|
-
try {
|
|
55
|
-
const samplesPerFilter = await getSamplesPerFilter(query, ds);
|
|
56
|
-
const filtersData = await getData({ terms: query.terms, __protected__: query.__protected__ }, ds);
|
|
57
|
-
const tw2List = {};
|
|
58
|
-
for (const tw of query.terms) {
|
|
59
|
-
tw2List[tw.term.id] = getList(samplesPerFilter, filtersData, tw);
|
|
60
|
-
}
|
|
61
|
-
res.send({ ...tw2List });
|
|
62
|
-
} catch (e) {
|
|
63
|
-
console.log(e);
|
|
64
|
-
res.send({ error: e.message || e });
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
75
|
export {
|
|
68
76
|
api
|
|
69
77
|
};
|