use of com.helger.photon.bootstrap4.button.BootstrapButton in project peppol-practical by phax.
the class PageSecureAdminAddons method fillContent.
@Override
public void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
// Perform
aNodeList.addChild(_handleAction(aWPEC.getAction()));
aNodeList.addChild(h2("Cache handling"));
aNodeList.addChild(div(new BootstrapButton().setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_EXPIRE_PAGE_CACHE)).addChild("Expire static page cache")));
}
use of com.helger.photon.bootstrap4.button.BootstrapButton 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.button.BootstrapButton in project phoss-directory by phax.
the class PageSecureParticipantActions method fillContent.
@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final IRequestWebScopeWithoutResponse aRequestScope = aWPEC.getRequestScope();
if (aWPEC.hasAction(ACTION_UPDATE_EXPORTED_BCS)) {
LOGGER.info("Manually exporting all Business Cards now");
// run in the background
ExportAllDataJob.exportAllBusinessCardsInBackground();
aWPEC.postRedirectGetInternal(success("The new exported data is (hopefully) available in a few minutes. Check the 'is running' state below."));
} else if (aWPEC.hasAction(ACTION_SYNC_BCS_UNFORCED)) {
LOGGER.info("Manually synchronizing all Business Cards now (unforced)");
if (SyncAllBusinessCardsJob.syncAllBusinessCards(false).isChanged())
aWPEC.postRedirectGetInternal(success("The unforced synchronization was started successfully and is now running in the background."));
else
aWPEC.postRedirectGetInternal(warn("The synchronization was not started because the last sync was at " + PDTToString.getAsString(SyncAllBusinessCardsJob.getLastSync(), aDisplayLocale)));
} else if (aWPEC.hasAction(ACTION_SYNC_BCS_FORCED)) {
LOGGER.info("Manually synchronizing all Business Cards now (FORCED)");
if (SyncAllBusinessCardsJob.syncAllBusinessCards(true).isChanged())
aWPEC.postRedirectGetInternal(success("The forced synchronization was started successfully and is now running in the background."));
else
aWPEC.postRedirectGetInternal(error("Force synchronization should always work"));
} else if (aWPEC.hasAction(ACTION_SHOW_DUPLICATES)) {
_showDuplicateIDs(aWPEC);
} else if (aWPEC.hasAction(ACTION_DELETE_DUPLICATES)) {
_deleteDuplicateIDs(aWPEC);
}
{
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.MAGNIFIER);
aNodeList.addChild(aToolbar);
}
final BootstrapCard aCard = aNodeList.addAndReturnChild(new BootstrapCard());
aCard.createAndAddHeader().addChild("Live data downloads - Danger zone").addClasses(CBootstrapCSS.BG_DANGER, CBootstrapCSS.TEXT_WHITE);
BootstrapCardBody aBody = aCard.createAndAddBody();
aBody.addChild(new BootstrapButton(EBootstrapButtonType.DANGER).addChild("Download all IDs (XML, live)").setOnClick(AJAX_DOWNLOAD_ALL_IDS_XML.getInvocationURL(aRequestScope)).setIcon(EDefaultIcon.SAVE_ALL));
aBody.addChild(new BootstrapButton(EBootstrapButtonType.DANGER).addChild("Download all Business Cards (XML, full, live) (may take long)").setOnClick(AJAX_DOWNLOAD_ALL_BCS_XML_FULL.getInvocationURL(aRequestScope)).setIcon(EDefaultIcon.SAVE_ALL));
aBody.addChild(new BootstrapButton(EBootstrapButtonType.DANGER).addChild("Download all Business Cards (XML, no document types, live) (may take long)").setOnClick(AJAX_DOWNLOAD_ALL_BCS_XML_NO_DOCTYPES.getInvocationURL(aRequestScope)).setIcon(EDefaultIcon.SAVE_ALL));
aBody.addChild(new BootstrapButton(EBootstrapButtonType.DANGER).addChild("Download all Business Cards (Excel, live) (may take long)").setOnClick(AJAX_DOWNLOAD_ALL_BCS_EXCEL.getInvocationURL(aRequestScope)).setIcon(EDefaultIcon.SAVE_ALL));
aBody.addChild(new BootstrapButton(EBootstrapButtonType.DANGER).addChild("Download all Business Cards (CSV, live) (may take long)").setOnClick(AJAX_DOWNLOAD_ALL_BCS_CSV.getInvocationURL(aRequestScope)).setIcon(EDefaultIcon.SAVE_ALL));
aCard.createAndAddHeader().addChild("Cached data downloads");
aBody = aCard.createAndAddBody();
aBody.addChild(new BootstrapButton().addChild("Download all Business Cards (XML, full, cached)").setOnClick(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_BUSINESS_CARDS_XML_FULL)).setIcon(EDefaultIcon.SAVE_ALL));
aBody.addChild(new BootstrapButton().addChild("Download all Business Cards (XML, no document types, cached)").setOnClick(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_BUSINESS_CARDS_XML_NO_DOC_TYPES)).setIcon(EDefaultIcon.SAVE_ALL));
if (CPDPublisher.EXPORT_BUSINESS_CARDS_EXCEL) {
aBody.addChild(new BootstrapButton().addChild("Download all Business Cards (Excel, cached)").setOnClick(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_BUSINESS_CARDS_EXCEL)).setIcon(EDefaultIcon.SAVE_ALL));
}
if (CPDPublisher.EXPORT_BUSINESS_CARDS_CSV) {
aBody.addChild(new BootstrapButton().addChild("Download all Business Cards (CSV, cached)").setOnClick(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_BUSINESS_CARDS_CSV)).setIcon(EDefaultIcon.SAVE_ALL));
}
if (CPDPublisher.EXPORT_PARTICIPANTS_XML) {
aBody.addChild(new BootstrapButton().addChild("Download all Participants (XML, cached)").setOnClick(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_PARTICIPANTS_XML)).setIcon(EDefaultIcon.SAVE_ALL));
}
if (CPDPublisher.EXPORT_PARTICIPANTS_JSON) {
aBody.addChild(new BootstrapButton().addChild("Download all Participants (JSON, cached)").setOnClick(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_PARTICIPANTS_JSON)).setIcon(EDefaultIcon.SAVE_ALL));
}
if (CPDPublisher.EXPORT_PARTICIPANTS_CSV) {
aBody.addChild(new BootstrapButton().addChild("Download all Participants (CSV, cached)").setOnClick(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_PARTICIPANTS_CSV)).setIcon(EDefaultIcon.SAVE_ALL));
}
aCard.createAndAddHeader().addChild("Cache management");
aBody = aCard.createAndAddBody();
final boolean bIsRunning = ExportAllDataJob.isExportCurrentlyRunning();
if (bIsRunning) {
final LocalDateTime aStartDT = ExportAllDataJob.getExportAllBusinessCardsStartDT();
aBody.addChild(info("Export of Business Card cache is currently running. Started at " + PDTToString.getAsString(aStartDT, aDisplayLocale)));
}
aBody.addChild(new BootstrapButton().addChild("Update Business Card export cache (in background; takes too long)").setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_UPDATE_EXPORTED_BCS)).setIcon(EDefaultIcon.INFO).setDisabled(bIsRunning));
aCard.createAndAddHeader().addChild("Data Synchronization");
aBody = aCard.createAndAddBody();
aBody.addChild(new BootstrapButton().addChild("Synchronize all Business Cards (re-query from SMP - unforced)").setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_SYNC_BCS_UNFORCED)).setIcon(EDefaultIcon.REFRESH));
aBody.addChild(new BootstrapButton(EBootstrapButtonType.DANGER).addChild("Synchronize all Business Cards (re-query from SMP - forced)").setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_SYNC_BCS_FORCED)).setIcon(EDefaultIcon.REFRESH));
aCard.createAndAddHeader().addChild("Duplication handling");
aBody = aCard.createAndAddBody();
if (PDMetaManager.getIdentifierFactory() instanceof SimpleIdentifierFactory) {
aBody.addChild(info("Since the simple identifier factory is used, duplicates cannot be determined"));
} else {
aBody.addChild(new BootstrapButton().addChild("Show all duplicate entries").setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_SHOW_DUPLICATES)).setIcon(EDefaultIcon.MAGNIFIER));
aBody.addChild(new BootstrapButton(EBootstrapButtonType.DANGER).addChild("Delete all duplicate entries").setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_DELETE_DUPLICATES)).setIcon(EDefaultIcon.DELETE));
}
}
use of com.helger.photon.bootstrap4.button.BootstrapButton in project phoss-directory by phax.
the class SecureHTMLProvider method _getNavbar.
@Nonnull
private static IHCNode _getNavbar(@Nonnull final SimpleWebExecutionContext aSWEC) {
final Locale aDisplayLocale = aSWEC.getDisplayLocale();
final IRequestWebScopeWithoutResponse aRequestScope = aSWEC.getRequestScope();
final ISimpleURL aLinkToStartPage = aSWEC.getLinkToMenuItem(aSWEC.getMenuTree().getDefaultMenuItemID());
final BootstrapNavbar aNavbar = new BootstrapNavbar();
aNavbar.addBrand(new HCNodeList().addChild(new HCSpan().addClass(AppCommonUI.CSS_CLASS_LOGO1).addChild(CPDPublisher.getApplicationTitle())).addChild(new HCSpan().addClass(AppCommonUI.CSS_CLASS_LOGO2).addChild(" Administration")), aLinkToStartPage);
final BootstrapNavbarToggleable aToggleable = aNavbar.addAndReturnToggleable();
{
final IUser aUser = LoggedInUserManager.getInstance().getCurrentUser();
aToggleable.addAndReturnText().addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2).addChild("Welcome ").addChild(new HCStrong().addChild(SecurityHelper.getUserDisplayName(aUser, aDisplayLocale)));
aToggleable.addChild(new BootstrapButton().addClass(CBootstrapCSS.MX_2).addChild("Goto public area").setOnClick(LinkHelper.getURLWithContext(AbstractPublicApplicationServlet.SERVLET_DEFAULT_PATH + "/")));
aToggleable.addChild(new BootstrapButton().addClass(CBootstrapCSS.MX_2).setOnClick(LinkHelper.getURLWithContext(aRequestScope, LogoutServlet.SERVLET_DEFAULT_PATH)).addChild(EPhotonCoreText.LOGIN_LOGOUT.getDisplayText(aDisplayLocale)));
}
return aNavbar;
}
use of com.helger.photon.bootstrap4.button.BootstrapButton in project phoss-directory by phax.
the class PagePublicContact method fillContent.
@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final boolean bShowForm = true;
final FormErrorList aFormErrors = new FormErrorList();
if (aWPEC.hasAction(CPageParam.ACTION_PERFORM)) {
final String sName = StringHelper.trim(aWPEC.params().getAsString(FIELD_NAME));
final String sEmail = StringHelper.trim(aWPEC.params().getAsString(FIELD_EMAIL));
final String sTopic = aWPEC.params().getAsString(FIELD_TOPIC);
final String sText = StringHelper.trim(aWPEC.params().getAsString(FIELD_TEXT));
final String sReCaptcha = StringHelper.trim(aWPEC.params().getAsString("g-recaptcha-response"));
if (StringHelper.hasNoText(sName))
aFormErrors.addFieldError(FIELD_NAME, "Your name must be provided.");
if (StringHelper.hasNoText(sEmail))
aFormErrors.addFieldError(FIELD_EMAIL, "Your email address must be provided.");
else if (!EmailAddressHelper.isValid(sEmail))
aFormErrors.addFieldError(FIELD_EMAIL, "The provided email address is invalid.");
if (StringHelper.hasNoText(sText))
aFormErrors.addFieldError(FIELD_TEXT, "A message text must be provided.");
if (aFormErrors.isEmpty() || StringHelper.hasText(sReCaptcha)) {
if (!CaptchaSessionSingleton.getInstance().isChecked()) {
// Check only if no other errors occurred
if (ReCaptchaServerSideValidator.check("6LfZFS0UAAAAAONDJHyDnuUUvMB_oNmJxz9Utxza", sReCaptcha).isFailure())
aFormErrors.addFieldError(FIELD_CAPTCHA, "Please confirm you are not a robot!");
else
CaptchaSessionSingleton.getInstance().setChecked();
}
}
if (aFormErrors.isEmpty()) {
final EmailData aEmailData = new EmailData(EEmailType.TEXT);
aEmailData.setFrom(CPDPublisher.EMAIL_SENDER);
aEmailData.to().add(new EmailAddress("pd@helger.com"));
aEmailData.replyTo().add(new EmailAddress(sEmail, sName));
aEmailData.setSubject("[" + CPDPublisher.getApplication() + "] Contact Form - " + sName);
final StringBuilder aSB = new StringBuilder();
aSB.append("Contact form from " + CPDPublisher.getApplication() + " was filled out.\n\n");
aSB.append("Name: ").append(sName).append("\n");
aSB.append("Email: ").append(sEmail).append("\n");
aSB.append("Topic: ").append(sTopic).append("\n");
aSB.append("Text:\n").append(sText).append("\n");
aEmailData.setBody(aSB.toString());
ScopedMailAPI.getInstance().queueMail(InternalErrorSettings.getSMTPSettings(), aEmailData);
aWPEC.postRedirectGetInternal(success("Thank you for your message. We will come back to you asap."));
}
}
if (bShowForm) {
aNodeList.addChild(info("Alternatively write an email to pd[at]helger.com - usually using the below form is more effective!"));
aNodeList.addChild(warn("Please don't request any change of data via this contact form - contact your service provider instead. Thank you."));
final BootstrapForm aForm = aNodeList.addAndReturnChild(getUIHandler().createFormSelf(aWPEC));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Your name").setCtrl(new HCEdit(new RequestField(FIELD_NAME))).setErrorList(aFormErrors.getListOfField(FIELD_NAME)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Your email address").setCtrl(new HCEdit(new RequestField(FIELD_EMAIL))).setErrorList(aFormErrors.getListOfField(FIELD_EMAIL)));
final HCExtSelect aSelect = new HCExtSelect(new RequestField(FIELD_TOPIC));
aSelect.addOption("SMP integration");
aSelect.addOption("Website");
aSelect.addOption("REST service");
aSelect.addOption("SMP Statement of use");
aSelect.addOption("General question");
aSelect.addOptionPleaseSelect(aDisplayLocale);
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Topic").setCtrl(aSelect).setErrorList(aFormErrors.getListOfField(FIELD_TOPIC)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Your message").setCtrl(new HCTextAreaAutosize(new RequestField(FIELD_TEXT)).setRows(5)).setErrorList(aFormErrors.getListOfField(FIELD_TEXT)));
if (!CaptchaSessionSingleton.getInstance().isChecked()) {
// Add visible Captcha
aForm.addFormGroup(new BootstrapFormGroup().setCtrl(HCReCaptchaV2.create("6LfZFS0UAAAAAJaqpHJdFS_xxY7dqMQjXoBIQWOD", aDisplayLocale)).setErrorList(aFormErrors.getListOfField(FIELD_CAPTCHA)));
}
aForm.addChild(new HCHiddenField(CPageParam.PARAM_ACTION, CPageParam.ACTION_PERFORM));
aForm.addChild(new BootstrapSubmitButton().addChild("Send message").setIcon(EDefaultIcon.YES));
aForm.addChild(new BootstrapButton().addChild("No thanks").setIcon(EDefaultIcon.CANCEL).setOnClick(aWPEC.getLinkToMenuItem(CMenuPublic.MENU_SEARCH_SIMPLE)));
}
}
Aggregations