use of com.helger.photon.bootstrap4.table.BootstrapTable in project phoss-directory by phax.
the class PageSecureListIndex method fillContent.
@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
// Add toolbar
{
final BootstrapButtonToolbar aToolbar = aNodeList.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
aToolbar.addChild(new BootstrapButton().addChild("Refresh").setIcon(EDefaultIcon.REFRESH).setOnClick(aWPEC.getSelfHref()));
aToolbar.addChild(span("Current server time: " + PDTToString.getAsString(PDTFactory.getCurrentLocalTime(), aDisplayLocale)).addClass(PDCommonUI.CSS_CLASS_VERTICAL_PADDED_TEXT));
}
final LinkedBlockingQueue<Object> aQueue = PDMetaManager.getIndexerMgr().getIndexerWorkQueue().getQueue();
final int nLength = aQueue.size();
if (nLength == 0) {
aNodeList.addChild(success("The Index Queue is currently empty"));
} else {
aNodeList.addChild(info("The Index Queue contains " + nLength + " entries"));
final BootstrapTable aTable = new BootstrapTable(new DTCol("Queue date time").setDisplayType(EDTColType.DATETIME, aDisplayLocale).setInitialSorting(ESortOrder.DESCENDING), new DTCol("Participant ID"), new DTCol("Action"), new DTCol("Owner"), new DTCol("Requestor")).setID("indexqueue");
for (final Object o : aQueue) if (o instanceof IIndexerWorkItem) {
final IIndexerWorkItem aObj = (IIndexerWorkItem) o;
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(PDTToString.getAsString(aObj.getCreationDateTime(), aDisplayLocale));
aRow.addCell(aObj.getParticipantID().getURIEncoded());
aRow.addCell(aObj.getType().getDisplayName());
aRow.addCell(aObj.getOwnerID());
aRow.addCell(aObj.getRequestingHost());
}
aNodeList.addChild(aTable).addChild(BootstrapDataTables.createDefaultDataTables(aWPEC, aTable));
}
}
use of com.helger.photon.bootstrap4.table.BootstrapTable in project phoss-directory by phax.
the class PDCommonUI method showBusinessInfoDetails.
@Nonnull
public static BootstrapViewForm showBusinessInfoDetails(@Nonnull final PDStoredBusinessEntity aStoredDoc, @Nonnull final Locale aDisplayLocale) {
final BootstrapViewForm aViewForm = new BootstrapViewForm();
if (aStoredDoc.hasCountryCode()) {
final HCNodeList aCountryCtrl = new HCNodeList();
final String sCountryCode = aStoredDoc.getCountryCode();
aCountryCtrl.addChild(getFlagNode(sCountryCode));
final Locale aCountry = CountryCache.getInstance().getCountry(sCountryCode);
if (aCountry != null)
aCountryCtrl.addChild(" " + aCountry.getDisplayCountry(aDisplayLocale) + " [" + sCountryCode + "]");
else
aCountryCtrl.addChild(" " + sCountryCode);
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Country").setCtrl(aCountryCtrl));
}
if (aStoredDoc.names().isNotEmpty()) {
final ICommonsList<PDStoredMLName> aNames = getUIFilteredNames(aStoredDoc.names(), aDisplayLocale);
IHCNode aNameCtrl;
if (aNames.size() == 1)
aNameCtrl = getMLNameNode(aNames.getFirst(), aDisplayLocale);
else {
final HCUL aNameUL = new HCUL();
aNames.forEach(x -> aNameUL.addItem(getMLNameNode(x, aDisplayLocale)));
aNameCtrl = aNameUL;
}
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Entity Name").setCtrl(aNameCtrl));
}
if (aStoredDoc.hasGeoInfo())
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Geographical information").setCtrl(HCExtHelper.nl2divList(aStoredDoc.getGeoInfo())));
if (aStoredDoc.identifiers().isNotEmpty()) {
final BootstrapTable aIDTable = new BootstrapTable(HCCol.star(), HCCol.star()).setStriped(true).setBordered(true).setCondensed(true);
aIDTable.addHeaderRow().addCells("Scheme", "Value");
for (final PDStoredIdentifier aStoredID : aStoredDoc.identifiers()) aIDTable.addBodyRow().addCells(aStoredID.getScheme(), aStoredID.getValue());
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Additional identifiers").setCtrl(aIDTable));
}
if (aStoredDoc.websiteURIs().isNotEmpty()) {
final HCOL aOL = new HCOL();
for (final String sWebsiteURI : aStoredDoc.websiteURIs()) aOL.addItem(HCA.createLinkedWebsite(sWebsiteURI, HC_Target.BLANK));
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Website URIs").setCtrl(aOL));
}
if (aStoredDoc.contacts().isNotEmpty()) {
final BootstrapTable aContactTable = new BootstrapTable(HCCol.star(), HCCol.star(), HCCol.star(), HCCol.star()).setStriped(true).setBordered(true);
aContactTable.addHeaderRow().addCells("Type", "Name", "Phone Number", "Email");
for (final PDStoredContact aStoredContact : aStoredDoc.contacts()) aContactTable.addBodyRow().addCells(aStoredContact.getType(), aStoredContact.getName(), aStoredContact.getPhone(), aStoredContact.getEmail());
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Contacts").setCtrl(aContactTable));
}
if (aStoredDoc.hasAdditionalInformation())
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Additional information").setCtrl(HCExtHelper.nl2divList(aStoredDoc.getAdditionalInformation())));
if (aStoredDoc.hasRegistrationDate())
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Registration date").setCtrl(PDTToString.getAsString(aStoredDoc.getRegistrationDate(), aDisplayLocale)));
return aViewForm;
}
use of com.helger.photon.bootstrap4.table.BootstrapTable in project phoss-smp by phax.
the class PageSecureBusinessCard method showBusinessCardEntity.
@Nonnull
public static IHCNode showBusinessCardEntity(@Nonnull final SMPBusinessCardEntity aEntity, final int nIndex, @Nonnull final Locale aDisplayLocale) {
final BootstrapCard aPanel = new BootstrapCard();
aPanel.createAndAddHeader().addChild("Business Entity " + nIndex);
final BootstrapViewForm aForm2 = aPanel.createAndAddBody().addAndReturnChild(new BootstrapViewForm());
aForm2.addFormGroup(new BootstrapFormGroup().setLabel("Name").setCtrl(aEntity.names().getFirst().getName()));
{
final Locale aCountry = CountryCache.getInstance().getCountry(aEntity.getCountryCode());
final HCNodeList aCtrl = new HCNodeList();
final EFamFamFlagIcon eIcon = EFamFamFlagIcon.getFromIDOrNull(aCountry.getCountry());
if (eIcon != null) {
aCtrl.addChild(eIcon.getAsNode());
aCtrl.addChild(" ");
}
aCtrl.addChild(aCountry.getDisplayCountry(aDisplayLocale) + " [" + aEntity.getCountryCode() + "]");
aForm2.addFormGroup(new BootstrapFormGroup().setLabel("Country code").setCtrl(aCtrl));
}
if (aEntity.hasGeographicalInformation()) {
aForm2.addFormGroup(new BootstrapFormGroup().setLabel("Geographical information").setCtrl(HCExtHelper.nl2divList(aEntity.getGeographicalInformation())));
}
if (aEntity.identifiers().isNotEmpty()) {
final BootstrapTable aTable = new BootstrapTable(HCCol.star(), HCCol.star());
aTable.addHeaderRow().addCells("Scheme", "Value");
for (final SMPBusinessCardIdentifier aIdentifier : aEntity.identifiers()) aTable.addBodyRow().addCells(aIdentifier.getScheme(), aIdentifier.getValue());
aForm2.addFormGroup(new BootstrapFormGroup().setLabel("Identifiers").setCtrl(aTable));
}
if (aEntity.websiteURIs().isNotEmpty()) {
final HCNodeList aNL = new HCNodeList();
for (final String sWebsiteURI : aEntity.websiteURIs()) aNL.addChild(new HCDiv().addChild(HCA.createLinkedWebsite(sWebsiteURI)));
aForm2.addFormGroup(new BootstrapFormGroup().setLabel("Website URIs").setCtrl(aNL));
}
if (aEntity.contacts().isNotEmpty()) {
final BootstrapTable aTable = new BootstrapTable(HCCol.star(), HCCol.star(), HCCol.star(), HCCol.star());
aTable.addHeaderRow().addCells("Type", "Name", "Phone number", "Email address");
for (final SMPBusinessCardContact aContact : aEntity.contacts()) {
final HCRow aBodyRow = aTable.addBodyRow();
aBodyRow.addCells(aContact.getType(), aContact.getName(), aContact.getPhoneNumber());
aBodyRow.addCell(HCA_MailTo.createLinkedEmail(aContact.getEmail()));
}
aForm2.addFormGroup(new BootstrapFormGroup().setLabel("Contacts").setCtrl(aTable));
}
if (aEntity.hasAdditionalInformation()) {
aForm2.addFormGroup(new BootstrapFormGroup().setLabel("Additional information").setCtrl(HCExtHelper.nl2divList(aEntity.getAdditionalInformation())));
}
if (aEntity.hasRegistrationDate()) {
aForm2.addFormGroup(new BootstrapFormGroup().setLabel("Registration date").setCtrl(PDTToString.getAsString(aEntity.getRegistrationDate(), aDisplayLocale)));
}
return aPanel;
}
use of com.helger.photon.bootstrap4.table.BootstrapTable in project phoss-smp by phax.
the class SMPCommonUI method createCertificateDetailsTable.
@Nonnull
public static BootstrapTable createCertificateDetailsTable(@Nullable final String sAlias, @Nonnull final X509Certificate aX509Cert, @Nonnull final LocalDateTime aNowLDT, @Nonnull final Locale aDisplayLocale) {
final LocalDateTime aNotBefore = PDTFactory.createLocalDateTime(aX509Cert.getNotBefore());
final LocalDateTime aNotAfter = PDTFactory.createLocalDateTime(aX509Cert.getNotAfter());
final PublicKey aPublicKey = aX509Cert.getPublicKey();
final BootstrapTable aCertDetails = new BootstrapTable(new HCCol().addStyle(CCSSProperties.WIDTH.newValue("12rem")), HCCol.star());
aCertDetails.setResponsive(true);
if (StringHelper.hasText(sAlias))
aCertDetails.addBodyRow().addCell("Alias:").addCell(sAlias);
aCertDetails.addBodyRow().addCell("Version:").addCell(Integer.toString(aX509Cert.getVersion()));
aCertDetails.addBodyRow().addCell("Subject:").addCell(aX509Cert.getSubjectX500Principal().getName());
aCertDetails.addBodyRow().addCell("Issuer:").addCell(aX509Cert.getIssuerX500Principal().getName());
aCertDetails.addBodyRow().addCell("Serial number:").addCell(aX509Cert.getSerialNumber().toString() + " / 0x" + _inGroupsOf(aX509Cert.getSerialNumber().toString(16), 4));
aCertDetails.addBodyRow().addCell("Valid from:").addCell(new HCTextNode(PDTToString.getAsString(aNotBefore, aDisplayLocale) + " "), aNowLDT.isBefore(aNotBefore) ? new BootstrapBadge(EBootstrapBadgeType.DANGER).addChild("!!!NOT YET VALID!!!") : null);
aCertDetails.addBodyRow().addCell("Valid to:").addCell(new HCTextNode(PDTToString.getAsString(aNotAfter, aDisplayLocale) + " "), aNowLDT.isAfter(aNotAfter) ? new BootstrapBadge(EBootstrapBadgeType.DANGER).addChild("!!!NO LONGER VALID!!!") : new HCDiv().addChild("Valid for: " + PDTDisplayHelper.getPeriodTextEN(aNowLDT, aNotAfter)));
if (aPublicKey instanceof RSAPublicKey) {
// Special handling for RSA
aCertDetails.addBodyRow().addCell("Public key:").addCell(aX509Cert.getPublicKey().getAlgorithm() + " (" + ((RSAPublicKey) aPublicKey).getModulus().bitLength() + " bits)");
} else {
// Usually EC or DSA key
aCertDetails.addBodyRow().addCell("Public key:").addCell(aX509Cert.getPublicKey().getAlgorithm());
}
aCertDetails.addBodyRow().addCell("Signature algorithm:").addCell(aX509Cert.getSigAlgName() + " (" + aX509Cert.getSigAlgOID() + ")");
return aCertDetails;
}
use of com.helger.photon.bootstrap4.table.BootstrapTable in project phoss-smp by phax.
the class PageSecureBusinessCard method _createEntityInputForm.
@Nonnull
private static IHCNode _createEntityInputForm(@Nonnull final LayoutExecutionContext aLEC, @Nullable final SMPBusinessCardEntity aExistingEntity, @Nullable final String sExistingID, @Nonnull final FormErrorList aFormErrors, final boolean bFormSubmitted) {
final Locale aDisplayLocale = aLEC.getDisplayLocale();
final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
final String sEntityID = StringHelper.hasText(sExistingID) ? sExistingID : TMP_ID_PREFIX + Integer.toString(GlobalIDFactory.getNewIntID());
final BootstrapCard aPanel = new BootstrapCard().setID(sEntityID);
aPanel.createAndAddHeader().addChild("Business Entity");
final BootstrapCardBody aBody = aPanel.createAndAddBody();
final BootstrapViewForm aForm = aBody.addAndReturnChild(new BootstrapViewForm());
final String sFieldName = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_NAME);
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Name").setCtrl(new HCEdit(new RequestField(sFieldName, aExistingEntity == null ? null : aExistingEntity.names().getFirst().getName()))).setErrorList(aFormErrors.getListOfField(sFieldName)));
final String sFieldCountryCode = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_COUNTRY_CODE);
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Country").setCtrl(new HCCountrySelect(new RequestField(sFieldCountryCode, aExistingEntity == null ? null : aExistingEntity.getCountryCode()), aDisplayLocale, HCCountrySelect.getAllCountries(EWithDeprecated.DEFAULT), (aLocale, aContentLocale) -> aLocale.getDisplayCountry(aContentLocale) + " (" + aLocale.getCountry() + ")")).setErrorList(aFormErrors.getListOfField(sFieldCountryCode)));
final String sFieldGeoInfo = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_GEO_INFO);
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Geographical Information").setCtrl(new HCTextArea(new RequestField(sFieldGeoInfo, aExistingEntity == null ? null : aExistingEntity.getGeographicalInformation()))).setErrorList(aFormErrors.getListOfField(sFieldGeoInfo)));
// Identifiers
{
final String sBodyID = sEntityID + PREFIX_IDENTIFIER;
final HCNodeList aNL = new HCNodeList();
final BootstrapTable aTable = aNL.addAndReturnChild(new BootstrapTable(HCCol.star(), HCCol.star(), HCCol.star()));
aTable.addHeaderRow().addCells("Scheme", "Value", "");
aTable.setBodyID(sBodyID);
final IRequestParamMap aIdentifiers = aLEC.getRequestParamMap().getMap(PREFIX_ENTITY, sEntityID, PREFIX_IDENTIFIER);
if (bFormSubmitted) {
// Re-show of form
if (aIdentifiers != null)
for (final String sIdentifierRowID : aIdentifiers.keySet()) aTable.addBodyRow(_createIdentifierInputForm(aLEC, sEntityID, null, sIdentifierRowID, aFormErrors));
} else {
if (aExistingEntity != null) {
// add all existing stored entities
for (final SMPBusinessCardIdentifier aIdentifier : aExistingEntity.identifiers()) aTable.addBodyRow(_createIdentifierInputForm(aLEC, sEntityID, aIdentifier, (String) null, aFormErrors));
}
}
{
final JSAnonymousFunction aJSAppend = new JSAnonymousFunction();
final JSVar aJSAppendData = aJSAppend.param("data");
aJSAppend.body().add(JQuery.idRef(sBodyID).append(aJSAppendData.ref(PhotonUnifiedResponse.HtmlHelper.PROPERTY_HTML)));
final JSPackage aOnAdd = new JSPackage();
aOnAdd.add(new JQueryAjaxBuilder().url(AJAX_CREATE_IDENTIFIER.getInvocationURL(aRequestScope).add(PARAM_ENTITY_ID, sEntityID)).data(new JSAssocArray()).success(JSJQueryHelper.jqueryAjaxSuccessHandler(aJSAppend, null)).build());
aNL.addChild(new BootstrapButton().setIcon(EDefaultIcon.PLUS).addChild("Add Identifier").setOnClick(aOnAdd));
}
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Identifiers").setCtrl(aNL));
}
// Website URIs
final String sFieldWebsiteURIs = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_WEBSITE_URIS);
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Website URIs").setCtrl(new HCTextArea(new RequestField(sFieldWebsiteURIs, aExistingEntity == null ? null : StringHelper.getImploded('\n', aExistingEntity.websiteURIs())))).setHelpText("Put each Website URI in a separate line").setErrorList(aFormErrors.getListOfField(sFieldWebsiteURIs)));
// Contacts
{
final String sBodyID = sEntityID + PREFIX_CONTACT;
final HCNodeList aNL = new HCNodeList();
final BootstrapTable aTable = aNL.addAndReturnChild(new BootstrapTable(HCCol.star(), HCCol.star(), HCCol.star(), HCCol.star(), HCCol.star()));
aTable.addHeaderRow().addCells("Type", "Name", "Phone number", "Email address", "");
aTable.setBodyID(sBodyID);
final IRequestParamMap aContacts = aLEC.getRequestParamMap().getMap(PREFIX_ENTITY, sEntityID, PREFIX_CONTACT);
if (bFormSubmitted) {
// Re-show of form
if (aContacts != null)
for (final String sIdentifierRowID : aContacts.keySet()) aTable.addBodyRow(_createContactInputForm(aLEC, sEntityID, null, sIdentifierRowID, aFormErrors));
} else {
if (aExistingEntity != null) {
// add all existing stored entities
for (final SMPBusinessCardContact aContact : aExistingEntity.contacts()) aTable.addBodyRow(_createContactInputForm(aLEC, sEntityID, aContact, (String) null, aFormErrors));
}
}
{
final JSAnonymousFunction aJSAppend = new JSAnonymousFunction();
final JSVar aJSAppendData = aJSAppend.param("data");
aJSAppend.body().add(JQuery.idRef(sBodyID).append(aJSAppendData.ref(PhotonUnifiedResponse.HtmlHelper.PROPERTY_HTML)));
final JSPackage aOnAdd = new JSPackage();
aOnAdd.add(new JQueryAjaxBuilder().url(AJAX_CREATE_CONTACT.getInvocationURL(aRequestScope).add(PARAM_ENTITY_ID, sEntityID)).data(new JSAssocArray()).success(JSJQueryHelper.jqueryAjaxSuccessHandler(aJSAppend, null)).build());
aNL.addChild(new BootstrapButton().setIcon(EDefaultIcon.PLUS).addChild("Add Contact").setOnClick(aOnAdd));
}
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Contacts").setCtrl(aNL));
}
final String sFieldAdditionalInfo = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_ADDITIONAL_INFO);
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Additional Information").setCtrl(new HCTextArea(new RequestField(sFieldAdditionalInfo, aExistingEntity == null ? null : aExistingEntity.getAdditionalInformation()))).setErrorList(aFormErrors.getListOfField(sFieldAdditionalInfo)));
final String sFieldRegDate = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_REG_DATE);
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Registration Date").setCtrl(BootstrapDateTimePicker.create(sFieldRegDate, aExistingEntity == null ? null : aExistingEntity.getRegistrationDate(), aDisplayLocale)).setErrorList(aFormErrors.getListOfField(sFieldRegDate)));
final BootstrapButtonToolbar aToolbar = aBody.addAndReturnChild(new BootstrapButtonToolbar(aLEC));
aToolbar.addButton("Delete this Entity", JQuery.idRef(aPanel).remove(), EDefaultIcon.DELETE);
return aPanel;
}
Aggregations