Mercurial Hosting > nabble
diff src/nabble/view/web/user/UserPendingNodes.jtp @ 0:7ecd1a4ef557
add content
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 21 Mar 2019 19:15:52 -0600 |
parents | |
children | 18cf4872fd7f |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/nabble/view/web/user/UserPendingNodes.jtp Thu Mar 21 19:15:52 2019 -0600 @@ -0,0 +1,179 @@ +<% +package nabble.view.web.user; + +import nabble.model.Node; +import nabble.model.User; +import nabble.view.lib.Jtp; +import nabble.view.lib.Shared; +import nabble.view.lib.HtmlViewUtils; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.List; + + +public final class UserPendingNodes extends HttpServlet { + + private static final int MAX_ROWS = 20; + + protected void service(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException + { + PrintWriter out = response.getWriter(); + User user = Jtp.getUser(request, response); + + if ( user == null ) { + Jtp.login("You must register/login to edit your profile.", request, response); + return; + } + + String iRecS = request.getParameter("i"); + int iRec = iRecS == null? 0 : Integer.valueOf(iRecS); + + List<Node> nodeArray = user.getPendingPosts().get(0, 1000); + SearchResults searchResults = cutResults(nodeArray, iRec); + + String title = "Pending Posts of "; + title += user.getName(); + + String url = "/user/UserPendingNodes.jtp"; + HtmlViewUtils.GenericPagingPath pagingPath = new HtmlViewUtils.GenericPagingPath(url); + %> + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> + <html> + <head> + <% Shared.title(request, response, title); %> + </head> + <body> + <% Shared.minHeaderGlobal(request, response); %> + <table> + <tr valign="top"> + <td><img src="<%=Shared.getAvatarImageURL(user, false)%>" class="avatar light-border-color" width=100 height=100/></td> + <td style="width:100%"> + <div class="second-font" style="font-size:170%"> + <%=user.getNameHtml()%> + </div> + <div style="margin-top:.5em"> + <a href="/template/NamlServlet.jtp?macro=user_profile">Account Settings</a> + </div> + </td> + </tr> + </table> + + <table style="border-collapse:collapse;width:100%;margin-top:.5em"> + <tr> + <td class="title-row light-border-color" colspan=3> + <div style="float:left;padding-top:.2em"> + <b>Pending Messages</b> + </div> + <% HtmlViewUtils.genericPaging(request, response, searchResults.getCount(), iRec, MAX_ROWS, pagingPath, ".4em 0 0 0"); %> + </td> + </tr> + </table> + + <style type="text/css"> + table.nodes { + width:100%; + border-width: 1px; + border-style: solid; + border-collapse:collapse; + margin-top:.5em; + } + + table.nodes td { + padding:.1em; + } + + table.nodes td.header { + padding: .2em .3em; + border-bottom-width: 1px; + border-bottom-style: solid; + } + </style> + + <% + String[] columns = new String[] { "Message", "Pending Since", "Forum" }; + %> + + <table class="nodes medium-border-color"> + <tr class="shaded-bg-color" style="font-weight: bold"> + <td class="header" style="width:16px"></td> + <td class="header"><%=columns[0]%></td> + <td class="header"><%=columns[1]%></td> + <td class="header"><%=columns[2]%></td> + </tr> + <% + Node[] nodes = searchResults.getNodes(); + int i = 0; + if (nodes.length > 0) { + for (Node node : nodes) { + %> + <tr <%=i++%2==1?"class=\"light-bg-color\"":""%>> + <td align="center"> + <%Shared.showPending(out, node);%> + </td> + <td style="padding:.3em .4em;"> + <a href="<%=Jtp.url(node)%>"><%=node.getSubjectHtml()%></a> + </td> + <td style="padding:.2em"> + <%=node.getMailToList() == null? "" : Jtp.formatDateLong(node.getMailToList().getWhenSent())%> + </td> + <td style="padding:.2em"> + <%=Jtp.link(node.getApp())%> + </td> + </tr> + <% + } + } else { + %> + <tr><td colspan=4 style="padding:.3em">None</td></tr> + <% + } + %> + </table> + <% HtmlViewUtils.genericPaging(request, response, searchResults.getCount(), iRec, MAX_ROWS, pagingPath, ".5em 0 0 0"); %> + + <% Shared.footer(request,response); %> + <% Shared.analytics(request,response); %> + </body> + </html> + <% + } + + private class SearchResults { + private int count; + private Node[] nodes; + + public SearchResults() {} + + public SearchResults(int count, Node[] nodes) { + this.count = count; + this.nodes = nodes; + } + + public int getCount() { return count; } + public void setCount(int count) { this.count = count; } + public Node[] getNodes() { return nodes; } + public void setNodes(Node[] nodes) { this.nodes = nodes; } + } + + private SearchResults cutResults(List<Node> array, int iRec) { + int i = iRec; + int count = 0; + List<Node> nodes = new ArrayList<Node>(); + while (count < MAX_ROWS) { + if (array.size()-1 < i) + break; + nodes.add(array.get(i++)); + count++; + } + Node[] nodesArray = nodes.toArray(new Node[0]); + return new SearchResults(array.size(), nodesArray); + } +} +%>