Skip to content

Commit 4c02952

Browse files
bodom0015lmarini
andauthored
File "CREATED" status should prevent user download / notify user why they can't download (#175)
* Disable the "Download" button for files that have a status of CREATED * Add a banner to call more attention that the file is in-transit * Disable per-File Download button on Dataset and Folder views when file is only CREATED Co-authored-by: Luigi Marini <[email protected]>
1 parent 7694773 commit 4c02952

File tree

3 files changed

+47
-13
lines changed

3 files changed

+47
-13
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## Unreleased
88

9+
### Fixed
10+
- Clowder will no longer offer a Download button for a file until it has been PROCESSED.
11+
912
### Changed
1013
- `/api/me` will now return some of the same information as response headers.
1114

app/views/file.scala.html

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,23 @@ <h1 id="file-name-title" class="inline break-word"> <span class="glyphicon glyph
268268
}
269269
</div>
270270
</div>
271+
@if(file.status == "CREATED") {
272+
<div class="alert alert-warning">
273+
<div class="row">
274+
<div class="col-sm-11">
275+
<strong>Warning!</strong>
276+
This file is still in transit, so the file bytes are not yet available.
277+
<p>You can still attach metadata and comments below.</p>
278+
</div>
279+
<div class="col-sm-1">
280+
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
281+
<span aria-hidden="true">&times;</span>
282+
</button>
283+
</div>
284+
</div>
285+
286+
</div>
287+
}
271288
@for((f, pvs) <- previews) {
272289
<div class="row" id="filePrevContainer_@(f.id.toString)" data-previewsCount="@(pvs.length)" data-filename="@f.filename">
273290
<div class="col-md-12">
@@ -316,13 +333,19 @@ <h4>No previews currently available for this file</h4>
316333
<div class="col-md-12">
317334
<hr/>
318335
<div class="btn-group" role="group" aria-label="...">
319-
@if( Permission.checkPermission(Permission.DownloadFiles, ResourceRef(ResourceRef.file, file.id))) {
320-
<button id="downloadButton" type="button" onclick="return downloadFile();" class="btn btn-link" title="Download and enjoy this file."> <span class="glyphicon glyphicon-save"></span>
336+
@if(file.status == "CREATED") {
337+
<!-- if 'disabled' title is not visible -->
338+
<button type="button" class="btn btn-link disabled" title="Please wait for the file to finish processing."> <span class="glyphicon glyphicon-save"></span>
321339
Download </button>
322340
} else {
341+
@if(!Permission.checkPermission(Permission.DownloadFiles, ResourceRef(ResourceRef.file, file.id))) {
323342
<!-- if 'disabled' title is not visible -->
324-
<button type="button" class="btn btn-link disabled" title="You don't have permission to download this file."> <span class="glyphicon glyphicon-save"></span>
325-
Download </button>
343+
<button type="button" class="btn btn-link disabled" title="You don't have permission to download this file."> <span class="glyphicon glyphicon-save"></span>
344+
Download </button>
345+
} else {
346+
<button id="downloadButton" type="button" onclick="return downloadFile();" class="btn btn-link" title="Download and enjoy this file."> <span class="glyphicon glyphicon-save"></span>
347+
Download </button>
348+
}
326349
}
327350
@if( play.Play.application().configuration().getBoolean("archiveEnabled")) {
328351
@if( Permission.checkPermission(Permission.ArchiveFile, ResourceRef(ResourceRef.file, file.id))) {

app/views/files/listitem.scala.html

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,26 @@ <h3><a href="@(routes.Files.file(file.id, dataset, space, folder))" class="break
5555
</div>
5656
<div class="col-md-4 col-lg-4 col-sm-4">
5757
<ul class="list-unstyled">
58-
@if( Permission.checkPermission(Permission.DownloadFiles, ResourceRef(ResourceRef.file, file.id))) {
58+
@if( file.status == "CREATED" ) {
5959
<li>
60-
<button id="downloadButton" onclick="window.open(jsRoutes.api.Files.download('@file.id').url, '_blank');" class="btn btn-link" title="Download and enjoy this file.">
61-
<span class="glyphicon glyphicon-save"></span> Download
62-
</button>
63-
</li>
64-
} else {
65-
<li>
66-
<div class="inline" title="No permission to download the file">
67-
<button disabled class="btn btn-link"><span class="glyphicon glyphicon-save"></span> Download</button>
60+
<div class="inline" title="Please wait for the file to finish processing.">
61+
<button class="btn btn-link disabled"><span class="glyphicon glyphicon-save"></span> Download</button>
6862
</div>
6963
</li>
64+
} else {
65+
@if( Permission.checkPermission(Permission.DownloadFiles, ResourceRef(ResourceRef.file, file.id))) {
66+
<li>
67+
<button id="downloadButton" onclick="window.open(jsRoutes.api.Files.download('@file.id').url, '_blank');" class="btn btn-link" title="Download and enjoy this file.">
68+
<span class="glyphicon glyphicon-save"></span> Download
69+
</button>
70+
</li>
71+
} else {
72+
<li>
73+
<div class="inline" title="No permission to download the file">
74+
<button disabled class="btn btn-link"><span class="glyphicon glyphicon-save"></span> Download</button>
75+
</div>
76+
</li>
77+
}
7078
}
7179

7280
@user match {

0 commit comments

Comments
 (0)