Mercurial > hg > LGServices
changeset 69:dd2fcc5f5deb
new: saved table in full text search page: new layout and sorting by time
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Wed, 10 Aug 2016 13:00:19 +0200 |
parents | 7e161f2e6660 |
children | 315a6360ea1b |
files | src/main/java/de/mpiwg/web/fullTextSearch/SortFullTextSearchFileByLastChanged.java src/main/java/de/mpiwg/web/jsp/FullTextSearchPage.java src/main/webapp/pages/fullTextSearch.jsp src/main/webapp/resources/css/style.css |
diffstat | 4 files changed, 242 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/mpiwg/web/fullTextSearch/SortFullTextSearchFileByLastChanged.java Wed Aug 10 13:00:19 2016 +0200 @@ -0,0 +1,17 @@ +package de.mpiwg.web.fullTextSearch; + +import java.util.Comparator; + +import de.mpiwg.gazetteer.bo.LGFullTextSearchFile; + + +public class SortFullTextSearchFileByLastChanged implements Comparator<LGFullTextSearchFile>{ + + public int compare(LGFullTextSearchFile o1, LGFullTextSearchFile o2) { + + if(o1.getLastChangeDate() == null || o2.getLastChangeDate() == null){ + return o1.getId().compareTo(o2.getId()); + } + return o1.getLastChangeDate().compareTo(o2.getLastChangeDate()); + } +}
--- a/src/main/java/de/mpiwg/web/jsp/FullTextSearchPage.java Fri Aug 05 13:36:37 2016 +0200 +++ b/src/main/java/de/mpiwg/web/jsp/FullTextSearchPage.java Wed Aug 10 13:00:19 2016 +0200 @@ -34,6 +34,7 @@ import de.mpiwg.web.fullTextSearch.SortContentByLevel2; import de.mpiwg.web.fullTextSearch.SortContentByPeriod; import de.mpiwg.web.fullTextSearch.SortContentByStartPage; +import de.mpiwg.web.fullTextSearch.SortFullTextSearchFileByLastChanged; @@ -226,7 +227,7 @@ this.olderFileList = new ArrayList<LGFullTextSearchFile>(); - // TODO + for (LGFullTextSearchFile aFile: this.getFileList()) { Date todayDate = new Date(); @@ -236,12 +237,19 @@ if ( aFile.getLastChangeDate().after(oneWeekAgo)) { this.weekFileList.add(aFile); + // sorting by last changed + this.sortByLastChangedDown(this.getWeekFileList()); + } else if (aFile.getLastChangeDate().after(oneMonthAgo)) { this.monthFileList.add(aFile); + // sorting by last changed + this.sortByLastChangedDown(this.getMonthFileList()); } else { this.olderFileList.add(aFile); + // sorting by last changed + this.sortByLastChangedDown(this.getOlderFileList()); } } @@ -510,7 +518,8 @@ if( (StringUtils.isEmpty(dynastyFilter) || StringUtils.startsWith(content.getSection().getBook().getDynasty(), dynastyFilter)) && (StringUtils.isEmpty(level1Filter) || StringUtils.startsWith(content.getSection().getBook().getLevel1(), level1Filter)) && (StringUtils.isEmpty(level2Filter) || StringUtils.startsWith(content.getSection().getBook().getLevel2(), level2Filter)) && - (StringUtils.isEmpty(adminTypeFilter) || StringUtils.startsWith(content.getSection().getBook().getAdmin_type(), adminTypeFilter)) && + (StringUtils.isEmpty(adminTypeFilter) || StringUtils.startsWith(content.getSection().getBook().getAdmin_type(), adminTypeFilter)) && + (StringUtils.isEmpty(periodFilter) || StringUtils.startsWith(content.getSection().getBook().getPeriod(), periodFilter)) && (StringUtils.isEmpty(bookIdFilter) || StringUtils.startsWith(content.getBookId(), bookIdFilter)) && (StringUtils.isEmpty(bookNameFilter) || StringUtils.startsWith(content.getSection().getBook().getName(), bookNameFilter)) && (StringUtils.isEmpty(sectionNameFilter) || StringUtils.startsWith(content.getSection().getName(), sectionNameFilter)) && @@ -1017,6 +1026,10 @@ /////// Sorting + public void sortByLastChangedDown(List<LGFullTextSearchFile> _list) { + Collections.sort(_list, new SortFullTextSearchFileByLastChanged()); + Collections.reverse(_list); + } public void sortByBookNameUp(){ Collections.sort(this.completeList, new SortContentByBookName());
--- a/src/main/webapp/pages/fullTextSearch.jsp Fri Aug 05 13:36:37 2016 +0200 +++ b/src/main/webapp/pages/fullTextSearch.jsp Wed Aug 10 13:00:19 2016 +0200 @@ -60,13 +60,28 @@ //position: { my: "left+100px", at: "top", of: $("#viewSavedResult") }, position: { my: "center", at: "top+200px", of: $("#viewSavedResult") }, // TODO width: "850px", - } ); + var dialogViewSavedResult2 = $("#dialogViewSavedResult2").dialog( + { + autoOpen: false, + //position: { my: "left+100px", at: "top", of: $("#viewSavedResult") }, + position: { my: "center", at: "top+200px", of: $("#viewSavedResult2") }, + width: 600, height: 1000 + + } + ); + $("#viewSavedResult").button().on( "click", function() { dialogViewSavedResult.dialog( "open" ); }); + $("#viewSavedResult2").button().on( "click", function() { + dialogViewSavedResult2.dialog( "open" ); + }); + + + $("#bookIdFilter").autocomplete({ source : function(request, response) { $.ajax({ @@ -376,10 +391,12 @@ </td> <td> <button - onclick="setAction('save', 'saveTableForm'); document.getElementById('saveTableForm').submit();">Save All</button> - + onclick="setAction('save', 'saveTableForm'); document.getElementById('saveTableForm').submit();">Save + All</button> + <button - onclick="setAction('saveFiltered', 'saveTableForm'); document.getElementById('saveTableForm').submit();">Save Filtered</button> + onclick="setAction('saveFiltered', 'saveTableForm'); document.getElementById('saveTableForm').submit();">Save + Filtered</button> </td> </tr> @@ -388,8 +405,9 @@ </div> + <div id="dialogViewSavedResult" title="Saved Table(s)"> - + <div class="label">This week:</div> <table class="savedResultTable"> <tr> @@ -412,8 +430,11 @@ target="_blank"> <img title="Download CSV" src="<%=sessionBean.getApplicationBean() .getDownloadImage()%>" /> - </a> <!-- view on LGMap --> <a - href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getSearchTerms()%>" + </a> <!-- view on LGMap --> <!-- + href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getFileName()%>" + Use file name instead as the name in the link to LGMap. + --> <a + href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getFileName()%>" target="_blank"> <img title="View on LGMap" src="<%=sessionBean.getApplicationBean().getViewOnMap()%>" /> </a> <input type="image" title="Delete it" @@ -433,8 +454,43 @@ <table class="savedResultTable"> <tr> <% - for (LGFullTextSearchFile aFile : sessionBean - .getFullTextSearchPage().getMonthFileList()) { + for (LGFullTextSearchFile aFile : sessionBean.getFullTextSearchPage().getMonthFileList()) { + %> + <td> + <div><%=aFile.getFileName()%></div> + <button type="button" class="lgButton" + onclick="setAction0('loadFile', 'fullTextSearchForm', 'fileId', <%=aFile.getId()%>); document.getElementById('fullTextSearchForm').submit();">load</button> + + <!-- getFullTextSearchFileText?fileId= &userId= --> <!-- click searching result to open it in the same table of full-text-search result --> + <a + href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/getFullTextSearchHtmlFile?fileId=<%=aFile.getId()%>" + target="_blank"> <img title="Show text in html" + src="<%=sessionBean.getApplicationBean().getShowImage()%>" /> + </a> <!-- download csv file --> <a + href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/downloadFullTextSearchCsvFile?file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv" + target="_blank"> <img title="Download CSV" + src="<%=sessionBean.getApplicationBean() + .getDownloadImage()%>" /> + </a> <!-- view on LGMap --> <a + href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getFileName()%>" + target="_blank"> <img title="View on LGMap" + src="<%=sessionBean.getApplicationBean().getViewOnMap()%>" /> + </a> <input type="image" title="Delete it" + onclick="<%=sessionBean.getApplicationBean() + .getJSConfirmationDelete()%> setAction0('deleteFile', 'fullTextSearchForm', 'fileId','<%=aFile.getId()%>'); document.getElementById('fullTextSearchForm').submit();" + src="<%=sessionBean.getApplicationBean().getDeleteImage()%>" /> + + </td> + + <% } %> + </tr> + </table> + + <div class="label">Older...</div> + <table class="savedResultTable"> + <tr> + <% + for (LGFullTextSearchFile aFile : sessionBean.getFullTextSearchPage().getOlderFileList()) { %> <td> <div><%=aFile.getFileName()%></div> @@ -443,6 +499,98 @@ <!-- getFullTextSearchFileText?fileId= &userId= --> <!-- click searching result to open it in the same table of full-text-search result --> <a + href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/getFullTextSearchHtmlFile?fileId=<%=aFile.getId()%>" + target="_blank"> <img title="Show text in html" + src="<%=sessionBean.getApplicationBean().getShowImage()%>" /> + </a> <!-- download csv file --> <a + href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/downloadFullTextSearchCsvFile?file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv" + target="_blank"> <img title="Download CSV" + src="<%=sessionBean.getApplicationBean() + .getDownloadImage()%>" /> + </a> <!-- view on LGMap --> <a + href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getFileName()%>" + target="_blank"> <img title="View on LGMap" + src="<%=sessionBean.getApplicationBean().getViewOnMap()%>" /> + </a> <input type="image" title="Delete it" + onclick="<%=sessionBean.getApplicationBean() + .getJSConfirmationDelete()%> setAction0('deleteFile', 'fullTextSearchForm', 'fileId','<%=aFile.getId()%>'); document.getElementById('fullTextSearchForm').submit();" + src="<%=sessionBean.getApplicationBean().getDeleteImage()%>" /> + + </td> + <% } %> + + </tr> + </table> + + + </div> + + <div id="dialogViewSavedResult2" title="Saved Table(s) *Test a new layout and sort by time:)"> + + <!-- TODO records in the table sorted by (1) saved time or (2) alphabet --> + + <div class="label">This week:</div> + <table class="savedResultTable2"> + <% + for (LGFullTextSearchFile aFile : sessionBean.getFullTextSearchPage().getWeekFileList()) { + %> + <tr> + <td> + <div><%=aFile.getFileName()%></div> + </td> + <td> + <button type="button" class="lgButton" + onclick="setAction0('loadFile', 'fullTextSearchForm', 'fileId', <%=aFile.getId()%>); document.getElementById('fullTextSearchForm').submit();">load</button> + + <!-- getFullTextSearchFileText?fileId= &userId= --> <!-- click searching result to open it in the same table of full-text-search result --> + <a + href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/getFullTextSearchHtmlFile?fileId=<%=aFile.getId()%>" + target="_blank"> <img title="Show text in html" + src="<%=sessionBean.getApplicationBean().getShowImage()%>" /> + </a> + <!-- download csv file --> + <a + href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/downloadFullTextSearchCsvFile?file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv" + target="_blank"> <img title="Download CSV" + src="<%=sessionBean.getApplicationBean() + .getDownloadImage()%>" /> + </a> + + <!-- view on LGMap --> <!-- + href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getFileName()%>" + Use file name instead as the name in the link to LGMap. + --> + <a + href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getFileName()%>" + target="_blank"> <img title="View on LGMap" + src="<%=sessionBean.getApplicationBean().getViewOnMap()%>" /> + </a> <input type="image" title="Delete it" + onclick="<%=sessionBean.getApplicationBean() + .getJSConfirmationDelete()%> setAction0('deleteFile', 'fullTextSearchForm', 'fileId','<%=aFile.getId()%>'); document.getElementById('fullTextSearchForm').submit();" + src="<%=sessionBean.getApplicationBean().getDeleteImage()%>" /> + + </td> + + </tr> + <% } %> + </table> + + <div class="label">This month:</div> + <table class="savedResultTable2"> + <% + for (LGFullTextSearchFile aFile : sessionBean + .getFullTextSearchPage().getMonthFileList()) { + %> + <tr> + <td> + <div><%=aFile.getFileName()%></div> + </td> + <td> + <button type="button" class="lgButton" + onclick="setAction0('loadFile', 'fullTextSearchForm', 'fileId', <%=aFile.getId()%>); document.getElementById('fullTextSearchForm').submit();">load</button> + + <!-- getFullTextSearchFileText?fileId= &userId= --> <!-- click searching result to open it in the same table of full-text-search result --> + <a href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/getFullTextSearchHtmlFile?fileId=<%=aFile.getId()%>" target="_blank"> <img title="Show text in html" src="<%=sessionBean.getApplicationBean().getShowImage()%>" /> @@ -452,7 +600,7 @@ src="<%=sessionBean.getApplicationBean() .getDownloadImage()%>" /> </a> <!-- view on LGMap --> <a - href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getSearchTerms()%>" + href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getFileName()%>" target="_blank"> <img title="View on LGMap" src="<%=sessionBean.getApplicationBean().getViewOnMap()%>" /> </a> <input type="image" title="Delete it" @@ -462,21 +610,22 @@ </td> - <% - } - %> + </tr> + <% } %> </table> <div class="label">Older...</div> - <table class="savedResultTable"> + <table class="savedResultTable2"> + <% + for (LGFullTextSearchFile aFile : sessionBean.getFullTextSearchPage().getOlderFileList()) { + %> + <tr> - <% - for (LGFullTextSearchFile aFile : sessionBean - .getFullTextSearchPage().getOlderFileList()) { - %> <td> <div><%=aFile.getFileName()%></div> + </td> + <td> <button type="button" class="lgButton" onclick="setAction0('loadFile', 'fullTextSearchForm', 'fileId', <%=aFile.getId()%>); document.getElementById('fullTextSearchForm').submit();">load</button> @@ -491,7 +640,7 @@ src="<%=sessionBean.getApplicationBean() .getDownloadImage()%>" /> </a> <!-- view on LGMap --> <a - href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getSearchTerms()%>" + href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getFileName()%>" target="_blank"> <img title="View on LGMap" src="<%=sessionBean.getApplicationBean().getViewOnMap()%>" /> </a> <input type="image" title="Delete it" @@ -501,21 +650,24 @@ </td> - <% - } - %> </tr> + <% } %> </table> </div> + + + + <label class="subTitel">Full Text Search</label> <form name="fullTextSearchForm" id="fullTextSearchForm" action="<%=sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp" method="post" class="contentForm"> <input name="bean" type="hidden" value="fullTextSearchBean" /> <input id="focusedId" type="hidden" - value="<%=sessionBean.getFullTextSearchPage().getFocusedContentId()%>" /> + value="<%=sessionBean.getFullTextSearchPage() + .getFocusedContentId()%>" /> <input id="mouseX" name="mouseX" type="hidden" value="<%=sessionBean.getFullTextSearchPage().getMouseX()%>" /> <input @@ -577,36 +729,41 @@ <tr> <td> - <button id="saveResult" type="button" class="lgButton">Save - Table</button> - <button id="viewSavedResult" type="button" class="lgButton">View/Load - Saved Table(s)</button> - - + <button id="saveResult" type="button" class="lgButton">Save Table</button> + <button id="viewSavedResult" type="button" class="lgButton">View/Load Saved Table(s)</button> + </td> + </tr> + <tr> + <td> + <span>*Test:</span> + <button id="viewSavedResult2" type="button" class="lgButton">View/Load Saved Table(s): new layout and sorting by time:)</button> + </td> </tr> <tr> <td> <!-- for view on LGMap, prompt to save if it's not saved. After saving, it could be shown on LGMap --> <% - if (sessionBean.getFullTextSearchPage().getFile() != null) { + if (sessionBean.getFullTextSearchPage().getFile() != null) { LGFullTextSearchFile theFile = sessionBean .getFullTextSearchPage().getFile(); - %> + %> <a - href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=theFile.getUserId().toString()%>_<%=theFile.getFileName()%>.csv&name=<%=theFile.getSearchTerms()%>" + href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=theFile.getUserId().toString()%>_<%=theFile.getFileName()%>.csv&name=<%=theFile.getFileName()%>" target="_blank">View on LGMap </a> <!-- download csv file --> <a href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/downloadFullTextSearchCsvFile?file=<%=theFile.getUserId().toString()%>_<%=theFile.getFileName()%>.csv" target="_blank"> <img title="Download CSV" src="<%=sessionBean.getApplicationBean() .getDownloadImage()%>" /> </a> - <% } else if (sessionBean.getFullTextSearchPage().getCompleteList() != null) { %> - <!-- prompt to save --> - <!-- A click icon for Save Table, showing the text as bellow --> - <button id="prompToSaveResult" type="button" class="lgButton">View on LGMap?</button> + <% + } else if (sessionBean.getFullTextSearchPage().getCompleteList() != null) { + %> + <!-- prompt to save --> <!-- A click icon for Save Table, showing the text as bellow --> + <button id="prompToSaveResult" type="button" class="lgButton">View + on LGMap?</button> <% } %> - + </td> </tr>
--- a/src/main/webapp/resources/css/style.css Fri Aug 05 13:36:37 2016 +0200 +++ b/src/main/webapp/resources/css/style.css Wed Aug 10 13:00:19 2016 +0200 @@ -161,6 +161,22 @@ width:60px; } +.savedResultTable2 tr { + background:#EBEBEB; + border-style: solid; +} + + +.savedResultTable2 td { + border-color: inherit; + /*border-style: solid; */ + border-width: 1px; + text-align: center; + border-collapse: collapse; + font-size: 12px; + min-width: 150px; + /*width:60px;*/ +} .pageTable{