-
Notifications
You must be signed in to change notification settings - Fork 0
/
home_page.js
254 lines (214 loc) · 7.32 KB
/
home_page.js
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
import { commonCss, getDataBroker } from './lib/iobio-charts/common.js';
import { navigateTo } from './router.js';
import { URLInputModal } from './url_input_modal.js';
import { LocalFileInputModal } from './local_file_input_modal.js';
import waygate from 'waygate';
const homePageTemplate = document.createElement('template');
homePageTemplate.innerHTML = `
<style>
${commonCss}
#main {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-left: auto;
margin-right: auto;
margin-top: 100px;
width: 100%;
height: 100%;
}
.home-page-title {
font-size: 28px;
color: rgb(110,110,110);
margin-bottom: 30px;
text-align: center;
}
.file-loading-container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 20px;
}
#local-file-selection {
display: none;
}
.local-file-input,
.remote-file-input,
.demo-data-input {
width: 300px;
height: 60px;
text-align: center;
background-color: var(--data-color);
}
.file-selection-button {
display: flex;
justify-content: center;
align-items: center;
color: white;
height: 100%;
font-size: 20px;
cursor: pointer;
}
#info {
margin-top: 50px;
}
#info ul {
list-style-type: none;
padding: 0;
text-align: center;
}
#info li {
display: inline;
margin-right: 25px;
cursor: pointer;
color: var(--data-color);
}
.variant-files {
margin: 50px auto 0px auto;
font-size: 23px;
width: 100%;
text-align: center;
color: rgb(110,110,110);
}
#marth-lab-footer {
width: 100%;
margin-top: 100px;
padding-bottom: 20px;
}
.logos {
margin: 0px auto 10px auto;
width: 1200px;
text-align: center;
position: relative;
height: 60px;
color: rgb(80,80,80);
}
a {
color: var(--data-color);
text-decoration: none; !important;
}
#marthlabtext {
position: absolute;
left: 100px;
top: 4px;
font-size: 50px;
color: rgb(80, 80, 80);
}
</style>
<div id="main">
<div class="home-page-title">
Examine your sequence alignment file in seconds
</div>
<div class="file-loading-container">
<div class="local-file-input">
<div id="local-file-selection-button" class="file-selection-button">LOCAL BAM/CRAM FILE</div>
</div>
<div class="remote-file-input">
<div id="remote-file-selection-button" class="file-selection-button">REMOTE BAM/CRAM URL</div>
</div>
<div class="demo-data-input">
<div id="demo-data-selection-button" class="file-selection-button">LAUNCH WITH DEMO DATA</div>
</div>
</div>
<div id="info">
<ul>
<li><a href="http://www.nature.com/nmeth/journal/v11/n12/full/nmeth.3174.html">Publication</a></li>
<li><span id="file-requirements-button" data-link="/file-requirements">File Requirements</span></li>
<li><span data-link="/license">License</span></li>
</ul>
</div>
<div class="variant-files">
<div>For variant files check out <a href="http://vcf.iobio.io">vcf.iobio</a></div>
</div>
</div>
<div id="marth-lab-footer">
<div class="logos">
<a href="https://marthlab.org/">
<div id="marthlabtext">Marthlab</div>
</a>
<a href="https://ucgd.genetics.utah.edu/">
<img src="https://s3.us-east-1.amazonaws.com/static.iobio.io/prod/bam.iobio.io/bam2.0/ustar-ucgd-logo.jpg" style="height:60px;" alt="USTAR UCGD Logo not found"/>
</a>
<a href="http://www.genetics.utah.edu/">
<img src="https://s3.us-east-1.amazonaws.com/static.iobio.io/prod/bam.iobio.io/bam2.0/genetics_mainlogo3_lrg.png" style="height:50px;position:absolute;right:0px;top:7px" alt="Genetics Logo not found"/>
</a>
</div>
</div>
<iobio-url-input-modal id="url-input-modal"></iobio-url-input-modal>
<iobio-local-file-input-modal id="local-file-input-modal"></iobio-local-file-input-modal>
`;
class HomePage extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.shadowRoot.appendChild(homePageTemplate.content.cloneNode(true));
this.initDOMElements();
}
initDOMElements() {
this.localFileButton = this.shadowRoot.querySelector('#local-file-selection-button');
this.remoteFileButton = this.shadowRoot.querySelector('#remote-file-selection-button');
this.demoFileButton = this.shadowRoot.querySelector('#demo-data-selection-button');
this.localFileInputModal = this.shadowRoot.querySelector('#local-file-input-modal');
this.urlInputModal = this.shadowRoot.querySelector('#url-input-modal');
}
connectedCallback() {
this.broker = getDataBroker(this);
this.localFileButton.addEventListener('click', () => this.localFileInputModal.showModal());
// Handle the custom event from the local-file-input-modal
this.localFileInputModal.addEventListener('local-file-loaded', async (event) => this.handleLocalFileLoaded(event));
this.remoteFileButton.addEventListener('click', () => this.urlInputModal.showModal());
// Handle the custom event from the url-input-modal
this.urlInputModal.addEventListener('remote-file-loaded', (event) => {
const [url1, url2] = event.detail.urls;
this.navigateToMainContent(url1, url2);
});
this.demoFileButton.addEventListener('click', () => this.handleDemoFilePick());
// Handle navigation clicks for internal links with data-link inside shadow DOM
this.shadowRoot.querySelectorAll('[data-link]').forEach(link => {
link.addEventListener('click', (event) => {
event.preventDefault();
const url = event.target.getAttribute('data-link');
navigateTo(url);
});
});
}
async handleLocalFileLoaded(event) {
const files = event.detail.files
// set up the waygate
const dirTree = waygate.openDirectory();
dirTree.addFiles(files)
const listener = await waygate.listen({
serverDomain: waygate.setServerUri('https://waygate.iobio.io'),
tunnelType: 'websocket',
});
// set up the new URLs for the files
const tunnelDomain = listener.getDomain();
waygate.serve(listener, waygate.directoryTreeHandler(dirTree));
const url1 = `https://${tunnelDomain}/${files[0].name}`;
const url2 = `https://${tunnelDomain}/${files[1].name}`;
this.navigateToMainContent(url1, url2);
}
handleDemoFilePick() {
const demoFileUrl = 'https://s3.amazonaws.com/iobio/NA12878/NA12878.autsome.bam'
this.navigateToMainContent(demoFileUrl, null);
}
// Navigate to the main content page with the URLs
navigateToMainContent(url1, url2) {
if (url1 !== this.broker.alignmentUrl) {
// reset the state
this.broker.reset();
}
const queryParams = new URLSearchParams({
'alignment-url': url1,
});
if (url2) {
queryParams.append('index-url', url2);
}
const mainContentUrl = `/?${queryParams.toString()}`;
navigateTo(mainContentUrl);
}
}
customElements.define('iobio-home-page', HomePage);
export { HomePage }