-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-4329][WebUI] HistoryPage pagenation #3194
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
Changes from 7 commits
cfa242b
755a004
ec7922e
b2240f8
76b05e3
1c2f605
c93932e
15d3d2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ import org.apache.spark.ui.{WebUIPage, UIUtils} | |
| private[spark] class HistoryPage(parent: HistoryServer) extends WebUIPage("") { | ||
|
|
||
| private val pageSize = 20 | ||
| private val maxNumIndices = 2 | ||
|
|
||
| def render(request: HttpServletRequest): Seq[Node] = { | ||
| val requestedPage = Option(request.getParameter("page")).getOrElse("1").toInt | ||
|
|
@@ -51,10 +52,7 @@ private[spark] class HistoryPage(parent: HistoryServer) extends WebUIPage("") { | |
| if (allApps.size > 0) { | ||
| <h4> | ||
| Showing {actualFirst + 1}-{last + 1} of {allApps.size} | ||
| <span style="float: right"> | ||
| {if (actualPage > 1) <a href={"/?page=" + (actualPage - 1)}><</a>} | ||
| {if (actualPage < pageCount) <a href={"/?page=" + (actualPage + 1)}>></a>} | ||
| </span> | ||
| {pageIndices(pageCount, actualPage)} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor, but I actually think this doesn't need to be in its own method. It's probably clearer if the HTML is in here directly. Right now it's not clear why it's floating right from first glance.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also add some comment here that says something like |
||
| </h4> ++ | ||
| appTable | ||
| } else { | ||
|
|
@@ -81,6 +79,38 @@ private[spark] class HistoryPage(parent: HistoryServer) extends WebUIPage("") { | |
| "Spark User", | ||
| "Last Updated") | ||
|
|
||
| private def pageIndices(pageCount: Int, actualPage: Int): Seq[Node] = { | ||
|
|
||
| def rangeIndices(range: Seq[Int], condition: Int => Boolean): Seq[Node] = { | ||
| range.filter(condition).map(nextPage => <a href={"/?page=" + nextPage}> {nextPage} </a>) | ||
| } | ||
|
|
||
| val littlerSideIndices = | ||
| rangeIndices(actualPage - maxNumIndices until actualPage, 1 < _) | ||
| val greaterSideIndices = | ||
| rangeIndices(actualPage + 1 to actualPage + maxNumIndices, _ < pageCount) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These could just be |
||
|
|
||
| <span style="float: right"> | ||
| { | ||
| if (actualPage > 1) { | ||
| <a href={"/?page=" + (actualPage - 1)}>< </a> | ||
| <a href={"/?page=1"}>1</a> | ||
| } | ||
| } | ||
| {if (actualPage - maxNumIndices > 2) " ... "} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the |
||
| {littlerSideIndices} | ||
| {actualPage} | ||
| {greaterSideIndices} | ||
| {if (actualPage + maxNumIndices < pageCount - 1) " ... "} | ||
| { | ||
| if (actualPage < pageCount) { | ||
| <a href={"/?page=" + pageCount}>{pageCount}</a> | ||
| <a href={"/?page=" + (actualPage + 1)}> ></a> | ||
| } | ||
| } | ||
| </span> | ||
| } | ||
|
|
||
| private def appRow(info: ApplicationHistoryInfo): Seq[Node] = { | ||
| val uiAddress = HistoryServer.UI_PATH_PREFIX + s"/${info.id}" | ||
| val startTime = UIUtils.formatDate(info.startTime) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call this
plusOrMinus