@@ -26,7 +26,7 @@ import org.apache.spark.ui.{WebUIPage, UIUtils}
26
26
private [spark] class HistoryPage (parent : HistoryServer ) extends WebUIPage (" " ) {
27
27
28
28
private val pageSize = 20
29
- private val maxNumIndices = 4
29
+ private val maxNumIndices = 2
30
30
31
31
def render (request : HttpServletRequest ): Seq [Node ] = {
32
32
val requestedPage = Option (request.getParameter(" page" )).getOrElse(" 1" ).toInt
@@ -52,23 +52,7 @@ private[spark] class HistoryPage(parent: HistoryServer) extends WebUIPage("") {
52
52
if (allApps.size > 0 ) {
53
53
<h4 >
54
54
Showing {actualFirst + 1 }- {last + 1 } of {allApps.size}
55
- <span style =" float: right" >
56
- {if (actualPage > 1 ) <a href ={" /?page=" + (actualPage - 1 )}>< </a >}
57
- {if (actualPage > 1 ) <a href ={" /?page=1" }>1 </a >}
58
- {if (actualPage - maxNumIndices > 2 ) " ... " }
59
- {(1 to maxNumIndices).reverse.filter(actualPage - _ > 1 ).map {offset =>
60
- val nextPage = actualPage - offset
61
- <a href ={" /?page=" + (nextPage)}> {nextPage} </a >
62
- }}
63
- {actualPage}
64
- {(1 to maxNumIndices).filter(actualPage + _ < pageCount).map{offset =>
65
- val nextPage = actualPage + offset
66
- <a href ={" /?page=" + nextPage}> {nextPage} </a >
67
- }}
68
- {if (actualPage + maxNumIndices < pageCount - 1 ) " ... " }
69
- {if (actualPage < pageCount) <a href ={" /?page=" + pageCount}>{pageCount}</a >}
70
- {if (actualPage < pageCount) <a href ={" /?page=" + (actualPage + 1 )}> > </a >}
71
- </span >
55
+ {pageIndices(pageCount, actualPage)}
72
56
</h4 > ++
73
57
appTable
74
58
} else {
@@ -89,6 +73,38 @@ private[spark] class HistoryPage(parent: HistoryServer) extends WebUIPage("") {
89
73
" Spark User" ,
90
74
" Last Updated" )
91
75
76
+ private def pageIndices (pageCount : Int , actualPage : Int ): Seq [Node ] = {
77
+
78
+ def rangeIndices (range : Seq [Int ], condition : Int => Boolean ): Seq [Node ] = {
79
+ range.filter(condition).map(nextPage => <a href ={" /?page=" + nextPage}> {nextPage} </a >)
80
+ }
81
+
82
+ val littlerSideIndices =
83
+ rangeIndices(actualPage- maxNumIndices until actualPage, 1 < _)
84
+ val greaterSideIndices =
85
+ rangeIndices(actualPage+ 1 to actualPage+ maxNumIndices, _ < pageCount)
86
+
87
+ <span style =" float: right" >
88
+ {
89
+ if (actualPage > 1 ) {
90
+ <a href ={" /?page=" + (actualPage - 1 )}>< </a >
91
+ <a href ={" /?page=1" }>1 </a >
92
+ }
93
+ }
94
+ {if (actualPage - maxNumIndices > 2 ) " ... " }
95
+ {littlerSideIndices}
96
+ {actualPage}
97
+ {greaterSideIndices}
98
+ {if (actualPage + maxNumIndices < pageCount - 1 ) " ... " }
99
+ {
100
+ if (actualPage < pageCount) {
101
+ <a href ={" /?page=" + pageCount}>{pageCount}</a >
102
+ <a href ={" /?page=" + (actualPage + 1 )}> > </a >
103
+ }
104
+ }
105
+ </span >
106
+ }
107
+
92
108
private def appRow (info : ApplicationHistoryInfo ): Seq [Node ] = {
93
109
val uiAddress = HistoryServer .UI_PATH_PREFIX + s " / ${info.id}"
94
110
val startTime = UIUtils .formatDate(info.startTime)
0 commit comments