Skip to content

Commit 12c0cb2

Browse files
committed
Add links in the "Missing activities" table
Also fix occurs_in column.
1 parent 8ab7caf commit 12c0cb2

File tree

1 file changed

+41
-16
lines changed

1 file changed

+41
-16
lines changed

gocam_app/templates/gocam_app/index.html

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,31 @@ <h4>Missing activities</h4>
9595
</div>
9696

9797
<script type="module">
98+
const makeLink = (id, label, title) => {
99+
const bits = id.split(":");
100+
if (bits.length == 2) {
101+
if (bits[0] == 'PomBase') {
102+
return `<a target="_blank" href="/gene/${bits[1]}">${label}</a>`;
103+
}
104+
if (bits[0] == 'FB') {
105+
return `<a target="_blank" href="https://www.flybase.org/reports/${bits[1]}">${label}</a>`;
106+
}
107+
if (bits[0] == 'CHEBI') {
108+
return `<a target="_blank" href="https://www.ebi.ac.uk/chebi/chebiOntology.do?chebiId=${id}">${label} (${id})</a>`;
109+
}
110+
if (bits[0] == 'GO') {
111+
return `<a target="_blank" href="https://amigo.geneontology.org/amigo/term/${id}">${label} (${id})</a>`;
112+
}
113+
if (bits[0].startsWith('gomodel')) {
114+
const modelId = bits[1];
115+
let href = `${appPath}/view/${modelId}`;
116+
return `<a target="_blank" href="${href}">${label}</a>`;
117+
}
118+
}
119+
120+
return label;
121+
};
122+
98123
const appPath = '{{app_path}}';
99124
const apiPath = '{{api_path}}';
100125
const holesUrl = `${apiPath}/missing_activities`;
@@ -106,43 +131,43 @@ <h4>Missing activities</h4>
106131
for (const hole of holes) {
107132
const rowEl = document.createElement("tr");
108133
tbody.appendChild(rowEl);
109-
let [modelId, modelTitle] = hole.models[0];
110-
modelId = modelId.replace('gomodel:', '');
134+
let [longModelId, modelTitle] = hole.models[0];
135+
const modelId = longModelId.replace('gomodel:', '');
111136

112137
const modelEl = document.createElement("td");
113138
rowEl.appendChild(modelEl);
114-
const modelLinkEl = document.createElement('a');
115-
modelEl.appendChild(modelLinkEl);
116-
modelLinkEl.textContent = modelTitle;
117-
modelLinkEl.setAttribute('target', '_blank');
118-
modelLinkEl.setAttribute('href', appPath + '/view/' + modelId);
139+
const modelHtml = makeLink(longModelId, modelTitle);
140+
modelEl.insertAdjacentHTML('afterbegin', modelHtml);
119141

120142
const missingActivityEl = document.createElement("td");
121143
rowEl.appendChild(missingActivityEl);
122-
missingActivityEl.textContent =
123-
hole.label + ' (' + hole.node_id + ')';
144+
const missingActivityHtml = makeLink(hole.node_id, hole.label);
145+
missingActivityEl.insertAdjacentHTML('afterbegin', missingActivityHtml);
124146

125147
const processEl = document.createElement("td");
126148
rowEl.appendChild(processEl);
127-
processEl.textContent = hole.part_of_process.label + ' (' +
128-
hole.part_of_process.id + ')';
149+
const processHtml = makeLink(hole.part_of_process.id, hole.part_of_process.label);
150+
processEl.insertAdjacentHTML('afterbegin', processHtml);
129151

130-
let inputs = hole.has_input.map(input => input.label).join(',');
152+
let inputs = hole.has_input.map(input => makeLink(input.id, input.label)).join(',');
131153
if (inputs.length == 0) {
132154
inputs = '?';
133155
}
134-
let outputs = hole.has_output.map(output => output.label).join(',');
156+
let outputs = hole.has_output.map(output => makeLink(output.id, output.label)).join(',');
135157
if (outputs.length == 0) {
136158
outputs = '?';
137159
}
138160
const inputOutputEl = document.createElement("td");
139161
rowEl.appendChild(inputOutputEl);
140-
inputOutputEl.textContent = inputs + ' / ' + outputs;
162+
inputOutputEl.insertAdjacentHTML('afterbegin', inputs + ' / ' + outputs);
141163

142-
let occursInText = hole.has_input.map(input => input.label).join(',');
143164
const occursInEl = document.createElement("td");
144165
rowEl.appendChild(occursInEl);
145-
occursInEl.textContent = occursInText;
166+
const occursInHtml = hole.occurs_in.map(occurs_in => {
167+
const component = occurs_in.complex_component || occurs_in.other_component;
168+
return makeLink(component.id, component.label);
169+
}).join(',');
170+
occursInEl.insertAdjacentHTML('afterbegin', occursInHtml);
146171
}
147172
</script>
148173
</body>

0 commit comments

Comments
 (0)