-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathstudiesOverview.html
More file actions
66 lines (57 loc) · 2.79 KB
/
studiesOverview.html
File metadata and controls
66 lines (57 loc) · 2.79 KB
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
<script type="text/javascript" nonce="<%=scriptNonce%>">
(function($, LABKEY) {
$(function(){
$( document ).ready(function() {
// TODO: ultimately replace this page with a better card view of the data:
var webpart = <%=webpartContext%>;
$('#' + webpart.wrapperDivId).append('<div id="' + webpart.wrapperDivId + '-studies"></div>')
LDK.Utils.getBasicQWP({
frame: 'portal',
title: 'List of Studies',
name: 'query',
schemaName: 'studies',
queryName: 'studies',
maxRows: 10
}).render(webpart.wrapperDivId + '-studies');
// LABKEY.Query.selectRows({
// schemaName: 'studies',
// queryName: 'studies',
// scope: this,
// failure: LDK.Utils.getErrorCallback(),
// success: function (results) {
// // TODO: render some sort of card/tile view
// //console.log(results)
// }
// })
LABKEY.Query.selectRows({
schemaName: 'study',
queryName: 'datasets',
columns: 'Name,Label,CategoryId/Label',
scope: this,
failure: LDK.Utils.getErrorCallback(),
success: function (results) {
let div = $('<div>')
const dataByCategory = {}
results.rows.sort((a, b) => a.Label.localeCompare(b.Label)).forEach(row => {
const dsUrl = LABKEY.ActionURL.buildURL('query', 'executeQuery', null, {
schemaName: 'study',
queryName: row.Name
});
dataByCategory[row['CategoryId/Label']] = dataByCategory[row['CategoryId/Label']] || []
dataByCategory[row['CategoryId/Label']].push(`<li><a href="${dsUrl}">${row.Label}</a></li>`)
})
Object.keys(dataByCategory).sort().forEach(category => {
div.append('<h4 style="font-weight: bold;">' + category + '</h4>').append('<ul>')
dataByCategory[category].forEach(item => {
div.append(item)
})
div.append('</ul>')
})
$('#' + webpart.wrapperDivId).append(div)
}
})
})
});
}(jQuery, LABKEY));
</script>
<div style="padding-bottom: 20px;">Below is a list of the studies tracked in this folder. Please use the <a href="<%=contextPath%>/project/<%=containerPath%>/begin.view?pageId=dataBrowser">Data Browser</a> tab to browse the dataset tracked in this project.</div>