use of com.helger.photon.bootstrap4.form.BootstrapFormGroup in project phoss-directory by phax.
the class AbstractPageSecureReIndex method showSelectedObject.
@Override
protected void showSelectedObject(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final IReIndexWorkItem aSelectedObject) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final ISMPURLProvider aURLProvider = PDServerConfiguration.getURLProvider();
final IIndexerWorkItem aWorkItem = aSelectedObject.getWorkItem();
final IParticipantIdentifier aParticipantID = aWorkItem.getParticipantID();
final BootstrapViewForm aViewForm = aNodeList.addAndReturnChild(new BootstrapViewForm());
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Creation datetime").setCtrl(PDTToString.getAsString(aWorkItem.getCreationDateTime(), aDisplayLocale)));
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Participant ID").setCtrl(aParticipantID.getURIEncoded()));
final String sBCSuffix = "/businesscard/" + aParticipantID.getURIPercentEncoded();
{
final HCNodeList aURLs = new HCNodeList();
for (final ISMLInfo aSMLInfo : PDPMetaManager.getSMLInfoMgr().getAll()) {
if (aURLs.hasChildren())
aURLs.addChild(div("or"));
try {
aURLs.addChild(div(HCA.createLinkedWebsite(aURLProvider.getSMPURIOfParticipant(aParticipantID, aSMLInfo).toString() + sBCSuffix)));
} catch (final SMPDNSResolutionException ex) {
// Non existing participant!
aURLs.addChild(div(aParticipantID.getURIPercentEncoded() + " on " + aSMLInfo.getDisplayName() + " @ " + sBCSuffix + " [" + ex.getMessage() + "]"));
}
}
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Business Card URL").setCtrl(aURLs));
}
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Action type").setCtrl(aWorkItem.getType().getDisplayName()));
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Owner").setCtrl(aWorkItem.getOwnerID()));
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Requesting host").setCtrl(aWorkItem.getRequestingHost()));
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Retries so far").setCtrl(Integer.toString(aSelectedObject.getRetryCount())));
if (aSelectedObject.hasPreviousRetryDT())
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Previous retry").setCtrl(PDTToString.getAsString(aSelectedObject.getPreviousRetryDT(), aDisplayLocale)));
if (!m_bDeadIndex)
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Next retry").setCtrl(PDTToString.getAsString(aSelectedObject.getNextRetryDT(), aDisplayLocale)));
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Last retry").setCtrl(PDTToString.getAsString(aSelectedObject.getMaxRetryDT(), aDisplayLocale)));
}
use of com.helger.photon.bootstrap4.form.BootstrapFormGroup in project phoss-directory by phax.
the class PageSecureIndexImport method fillContent.
@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final IIdentifierFactory aIdentifierFactory = PDMetaManager.getIdentifierFactory();
final FormErrorList aFormErrors = new FormErrorList();
{
final IPDBusinessCardProvider aBCProv = PDMetaManager.getBusinessCardProvider();
if (aBCProv instanceof SMPBusinessCardProvider) {
final SMPBusinessCardProvider aSMPBCProv = (SMPBusinessCardProvider) aBCProv;
if (aSMPBCProv.isFixedSMP()) {
aNodeList.addChild(info("Fixed SMP URI " + aSMPBCProv.getFixedSMPURI() + " is used."));
} else {
aNodeList.addChild(info("The following SMLs are crawled for entries: " + StringHelper.getImplodedMapped(", ", aSMPBCProv.getAllSMLsToUse(), ISMLInfo::getDisplayName)));
}
}
}
final boolean bIsFormSubmitted = aWPEC.hasAction(CPageParam.ACTION_PERFORM);
if (bIsFormSubmitted) {
final IFileItem aFile = aWPEC.params().getAsFileItem(FIELD_FILE);
if (aFile == null || StringHelper.hasNoText(aFile.getName()))
aFormErrors.addFieldError(FIELD_FILE, "No file was selected");
if (aFormErrors.isEmpty()) {
final HCNodeList aResultNL = new HCNodeList();
final SAXReaderSettings aSettings = new SAXReaderSettings();
aSettings.setFeatureValues(EXMLParserFeature.AVOID_DOS_SETTINGS);
final CollectingSAXErrorHandler aErrorHandler = new CollectingSAXErrorHandler();
aSettings.setErrorHandler(aErrorHandler);
final ICommonsList<IParticipantIdentifier> aQueued = new CommonsArrayList<>();
final ICommonsList<IParticipantIdentifier> aNotQueued = new CommonsArrayList<>();
aSettings.setContentHandler(new DefaultHandler() {
@Override
public void startElement(final String sURI, final String sLocalName, final String sQName, final Attributes aAttributes) throws SAXException {
if (sQName.equals("participant")) {
final String sScheme = aAttributes.getValue("scheme");
final String sValue = aAttributes.getValue("value");
final IParticipantIdentifier aParticipantID = aIdentifierFactory.createParticipantIdentifier(sScheme, sValue);
if (aParticipantID != null) {
if (PDMetaManager.getIndexerMgr().queueWorkItem(aParticipantID, EIndexerWorkItemType.CREATE_UPDATE, "import-triggered", PDIndexerManager.HOST_LOCALHOST).isChanged()) {
aQueued.add(aParticipantID);
} else {
aNotQueued.add(aParticipantID);
}
} else
LOGGER.error("Failed to convert '" + sScheme + "' and '" + sValue + "' to a participant identifier");
}
}
});
LOGGER.info("Importing participant IDs from '" + aFile.getNameSecure() + "'");
final ESuccess eSuccess = SAXReader.readXMLSAX(new FileItemResource(aFile), aSettings);
LOGGER.info("Finished reading XML file. Queued " + aQueued.size() + "; not queued: " + aNotQueued.size() + "; errors: " + aErrorHandler.getErrorList().size());
// Some things may have been queued even in case of error
if (aQueued.isNotEmpty()) {
final HCUL aUL = new HCUL();
for (final IParticipantIdentifier aPI : aQueued) aUL.addItem(aPI.getURIEncoded());
aResultNL.addChild(success(div("The following identifiers were successfully queued for indexing:")).addChild(aUL));
}
if (aNotQueued.isNotEmpty()) {
final HCUL aUL = new HCUL();
for (final IParticipantIdentifier aPI : aNotQueued) aUL.addItem(aPI.getURIEncoded());
aResultNL.addChild(warn(div("The following identifiers could not be queued (because they are already in the queue):")).addChild(aUL));
}
if (eSuccess.isFailure()) {
final HCUL aUL = new HCUL();
for (final IError aError : aErrorHandler.getErrorList()) {
final String sMsg = aError.getAsString(AppCommonUI.DEFAULT_LOCALE);
LOGGER.error(" " + sMsg);
aUL.addItem(sMsg);
}
aResultNL.addChild(error(div("Error parsing provided XML:")).addChild(aUL));
}
aWPEC.postRedirectGetInternal(aResultNL);
}
}
final BootstrapForm aForm = aNodeList.addAndReturnChild(getUIHandler().createFormFileUploadSelf(aWPEC, bIsFormSubmitted));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Import file").setCtrl(new BootstrapFileUpload(FIELD_FILE, aDisplayLocale)).setHelpText("Select a file that was created from a full XML export to index of all them manually.").setErrorList(aFormErrors.getListOfField(FIELD_FILE)));
final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
aToolbar.addHiddenField(CPageParam.PARAM_ACTION, CPageParam.ACTION_PERFORM);
aToolbar.addSubmitButton("Import all", EDefaultIcon.YES);
}
use of com.helger.photon.bootstrap4.form.BootstrapFormGroup in project phoss-directory by phax.
the class PagePublicSearchExtended method fillContent.
@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
aNodeList.addChild(info("This is a placeholder page - has no effect yet!"));
final BootstrapViewForm aViewForm = new BootstrapViewForm();
// Add all search fields
for (final EPDSearchField eField : EPDSearchField.values()) {
final HCSearchOperatorSelect aSelect = new HCSearchOperatorSelect(new RequestField(PREFIX_OPERATOR + eField.getFieldName(), ESearchOperator.EQ.getID()), eField.getDataType(), aDisplayLocale);
final HCNodeList aCtrl = _createCtrl(eField, aDisplayLocale);
final BootstrapRow aRow = new BootstrapRow();
aRow.createColumn(2).addChild(aSelect);
aRow.createColumn(10).addChild(aCtrl);
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel(eField.getDisplayText(aDisplayLocale)).setCtrl(aRow));
}
aNodeList.addChild(aViewForm);
}
use of com.helger.photon.bootstrap4.form.BootstrapFormGroup in project phoss-directory by phax.
the class AppCommonUI method createViewLoginForm.
@Nonnull
public static BootstrapForm createViewLoginForm(@Nonnull final LayoutExecutionContext aLEC, @Nullable final String sPreselectedUserName) {
final Locale aDisplayLocale = aLEC.getDisplayLocale();
final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
// Use new IDs for both fields, in case the login stuff is displayed more
// than once!
final String sIDUserName = GlobalIDFactory.getNewStringID();
final String sIDPassword = GlobalIDFactory.getNewStringID();
final String sIDErrorField = GlobalIDFactory.getNewStringID();
final BootstrapForm aForm = new BootstrapForm(aLEC).setAction(aLEC.getSelfHref()).setFormType(EBootstrapFormType.DEFAULT);
aForm.setLeft(3);
// User name field
aForm.addFormGroup(new BootstrapFormGroup().setLabel(EPhotonCoreText.EMAIL_ADDRESS.getDisplayText(aDisplayLocale)).setCtrl(new HCEdit(new RequestField(CLogin.REQUEST_ATTR_USERID, sPreselectedUserName)).setID(sIDUserName)));
// Password field
aForm.addFormGroup(new BootstrapFormGroup().setLabel(EPhotonCoreText.LOGIN_FIELD_PASSWORD.getDisplayText(aDisplayLocale)).setCtrl(new HCEditPassword(CLogin.REQUEST_ATTR_PASSWORD).setID(sIDPassword)));
// Placeholder for error message
aForm.addChild(new HCDiv().setID(sIDErrorField).addStyle(CCSSProperties.MARGIN.newValue("4px 0")));
// Login button
final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(new BootstrapButtonToolbar(aLEC));
final JSPackage aOnClick = new JSPackage();
{
final JSAnonymousFunction aJSSuccess = new JSAnonymousFunction();
final JSVar aJSData = aJSSuccess.param("data");
aJSSuccess.body()._if(aJSData.ref(AjaxExecutorPublicLogin.JSON_LOGGEDIN), JSHtml.windowLocationReload(), JQuery.idRef(sIDErrorField).empty().append(aJSData.ref(AjaxExecutorPublicLogin.JSON_HTML)));
aOnClick.add(new JQueryAjaxBuilder().url(CAjax.LOGIN.getInvocationURI(aRequestScope)).method(EHttpMethod.POST).data(new JSAssocArray().add(CLogin.REQUEST_ATTR_USERID, JQuery.idRef(sIDUserName).val()).add(CLogin.REQUEST_ATTR_PASSWORD, JQuery.idRef(sIDPassword).val())).success(aJSSuccess).build());
}
aOnClick._return(false);
aToolbar.addSubmitButton(EPhotonCoreText.LOGIN_BUTTON_SUBMIT.getDisplayText(aDisplayLocale), aOnClick);
return aForm;
}
use of com.helger.photon.bootstrap4.form.BootstrapFormGroup in project phoss-smp by phax.
the class AbstractPageSecureEndpoint method showSelectedObject.
@Override
protected void showSelectedObject(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final ISMPServiceInformation aSelectedObject) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final IDocumentTypeIdentifier aDocumentTypeID = aSelectedObject.getDocumentTypeIdentifier();
final ISMPProcess aSelectedProcess = aWPEC.getRequestScope().attrs().getCastedValue(REQUEST_ATTR_PROCESS);
final ISMPEndpoint aSelectedEndpoint = aWPEC.getRequestScope().attrs().getCastedValue(REQUEST_ATTR_ENDPOINT);
final LocalDateTime aNowLDT = PDTFactory.getCurrentLocalDateTime();
aNodeList.addChild(getUIHandler().createActionHeader("Show details of endpoint"));
final BootstrapViewForm aForm = new BootstrapViewForm();
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Service group").setCtrl(new HCA(createViewURL(aWPEC, CMenuSecure.MENU_SERVICE_GROUPS, aSelectedObject.getServiceGroup())).addChild(aSelectedObject.getServiceGroupID())));
// Document type identifier
{
final HCNodeList aCtrl = new HCNodeList();
aCtrl.addChild(div(NiceNameUI.getDocumentTypeID(aDocumentTypeID, true)));
try {
final IPeppolDocumentTypeIdentifierParts aParts = PeppolDocumentTypeIdentifierParts.extractFromIdentifier(aDocumentTypeID);
aCtrl.addChild(SMPCommonUI.getDocumentTypeIDDetails(aParts));
} catch (final IllegalArgumentException ex) {
if (false)
aCtrl.addChild(error("Failed to parse document type identifier: " + ex.getMessage()));
}
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Document type ID").setCtrl(aCtrl));
}
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Process ID").setCtrl(NiceNameUI.getProcessID(aSelectedObject.getDocumentTypeIdentifier(), aSelectedProcess.getProcessIdentifier(), true)));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Transport profile").setCtrl(new HCA(createViewURL(aWPEC, CMenuSecure.MENU_TRANSPORT_PROFILES, aSelectedEndpoint.getTransportProfile())).addChild(NiceNameUI.getTransportProfile(aSelectedEndpoint.getTransportProfile(), true))));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Endpoint reference").setCtrl(StringHelper.hasText(aSelectedEndpoint.getEndpointReference()) ? HCA.createLinkedWebsite(aSelectedEndpoint.getEndpointReference(), HC_Target.BLANK) : em("none")));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Requires business level signature").setCtrl(EPhotonCoreText.getYesOrNo(aSelectedEndpoint.isRequireBusinessLevelSignature(), aDisplayLocale)));
if (aSelectedEndpoint.hasMinimumAuthenticationLevel())
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Minimum authentication level").setCtrl(aSelectedEndpoint.getMinimumAuthenticationLevel()));
if (aSelectedEndpoint.hasServiceActivationDateTime()) {
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Not before").setCtrl(PDTToString.getAsString(aSelectedEndpoint.getServiceActivationDateTime(), aDisplayLocale)));
}
if (aSelectedEndpoint.hasServiceExpirationDateTime()) {
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Not after").setCtrl(PDTToString.getAsString(aSelectedEndpoint.getServiceExpirationDateTime(), aDisplayLocale)));
}
if (aSelectedEndpoint.hasCertificate()) {
final X509Certificate aEndpointCert = CertificateHelper.convertStringToCertficateOrNull(aSelectedEndpoint.getCertificate());
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Certificate").setCtrl(aEndpointCert == null ? strong("!!!FAILED TO INTERPRETE!!!") : SMPCommonUI.createCertificateDetailsTable(null, aEndpointCert, aNowLDT, aDisplayLocale).setResponsive(true)));
}
if (aSelectedEndpoint.hasServiceDescription())
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Service description").setCtrl(aSelectedEndpoint.getServiceDescription()));
if (aSelectedEndpoint.hasTechnicalContactUrl())
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Technical contact").setCtrl(HCA_MailTo.createLinkedEmail(aSelectedEndpoint.getTechnicalContactUrl())));
if (aSelectedEndpoint.hasTechnicalInformationUrl())
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Technical information").setCtrl(HCA.createLinkedWebsite(aSelectedEndpoint.getTechnicalInformationUrl(), HC_Target.BLANK)));
if (aSelectedEndpoint.extensions().isNotEmpty())
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Extension").setCtrl(SMPCommonUI.getExtensionDisplay(aSelectedEndpoint)));
aNodeList.addChild(aForm);
}
Aggregations