Skip to content

Commit

Permalink
#4342 - Show document size in documents table
Browse files Browse the repository at this point in the history
- Added size column
  • Loading branch information
reckart committed Dec 3, 2023
1 parent 6bc1736 commit 523e8ec
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 77 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!DOCTYPE html>
<!--
/*
Licensed to the Technische Universität Darmstadt under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
Expand All @@ -15,77 +14,15 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html xmlns:wicket="http://wicket.apache.org">
<wicket:head>
<style type="text/css">
.document-table thead { background: var(--bs-body-bg); position: sticky; top: 0; z-index: 1; }
.document-table thead td, .document-table thead th{ border-bottom-width: 0 !important; }
.document-table tr td, .document-table tr th { text-align: center; }
.document-table tr th { white-space: nowrap; }
.document-table tr td:nth-child(3), .document-table tr th:nth-child(3) { text-align: left; width: 100%;}
.document-table tr td:nth-child(4), .document-table tr th:nth-child(4) { white-space: nowrap;}
.document-table tr td:nth-child(5), .document-table tr th:nth-child(5) { white-space: nowrap;}
.document-table tr td:nth-child(6), .document-table tr th:nth-child(6) { white-space: nowrap;}
.document-table col.s, .document-table tr.s , .document-table td.s { background-color: var(--primary); }
.document-table .state-toggle { white-space: nowrap; cursor: pointer; }
</style>
</wicket:head>
<wicket:panel>
<div class="flex-v-container flex-content">
<div wicket:id="confirmationDialog"/>
<div class="flex-h-container flex-gutter flex-only-internal-gutter justify-content-end mb-3">
<div class="flex-content">
<input wicket:id="nameFilter" class="form-control" wicket:message="placeholder:nameFilter.placeholder"/>
</div>
<div wicket:id="stateFilters" />
<span class="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="btn-group" role="group">
<button wicket:id="toggleBulkChange" class="btn btn-action" type="button">
Bulk action
</button>
<button wicket:id="bulkActionDropdownButton" class="btn btn-primary btn-action dropdown-toggle flex-content border-start" type="button" data-bs-toggle="dropdown"></button>
<div wicket:id="bulkActionDropdown" class="dropdown-menu shadow-lg" role="menu" style="min-width: 20em;">
<a wicket:id="bulkExport" class="dropdown-item">
<span class="badge text-reset">
<i class="fas fa-file-download"></i>
</span>
Export selected
</a>
<a wicket:id="bulkDelete" class="dropdown-item">
<span class="badge badge-pill text-bg-danger">
<i class="fas fa-trash"></i>
</span>
Delete selected
</a>
</div>
</span>
</span>
</div>
<div class="flex-content scrolling flex-h-container border">
<div class="flex-content">
<table wicket:id="dataTable" class="table table-sm table-hover table-striped document-table" cellspacing="0"
align="center" />
</div>
</div>
</div>
</wicket:panel>
<wicket:fragment wicket:id="select-column-header">
<input wicket:id="allSelected" type="checkbox"/>
</wicket:fragment>
<wicket:fragment wicket:id="select-column">
<input wicket:id="selected" type="checkbox"/>
</wicket:fragment>
<wicket:fragment wicket:id="deleteDocumentColumn">
<button wicket:id="delete" type="button" class="btn btn-inline btn-outline-danger btn-inline text-nowrap">
<i class="fas fa-trash"></i>
<wicket:message key="delete"/>
</button>
</wicket:fragment>
<wicket:fragment wicket:id="exportDocumentColumn">
<button wicket:id="export" type="button" class="btn btn-inline btn-outline-secondary btn-inline text-nowrap">
<i class="fas fa-file-download"></i>
<wicket:message key="export"/>
</button>
</wicket:fragment>
</html>
*/
.document-table thead { background: var(--bs-body-bg); position: sticky; top: 0; z-index: 1; }
.document-table thead td, .document-table thead th{ border-bottom-width: 0 !important; }
.document-table tr td, .document-table tr th { text-align: center; }
.document-table tr th { white-space: nowrap; }
.document-table tr td:nth-child(3), .document-table tr th:nth-child(3) { text-align: left; width: 100%;}
.document-table tr td:nth-child(4), .document-table tr th:nth-child(4) { white-space: nowrap;}
.document-table tr td:nth-child(5), .document-table tr th:nth-child(5) { white-space: nowrap;}
.document-table tr td:nth-child(6), .document-table tr th:nth-child(6) { white-space: nowrap;}
.document-table tr td:nth-child(7), .document-table tr th:nth-child(7) { white-space: nowrap;}
.document-table col.s, .document-table tr.s , .document-table td.s { background-color: var(--primary); }
.document-table .state-toggle { white-space: nowrap; cursor: pointer; }
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static de.tudarmstadt.ukp.clarin.webanno.ui.project.documents.SourceDocumentTableSortKeys.CREATED;
import static de.tudarmstadt.ukp.clarin.webanno.ui.project.documents.SourceDocumentTableSortKeys.FORMAT;
import static de.tudarmstadt.ukp.clarin.webanno.ui.project.documents.SourceDocumentTableSortKeys.NAME;
import static de.tudarmstadt.ukp.clarin.webanno.ui.project.documents.SourceDocumentTableSortKeys.SIZE;
import static de.tudarmstadt.ukp.clarin.webanno.ui.project.documents.SourceDocumentTableSortKeys.STATE;
import static de.tudarmstadt.ukp.inception.support.lambda.HtmlElementEvents.INPUT_EVENT;
import static de.tudarmstadt.ukp.inception.support.lambda.LambdaBehavior.visibleWhen;
Expand All @@ -34,6 +35,7 @@
import java.util.Date;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalDialog;
import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackHeadersToolbar;
Expand Down Expand Up @@ -120,6 +122,8 @@ public SourceDocumentTable(String aId, IModel<List<SourceDocument>> aModel)
$ -> $.getDocument().getName()));
columns.add(new LambdaColumn<>(new ResourceModel("DocumentFormat"), FORMAT,
$ -> renderFormat($.getDocument().getFormat())));
columns.add(new LambdaColumn<>(new ResourceModel("DocumentSize"), SIZE,
$ -> renderSize($.getDocument())));
columns.add(new LambdaColumn<>(new ResourceModel("DocumentCreated"), CREATED,
$ -> renderDate($.getDocument().getCreated())));
columns.add(new SourceDocumentTableDeleteActionColumn(this));
Expand Down Expand Up @@ -194,6 +198,12 @@ private String renderDate(Date aDate)
return dateFormat.format(aDate);
}

private String renderSize(SourceDocument aDocumnent)
{
return FileUtils.byteCountToDisplaySize(
FileUtils.sizeOf(documentService.getSourceDocumentFile(aDocumnent)));
}

@Override
public void renderHead(IHeaderResponse aResponse)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ DocumentState=State
DocumentName=Name
DocumentFormat=Format
DocumentCreated=Created
DocumentSize=Size
nameFilter.placeholder=Filter by name...
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@

public enum SourceDocumentTableSortKeys
{
NAME, STATE, CREATED, UPDATED, FORMAT;
NAME, STATE, CREATED, UPDATED, SIZE, FORMAT;
}

0 comments on commit 523e8ec

Please sign in to comment.