use of com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction in project phoss-smp by phax.
the class PageSecureRedirect method showListOfExistingObjects.
@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final ISMPRedirectManager aRedirectMgr = SMPMetaManager.getRedirectMgr();
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton("Create new Redirect", createCreateURL(aWPEC), EDefaultIcon.NEW);
aNodeList.addChild(aToolbar);
final HCTable aTable = new HCTable(new DTCol("Service Group").setDataSort(0, 1).setInitialSorting(ESortOrder.ASCENDING), new DTCol("Document type ID").setDataSort(1, 0), new DTCol("Target URL"), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
for (final ISMPRedirect aCurObject : aRedirectMgr.getAllSMPRedirects()) {
final StringMap aParams = new StringMap();
aParams.putIn(FIELD_SERVICE_GROUP_ID, aCurObject.getServiceGroupID());
aParams.putIn(FIELD_DOCTYPE_ID, aCurObject.getDocumentTypeIdentifier().getURIEncoded());
final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject, aParams);
final String sDisplayName = aCurObject.getServiceGroupID();
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(new HCA(aViewLink).addChild(sDisplayName));
aRow.addCell(NiceNameUI.getDocumentTypeID(aCurObject.getDocumentTypeIdentifier(), false));
aRow.addCell(aCurObject.getTargetHref());
final ISimpleURL aEditURL = createEditURL(aWPEC, aCurObject).addAll(aParams);
final ISimpleURL aCopyURL = createCopyURL(aWPEC, aCurObject).addAll(aParams);
final ISimpleURL aDeleteURL = createDeleteURL(aWPEC, aCurObject).addAll(aParams);
final ISimpleURL aPreviewURL = LinkHelper.getURLWithServerAndContext(aCurObject.getServiceGroup().getParticipantIdentifier().getURIPercentEncoded() + SMPRestFilter.PATH_SERVICES + aCurObject.getDocumentTypeIdentifier().getURIPercentEncoded());
aRow.addCell(new HCA(aEditURL).setTitle("Edit " + sDisplayName).addChild(EDefaultIcon.EDIT.getAsNode()), new HCTextNode(" "), new HCA(aCopyURL).setTitle("Create a copy of " + sDisplayName).addChild(EDefaultIcon.COPY.getAsNode()), new HCTextNode(" "), new HCA(aDeleteURL).setTitle("Delete " + sDisplayName).addChild(EDefaultIcon.DELETE.getAsNode()), new HCTextNode(" "), new HCA(aPreviewURL).setTitle("Perform SMP query on " + sDisplayName).setTargetBlank().addChild(EFamFamIcon.SCRIPT_GO.getAsNode()));
}
final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
aNodeList.addChild(aTable).addChild(aDataTables);
}
use of com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction in project phoss-smp by phax.
the class PageSecureEndpointChangeCertificate method fillContent.
@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
boolean bShowList = true;
final ICommonsMap<String, ICommonsList<ISMPEndpoint>> aEndpointsGroupedPerURL = new CommonsHashMap<>();
final ICommonsMap<String, ICommonsSet<ISMPServiceGroup>> aServiceGroupsGroupedPerURL = new CommonsHashMap<>();
final ICommonsList<ISMPServiceInformation> aAllSIs = aServiceInfoMgr.getAllSMPServiceInformation();
int nTotalEndpointCount = 0;
for (final ISMPServiceInformation aSI : aAllSIs) {
final ISMPServiceGroup aSG = aSI.getServiceGroup();
for (final ISMPProcess aProcess : aSI.getAllProcesses()) for (final ISMPEndpoint aEndpoint : aProcess.getAllEndpoints()) {
final String sUnifiedCertificate = _getUnifiedCert(aEndpoint.getCertificate());
aEndpointsGroupedPerURL.computeIfAbsent(sUnifiedCertificate, k -> new CommonsArrayList<>()).add(aEndpoint);
aServiceGroupsGroupedPerURL.computeIfAbsent(sUnifiedCertificate, k -> new CommonsHashSet<>()).add(aSG);
++nTotalEndpointCount;
}
}
{
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.REFRESH);
aNodeList.addChild(aToolbar);
final int nCount = BulkChangeCertificate.getRunningJobCount();
if (nCount > 0) {
aNodeList.addChild(warn((nCount == 1 ? "1 bulk change is" : nCount + " bulk changes are") + " currently running in the background"));
}
}
if (aWPEC.hasAction(CPageParam.ACTION_EDIT)) {
bShowList = false;
final FormErrorList aFormErrors = new FormErrorList();
final String sOldUnifiedCert = _getUnifiedCert(aWPEC.params().getAsString(FIELD_OLD_CERTIFICATE));
if (aWPEC.hasSubAction(CPageParam.ACTION_SAVE)) {
final String sNewCert = aWPEC.params().getAsString(FIELD_NEW_CERTIFICATE);
final String sNewUnifiedCert = _getUnifiedCert(sNewCert);
if (StringHelper.hasNoText(sOldUnifiedCert))
aFormErrors.addFieldInfo(FIELD_OLD_CERTIFICATE, "An old certificate must be provided");
else {
final String sErrorDetails = _getCertificateParsingError(sOldUnifiedCert);
if (sErrorDetails != null)
aFormErrors.addFieldInfo(FIELD_OLD_CERTIFICATE, "The old certificate is invalid: " + sErrorDetails);
}
if (StringHelper.hasNoText(sNewUnifiedCert))
aFormErrors.addFieldError(FIELD_NEW_CERTIFICATE, "A new certificate must be provided");
else {
final String sErrorDetails = _getCertificateParsingError(sNewUnifiedCert);
if (sErrorDetails != null)
aFormErrors.addFieldError(FIELD_NEW_CERTIFICATE, "The new certificate is invalid: " + sErrorDetails);
else if (sNewUnifiedCert.equals(sOldUnifiedCert))
aFormErrors.addFieldError(FIELD_NEW_CERTIFICATE, "The new certificate is identical to the old certificate");
}
// Validate parameters
if (aFormErrors.containsNoError()) {
PhotonWorkerPool.getInstance().run("BulkChangeCertificate", new BulkChangeCertificate(aAllSIs, aDisplayLocale, sOldUnifiedCert, sNewCert));
aWPEC.postRedirectGetInternal(success().addChildren(div("The bulk change of the endpoint certificate to"), _getCertificateDisplay(sNewUnifiedCert, aDisplayLocale), div("is now running in the background. Please manually refresh the page to see the update.")));
}
}
final ICommonsSet<ISMPServiceGroup> aServiceGroups = aServiceGroupsGroupedPerURL.get(sOldUnifiedCert);
final int nSGCount = CollectionHelper.getSize(aServiceGroups);
final int nEPCount = CollectionHelper.getSize(aEndpointsGroupedPerURL.get(sOldUnifiedCert));
aNodeList.addChild(info("The selected old certificate is currently used in " + nEPCount + " " + (nEPCount == 1 ? "endpoint" : "endpoints") + " of " + nSGCount + " " + (nSGCount == 1 ? "service group" : "service groups") + "."));
// Show edit screen
final BootstrapForm aForm = aNodeList.addAndReturnChild(getUIHandler().createFormSelf(aWPEC));
aForm.addChild(new HCHiddenField(CPageParam.PARAM_ACTION, CPageParam.ACTION_EDIT));
aForm.addChild(new HCHiddenField(CPageParam.PARAM_SUBACTION, CPageParam.ACTION_SAVE));
aForm.addChild(new HCHiddenField(FIELD_OLD_CERTIFICATE, sOldUnifiedCert));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Old certificate").setCtrl(_getCertificateDisplay(sOldUnifiedCert, aDisplayLocale)).setHelpText("The old certificate that is to be changed in all matching endpoints").setErrorList(aFormErrors.getListOfField(FIELD_OLD_CERTIFICATE)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("New certificate").setCtrl(new HCTextArea(new RequestField(FIELD_NEW_CERTIFICATE, sOldUnifiedCert)).setRows(10)).setHelpText("The new certificate that is used instead").setErrorList(aFormErrors.getListOfField(FIELD_NEW_CERTIFICATE)));
final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(getUIHandler().createToolbar(aWPEC));
aToolbar.addSubmitButton("Save changes", EDefaultIcon.SAVE);
aToolbar.addButtonCancel(aDisplayLocale);
}
if (bShowList) {
aNodeList.addChild(info().addChildren(div("This page lets you change the certificates of multiple endpoints at once. This is e.g. helpful when the old certificate expired."), div("Currently " + (nTotalEndpointCount == 1 ? "1 endpoint is" : nTotalEndpointCount + " endpoints are") + " registered.")));
final HCTable aTable = new HCTable(new DTCol("Certificate").setInitialSorting(ESortOrder.ASCENDING), new DTCol("Service Group Count").setDisplayType(EDTColType.INT, aDisplayLocale), new DTCol("Endpoint Count").setDisplayType(EDTColType.INT, aDisplayLocale), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
aEndpointsGroupedPerURL.forEach((sCert, aEndpoints) -> {
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(_getCertificateDisplay(sCert, aDisplayLocale));
final int nSGCount = CollectionHelper.getSize(aServiceGroupsGroupedPerURL.get(sCert));
aRow.addCell(Integer.toString(nSGCount));
aRow.addCell(Integer.toString(aEndpoints.size()));
final ISimpleURL aEditURL = aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, CPageParam.ACTION_EDIT).add(FIELD_OLD_CERTIFICATE, sCert);
aRow.addCell(new HCA(aEditURL).setTitle("Change all endpoints using this certificate").addChild(EDefaultIcon.EDIT.getAsNode()));
});
final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
aNodeList.addChild(aTable).addChild(aDataTables);
}
}
use of com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction 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."));
}
}
use of com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction in project phoss-smp by phax.
the class PageSecureTransportProfiles method showListOfExistingObjects.
@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final ISMPTransportProfileManager aTransportProfileMgr = SMPMetaManager.getTransportProfileMgr();
aNodeList.addChild(info("This page lets you create custom transport profiles that can be used in service information endpoints."));
final ICommonsList<ISMPTransportProfile> aList = aTransportProfileMgr.getAllSMPTransportProfiles();
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addChild(new BootstrapButton().addChild("Create new transport profile").setOnClick(createCreateURL(aWPEC)).setIcon(EDefaultIcon.NEW));
final ICommonsSet<String> aExistingIDs = new CommonsHashSet<>(aList, ISMPTransportProfile::getID);
if (!aExistingIDs.containsAll(DEFAULT_PROFILE_IDS)) {
// Show button only on demand
aToolbar.addChild(new BootstrapButton().addChild("Ensure all default transport profiles").setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_ENSURE_DEFAULT)).setIcon(EDefaultIcon.PLUS));
}
aNodeList.addChild(aToolbar);
final HCTable aTable = new HCTable(new DTCol("ID").setInitialSorting(ESortOrder.ASCENDING), new DTCol("Name"), new DTCol("Deprecated?"), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
for (final ISMPTransportProfile aCurObject : aList) {
final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject);
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(new HCA(aViewLink).addChild(aCurObject.getID()));
aRow.addCell(aCurObject.getName());
aRow.addCell(EPhotonCoreText.getYesOrNo(aCurObject.isDeprecated(), aDisplayLocale));
aRow.addCell(createEditLink(aWPEC, aCurObject, "Edit " + aCurObject.getID()), new HCTextNode(" "), createCopyLink(aWPEC, aCurObject, "Copy " + aCurObject.getID()), new HCTextNode(" "), isActionAllowed(aWPEC, EWebPageFormAction.DELETE, aCurObject) ? createDeleteLink(aWPEC, aCurObject, "Delete " + aCurObject.getID()) : createEmptyAction());
}
final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
aNodeList.addChild(aTable).addChild(aDataTables);
}
Aggregations