Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAK-49250 Site Archive No pagination, no ability to sort columns and no search #13231

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions admin-tools/src/bundle/archive.properties
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,25 @@ archive.download.size = Size
archive.download.hash = Hash <small>(SHA-1)</small>
archive.download.auth = Archive download is limited to administrators.
archive.download.none = No archives are available to download at this time.

# Search related messages
search.label=Search
search.button=Search
search.clear=Clear Search

no.archives=No archives available
no.archives.search=No archives found matching

# Search
archive.search.placeholder=Search archives...
archive.search.button=Search
archive.search.clear=Clear

# Paging
archive.list.youare=Viewing {0} to {1} of {2} items
archive.list.show=Show {0} items
archive.list.first=Go to first page
archive.list.previous.withsize=Previous {0}
archive.list.next.withsize=Next {0}
archive.list.last=Go to last page
archive.list.listnavselect=To operate the combo box, press Alt+Down to open it, Alt+Up to close it, and Alt+# to select an option.
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public String buildDownloadContext(VelocityPortlet portlet, Context context, Run

Calendar calendar = Calendar.getInstance();

//porcess the list. also get the hash for the file if it exists
//process the list. also get the hash for the file if it exists
for(File f: files) {

String absolutePath = f.getAbsolutePath();
Expand Down Expand Up @@ -311,8 +311,31 @@ public String buildDownloadContext(VelocityPortlet portlet, Context context, Run

zips.add(sf);
}

context.put("archives", zips);

int totalItems = zips.size();
int pageSize = state.getAttribute("pagesize") != null ? ((Integer) state.getAttribute("pagesize")).intValue() : 10;
int currentPage = state.getAttribute("current-page") != null ? ((Integer) state.getAttribute("current-page")).intValue() : 1;
int startIndex = (currentPage - 1) * pageSize;
int endIndex = Math.min(startIndex + pageSize, totalItems);

context.put("totalNumber", totalItems);
context.put("pagesize", pageSize);
context.put("numbers", new Integer[]{startIndex + 1, endIndex, totalItems});
context.put("goFPButton", currentPage > 1 ? "true" : "false");
context.put("goPPButton", currentPage > 1 ? "true" : "false");
context.put("goNPButton", endIndex < totalItems ? "true" : "false");
context.put("goLPButton", endIndex < totalItems ? "true" : "false");

List<Integer[]> sizeList = new ArrayList<>();
sizeList.add(new Integer[]{10});
sizeList.add(new Integer[]{20});
sizeList.add(new Integer[]{50});
sizeList.add(new Integer[]{100});
sizeList.add(new Integer[]{200});
context.put("sizeList", sizeList);

List<SparseFile> pagedZips = zips.subList(startIndex, endIndex);
context.put("archives", pagedZips);

return "-download";
}
Expand Down Expand Up @@ -589,10 +612,63 @@ public void doView_batch(RunData data){
* @param data RunData
*/
public void doView_download(RunData data){
SessionState state = ((JetspeedRunData) data).getPortletSessionState(((JetspeedRunData) data).getJs_peid());
SessionState state = ((JetspeedRunData)data).getPortletSessionState(((JetspeedRunData)data).getJs_peid());
state.setAttribute(STATE_MODE, DOWNLOAD_MODE);
}

/**
* Handle a request to change the page size
*/
public void doChange_pagesize(RunData data) {
SessionState state = ((JetspeedRunData)data).getPortletSessionState(((JetspeedRunData)data).getJs_peid());
String newPageSize = data.getParameters().getString("selectPageSize");
if (newPageSize != null) {
state.setAttribute("pagesize", Integer.valueOf(newPageSize));
state.setAttribute("current-page", Integer.valueOf(1));
}
}

/**
* Handle a request to go to the first page
*/
public void doList_first(RunData data) {
SessionState state = ((JetspeedRunData)data).getPortletSessionState(((JetspeedRunData)data).getJs_peid());
state.setAttribute("current-page", Integer.valueOf(1));
}

/**
* Handle a request to go to the previous page
*/
public void doList_prev(RunData data) {
SessionState state = ((JetspeedRunData)data).getPortletSessionState(((JetspeedRunData)data).getJs_peid());
Integer currentPage = (Integer) state.getAttribute("current-page");
if (currentPage != null && currentPage > 1) {
state.setAttribute("current-page", Integer.valueOf(currentPage - 1));
}
}

/**
* Handle a request to go to the next page
*/
public void doList_next(RunData data) {
SessionState state = ((JetspeedRunData)data).getPortletSessionState(((JetspeedRunData)data).getJs_peid());
Integer currentPage = (Integer) state.getAttribute("current-page");
if (currentPage != null) {
state.setAttribute("current-page", Integer.valueOf(currentPage + 1));
}
}

/**
* Handle a request to go to the last page
*/
public void doList_last(RunData data) {
SessionState state = ((JetspeedRunData)data).getPortletSessionState(((JetspeedRunData)data).getJs_peid());
Integer pageSize = state.getAttribute("pagesize") != null ? (Integer) state.getAttribute("pagesize") : 10;
Integer totalItems = state.getAttribute("totalNumber") != null ? (Integer) state.getAttribute("totalNumber") : 0;
Integer lastPage = (totalItems + pageSize - 1) / pageSize;
state.setAttribute("current-page", lastPage);
}

/**
* Process that archives the sites
* @param sites list of SparseSite
Expand Down Expand Up @@ -660,7 +736,6 @@ private void archiveSites(List<SparseSite> sites, String selectedTerm, Session c
}



}

//complete
Expand Down
76 changes: 76 additions & 0 deletions admin-tools/src/webapp/vm/archive/chef_archive-download.vm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,82 @@
#if($archives.size() == 0)
<p>$tlang.getString("archive.download.none")</p>
#else
<div class="sakai-table-toolBar">
<div class="sakai-table-filterContainer">
#searchFilterPanel("searchFilter1", $!archiveSearch, "doArchive_search", "doArchive_search_clear")
</div>
</div>

## paging widget
<div class="listNav">
#if($totalNumber>0)
<div class="instruction">
$tlang.getFormattedMessage("archive.list.youare", $numbers)
</div>
#end
#if ($pagesize != 0)
#if ($goFPButton == "true")
<form name="firstpageForm" class="inlineForm" method="post" action="#toolForm("$action")">
<input type="submit" name="eventSubmit_doList_first" value="|&lt;" title="$tlang.getString("archive.list.first")" />
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
</form>
#else
<form name="firstpageForm" class="inlineForm" method="post" action="#toolForm("$action")">
<input type="submit" name="eventSubmit_doList_first" value="|&lt;" disabled="disabled" />
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
</form>
#end
#if ($goPPButton == "true")
<form name="prevpageForm" class="inlineForm" method="post" action="#toolForm("$action")">
<input type="submit" name="eventSubmit_doList_prev" value="&lt;" title="$tlang.getFormattedMessage('archive.list.previous.withsize', $pagesize)" accesskey="p" />
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
</form>
#else
<form name="prevpageForm" class="inlineForm" method="post" action="#toolForm("$action")">
<input type="submit" name="eventSubmit_doList_prev" value="&lt;" disabled="disabled" />
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
</form>
#end
#end
<form name="pagesizeForm" class="inlineForm" method="post" action="#toolForm("$action")">
<input type="hidden" name="eventSubmit_doChange_pagesize" value="changepagesize" />
<span class="skip">$tlang.getString("archive.list.listnavselect")</span>
<select name="selectPageSize" onchange="document.pagesizeForm.submit();">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control.

#foreach ($value in $sizeList)
#foreach($intValue in $value)
#set($ivalue=$intValue.intValue())
#end
<option value="$ivalue" #if($pagesize == $ivalue) selected="selected" #end>$tlang.getFormattedMessage("archive.list.show", $value)</option>
#end
</select>
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
</form>
#if ($pagesize != 0)
#if ($goNPButton == "true")
<form name="nextpageForm" class="inlineForm" method="post" action="#toolForm("$action")">
<input type="submit" name="eventSubmit_doList_next" value="&gt;" title="$tlang.getFormattedMessage('archive.list.next.withsize', $pagesize)" accesskey="n" />
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
</form>
#else
<form name="nextpageForm" class="inlineForm" method="post" action="#toolForm("$action")">
<input type="submit" name="eventSubmit_doList_next" value="&gt;" disabled="disabled" />
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
</form>
#end
#if ($goLPButton == "true")
<form name="lastpageForm" class="inlineForm" method="post" action="#toolForm("$action")">
<input type="submit" name="eventSubmit_doList_last" value="&gt;|" title="$tlang.getString('archive.list.last')" />
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
</form>
#else
<form name="lastpageForm" class="inlineForm" method="post" action="#toolForm("$action")">
<input type="submit" name="eventSubmit_doList_last" value="&gt;|" disabled="disabled" />
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
</form>
#end
#end
</div>

<table class="table table-hover table-striped table-bordered">
<thead>
<tr>
Expand Down
Loading