mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-28 12:07:35 +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 List<Serializable[]> values;
|
||||
|
||||
private boolean jqueryDatatable;
|
||||
|
||||
private String color;
|
||||
|
||||
/**
|
||||
@ -43,7 +45,7 @@ public class TableContainer {
|
||||
}
|
||||
|
||||
public final String parseHtml() {
|
||||
return Html.TABLE_SCROLL.parse() +
|
||||
return getTableHeader() +
|
||||
parseHeader() +
|
||||
parseBody() +
|
||||
"</table>";
|
||||
@ -85,4 +87,21 @@ public class TableContainer {
|
||||
header.append("</tr></thead>");
|
||||
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("<table class=\"table table-striped\">"),
|
||||
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_HEAD("<thead>${0}</thead>"),
|
||||
TABLE_BODY("<tbody>${0}</tbody>"),
|
||||
|
@ -66,11 +66,11 @@ public class PlayersTableCreator {
|
||||
html.append(Html.TABLELINE_PLAYERS.parse(
|
||||
Html.LINK_EXTERNAL.parse(PlanAPI.getInstance().getPlayerInspectPageLink(profile.getName()), profile.getName()),
|
||||
activityString,
|
||||
String.valueOf(playtime), FormatUtils.formatTimeAmount(playtime),
|
||||
String.valueOf(loginTimes),
|
||||
String.valueOf(registered), FormatUtils.formatTimeStampYear(registered),
|
||||
String.valueOf(lastSeen), lastSeen != 0 ? FormatUtils.formatTimeStamp(lastSeen) : "-",
|
||||
String.valueOf(geoLocation)
|
||||
playtime, FormatUtils.formatTimeAmount(playtime),
|
||||
loginTimes,
|
||||
registered, FormatUtils.formatTimeStampYear(registered),
|
||||
lastSeen, lastSeen != 0 ? FormatUtils.formatTimeStamp(lastSeen) : "-",
|
||||
geoLocation
|
||||
));
|
||||
} catch (NullPointerException e) {
|
||||
if (Settings.DEV_MODE.isTrue()) {
|
||||
|
Loading…
Reference in New Issue
Block a user