use of com.helger.html.hc.html.textlevel.HCA in project phoss-directory by phax.
the class PageSecureAdminSMLConfiguration method showListOfExistingObjects.
@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final ISMLInfoManager aSMLInfoMgr = PDPMetaManager.getSMLInfoMgr();
aNodeList.addChild(info("This page lets you create custom SML configurations that can be used for registration."));
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton("Create new SML configuration", createCreateURL(aWPEC), EDefaultIcon.NEW);
aNodeList.addChild(aToolbar);
final HCTable aTable = new HCTable(new DTCol("Name").setInitialSorting(ESortOrder.ASCENDING), new DTCol("DNS Zone"), new DTCol("Management Service URL"), new DTCol("Client Cert?"), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
for (final ISMLInfo aCurObject : aSMLInfoMgr.getAll()) {
final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject);
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(new HCA(aViewLink).addChild(aCurObject.getDisplayName()));
aRow.addCell(aCurObject.getDNSZone());
aRow.addCell(aCurObject.getManagementServiceURL());
aRow.addCell(EPhotonCoreText.getYesOrNo(aCurObject.isClientCertificateRequired(), 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.getDisplayName()) : createEmptyAction());
}
final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
aNodeList.addChild(aTable).addChild(aDataTables);
}
use of com.helger.html.hc.html.textlevel.HCA in project phoss-smp by phax.
the class SMPRendererPublic method createDefaultFooter.
/**
* @param bShowApplicationName
* <code>true</code> to show the application name and version,
* <code>false</code> to hide it.
* @param bShowSource
* <code>true</code> to show the link to the source, <code>false</code>
* to hide it.
* @param bShowAuthor
* <code>true</code> to show the author, <code>false</code> to hide it.
* @return The footer to be used for /public and /secure. Never
* <code>null</code> but maybe empty.
*/
@Nonnull
public static BootstrapContainer createDefaultFooter(final boolean bShowApplicationName, final boolean bShowSource, final boolean bShowAuthor) {
final BootstrapContainer aContainer = new BootstrapContainer().setID(CLayout.LAYOUT_AREAID_FOOTER).setFluid(true);
if (bShowApplicationName) {
aContainer.addChild(new HCP().addChild(CSMP.getApplicationTitleAndVersion() + " with " + SMPServerConfiguration.getRESTType().getDisplayName() + " API"));
}
// By
{
final HCP aBy = new HCP();
// Author
if (bShowAuthor)
aBy.addChild("Created by ").addChild(HCA_MailTo.createLinkedEmail("philip@helger.com", "Philip Helger"));
// Source
if (bShowSource) {
if (aBy.hasChildren())
aBy.addChild(" - ");
aBy.addChild(new HCA(new SimpleURL("https://github.com/phax/phoss-smp")).setTargetBlank().addChild(CSMP.APPLICATION_TITLE + " on GitHub"));
}
if (aBy.hasChildren())
aContainer.addChild(aBy);
}
// Imprint
if (SMPWebAppConfiguration.isImprintEnabled()) {
final String sImprintText = SMPWebAppConfiguration.getImprintText();
if (StringHelper.hasText(sImprintText)) {
final ISimpleURL aImprintHref = SMPWebAppConfiguration.getImprintHref();
final IHCElementWithChildren<?> aNode;
if (aImprintHref != null) {
// Link and text
final String sImprintTarget = SMPWebAppConfiguration.getImprintTarget();
final HC_Target aTarget = StringHelper.hasText(sImprintTarget) ? new HC_Target(sImprintTarget) : null;
aNode = new HCA(aImprintHref).addChild(sImprintText).setTarget(aTarget);
} else {
// Text only
aNode = new HCSpan().addChild(sImprintText);
}
// Already trimmed
final String sImprintCSSClasses = SMPWebAppConfiguration.getImprintCSSClasses();
if (StringHelper.hasText(sImprintCSSClasses)) {
final ICommonsSet<String> aUniqueNames = new CommonsHashSet<>(RegExHelper.getSplitToList(sImprintCSSClasses, "\\s+"));
for (final String sCSSClass : aUniqueNames) aNode.addClass(DefaultCSSClassProvider.create(sCSSClass));
}
aContainer.addChild(new HCP().addChild("Imprint ").addChild(aNode));
}
}
return aContainer;
}
use of com.helger.html.hc.html.textlevel.HCA in project phoss-smp by phax.
the class PageSecureBusinessCard method showSelectedObject.
@Override
protected void showSelectedObject(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final ISMPBusinessCard aSelectedObject) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
aNodeList.addChild(getUIHandler().createActionHeader("Show details of Business Card"));
final BootstrapViewForm aForm = new BootstrapViewForm();
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Service Group").setCtrl(new HCA(createViewURL(aWPEC, CMenuSecure.MENU_SERVICE_GROUPS, aSelectedObject)).addChild(aSelectedObject.getID())));
int nIndex = 0;
for (final SMPBusinessCardEntity aEntity : aSelectedObject.getAllEntities()) {
++nIndex;
aForm.addChild(showBusinessCardEntity(aEntity, nIndex, aDisplayLocale));
}
if (nIndex == 0)
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Entity").setCtrl(em("none defined")));
aNodeList.addChild(aForm);
}
use of com.helger.html.hc.html.textlevel.HCA in project phoss-smp by phax.
the class PageSecureEndpointChangeURL method fillContent.
@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
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;
int nTotalEndpointCountWithURL = 0;
for (final ISMPServiceInformation aSI : aAllSIs) {
final ISMPServiceGroup aSG = aSI.getServiceGroup();
for (final ISMPProcess aProcess : aSI.getAllProcesses()) for (final ISMPEndpoint aEndpoint : aProcess.getAllEndpoints()) {
++nTotalEndpointCount;
if (aEndpoint.hasEndpointReference()) {
aEndpointsGroupedPerURL.computeIfAbsent(aEndpoint.getEndpointReference(), k -> new CommonsArrayList<>()).add(aEndpoint);
aServiceGroupsGroupedPerURL.computeIfAbsent(aEndpoint.getEndpointReference(), k -> new CommonsHashSet<>()).add(aSG);
++nTotalEndpointCountWithURL;
}
}
}
{
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.REFRESH);
aNodeList.addChild(aToolbar);
final int nCount = BulkChangeEndpointURL.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 sOldURL = aWPEC.params().getAsString(FIELD_OLD_URL);
if (aWPEC.hasSubAction(CPageParam.ACTION_SAVE)) {
// Find selected service group (if any)
final String sServiceGroupID = aWPEC.params().getAsString(FIELD_SERVICE_GROUP);
ISMPServiceGroup aServiceGroup = null;
if (StringHelper.hasText(sServiceGroupID)) {
final IParticipantIdentifier aParticipantID = aIdentifierFactory.parseParticipantIdentifier(sServiceGroupID);
if (aParticipantID != null)
aServiceGroup = aServiceGroupMgr.getSMPServiceGroupOfID(aParticipantID);
}
final String sNewURL = aWPEC.params().getAsString(FIELD_NEW_URL);
if (StringHelper.hasNoText(sOldURL))
aFormErrors.addFieldInfo(FIELD_OLD_URL, "An old URL must be provided");
else if (!URLValidator.isValid(sOldURL))
aFormErrors.addFieldInfo(FIELD_OLD_URL, "The old URL is invalid");
if (StringHelper.hasNoText(sNewURL))
aFormErrors.addFieldInfo(FIELD_NEW_URL, "A new URL must be provided");
else if (!URLValidator.isValid(sNewURL))
aFormErrors.addFieldInfo(FIELD_NEW_URL, "The new URL is invalid");
else if (sNewURL.equals(sOldURL))
aFormErrors.addFieldInfo(FIELD_NEW_URL, "The new URL is identical to the old URL");
// Validate parameters
if (aFormErrors.isEmpty()) {
PhotonWorkerPool.getInstance().run("BulkChangeEndpointURL", new BulkChangeEndpointURL(aAllSIs, aServiceGroup, sOldURL, sNewURL));
aWPEC.postRedirectGetInternal(success("The bulk change of the endpoint URL from '" + sOldURL + "' to '" + sNewURL + "' is now running in the background. Please manually refresh the page to see the update."));
}
}
final ICommonsSet<ISMPServiceGroup> aServiceGroups = aServiceGroupsGroupedPerURL.get(sOldURL);
final int nSGCount = CollectionHelper.getSize(aServiceGroups);
final int nEPCount = CollectionHelper.getSize(aEndpointsGroupedPerURL.get(sOldURL));
aNodeList.addChild(info("The selected old URL '" + sOldURL + "' 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));
if (nSGCount > 1) {
// Select the affected service groups if more than one is available
final HCSelect aSGSelect = new HCSelect(new RequestField(FIELD_SERVICE_GROUP));
aSGSelect.addOption(SERVICE_GROUP_ALL, "All affected Service Groups");
if (aServiceGroups != null)
for (final ISMPServiceGroup aSG : aServiceGroups.getSorted(ISMPServiceGroup.comparator())) aSGSelect.addOption(aSG.getID(), aSG.getParticipantIdentifier().getURIEncoded());
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Service group").setCtrl(aSGSelect).setHelpText("If a specific service group is selected, the URL change will only happen in the endpoints of the selected service group. Othwerwise the endpoint is changed in ALL service groups with matching endpoints.").setErrorList(aFormErrors.getListOfField(FIELD_OLD_URL)));
} else {
// If less than 2 service groups are affected, use the 0/1
// automatically.
aForm.addChild(new HCHiddenField(FIELD_SERVICE_GROUP, SERVICE_GROUP_ALL));
}
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Old endpoint URL").setCtrl(new HCEdit(new RequestField(FIELD_OLD_URL, sOldURL))).setHelpText("The old URL that is to be changed in all matching endpoints").setErrorList(aFormErrors.getListOfField(FIELD_OLD_URL)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("New endpoint URL").setCtrl(new HCEdit(new RequestField(FIELD_NEW_URL, sOldURL))).setHelpText("The new URL that is used instead").setErrorList(aFormErrors.getListOfField(FIELD_NEW_URL)));
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 URLs of multiple endpoints at once. This is e.g. helpful when the underlying server got a new URL."), div("Currently " + (nTotalEndpointCount == 1 ? "1 endpoint is" : nTotalEndpointCount + " endpoints are") + " registered" + (nTotalEndpointCountWithURL < nTotalEndpointCount ? " of which " + nTotalEndpointCountWithURL + " have an endpoint reference" : "") + ".")));
final HCTable aTable = new HCTable(new DTCol("Endpoint URL").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((sURL, aEndpoints) -> {
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(sURL);
final int nSGCount = CollectionHelper.getSize(aServiceGroupsGroupedPerURL.get(sURL));
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_URL, sURL);
aRow.addCell(new HCA(aEditURL).setTitle("Change all endpoints pointing to " + sURL).addChild(EDefaultIcon.EDIT.getAsNode()));
});
final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
aNodeList.addChild(aTable).addChild(aDataTables);
}
}
use of com.helger.html.hc.html.textlevel.HCA in project phoss-smp by phax.
the class PageSecureEndpointList method showListOfExistingObjects.
@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
final ICommonsList<ISMPServiceInformation> aAllServiceInfos = aServiceInfoMgr.getAllSMPServiceInformation();
// Count unique service groups
final ICommonsSet<String> aServiceGroupIDs = new CommonsHashSet<>();
aAllServiceInfos.findAllMapped(ISMPServiceInformation::getServiceGroupID, aServiceGroupIDs::add);
final boolean bHideDetails = aServiceGroupIDs.size() > 1000;
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton("Create new Endpoint", createCreateURL(aWPEC), EDefaultIcon.NEW);
aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.REFRESH);
if (!bHideDetails)
aToolbar.addButton("Tree view", aWPEC.getLinkToMenuItem(CMenuSecure.MENU_ENDPOINT_TREE), EDefaultIcon.MAGNIFIER);
aNodeList.addChild(aToolbar);
final HCTable aTable = new HCTable(new DTCol("Service group").setInitialSorting(ESortOrder.ASCENDING).setDataSort(0, 1, 2, 3), new DTCol("Document type ID").setDataSort(1, 0, 2, 3), new DTCol("Process ID").setDataSort(2, 0, 1, 3), new DTCol("Transport profile").setDataSort(3, 0, 1, 2), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
for (final ISMPServiceInformation aServiceInfo : aAllServiceInfos) {
final ISMPServiceGroup aServiceGroup = aServiceInfo.getServiceGroup();
final IParticipantIdentifier aParticipantID = aServiceGroup.getParticipantIdentifier();
final IDocumentTypeIdentifier aDocTypeID = aServiceInfo.getDocumentTypeIdentifier();
for (final ISMPProcess aProcess : aServiceInfo.getAllProcesses()) {
final IProcessIdentifier aProcessID = aProcess.getProcessIdentifier();
for (final ISMPEndpoint aEndpoint : aProcess.getAllEndpoints()) {
final StringMap aParams = createParamMap(aServiceInfo, aProcess, aEndpoint);
final HCRow aRow = aTable.addBodyRow();
final ISimpleURL aViewURL = createViewURL(aWPEC, aServiceInfo, aParams);
aRow.addCell(new HCA(aViewURL).addChild(aServiceGroup.getID()));
aRow.addCell(NiceNameUI.getDocumentTypeID(aDocTypeID, false));
aRow.addCell(NiceNameUI.getProcessID(aDocTypeID, aProcessID, false));
final String sTransportProfile = aEndpoint.getTransportProfile();
aRow.addCell(new HCA(createViewURL(aWPEC, CMenuSecure.MENU_TRANSPORT_PROFILES, sTransportProfile)).addChild(NiceNameUI.getTransportProfile(sTransportProfile, false)));
final ISimpleURL aEditURL = createEditURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aCopyURL = createCopyURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aDeleteURL = createDeleteURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aPreviewURL = LinkHelper.getURLWithServerAndContext(aParticipantID.getURIPercentEncoded() + SMPRestFilter.PATH_SERVICES + aDocTypeID.getURIPercentEncoded());
aRow.addCell(new HCA(aViewURL).setTitle("View endpoint").addChild(EDefaultIcon.MAGNIFIER.getAsNode()), new HCTextNode(" "), new HCA(aEditURL).setTitle("Edit endpoint").addChild(EDefaultIcon.EDIT.getAsNode()), new HCTextNode(" "), new HCA(aCopyURL).setTitle("Copy endpoint").addChild(EDefaultIcon.COPY.getAsNode()), new HCTextNode(" "), new HCA(aDeleteURL).setTitle("Delete endpoint").addChild(EDefaultIcon.DELETE.getAsNode()), new HCTextNode(" "), new HCA(aPreviewURL).setTitle("Perform SMP query on endpoint").setTargetBlank().addChild(EFamFamIcon.SCRIPT_GO.getAsNode()));
}
}
}
final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
aNodeList.addChild(aTable).addChild(aDataTables);
}
Aggregations