-
Notifications
You must be signed in to change notification settings - Fork 479
/
file-download-button-fragment.xhtml
266 lines (259 loc) · 18.5 KB
/
file-download-button-fragment.xhtml
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
255
256
257
258
259
260
261
262
263
264
265
266
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:jsf="http://xmlns.jcp.org/jsf"
xmlns:pt="http://java.sun.com/jsf/passthrough"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:o="http://omnifaces.org/ui"
xmlns:iqbs="http://xmlns.jcp.org/jsf/composite/iqbs">
<!-- Download Options -->
<ui:fragment rendered="#{fileDownloadHelper.canDownloadFile(fileMetadata)}">
<li class="dropdown-header">#{bundle['file.accessBtn.header.download']} <span class="glyphicon glyphicon-download-alt"/></li>
<li jsf:rendered="#{!fileMetadata.dataFile.tabularData}">
<p:commandLink rendered="#{!(fileMetadata.dataFile.tabularData) and !(downloadPopupRequired)
and fileMetadata.dataFile.filePackage and systemConfig.HTTPDownload}"
styleClass="btn-download" process="@this"
disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
update="@widgetVar(downloadPackagePopup)" oncomplete="PF('downloadPackagePopup').show();handleResizeDialog('downloadPackagePopup');">
<f:actionListener binding="#{packagePopupFragmentBean.setFileMetadata(fileMetadata)}" />
<f:actionListener binding="#{fileDownloadService.writeGuestbookResponseRecord(guestbookResponse, fileMetadata, 'package')}" />
<!-- package data file: -->
<!-- no guest book/terms of use/etc. - straight package popup -->
#{bundle.download}
</p:commandLink>
<p:commandLink rendered="#{!(fileMetadata.dataFile.tabularData) and (downloadPopupRequired)
and fileMetadata.dataFile.filePackage and systemConfig.HTTPDownload}"
styleClass="btn-download"
process="@this"
disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
action="#{guestbookResponseService.modifyDatafileAndFormat(guestbookResponse, fileMetadata, 'package')}"
update="@widgetVar(downloadPopup)" oncomplete="PF('downloadPopup').show();handleResizeDialog('downloadPopup');">
<f:actionListener binding="#{packagePopupFragmentBean.setFileMetadata(fileMetadata)}" />
<!-- package data file: -->
<!-- guest book or terms of use, etc. enabled - open "download popup" first: -->
#{bundle.download}
</p:commandLink>
<p:commandLink rendered="#{!(fileMetadata.dataFile.tabularData) and !(downloadPopupRequired)
and !(fileMetadata.dataFile.filePackage and systemConfig.HTTPDownload)}"
styleClass="btn-download"
process="@this"
disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
actionListener="#{fileDownloadService.writeGuestbookAndStartFileDownload(guestbookResponse, fileMetadata, 'Download')}">
<!-- non-tabular data file: -->
<!-- no guest book/terms of use/etc. - straight to the download API url: -->
#{bundle.download}
</p:commandLink>
<p:commandLink rendered="#{!(fileMetadata.dataFile.tabularData) and downloadPopupRequired
and !(fileMetadata.dataFile.filePackage and systemConfig.HTTPDownload)}"
styleClass="btn-download"
process="@this"
disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
action="#{guestbookResponseService.modifyDatafile(guestbookResponse, fileMetadata)}"
update="@widgetVar(downloadPopup)" oncomplete="PF('downloadPopup').show();handleResizeDialog('downloadPopup');">
<!-- guest book or terms of use, etc. enabled - open "download popup" first: -->
#{bundle.download}
</p:commandLink>
</li>
<!-- SUBMENU LINK -->
<ui:fragment rendered="#{fileMetadata.dataFile.tabularData}">
<ui:remove>
<li>
<p:commandLink styleClass="highlightBold btn-download" rendered="#{!(downloadPopupRequired)}"
process="@this"
actionListener="#{fileDownloadService.writeGuestbookAndStartFileDownload(guestbookResponse, fileMetadata, 'bundle')}">
#{bundle['file.downloadBtn.format.all']}
</p:commandLink>
<p:commandLink styleClass="highlightBold btn-download" rendered="#{downloadPopupRequired}"
process="@this"
action="#{guestbookResponseService.modifyDatafileAndFormat(guestbookResponse, fileMetadata, 'bundle' )}"
update="@widgetVar(downloadPopup)"
oncomplete="PF('downloadPopup').show();handleResizeDialog('downloadPopup');">
#{bundle['file.downloadBtn.format.all']}
</p:commandLink>
</li>
<li role="presentation" class="divider"></li>
</ui:remove>
<li>
<p:commandLink styleClass="btn-download" rendered="#{!downloadPopupRequired and !(fileMetadata.dataFile.originalFormatLabel == 'UNKNOWN')}"
process="@this"
disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
actionListener="#{fileDownloadService.writeGuestbookAndStartFileDownload(guestbookResponse, fileMetadata, 'original')}">
<h:outputFormat value="#{bundle['file.downloadBtn.format.original']}">
<f:param value="#{fileMetadata.dataFile.originalFormatLabel}"/>
</h:outputFormat>
</p:commandLink>
<p:commandLink styleClass="btn-download" rendered="#{downloadPopupRequired and !(fileMetadata.dataFile.originalFormatLabel == 'UNKNOWN')}"
process="@this"
disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
action="#{guestbookResponseService.modifyDatafileAndFormat(guestbookResponse, fileMetadata, 'original' )}"
update="@widgetVar(downloadPopup)"
oncomplete="PF('downloadPopup').show();handleResizeDialog('downloadPopup');">
<h:outputFormat value="#{bundle['file.downloadBtn.format.original']}">
<f:param value="#{fileMetadata.dataFile.originalFormatLabel}"/>
</h:outputFormat>
</p:commandLink>
</li>
<li>
<p:commandLink styleClass="btn-download" rendered="#{!downloadPopupRequired}"
process="@this"
disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
actionListener="#{fileDownloadService.writeGuestbookAndStartFileDownload(guestbookResponse, fileMetadata, 'tab')}">
#{bundle['file.downloadBtn.format.tab']}
</p:commandLink>
<p:commandLink styleClass="btn-download" rendered="#{downloadPopupRequired}"
action="#{guestbookResponseService.modifyDatafileAndFormat(guestbookResponse, fileMetadata, 'tab' )}"
disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
update="@widgetVar(downloadPopup)"
oncomplete="PF('downloadPopup').show();handleResizeDialog('downloadPopup');">
#{bundle['file.downloadBtn.format.tab']}
</p:commandLink>
</li>
<ui:fragment rendered="#{!(fileMetadata.dataFile.originalFormatLabel == 'RData')}">
<li>
<p:commandLink styleClass="btn-download" rendered="#{!downloadPopupRequired}"
process="@this"
disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
actionListener="#{fileDownloadService.writeGuestbookAndStartFileDownload(guestbookResponse, fileMetadata, 'RData')}">
#{bundle['file.downloadBtn.format.rdata']}
</p:commandLink>
<p:commandLink styleClass="btn-download" rendered="#{downloadPopupRequired}"
process="@this"
disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
action="#{guestbookResponseService.modifyDatafileAndFormat(guestbookResponse, fileMetadata, 'RData' )}"
update="@widgetVar(downloadPopup)"
oncomplete="PF('downloadPopup').show();handleResizeDialog('downloadPopup');">
#{bundle['file.downloadBtn.format.rdata']}
</p:commandLink>
</li>
</ui:fragment>
<li>
<p:commandLink styleClass="btn-download" rendered="#{!downloadPopupRequired}"
process="@this"
disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
actionListener="#{fileDownloadService.writeGuestbookAndStartFileDownload(guestbookResponse, fileMetadata, 'var')}">
#{bundle['file.downloadBtn.format.var']}
</p:commandLink>
<p:commandLink styleClass="btn-download" rendered="#{downloadPopupRequired}"
process="@this"
disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
action="#{guestbookResponseService.modifyDatafileAndFormat(guestbookResponse, fileMetadata, 'var' )}"
update="@widgetVar(downloadPopup)"
oncomplete="PF('downloadPopup').show();handleResizeDialog('downloadPopup');">
#{bundle['file.downloadBtn.format.var']}
</p:commandLink>
</li>
<li class="dropdown-submenu pull-left">
<a tabindex="-1" href="javascript:void(0);">#{bundle['file.downloadBtn.format.citation']}</a>
<ul class="dropdown-menu">
<li>
<h:commandLink styleClass="btn-download" actionListener="#{fileDownloadService.downloadDatafileCitationRIS(fileMetadata)}">
<h:outputText value="#{bundle['dataset.cite.downloadBtn.ris']}" />
</h:commandLink>
</li>
<li>
<h:commandLink styleClass="btn-download" action="#{fileDownloadService.downloadDatafileCitationXML(fileMetadata)}">
<h:outputText value="#{bundle['dataset.cite.downloadBtn.xml']}" />
</h:commandLink>
</li>
<li>
<h:commandLink styleClass="btn-download" action="#{fileDownloadService.downloadDatafileCitationBibtex(fileMetadata)}">
<h:outputText value="#{bundle['dataset.cite.downloadBtn.bib']}" />
</h:commandLink>
</li>
</ul>
</li>
</ui:fragment>
<!-- END: SUBMENU LINK -->
<!-- UI HACK FIX SUBMENU PULL-FLOAT FIX -->
<li role="presentation" class="clearfix"></li>
</ui:fragment>
<!-- Download Options -->
<!-- Request Access Options -->
<!-- Output panel makes the "Request Access" button label pull left Access Requested looks OK -->
<p:outputPanel layout="#{fileMetadata.dataFile.fileAccessRequesters.contains(dataverseSession.user) ? 'block' : 'inline'}" id="requestPanel">
<ui:fragment rendered="#{!fileMetadata.datasetVersion.deaccessioned and !fileDownloadHelper.canDownloadFile(fileMetadata)
and fileMetadata.dataFile.owner.fileAccessRequest}" >
<li class="dropdown-header">#{bundle['file.accessBtn.header.download']} <span class="glyphicon glyphicon-download-alt"/></li>
<li class="#{fileMetadata.dataFile.fileAccessRequesters.contains(dataverseSession.user) ? 'disabled' : ''}">
<p:commandLink styleClass="btn-request" rendered="#{fileDownloadHelper.session.user.authenticated}"
actionListener="#{fileDownloadHelper.handleCommandLinkClick(fileMetadata)}"
update="@([id$=requestAccessConsolidated]), @([id$=requestPanel])"
id="requestAccessConsolidated"
disabled="#{fileMetadata.dataFile.fileAccessRequesters.contains(dataverseSession.user)}">
<!-- TODO fix disabled styling span vs a -->
#{fileMetadata.dataFile.fileAccessRequesters.contains(dataverseSession.user) ? bundle['file.accessRequested'] : bundle['file.requestAccess']}
</p:commandLink>
<p:commandLink styleClass="btn-request" rendered="#{!fileDownloadHelper.session.user.authenticated }"
process="@this"
onclick="PF('accessSignUpLogIn_popup').show()">
#{bundle['file.requestAccess']}
</p:commandLink>
</li>
</ui:fragment>
</p:outputPanel>
<!-- END: Request Access Options -->
<!-- Explore Options -->
<ui:fragment rendered="#{fileDownloadHelper.canDownloadFile(fileMetadata) and not empty exploreTools or (worldMapPermissionHelper.canUserSeeExploreWorldMapButtonFromPage(fileMetadata))}">
<!--exploreTools is set as a ui:param by the file and dataset pages-->
<!--Note that "WorldMap Explore" is not an explore tool (external tool)-->
<li class="dropdown-header">#{bundle['dataset.accessBtn.header.explore']} <span class="glyphicon glyphicon-equalizer"/></li>
<!-- externalTools -->
<ui:repeat var="tool" value="#{exploreTools}">
<li>
<p:commandLink rendered="#{!downloadPopupRequired}"
styleClass="btn-explore #{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
action="#{fileDownloadService.explore(guestbookResponse, fileMetadata, tool )}">
#{tool.getDisplayNameLang()}
</p:commandLink>
<!--The modifyDatafileAndFormat method below was added because on the dataset page, "tool" is null in the popup so we store it in the guestbookResponse because we know we'll need it later in the popup.-->
<p:commandLink rendered="#{downloadPopupRequired}"
action="#{guestbookResponseService.modifyDatafileAndFormat(guestbookResponse, fileMetadata, 'externalTool', tool)}"
styleClass="btn-explore #{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload)}"
process="@this"
update="@widgetVar(downloadPopup)"
oncomplete="PF('downloadPopup').show();handleResizeDialog('downloadPopup');">
#{tool.getDisplayNameLang()}
</p:commandLink>
</li>
</ui:repeat>
<!-- END: externalTools -->
<!-- WorldMap -->
<li jsf:rendered="#{worldMapPermissionHelper.canUserSeeExploreWorldMapButtonFromPage(fileMetadata)}">
<h:commandLink rendered="#{!downloadPopupRequired}"
styleClass="btn-explore #{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
action="#{fileDownloadService.startWorldMapDownloadLink(guestbookResponse, fileMetadata )}"
target="_blank" rel="noopener">
#{bundle['file.mapData.worldMap']}
</h:commandLink>
<p:commandLink rendered="#{downloadPopupRequired}"
styleClass="btn-explore #{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
disabled="#{fileMetadata.dataFile.ingestInProgress or lockedFromDownload}"
process="@this"
action="#{guestbookResponseService.modifyDatafileAndFormat(guestbookResponse, fileMetadata, 'worldMap' )}"
update="@widgetVar(downloadPopup)"
oncomplete="PF('downloadPopup').show();handleResizeDialog('downloadPopup');">
#{bundle['file.mapData.worldMap']}
</p:commandLink>
</li>
<!-- END: WorldMap -->
</ui:fragment>
<!-- Explore Options -->
<!-- Compute Options -->
<ui:fragment rendered="#{(isFilePg ? FilePage.showComputeButton() : DatasetPage.showComputeButton(fileMetadata)) and fileDownloadHelper.canDownloadFile(fileMetadata)}">
<li class="dropdown-header">#{bundle['dataset.accessBtn.header.compute']} <span class="glyphicon glyphicon-flash"/></li>
<li>
<h:outputLink value="#{isFilePg ? FilePage.computeUrl : DatasetPage.getComputeUrl(fileMetadata)}" styleClass="btn-compute"
target="_blank" rel="noopener">
#{bundle['file.compute']}
</h:outputLink>
</li>
</ui:fragment>
<!-- END: Compute Options -->
</ui:composition>