Skip to content

Commit 5a259cb

Browse files
authored
Merge pull request #31 from PathwayCommons/iss22_load-single-data-file
Do not hardcode topics
2 parents b811093 + edb22f4 commit 5a259cb

3 files changed

Lines changed: 1319 additions & 53 deletions

File tree

example-data/data.json

Lines changed: 1313 additions & 0 deletions
Large diffs are not rendered by default.

src/dashboard/categories.js

Lines changed: 5 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,15 @@
1-
import alzheimersDisease from '../../example-data/alzheimers-disease.json';
2-
import alzheimersDiagnosis from '../../example-data/alzheimers-diagnosis.json';
3-
import alzheimersNeuroinflammation from '../../example-data/alzheimers-neuroinflammation.json';
4-
// import alzheimersTherapeutics from '../../example-data/alzheimers-therapeutics.json';
5-
6-
const ALZHEIMERS_DISEASE_ID = 'alzheimers-disease';
7-
const ALZHEIMERS_DIAGNOSIS_ID = 'alzheimers-diagnosis';
8-
const ALZHEIMERS_NEUROINFLAMMATION_ID = 'alzheimers-neuroinflammation';
9-
// const ALZHEIMERS_THERAPEUTICS = 'alzheimers-therapeutics';
1+
import data from '../../example-data/data.json';
102

113
const toDate = o => {
124
o.date = new Date(o.date);
135
return o;
146
};
157
const byDate = (a, b) => { return b.date - a.date; };
16-
export const categories = [
17-
{
18-
id: ALZHEIMERS_DISEASE_ID,
19-
name: 'Alzheimer\'s Disease',
20-
description: 'Latest research reports about AD in the clinic and at the bench.'
21-
},
22-
{
23-
id: ALZHEIMERS_DIAGNOSIS_ID,
24-
name: 'Alzheimer\'s Disease: Diagnosis',
25-
description: 'Diagnostics, biomarkers and their relationship to AD phenotypes.'
26-
},
27-
{
28-
id: ALZHEIMERS_NEUROINFLAMMATION_ID,
29-
name: 'Alzheimer\'s Disease: Neuroinflammation',
30-
description: 'Relationships between neuroinflammation and amyloid and tau pathologies and its effect on disease trajectory.'
31-
}
32-
// ,
33-
// {
34-
// id: ALZHEIMERS_THERAPEUTICS,
35-
// name: 'Alzheimer\'s Disease: Therapeutics',
36-
// description: 'Nonpharmacological and pharmacological management of the cognitive and behavioral symptoms of AD.'
37-
// }
38-
];
39-
8+
export const categories = data.map(({ id, name, description, img }) => ({ id, name, description, img }));
409
export const getPapers = ({ id, limit = 20 }) => {
41-
let papers;
42-
43-
switch (id) {
44-
case ALZHEIMERS_DISEASE_ID:
45-
papers = alzheimersDisease;
46-
break;
47-
case ALZHEIMERS_DIAGNOSIS_ID:
48-
papers = alzheimersDiagnosis;
49-
break;
50-
case ALZHEIMERS_NEUROINFLAMMATION_ID:
51-
papers = alzheimersNeuroinflammation;
52-
break;
53-
// case ALZHEIMERS_THERAPEUTICS:
54-
// papers = alzheimersTherapeutics;
55-
// break;
56-
default:
57-
console.error(`Unable to load ${id}.`);
58-
}
59-
papers = papers.map(toDate).sort(byDate).slice(1, limit);
10+
let papers = [];
11+
const category = data.find(cat => cat.id === id);
12+
papers = category && category.papers.map(toDate).sort(byDate).slice(1, limit);
6013
return papers;
6114
};
6215

src/dashboard/category-card.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function CategoryCard ({ category, store, selectable = true, incl
88
h('div', {
99
class: 'category-bg-img',
1010
style: {
11-
'background-image': `url("img/${category.id}.jpg")`
11+
'background-image': `url("${category.img}")`
1212
}
1313
}),
1414
includeName

0 commit comments

Comments
 (0)