use of com.helger.photon.bootstrap4.button.BootstrapButton in project phoss-smp by phax.
the class PageSecureServiceGroupMigrationOutbound method showListOfExistingObjects.
@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final ISMPParticipantMigrationManager aParticipantMigrationMgr = SMPMetaManager.getParticipantMigrationMgr();
final ISMPSettings aSettings = SMPMetaManager.getSettings();
final ISMPServiceGroupManager aServiceGroupManager = SMPMetaManager.getServiceGroupMgr();
{
final HCOL aOL = new HCOL();
aOL.addItem("The migration is initiated on this SMP, and the SML is informed about the upcoming migration");
aOL.addItem("The other SMP, that is taking over the Service Group, must acknowledge the migration by providing the same migration code (created by this SMP) to the SML");
aOL.addItem("If the migration was successful, the Service Group must be deleted from this SMP, ideally a temporary redirect to the new SMP is created. If the migration was cancelled no action is needed.");
aNodeList.addChild(info().addChild(div("The process of migrating a Service Group to another SMP consists of multiple steps:")).addChild(aOL).addChild(div("Therefore each open Migration must either be finished (deleting the Service Group) or cancelled (no action taken)." + " If a Migration is cancelled, it can be retried later.")));
}
EValidity eCanStartMigration = EValidity.VALID;
if (aSettings.getSMLInfo() == null) {
final BootstrapWarnBox aWarn = aNodeList.addAndReturnChild(warn().addChild(div("No valid SML Configuration is selected hence no participant can be migrated.")).addChild(div(new BootstrapButton().addChild("Select SML Configuration in the Settings").setOnClick(aWPEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).setIcon(EDefaultIcon.EDIT))));
if (aSettings.isSMLEnabled() || aSettings.isSMLRequired()) {
aWarn.addChild(div(new BootstrapButton().addChild("Create a new SML Configuration").setOnClick(createCreateURL(aWPEC, CMenuSecure.MENU_SML_CONFIGURATION)).setIcon(EDefaultIcon.YES)));
}
eCanStartMigration = EValidity.INVALID;
} else if (!aSettings.isSMLEnabled()) {
aNodeList.addChild(warn().addChild(div("SML Connection is not enabled hence no participant can be migrated.")).addChild(div(new BootstrapButton().addChild("Enable SML in the Settings").setOnClick(aWPEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).setIcon(EDefaultIcon.EDIT))));
eCanStartMigration = EValidity.INVALID;
} else {
if (aServiceGroupManager.getSMPServiceGroupCount() <= 0) {
aNodeList.addChild(warn("No Service Group is present! At least one Service Group must be present to migrate it."));
// Note: makes no to allow to create a new Service Group here and than
// directly migrate it away
eCanStartMigration = EValidity.INVALID;
}
}
{
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.REFRESH);
aToolbar.addChild(new BootstrapButton().addChild("Start Participant Migration").setOnClick(createCreateURL(aWPEC)).setDisabled(eCanStartMigration.isInvalid()).setIcon(EDefaultIcon.NEW));
aNodeList.addChild(aToolbar);
}
final BootstrapTabBox aTabBox = aNodeList.addAndReturnChild(new BootstrapTabBox());
final ICommonsList<ISMPParticipantMigration> aAllMigs = aParticipantMigrationMgr.getAllOutboundParticipantMigrations(null);
for (final EParticipantMigrationState eState : EParticipantMigrationState.values()) if (eState.isOutboundState()) {
final ICommonsList<ISMPParticipantMigration> aMatchingMigs = aAllMigs.getAll(x -> x.getState() == eState);
aTabBox.addTab(eState.getID(), eState.getDisplayName() + " (" + aMatchingMigs.size() + ")", _createTable(aWPEC, aMatchingMigs, eState));
}
}
use of com.helger.photon.bootstrap4.button.BootstrapButton in project phoss-smp by phax.
the class PageSecureTransportProfiles method showListOfExistingObjects.
@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final ISMPTransportProfileManager aTransportProfileMgr = SMPMetaManager.getTransportProfileMgr();
aNodeList.addChild(info("This page lets you create custom transport profiles that can be used in service information endpoints."));
final ICommonsList<ISMPTransportProfile> aList = aTransportProfileMgr.getAllSMPTransportProfiles();
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addChild(new BootstrapButton().addChild("Create new transport profile").setOnClick(createCreateURL(aWPEC)).setIcon(EDefaultIcon.NEW));
final ICommonsSet<String> aExistingIDs = new CommonsHashSet<>(aList, ISMPTransportProfile::getID);
if (!aExistingIDs.containsAll(DEFAULT_PROFILE_IDS)) {
// Show button only on demand
aToolbar.addChild(new BootstrapButton().addChild("Ensure all default transport profiles").setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_ENSURE_DEFAULT)).setIcon(EDefaultIcon.PLUS));
}
aNodeList.addChild(aToolbar);
final HCTable aTable = new HCTable(new DTCol("ID").setInitialSorting(ESortOrder.ASCENDING), new DTCol("Name"), new DTCol("Deprecated?"), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
for (final ISMPTransportProfile aCurObject : aList) {
final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject);
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(new HCA(aViewLink).addChild(aCurObject.getID()));
aRow.addCell(aCurObject.getName());
aRow.addCell(EPhotonCoreText.getYesOrNo(aCurObject.isDeprecated(), 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.getID()) : createEmptyAction());
}
final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
aNodeList.addChild(aTable).addChild(aDataTables);
}
use of com.helger.photon.bootstrap4.button.BootstrapButton in project phoss-smp by phax.
the class PageSecureServiceGroup method isValidToDisplayPage.
@Override
@Nonnull
protected IValidityIndicator isValidToDisplayPage(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final IUserManager aUserMgr = PhotonSecurityManager.getUserMgr();
if (aUserMgr.getActiveUserCount() == 0) {
aNodeList.addChild(warn("No user is present! At least one user must be present to create a service group."));
aNodeList.addChild(new BootstrapButton().addChild("Create new user").setOnClick(createCreateURL(aWPEC, BootstrapPagesMenuConfigurator.MENU_ADMIN_SECURITY_USER)).setIcon(EDefaultIcon.YES));
return EValidity.INVALID;
}
return super.isValidToDisplayPage(aWPEC);
}
use of com.helger.photon.bootstrap4.button.BootstrapButton in project phoss-smp by phax.
the class PageSecureServiceGroupExport method fillContent.
@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final IRequestWebScopeWithoutResponse aRequestScope = aWPEC.getRequestScope();
final ISMPSettings aSettings = SMPMetaManager.getSettings();
final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
final long nServiceGroupCount = aServiceGroupMgr.getSMPServiceGroupCount();
final boolean bHandleBusinessCards = aSettings.isDirectoryIntegrationEnabled();
if (nServiceGroupCount < 0)
aNodeList.addChild(error("The number of service groups is unknown, hence nothing can be exported!"));
else if (nServiceGroupCount == 0)
aNodeList.addChild(warn("Since no service group is present, nothing can be exported!"));
else {
aNodeList.addChild(info("Export " + (nServiceGroupCount == 1 ? "service group" : "all " + nServiceGroupCount + " service groups") + (bHandleBusinessCards ? " and business card" + (nServiceGroupCount == 1 ? "" : "s") : "") + " to an XML file."));
}
// The main export logic happens in the AJAX handler
final BootstrapButtonToolbar aToolbar = aNodeList.addAndReturnChild(getUIHandler().createToolbar(aWPEC));
aToolbar.addChild(new BootstrapButton().addChild("Export all Service Groups").setIcon(EDefaultIcon.SAVE_ALL).setOnClick(AJAX_EXPORT_SG.getInvocationURL(aRequestScope)).setDisabled(nServiceGroupCount <= 0));
}
use of com.helger.photon.bootstrap4.button.BootstrapButton in project peppol-practical by phax.
the class CommentUI method getCommentList.
@Nonnull
public static IHCNode getCommentList(@Nonnull final ILayoutExecutionContext aLEC, @Nonnull final ITypedObject<String> aObject, @Nonnull final CommentAction aCommentAction, @Nullable final CommentFormErrors aFormErrors, @Nullable final IHCNode aMessageBox, final boolean bShowCreateComments) {
ValueEnforcer.notNull(aLEC, "LEC");
ValueEnforcer.notNull(aObject, "Object");
ValueEnforcer.notNull(aCommentAction, "CommentAction");
final Locale aDisplayLocale = aLEC.getDisplayLocale();
final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
final HCDiv ret = new HCDiv();
final String sResultDivID = ret.ensureID().getID();
final boolean bUserCanCreateComments = CommentSecurity.canCurrentUserPostComments();
final boolean bIsAdmin = aLEC.isLoggedInUserAdministrator();
// Get all existing comments
final List<ICommentThread> aComments = CommentThreadManager.getInstance().getAllCommentThreadsOfObject(aObject);
if (CollectionHelper.isNotEmpty(aComments)) {
final IUserManager aUserMgr = PhotonSecurityManager.getUserMgr();
final boolean bIsCommentModerator = CommentSecurity.isCurrentUserCommentModerator();
// Container for all threads
final HCDiv aAllThreadsContainer = new HCDiv().addClass(CCommentCSS.CSS_CLASS_COMMENT_CONTAINER);
for (final ICommentThread aCommentThread : CollectionHelper.getSorted(aComments, Comparator.comparing(ICommentThread::getInitialCommentCreationDateTime))) {
// Container for this thread
final HCDiv aThreadContainer = new HCDiv();
aThreadContainer.addClass(CCommentCSS.CSS_CLASS_COMMENT_THREAD);
final NonBlockingStack<AbstractHCDiv<?>> aStack = new NonBlockingStack<>();
aStack.push(aThreadContainer);
aCommentThread.iterateAllComments(new ICommentIterationCallback() {
public void onCommentStart(final int nLevel, @Nullable final IComment aParentComment, @Nonnull final IComment aComment) {
// Show only approved comments
final boolean bIsApproved = aComment.getState().isApproved();
if (bIsApproved || bIsCommentModerator) {
// Get author name and determine if it is a registered user
boolean bRegisteredUser = false;
String sAuthor = null;
if (StringHelper.hasText(aComment.getUserID())) {
final IUser aUser = aUserMgr.getUserOfID(aComment.getUserID());
if (aUser != null) {
sAuthor = aUser.getDisplayName();
bRegisteredUser = true;
}
}
if (sAuthor == null)
sAuthor = aComment.getCreatorName();
// Fill panel header
final BootstrapCard aCommentPanel = new BootstrapCard();
final BootstrapCardHeader aHeader = aCommentPanel.createAndAddHeader();
final BootstrapCardBody aBody = aCommentPanel.createAndAddBody();
if (!bIsApproved)
aHeader.addClass(CBootstrapCSS.BG_DANGER);
// Is comment deleted?
if (aComment.isDeleted())
aHeader.addChild(new HCStrong().addChild(ECommentText.MSG_IS_DELETED.getDisplayText(aDisplayLocale)));
// Creation date
aHeader.addChild(new HCSpan().addChild(PDTToString.getAsString(aComment.getCreationDateTime(), aDisplayLocale)).addClass(CCommentCSS.CSS_CLASS_COMMENT_CREATIONDT));
// Author
aHeader.addChild(ECommentText.MSG_BY.getDisplayText(aDisplayLocale));
final HCSpan aAuthor = new HCSpan().addChild(sAuthor).addClass(CCommentCSS.CSS_CLASS_COMMENT_AUTHOR);
if (bRegisteredUser)
aAuthor.addClass(CCommentCSS.CSS_CLASS_COMMENT_REGISTERED_USER);
if (bIsAdmin)
aAuthor.addChild(bRegisteredUser ? " [registered]" : " [not-registered]");
aHeader.addChild(aAuthor);
// Title
if (StringHelper.hasText(aComment.getTitle())) {
aHeader.addChild(ECommentText.MSG_SEPARATOR_AUTHOR_TITLE.getDisplayText(aDisplayLocale));
aHeader.addChild(new HCSpan().addChild(aComment.getTitle()).addClass(CCommentCSS.CSS_CLASS_COMMENT_TITLE));
}
// Toolbar
final HCSpan aCommentToolbar = new HCSpan().addClass(CCommentCSS.CSS_CLASS_COMMENT_TOOLBAR);
HCDiv aCommentResponseContainer = null;
// Respond to a comment - at maximum 6 levels
if (bShowCreateComments && bUserCanCreateComments && !aComment.isDeleted() && nLevel < 6) {
aCommentResponseContainer = new HCDiv();
final BootstrapButton aResponseButton = new BootstrapButton(EBootstrapButtonSize.SMALL).setIcon(EDefaultIcon.ADD);
aCommentToolbar.addChild(aResponseButton);
aCommentToolbar.addChild(new BootstrapTooltip(aResponseButton).setTitle(ECommentText.TOOLTIP_RESPONSE.getDisplayText(aDisplayLocale)));
if (aCommentAction.isMatching(ECommentAction.ADD_COMMENT, aCommentThread, aComment) && aFormErrors != null && aFormErrors.isReplyTo(aCommentThread, aComment)) {
// Upon adding a response
if (aMessageBox == null || !aFormErrors.isEmpty()) {
// Show the input form again
aCommentResponseContainer.addChild(getCreateComment(aLEC, sResultDivID, aObject, aCommentThread, aComment, aFormErrors, aMessageBox));
} else {
// Show the success or error message
aBody.addChild(aMessageBox);
}
} else {
// Add the JS to show the input form
final JSAnonymousFunction aOnSuccess = new JSAnonymousFunction();
final JSVar aJSData = aOnSuccess.param("data");
aOnSuccess.body().add(JQuery.idRef(aCommentResponseContainer).empty().append(aJSData.ref(PhotonUnifiedResponse.HtmlHelper.PROPERTY_HTML)));
final JQueryInvocation aResponseAction = new JQueryAjaxBuilder().url(CAjax.COMMENT_SHOW_INPUT.getInvocationURL(aRequestScope)).data(new JSAssocArray().add(AjaxExecutorCommentShowInput.PARAM_OBJECT_TYPE, aObject.getObjectType().getName()).add(AjaxExecutorCommentShowInput.PARAM_OBJECT_ID, aObject.getID()).add(AjaxExecutorCommentShowInput.PARAM_COMMENT_THREAD_ID, aCommentThread.getID()).add(AjaxExecutorCommentShowInput.PARAM_COMMENT_ID, aComment.getID()).add(AjaxExecutorCommentShowInput.PARAM_RESULT_DIV_ID, sResultDivID)).success(JSJQueryHelper.jqueryAjaxSuccessHandler(aOnSuccess, null)).build();
aResponseButton.setOnClick(aResponseAction);
}
}
if (bIsCommentModerator) {
if (aCommentAction.isMatching(ECommentAction.DELETE_COMMENT, aCommentThread, aComment))
aBody.addChild(aMessageBox);
// Can the comment be deleted?
if (!aComment.isDeleted()) {
final BootstrapButton aDeleteButton = new BootstrapButton(EBootstrapButtonSize.SMALL).setIcon(EDefaultIcon.DELETE);
aCommentToolbar.addChild(aDeleteButton);
aCommentToolbar.addChild(new BootstrapTooltip(aDeleteButton).setTitle(ECommentText.TOOLTIP_DELETE.getDisplayText(aDisplayLocale)));
final JSAnonymousFunction aOnSuccess = new JSAnonymousFunction();
final JSVar aJSData = aOnSuccess.param("data");
aOnSuccess.body().add(JQuery.idRef(sResultDivID).replaceWith(aJSData.ref(PhotonUnifiedResponse.HtmlHelper.PROPERTY_HTML)));
final JQueryInvocation aDeleteAction = new JQueryAjaxBuilder().url(CAjax.COMMENT_DELETE.getInvocationURL(aRequestScope)).data(new JSAssocArray().add(AjaxExecutorCommentDelete.PARAM_OBJECT_TYPE, aObject.getObjectType().getName()).add(AjaxExecutorCommentDelete.PARAM_OBJECT_ID, aObject.getID()).add(AjaxExecutorCommentDelete.PARAM_COMMENT_THREAD_ID, aCommentThread.getID()).add(AjaxExecutorCommentDelete.PARAM_COMMENT_ID, aComment.getID())).success(JSJQueryHelper.jqueryAjaxSuccessHandler(aOnSuccess, null)).build();
aDeleteButton.setOnClick(aDeleteAction);
}
// Show source host and further info
aCommentToolbar.addChild(BootstrapSimpleTooltip.createSimpleTooltip(ECommentText.TOOLTIP_HOST.getDisplayTextWithArgs(aDisplayLocale, aComment.getHost())));
}
if (aCommentToolbar.hasChildren())
aHeader.addChild(aCommentToolbar);
// Last modification
if (aComment.getLastModificationDateTime() != null) {
final String sLastModDT = PDTToString.getAsString(aComment.getLastModificationDateTime(), aDisplayLocale);
final String sLastModText = aComment.getEditCount() > 0 ? ECommentText.MSG_EDITED_AND_LAST_MODIFICATION.getDisplayTextWithArgs(aDisplayLocale, Integer.valueOf(aComment.getEditCount()), sLastModDT) : ECommentText.MSG_LAST_MODIFICATION.getDisplayTextWithArgs(aDisplayLocale, sLastModDT);
aHeader.addChild(new HCDiv().addChild(sLastModText).addClass(CCommentCSS.CSS_CLASS_COMMENT_LAST_MODIFICATION));
}
// Show the main comment text
aBody.addClass(CCommentCSS.CSS_CLASS_SINGLE_COMMENT);
// Always put the text as the first part of the body
aBody.addChildAt(0, new HCDiv().addChildren(HCExtHelper.nl2brList(aComment.getText())).addClass(CCommentCSS.CSS_CLASS_COMMENT_TEXT));
// the dummy container for new comment form
aBody.addChild(aCommentResponseContainer);
aStack.peek().addChild(aCommentPanel);
aStack.push(aBody);
} else {
// Don't display - push the previous item
aStack.push(aStack.peek());
}
}
public void onCommentEnd(final int nLevel, @Nullable final IComment aParentComment, @Nonnull final IComment aComment) {
aStack.pop();
}
});
// Show only thread panels which contain at least one comment
if (aThreadContainer.hasChildren())
aAllThreadsContainer.addChild(aThreadContainer);
}
ret.addChild(aAllThreadsContainer);
}
if (bShowCreateComments) {
// Create comment only for logged in users
if (bUserCanCreateComments) {
// Add "create comment" button
final boolean bIsForCreateThread = aCommentAction.isMatching(ECommentAction.CREATE_THREAD);
ret.addChild(getCreateComment(aLEC, sResultDivID, aObject, null, null, bIsForCreateThread ? aFormErrors : null, bIsForCreateThread ? aMessageBox : null));
} else
ret.addChild(new BootstrapBadge(EBootstrapBadgeType.INFO).addChild(ECommentText.MSG_LOGIN_TO_COMMENT.getDisplayText(aDisplayLocale)));
}
return ret;
}
Aggregations