Skip to content

Commit 5186150

Browse files
committed
save progress
1 parent bdf7885 commit 5186150

File tree

3 files changed

+178
-5
lines changed

3 files changed

+178
-5
lines changed

Diff for: admin-tools/src/bundle/archive.properties

+22
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,25 @@ archive.download.size = Size
4646
archive.download.hash = Hash <small>(SHA-1)</small>
4747
archive.download.auth = Archive download is limited to administrators.
4848
archive.download.none = No archives are available to download at this time.
49+
50+
# Search related messages
51+
search.label=Search
52+
search.button=Search
53+
search.clear=Clear Search
54+
55+
no.archives=No archives available
56+
no.archives.search=No archives found matching
57+
58+
# Search
59+
archive.search.placeholder=Search archives...
60+
archive.search.button=Search
61+
archive.search.clear=Clear
62+
63+
# Paging
64+
archive.list.youare=Viewing {0} to {1} of {2} items
65+
archive.list.show=Show {0} items
66+
archive.list.first=Go to first page
67+
archive.list.previous.withsize=Previous {0}
68+
archive.list.next.withsize=Next {0}
69+
archive.list.last=Go to last page
70+
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.

Diff for: admin-tools/src/java/org/sakaiproject/archive/tool/ArchiveAction.java

+80-5
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public String buildDownloadContext(VelocityPortlet portlet, Context context, Run
265265

266266
Calendar calendar = Calendar.getInstance();
267267

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

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

312312
zips.add(sf);
313313
}
314-
315-
context.put("archives", zips);
314+
315+
int totalItems = zips.size();
316+
int pageSize = state.getAttribute("pagesize") != null ? ((Integer) state.getAttribute("pagesize")).intValue() : 10;
317+
int currentPage = state.getAttribute("current-page") != null ? ((Integer) state.getAttribute("current-page")).intValue() : 1;
318+
int startIndex = (currentPage - 1) * pageSize;
319+
int endIndex = Math.min(startIndex + pageSize, totalItems);
320+
321+
context.put("totalNumber", totalItems);
322+
context.put("pagesize", pageSize);
323+
context.put("numbers", new Integer[]{startIndex + 1, endIndex, totalItems});
324+
context.put("goFPButton", currentPage > 1 ? "true" : "false");
325+
context.put("goPPButton", currentPage > 1 ? "true" : "false");
326+
context.put("goNPButton", endIndex < totalItems ? "true" : "false");
327+
context.put("goLPButton", endIndex < totalItems ? "true" : "false");
328+
329+
List<Integer[]> sizeList = new ArrayList<>();
330+
sizeList.add(new Integer[]{10});
331+
sizeList.add(new Integer[]{20});
332+
sizeList.add(new Integer[]{50});
333+
sizeList.add(new Integer[]{100});
334+
sizeList.add(new Integer[]{200});
335+
context.put("sizeList", sizeList);
336+
337+
List<SparseFile> pagedZips = zips.subList(startIndex, endIndex);
338+
context.put("archives", pagedZips);
316339

317340
return "-download";
318341
}
@@ -589,10 +612,63 @@ public void doView_batch(RunData data){
589612
* @param data RunData
590613
*/
591614
public void doView_download(RunData data){
592-
SessionState state = ((JetspeedRunData) data).getPortletSessionState(((JetspeedRunData) data).getJs_peid());
615+
SessionState state = ((JetspeedRunData)data).getPortletSessionState(((JetspeedRunData)data).getJs_peid());
593616
state.setAttribute(STATE_MODE, DOWNLOAD_MODE);
594617
}
595618

619+
/**
620+
* Handle a request to change the page size
621+
*/
622+
public void doChange_pagesize(RunData data) {
623+
SessionState state = ((JetspeedRunData)data).getPortletSessionState(((JetspeedRunData)data).getJs_peid());
624+
String newPageSize = data.getParameters().getString("selectPageSize");
625+
if (newPageSize != null) {
626+
state.setAttribute("pagesize", Integer.valueOf(newPageSize));
627+
state.setAttribute("current-page", Integer.valueOf(1));
628+
}
629+
}
630+
631+
/**
632+
* Handle a request to go to the first page
633+
*/
634+
public void doList_first(RunData data) {
635+
SessionState state = ((JetspeedRunData)data).getPortletSessionState(((JetspeedRunData)data).getJs_peid());
636+
state.setAttribute("current-page", Integer.valueOf(1));
637+
}
638+
639+
/**
640+
* Handle a request to go to the previous page
641+
*/
642+
public void doList_prev(RunData data) {
643+
SessionState state = ((JetspeedRunData)data).getPortletSessionState(((JetspeedRunData)data).getJs_peid());
644+
Integer currentPage = (Integer) state.getAttribute("current-page");
645+
if (currentPage != null && currentPage > 1) {
646+
state.setAttribute("current-page", Integer.valueOf(currentPage - 1));
647+
}
648+
}
649+
650+
/**
651+
* Handle a request to go to the next page
652+
*/
653+
public void doList_next(RunData data) {
654+
SessionState state = ((JetspeedRunData)data).getPortletSessionState(((JetspeedRunData)data).getJs_peid());
655+
Integer currentPage = (Integer) state.getAttribute("current-page");
656+
if (currentPage != null) {
657+
state.setAttribute("current-page", Integer.valueOf(currentPage + 1));
658+
}
659+
}
660+
661+
/**
662+
* Handle a request to go to the last page
663+
*/
664+
public void doList_last(RunData data) {
665+
SessionState state = ((JetspeedRunData)data).getPortletSessionState(((JetspeedRunData)data).getJs_peid());
666+
Integer pageSize = state.getAttribute("pagesize") != null ? (Integer) state.getAttribute("pagesize") : 10;
667+
Integer totalItems = state.getAttribute("totalNumber") != null ? (Integer) state.getAttribute("totalNumber") : 0;
668+
Integer lastPage = (totalItems + pageSize - 1) / pageSize;
669+
state.setAttribute("current-page", lastPage);
670+
}
671+
596672
/**
597673
* Process that archives the sites
598674
* @param sites list of SparseSite
@@ -660,7 +736,6 @@ private void archiveSites(List<SparseSite> sites, String selectedTerm, Session c
660736
}
661737

662738

663-
664739
}
665740

666741
//complete

Diff for: admin-tools/src/webapp/vm/archive/chef_archive-download.vm

+76
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,82 @@
99
#if($archives.size() == 0)
1010
<p>$tlang.getString("archive.download.none")</p>
1111
#else
12+
<div class="sakai-table-toolBar">
13+
<div class="sakai-table-filterContainer">
14+
#searchFilterPanel("searchFilter1", $!archiveSearch, "doArchive_search", "doArchive_search_clear")
15+
</div>
16+
</div>
17+
18+
## paging widget
19+
<div class="listNav">
20+
#if($totalNumber>0)
21+
<div class="instruction">
22+
$tlang.getFormattedMessage("archive.list.youare", $numbers)
23+
</div>
24+
#end
25+
#if ($pagesize != 0)
26+
#if ($goFPButton == "true")
27+
<form name="firstpageForm" class="inlineForm" method="post" action="#toolForm("$action")">
28+
<input type="submit" name="eventSubmit_doList_first" value="|&lt;" title="$tlang.getString("archive.list.first")" />
29+
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
30+
</form>
31+
#else
32+
<form name="firstpageForm" class="inlineForm" method="post" action="#toolForm("$action")">
33+
<input type="submit" name="eventSubmit_doList_first" value="|&lt;" disabled="disabled" />
34+
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
35+
</form>
36+
#end
37+
#if ($goPPButton == "true")
38+
<form name="prevpageForm" class="inlineForm" method="post" action="#toolForm("$action")">
39+
<input type="submit" name="eventSubmit_doList_prev" value="&lt;" title="$tlang.getFormattedMessage('archive.list.previous.withsize', $pagesize)" accesskey="p" />
40+
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
41+
</form>
42+
#else
43+
<form name="prevpageForm" class="inlineForm" method="post" action="#toolForm("$action")">
44+
<input type="submit" name="eventSubmit_doList_prev" value="&lt;" disabled="disabled" />
45+
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
46+
</form>
47+
#end
48+
#end
49+
<form name="pagesizeForm" class="inlineForm" method="post" action="#toolForm("$action")">
50+
<input type="hidden" name="eventSubmit_doChange_pagesize" value="changepagesize" />
51+
<span class="skip">$tlang.getString("archive.list.listnavselect")</span>
52+
<select name="selectPageSize" onchange="document.pagesizeForm.submit();">
53+
#foreach ($value in $sizeList)
54+
#foreach($intValue in $value)
55+
#set($ivalue=$intValue.intValue())
56+
#end
57+
<option value="$ivalue" #if($pagesize == $ivalue) selected="selected" #end>$tlang.getFormattedMessage("archive.list.show", $value)</option>
58+
#end
59+
</select>
60+
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
61+
</form>
62+
#if ($pagesize != 0)
63+
#if ($goNPButton == "true")
64+
<form name="nextpageForm" class="inlineForm" method="post" action="#toolForm("$action")">
65+
<input type="submit" name="eventSubmit_doList_next" value="&gt;" title="$tlang.getFormattedMessage('archive.list.next.withsize', $pagesize)" accesskey="n" />
66+
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
67+
</form>
68+
#else
69+
<form name="nextpageForm" class="inlineForm" method="post" action="#toolForm("$action")">
70+
<input type="submit" name="eventSubmit_doList_next" value="&gt;" disabled="disabled" />
71+
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
72+
</form>
73+
#end
74+
#if ($goLPButton == "true")
75+
<form name="lastpageForm" class="inlineForm" method="post" action="#toolForm("$action")">
76+
<input type="submit" name="eventSubmit_doList_last" value="&gt;|" title="$tlang.getString('archive.list.last')" />
77+
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
78+
</form>
79+
#else
80+
<form name="lastpageForm" class="inlineForm" method="post" action="#toolForm("$action")">
81+
<input type="submit" name="eventSubmit_doList_last" value="&gt;|" disabled="disabled" />
82+
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
83+
</form>
84+
#end
85+
#end
86+
</div>
87+
1288
<table class="table table-hover table-striped table-bordered">
1389
<thead>
1490
<tr>

0 commit comments

Comments
 (0)