use of com.helger.photon.bootstrap4.card.BootstrapCardBody 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.card.BootstrapCardBody 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;
}
use of com.helger.photon.bootstrap4.card.BootstrapCardBody in project phoss-smp by phax.
the class PageSecureSMPSettings method showObject.
@Override
protected void showObject(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final ISMPSettings aObject) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final String sDirectoryName = SMPWebAppConfiguration.getDirectoryName();
{
final BootstrapCard aCard = aNodeList.addAndReturnChild(new BootstrapCard());
aCard.createAndAddHeader().addChild("REST API");
final BootstrapCardBody aCardBody = aCard.createAndAddBody();
final BootstrapViewForm aTable = aCardBody.addAndReturnChild(new BootstrapViewForm());
aTable.setLeft(4);
aTable.addFormGroup(new BootstrapFormGroup().setLabel("REST writable API disabled?").setCtrl(EPhotonCoreText.getYesOrNo(aObject.isRESTWritableAPIDisabled(), aDisplayLocale)));
}
{
final BootstrapCard aCard = aNodeList.addAndReturnChild(new BootstrapCard());
aCard.createAndAddHeader().addChild("SMK/SML");
final BootstrapCardBody aCardBody = aCard.createAndAddBody();
final BootstrapViewForm aTable = aCardBody.addAndReturnChild(new BootstrapViewForm());
aTable.setLeft(4);
aTable.addFormGroup(new BootstrapFormGroup().setLabel("SML connection required?").setCtrl(EPhotonCoreText.getYesOrNo(aObject.isSMLRequired(), aDisplayLocale)));
aTable.addFormGroup(new BootstrapFormGroup().setLabel("SML connection enabled?").setCtrl(EPhotonCoreText.getYesOrNo(aObject.isSMLEnabled(), aDisplayLocale)));
final ISMLInfo aSMLInfo = aObject.getSMLInfo();
aTable.addFormGroup(new BootstrapFormGroup().setLabel("SML to be used").setCtrl(aSMLInfo == null ? em("none") : HCSMLSelect.getDisplayNameNode(aSMLInfo)));
}
{
final BootstrapCard aCard = aNodeList.addAndReturnChild(new BootstrapCard());
aCard.createAndAddHeader().addChild(sDirectoryName);
final BootstrapCardBody aCardBody = aCard.createAndAddBody();
final BootstrapViewForm aTable = aCardBody.addAndReturnChild(new BootstrapViewForm());
aTable.setLeft(4);
aTable.addFormGroup(new BootstrapFormGroup().setLabel(sDirectoryName + " integration required?").setCtrl(EPhotonCoreText.getYesOrNo(aObject.isDirectoryIntegrationRequired(), aDisplayLocale)));
aTable.addFormGroup(new BootstrapFormGroup().setLabel(sDirectoryName + " integration enabled?").setCtrl(EPhotonCoreText.getYesOrNo(aObject.isDirectoryIntegrationEnabled(), aDisplayLocale)));
aTable.addFormGroup(new BootstrapFormGroup().setLabel(sDirectoryName + " integration automatic update?").setCtrl(EPhotonCoreText.getYesOrNo(aObject.isDirectoryIntegrationAutoUpdate(), aDisplayLocale)));
aTable.addFormGroup(new BootstrapFormGroup().setLabel(sDirectoryName + " hostname").setCtrl(HCA.createLinkedWebsite(aObject.getDirectoryHostName())));
}
}
Aggregations