1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
{%extends "phenotypes/base.html"%}
{%from "flash_messages.html" import flash_all_messages%}
{%from "macro-table-pagination.html" import table_pagination%}
{%from "populations/macro-display-population-card.html" import display_population_card%}
{%block title%}Phenotypes{%endblock%}
{%block pagetitle%}Phenotypes{%endblock%}
{%block lvl4_breadcrumbs%}
<li {%if activelink=="view-dataset"%}
class="breadcrumb-item active"
{%else%}
class="breadcrumb-item"
{%endif%}>
<a href="{{url_for('species.populations.phenotypes.view_dataset',
species_id=species.SpeciesId,
population_id=population.Id,
dataset_id=dataset.Id)}}">View</a>
</li>
{%endblock%}
{%block contents%}
{{flash_all_messages()}}
<div class="row">
<p>The basic dataset details are:</p>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Full Name</th>
<th>Short Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{dataset.Name}}</td>
<td>{{dataset.FullName}}</td>
<td>{{dataset.ShortName}}</td>
</tr>
</tbody>
</table>
</div>
<div class="row">
<p><a href="{{url_for('species.populations.phenotypes.add_phenotypes',
species_id=species.SpeciesId,
population_id=population.Id,
dataset_id=dataset.Id)}}"
title="Add a bunch of phenotypes"
class="btn btn-primary">Add phenotypes</a></p>
</div>
<div class="row">
<h2>Phenotype Data</h2>
<p>Click on any of the phenotypes in the table below to view and edit that
phenotype's data.</p>
<p>Use the search to filter through all the phenotypes and find specific
phenotypes of interest.</p>
</div>
<div class="row">
<table id="tbl-phenotypes-list" class="table compact stripe cell-border">
<thead>
<tr>
<th></th>
<th>Index</th>
<th>Record</th>
<th>Description</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
{%endblock%}
{%block sidebarcontents%}
{{display_population_card(species, population)}}
{%endblock%}
{%block javascript%}
<script type="text/javascript">
$(function() {
var species_id = {{species.SpeciesId}};
var population_id = {{population.Id}};
var dataset_id = {{dataset.Id}};
var dataset_name = "{{dataset.Name}}";
var data = {{phenotypes | tojson}};
var dtPhenotypesList = buildDataTable(
"#tbl-phenotypes-list",
data,
[
{
data: function(pheno) {
return `<input type="checkbox" name="selected-phenotypes" `
+ `id="chk-selected-phenotypes-${pheno.InbredSetCode}_${pheno.xref_id}" `
+ `value="${pheno.InbredSetCode}_${pheno.xref_id}" `
+ `class="chk-row-select" />`
}
},
{data: "sequence_number"},
{
data: function(pheno, type, set, meta) {
var spcs_id = {{species.SpeciesId}};
var pop_id = {{population.Id}};
var dtst_id = {{dataset.Id}};
return `<a href="/species/${spcs_id}` +
`/populations/${pop_id}` +
`/phenotypes/datasets/${dtst_id}` +
`/phenotype/${pheno.xref_id}` +
`" target="_blank">` +
`${pheno.InbredSetCode}_${pheno.xref_id}` +
`</a>`;
}
},
{
data: function(pheno) {
return (pheno.Post_publication_description ||
pheno.Original_description ||
pheno.Pre_publication_description);
}
}
],
{
select: "multi+shift",
layout: {
top2: {
buttons: [
{
extend: "selectAll",
className: "btn btn-info",
titleAttr: "Click to select ALL records in the table."
},
{
extend: "selectNone",
className: "btn btn-info",
titleAttr: "Click to deselect ANY selected record(s) in the table."
},
{
text: "Bulk Edit (Download Data)",
action: (event, dt, node, config) => {
var phenoids = [];
var selected = dt.rows({selected: true, page: "all"}).data();
for(var idx = 0; idx < selected.length; idx++) {
phenoids.push({
phenotype_id: selected[idx].Id,
xref_id: selected[idx].xref_id
});
}
if(phenoids.length == 0) {
alert("No record selected. Nothing to do!");
return false;
}
$.ajax(
(`/species/${species_id}/populations/` +
`${population_id}/phenotypes/datasets/` +
`${dataset_id}/download`),
{
method: "POST",
data: JSON.stringify(phenoids),
xhrFields: {
responseType: "blob"
},
success: (data, textStatus, jqXHR) => {
var link = document.createElement("a");
uri = window.URL.createObjectURL(data);
link.href = uri;
link.download = `${dataset_name}_data.tsv`;
document.body.appendChild(link);
link.click();
window.URL.revokeObjectURL(uri);
link.remove();
},
error: (jQXHR, textStatus, errorThrown) => {
console.log("Experienced an error: ", textStatus);
console.log("The ERROR: ", errorThrown);
},
contentType: "application/json"
});
},
className: "btn btn-info",
titleAttr: "Click to download data for editing."
},
{
text: "Bulk Edit (Upload Data)",
action: (event, dt, node, config) => {
alert("Not implemented yet!")
},
className: "btn btn-info",
titleAttr: "Click to upload edited data you got by clicking the `Bulk Edit (Download Data)` button."
}
]
},
top1Start: {
pageLength: {
text: "Show _MENU_ of _TOTAL_"
}
},
topStart: "info",
top1End: null
},
rowId: function(pheno) {
return `${pheno.InbredSetCode}_${pheno.xref_id}`;
}
});
});
</script>
{%endblock%}
|