Skip to content
Closed
Changes from 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

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


def render(request: HttpServletRequest): Seq[Node] = {
val requestedPage = Option(request.getParameter("page")).getOrElse("1").toInt
Expand All @@ -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)}>&lt;</a>}
{if (actualPage < pageCount) <a href={"/?page=" + (actualPage + 1)}>&gt;</a>}
</span>
{pageIndices(pageCount, actualPage)}
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also add some comment here that says something like

// This displays the indices of pages that are within `plusOrMinus` pages of the current page
// Regardless of where the current page is, this also links to the first and last page

</h4> ++
appTable
} else {
Expand All @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

These could just be leftSideIndices and rightSideIndices


<span style="float: right">
{
if (actualPage > 1) {
<a href={"/?page=" + (actualPage - 1)}>&lt; </a>
<a href={"/?page=1"}>1</a>
}
}
{if (actualPage - maxNumIndices > 2) " ... "}
Copy link
Contributor

Choose a reason for hiding this comment

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

the 2 here should be maxNumIndices right?

{littlerSideIndices}
{actualPage}
{greaterSideIndices}
{if (actualPage + maxNumIndices < pageCount - 1) " ... "}
{
if (actualPage < pageCount) {
<a href={"/?page=" + pageCount}>{pageCount}</a>
<a href={"/?page=" + (actualPage + 1)}> &gt;</a>
}
}
</span>
}

private def appRow(info: ApplicationHistoryInfo): Seq[Node] = {
val uiAddress = HistoryServer.UI_PATH_PREFIX + s"/${info.id}"
val startTime = UIUtils.formatDate(info.startTime)
Expand Down