YARN-237. Refreshing the RM page forgets how many rows I had in my Datatables (jian he via bobby)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1456536 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Joseph Evans 2013-03-14 16:56:10 +00:00
parent 2c42337545
commit 1b6f0582fb
5 changed files with 28 additions and 5 deletions

View File

@ -111,7 +111,7 @@ public class CountersBlock extends HtmlBlock {
th().$title(g.getName()).$class("ui-state-default").
_(fixGroupDisplayName(g.getDisplayName()))._().
td().$class(C_TABLE).
table(".dt-counters").
table(".dt-counters").$id(job.getID()+"."+g.getName()).
thead().
tr().th(".name", "Name");

View File

@ -65,8 +65,12 @@ public class HsTasksBlock extends HtmlBlock {
if (!symbol.isEmpty()) {
type = MRApps.taskType(symbol);
}
THEAD<TABLE<Hamlet>> thead = html.table("#tasks").thead();
THEAD<TABLE<Hamlet>> thead;
if(type != null)
thead = html.table("#"+app.getJob().getID()
+ type).$class("dt-tasks").thead();
else
thead = html.table("#tasks").thead();
//Create the spanning row
int attemptColSpan = type == TaskType.REDUCE ? 8 : 3;
thead.tr().

View File

@ -22,7 +22,9 @@
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.ACCORDION;
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES;
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES_ID;
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES_SELECTOR;
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initID;
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initSelector;
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.postInitID;
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.tableInit;
@ -42,6 +44,8 @@ public class HsTasksPage extends HsView {
@Override protected void preHead(Page.HTML<_> html) {
commonPreHead(html);
set(DATATABLES_ID, "tasks");
set(DATATABLES_SELECTOR, ".dt-tasks" );
set(initSelector(DATATABLES), tasksTableInit());
set(initID(ACCORDION, "nav"), "{autoHeight:false, active:1}");
set(initID(DATATABLES, "tasks"), tasksTableInit());
set(postInitID(DATATABLES, "tasks"), jobsPostTableInit());

View File

@ -69,6 +69,9 @@ Release 2.0.5-beta - UNRELEASED
YARN-198. Added a link to RM pages from the NodeManager web app. (Jian He
via vinodkv)
YARN-237. Refreshing the RM page forgets how many rows I had in my
Datatables (jian he via bobby)
OPTIMIZATIONS
BUG FIXES

View File

@ -107,12 +107,21 @@ protected void initAccordions(List<String> list) {
protected void initDataTables(List<String> list) {
String defaultInit = "{bJQueryUI: true, sPaginationType: 'full_numbers'}";
String stateSaveInit = "bStateSave : true, " +
"\"fnStateSave\": function (oSettings, oData) { " +
"sessionStorage.setItem( oSettings.sTableId, JSON.stringify(oData) ); }, " +
"\"fnStateLoad\": function (oSettings) { " +
"return JSON.parse( sessionStorage.getItem(oSettings.sTableId) );}, ";
for (String id : split($(DATATABLES_ID))) {
if (Html.isValidId(id)) {
String init = $(initID(DATATABLES, id));
if (init.isEmpty()) {
init = defaultInit;
}
// for inserting stateSaveInit
int pos = init.indexOf('{') + 1;
init = new StringBuffer(init).insert(pos, stateSaveInit).toString();
list.add(join(id,"DataTable = $('#", id, "').dataTable(", init,
").fnSetFilteringDelay(188);"));
String postInit = $(postInitID(DATATABLES, id));
@ -126,9 +135,12 @@ protected void initDataTables(List<String> list) {
String init = $(initSelector(DATATABLES));
if (init.isEmpty()) {
init = defaultInit;
}
}
int pos = init.indexOf('{') + 1;
init = new StringBuffer(init).insert(pos, stateSaveInit).toString();
list.add(join(" $('", escapeJavaScript(selector), "').dataTable(", init,
").fnSetFilteringDelay(288);"));
").fnSetFilteringDelay(288);"));
}
}