use of com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables in project phoss-smp by phax.
the class PagePublicStart method fillContent.
@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final IRequestWebScopeWithoutResponse aRequestScope = aWPEC.getRequestScope();
if (SMPWebAppConfiguration.isStartPageParticipantsNone()) {
// New in v5.0.4
aNodeList.addChild(info("This SMP has disabled the list of participants."));
} else {
final ISMPServiceGroupManager aSMPServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
final ICommonsList<ISMPServiceGroup> aServiceGroups = aSMPServiceGroupMgr.getAllSMPServiceGroups();
// Use dynamic or static table?
final boolean bUseDataTables = SMPWebAppConfiguration.isStartPageDynamicTable();
final boolean bShowExtensionDetails = SMPWebAppConfiguration.isStartPageExtensionsShow();
AbstractHCTable<?> aFinalTable;
if (bUseDataTables) {
// Dynamic
final HCTable aTable = new HCTable(new DTCol("Participant ID").setInitialSorting(ESortOrder.ASCENDING), new DTCol(bShowExtensionDetails ? "Extension" : "Extension?").setDataSort(1, 0), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
aFinalTable = aTable;
} else {
// Static
final BootstrapTable aTable = new BootstrapTable();
aTable.setBordered(true);
aTable.setCondensed(true);
aTable.setStriped(true);
aTable.addHeaderRow().addCell("Participant ID").addCell(bShowExtensionDetails ? "Extension" : "Extension?").addCell(EPhotonCoreText.ACTIONS.getDisplayText(aDisplayLocale));
aFinalTable = aTable;
// Sort manually
aServiceGroups.sort(Comparator.comparing(x -> x.getParticipantIdentifier().getURIEncoded()));
}
for (final ISMPServiceGroup aServiceGroup : aServiceGroups) {
final String sDisplayName = aServiceGroup.getParticipantIdentifier().getURIEncoded();
final HCRow aRow = aFinalTable.addBodyRow();
aRow.addCell(sDisplayName);
if (bShowExtensionDetails) {
if (aServiceGroup.extensions().isNotEmpty())
aRow.addCell(code(HCExtHelper.nl2divList(aServiceGroup.getFirstExtensionXML())));
else
aRow.addCell();
} else {
aRow.addCell(EPhotonCoreText.getYesOrNo(aServiceGroup.extensions().isNotEmpty(), aDisplayLocale));
}
final SMPRestDataProvider aDP = new SMPRestDataProvider(aRequestScope, aServiceGroup.getParticipantIdentifier().getURIEncoded());
aRow.addCell(new HCA(new SimpleURL(aDP.getServiceGroupHref(aServiceGroup.getParticipantIdentifier()))).setTitle("Perform SMP query on " + sDisplayName).setTargetBlank().addChild(EFamFamIcon.SCRIPT_GO.getAsNode()));
}
if (aFinalTable.hasBodyRows()) {
aNodeList.addChild(aFinalTable);
if (bUseDataTables) {
final BootstrapDataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aFinalTable);
aNodeList.addChild(aDataTables);
}
} else
aNodeList.addChild(info("This SMP does not manage any participant yet."));
}
}
Aggregations