mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-29 04:27:53 +01:00
Added partial JQuery datatables support to TableContainer
This commit is contained in:
parent
d3621302e6
commit
19736cbe8f
@ -21,6 +21,8 @@ public class TableContainer {
|
|||||||
private final String[] header;
|
private final String[] header;
|
||||||
private List<Serializable[]> values;
|
private List<Serializable[]> values;
|
||||||
|
|
||||||
|
private boolean jqueryDatatable;
|
||||||
|
|
||||||
private String color;
|
private String color;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,7 +45,7 @@ public class TableContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final String parseHtml() {
|
public final String parseHtml() {
|
||||||
return Html.TABLE_SCROLL.parse() +
|
return getTableHeader() +
|
||||||
parseHeader() +
|
parseHeader() +
|
||||||
parseBody() +
|
parseBody() +
|
||||||
"</table>";
|
"</table>";
|
||||||
@ -85,4 +87,21 @@ public class TableContainer {
|
|||||||
header.append("</tr></thead>");
|
header.append("</tr></thead>");
|
||||||
return header.toString();
|
return header.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make use of JQuery Datatables plugin.
|
||||||
|
* <p>
|
||||||
|
* If this is called, result of {@code parseHtml()} should be wrapped with {@code Html.PANEL.parse(Html.PANEL_BODY.parse(result))}
|
||||||
|
*/
|
||||||
|
public void useJqueryDataTables() {
|
||||||
|
this.jqueryDatatable = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getTableHeader() {
|
||||||
|
if (jqueryDatatable) {
|
||||||
|
return "<div class=\"table-responsive\">" + Html.TABLE_JQUERY.parse() + "</div>";
|
||||||
|
} else {
|
||||||
|
return Html.TABLE_SCROLL.parse();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -60,6 +60,7 @@ public enum Html {
|
|||||||
TABLE_END("</tbody></table>"),
|
TABLE_END("</tbody></table>"),
|
||||||
TABLE("<table class=\"table table-striped\">"),
|
TABLE("<table class=\"table table-striped\">"),
|
||||||
TABLE_SCROLL("<table class=\"table table-striped scrollbar\">"),
|
TABLE_SCROLL("<table class=\"table table-striped scrollbar\">"),
|
||||||
|
TABLE_JQUERY("<table class=\"table table-bordered table-striped table-hover player-table dataTable\">"),
|
||||||
TABLE_COLORED("<table class=\"bg-${0} table table-striped\">"),
|
TABLE_COLORED("<table class=\"bg-${0} table table-striped\">"),
|
||||||
TABLE_HEAD("<thead>${0}</thead>"),
|
TABLE_HEAD("<thead>${0}</thead>"),
|
||||||
TABLE_BODY("<tbody>${0}</tbody>"),
|
TABLE_BODY("<tbody>${0}</tbody>"),
|
||||||
|
@ -66,11 +66,11 @@ public class PlayersTableCreator {
|
|||||||
html.append(Html.TABLELINE_PLAYERS.parse(
|
html.append(Html.TABLELINE_PLAYERS.parse(
|
||||||
Html.LINK_EXTERNAL.parse(PlanAPI.getInstance().getPlayerInspectPageLink(profile.getName()), profile.getName()),
|
Html.LINK_EXTERNAL.parse(PlanAPI.getInstance().getPlayerInspectPageLink(profile.getName()), profile.getName()),
|
||||||
activityString,
|
activityString,
|
||||||
String.valueOf(playtime), FormatUtils.formatTimeAmount(playtime),
|
playtime, FormatUtils.formatTimeAmount(playtime),
|
||||||
String.valueOf(loginTimes),
|
loginTimes,
|
||||||
String.valueOf(registered), FormatUtils.formatTimeStampYear(registered),
|
registered, FormatUtils.formatTimeStampYear(registered),
|
||||||
String.valueOf(lastSeen), lastSeen != 0 ? FormatUtils.formatTimeStamp(lastSeen) : "-",
|
lastSeen, lastSeen != 0 ? FormatUtils.formatTimeStamp(lastSeen) : "-",
|
||||||
String.valueOf(geoLocation)
|
geoLocation
|
||||||
));
|
));
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
if (Settings.DEV_MODE.isTrue()) {
|
if (Settings.DEV_MODE.isTrue()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user