Search in sources :

Example 6 with BootstrapNavbar

use of com.helger.photon.bootstrap4.navbar.BootstrapNavbar in project phoss-directory by phax.

the class PublicHTMLProvider method _addNavbarLoginLogout.

private static void _addNavbarLoginLogout(@Nonnull final LayoutExecutionContext aLEC, @Nonnull final BootstrapNavbar aNavbar) {
    final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
    final Locale aDisplayLocale = aLEC.getDisplayLocale();
    // Documentation
    {
        final BootstrapNavbarNav aNav = aNavbar.addAndReturnNav();
        final BootstrapDropdownMenu aDropDown = new BootstrapDropdownMenu();
        aDropDown.createAndAddItem().addChild("Introduction").setHref(aLEC.getLinkToMenuItem(CMenuPublic.MENU_DOCS_INTRODUCTION));
        aDropDown.createAndAddItem().addChild("How to use it").setHref(aLEC.getLinkToMenuItem(CMenuPublic.MENU_DOCS_HOW_TO));
        aDropDown.createAndAddItem().addChild("REST API").setHref(aLEC.getLinkToMenuItem(CMenuPublic.MENU_DOCS_REST_API));
        aDropDown.createAndAddItem().addChild("Export data").setHref(aLEC.getLinkToMenuItem(CMenuPublic.MENU_DOCS_EXPORT_ALL));
        aDropDown.createAndAddItem().addChild("Specification v1.1.1 (PDF)").setHref(LinkHelper.getURLWithContext("/files/PEPPOL-EDN-Directory-1.1.1-2020-10-15.pdf"));
        aDropDown.createAndAddItem().addChild("Guide for SMP providers (PDF)").setHref(LinkHelper.getURLWithContext("/files/OpenPEPPOL Directory for SMP providers 2016-12-05.pdf"));
        aNav.addItem().addNavDropDown("Documentation", aDropDown);
    }
    // Support
    {
        final BootstrapNavbarNav aNav = aNavbar.addAndReturnNav();
        final BootstrapDropdownMenu aDropDown = new BootstrapDropdownMenu();
        if (PDServerConfiguration.isWebAppShowContactPage()) {
            final String sTitle = PDServerConfiguration.getWebAppContactTitle("Contact us");
            final URL aExternalURL = PDServerConfiguration.getWebAppContactExternalURL();
            if (aExternalURL != null)
                aDropDown.createAndAddItem().addChild(sTitle).setHref(new SimpleURL(aExternalURL));
            else
                aDropDown.createAndAddItem().addChild(sTitle).setHref(aLEC.getLinkToMenuItem(CMenuPublic.MENU_SUPPORT_CONTACT_US));
        }
        aDropDown.createAndAddItem().addChild("Issue tracker (external)").setHref(new SimpleURL("https://github.com/phax/phoss-directory/issues")).setTargetBlank();
        aNav.addItem().addNavDropDown("Support", aDropDown);
    }
    // About
    {
        final BootstrapNavbarNav aNav = aNavbar.addAndReturnNav();
        final BootstrapDropdownMenu aDropDown = new BootstrapDropdownMenu();
        aDropDown.createAndAddItem().addChild("About " + CPDPublisher.getApplication()).setHref(aLEC.getLinkToMenuItem(CMenuPublic.MENU_ABOUT));
        aNav.addItem().addNavDropDown("About", aDropDown);
    }
    final BootstrapNavbarToggleable aToggleable = aNavbar.addAndReturnToggleable();
    // Login etc
    {
        final IUser aUser = LoggedInUserManager.getInstance().getCurrentUser();
        if (aUser != null) {
            aToggleable.addAndReturnText().addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MR_2).addChild("Welcome ").addChild(new HCStrong().addChild(SecurityHelper.getUserDisplayName(aUser, aDisplayLocale)));
            if (SecurityHelper.hasUserRole(aUser.getID(), AppSecurity.ROLE_CONFIG_ID)) {
                aToggleable.addChild(new BootstrapButton().addClass(CBootstrapCSS.MR_2).addChild("Goto secure area").setOnClick(LinkHelper.getURLWithContext(AbstractSecureApplicationServlet.SERVLET_DEFAULT_PATH + "/")));
            }
            aToggleable.addChild(new BootstrapButton().setOnClick(LinkHelper.getURLWithContext(aRequestScope, LogoutServlet.SERVLET_DEFAULT_PATH)).addChild(EPhotonCoreText.LOGIN_LOGOUT.getDisplayText(aDisplayLocale)).addStyle(CCSSProperties.MARGIN_RIGHT.newValue("8px")));
        } else {
            final BootstrapNavbarNav aNav = aToggleable.addAndReturnNav();
            final BootstrapDropdownMenu aDropDown = new BootstrapDropdownMenu();
            {
                final HCDiv aDiv = new HCDiv().addClass(CBootstrapCSS.P_2).addStyle(CCSSProperties.MIN_WIDTH.newValue("400px"));
                aDiv.addChild(AppCommonUI.createViewLoginForm(aLEC, null));
                aDropDown.addChild(aDiv);
            }
            aNav.addItem().addNavDropDown("Login", aDropDown);
        }
    }
}
Also used : Locale(java.util.Locale) HCDiv(com.helger.html.hc.html.grouping.HCDiv) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) HCStrong(com.helger.html.hc.html.textlevel.HCStrong) BootstrapNavbarNav(com.helger.photon.bootstrap4.navbar.BootstrapNavbarNav) BootstrapDropdownMenu(com.helger.photon.bootstrap4.dropdown.BootstrapDropdownMenu) BootstrapNavbarToggleable(com.helger.photon.bootstrap4.navbar.BootstrapNavbarToggleable) IUser(com.helger.photon.security.user.IUser) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) URL(java.net.URL) SimpleURL(com.helger.commons.url.SimpleURL) ISimpleURL(com.helger.commons.url.ISimpleURL) SimpleURL(com.helger.commons.url.SimpleURL) ISimpleURL(com.helger.commons.url.ISimpleURL)

Example 7 with BootstrapNavbar

use of com.helger.photon.bootstrap4.navbar.BootstrapNavbar in project phoss-smp by phax.

the class SMPRendererPublic method _getNavbar.

@Nonnull
private static BootstrapNavbar _getNavbar(@Nonnull final ILayoutExecutionContext aLEC) {
    final ISimpleURL aLinkToStartPage = aLEC.getLinkToMenuItem(aLEC.getMenuTree().getDefaultMenuItemID());
    final BootstrapNavbar aNavBar = new BootstrapNavbar();
    aNavBar.addBrand(createLogo(aLEC), aLinkToStartPage);
    aNavBar.addBrand(new HCSpan().addChild(CSMP.getApplicationTitle()), aLinkToStartPage);
    _addNavbarLoginLogout(aLEC, aNavBar);
    return aNavBar;
}
Also used : HCSpan(com.helger.html.hc.html.textlevel.HCSpan) BootstrapNavbar(com.helger.photon.bootstrap4.navbar.BootstrapNavbar) ISimpleURL(com.helger.commons.url.ISimpleURL) Nonnull(javax.annotation.Nonnull)

Example 8 with BootstrapNavbar

use of com.helger.photon.bootstrap4.navbar.BootstrapNavbar in project peppol-practical by phax.

the class LayoutAreaContentProviderPublic method _getNavbar.

@Nonnull
private static BootstrapNavbar _getNavbar(final LayoutExecutionContext aLEC) {
    final ISimpleURL aLinkToStartPage = aLEC.getLinkToMenuItem(aLEC.getMenuTree().getDefaultMenuItemID());
    final Locale aDisplayLocale = aLEC.getDisplayLocale();
    final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
    final IUser aUser = LoggedInUserManager.getInstance().getCurrentUser();
    final BootstrapNavbar aNavbar = new BootstrapNavbar();
    aNavbar.addBrand(new HCSpan().addClass(AppCommonUI.CSS_CLASS_LOGO1).addChild(AppHelper.getApplicationTitle()), aLinkToStartPage);
    aNavbar.addChild(new BootstrapButton(EBootstrapButtonType.DEFAULT).addChild("Participant information").setIcon(EFamFamIcon.USER_GREEN).setOnClick(aLEC.getLinkToMenuItem(CMenuPublic.MENU_TOOLS_PARTICIPANT_INFO)).addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2));
    aNavbar.addChild(new BootstrapButton(EBootstrapButtonType.DEFAULT).addChild("Document validation").setIcon(EFamFamIcon.SCRIPT_GO).setOnClick(aLEC.getLinkToMenuItem(CMenuPublic.MENU_VALIDATION_UPLOAD)).addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2));
    aNavbar.addChild(new BootstrapButton(EBootstrapButtonType.DEFAULT).addChild("ID information").setIcon(EFamFamIcon.CUP).setOnClick(aLEC.getLinkToMenuItem(CMenuPublic.MENU_TOOLS_ID_INFO)).addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2));
    final BootstrapNavbarToggleable aToggleable = aNavbar.addAndReturnToggleable();
    if (aUser != null) {
        aToggleable.addAndReturnText().addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2).addChild("Welcome ").addChild(new HCStrong().addChild(SecurityHelper.getUserDisplayName(aUser, aDisplayLocale)));
        if (SecurityHelper.hasUserRole(aUser.getID(), CPPApp.ROLE_CONFIG_ID)) {
            aToggleable.addChild(new BootstrapButton().setOnClick(LinkHelper.getURLWithContext(AbstractSecureApplicationServlet.SERVLET_DEFAULT_PATH)).addChild("Administration").addClass(CBootstrapCSS.MX_2));
        }
        aToggleable.addChild(new BootstrapButton().setOnClick(LinkHelper.getURLWithContext(aRequestScope, LogoutServlet.SERVLET_DEFAULT_PATH)).addChild(EPhotonCoreText.LOGIN_LOGOUT.getDisplayText(aDisplayLocale)).addClass(CBootstrapCSS.MX_2));
    } else {
        // show login in Navbar
        final BootstrapNavbarNav aNav = aToggleable.addAndReturnNav();
        final BootstrapDropdownMenu aDropDown = new BootstrapDropdownMenu();
        {
            final HCDiv aDiv = new HCDiv().addClass(CBootstrapCSS.P_2).addStyle(CCSSProperties.MIN_WIDTH.newValue("400px"));
            aDiv.addChild(AppCommonUI.createViewLoginForm(aLEC, null, false));
            aDropDown.addChild(aDiv);
        }
        aNav.addItem().addNavDropDown("Login", aDropDown);
        aToggleable.addChild(new BootstrapButton(EBootstrapButtonType.SUCCESS).addChild(EPhotonCoreText.BUTTON_SIGN_UP.getDisplayText(aDisplayLocale)).setOnClick(aLEC.getLinkToMenuItem(CMenuPublic.MENU_SIGN_UP)).addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2));
    }
    return aNavbar;
}
Also used : Locale(java.util.Locale) HCDiv(com.helger.html.hc.html.grouping.HCDiv) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) HCSpan(com.helger.html.hc.html.textlevel.HCSpan) HCStrong(com.helger.html.hc.html.textlevel.HCStrong) BootstrapNavbarNav(com.helger.photon.bootstrap4.navbar.BootstrapNavbarNav) BootstrapNavbar(com.helger.photon.bootstrap4.navbar.BootstrapNavbar) BootstrapDropdownMenu(com.helger.photon.bootstrap4.dropdown.BootstrapDropdownMenu) ISimpleURL(com.helger.commons.url.ISimpleURL) IUser(com.helger.photon.security.user.IUser) BootstrapNavbarToggleable(com.helger.photon.bootstrap4.navbar.BootstrapNavbarToggleable) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) Nonnull(javax.annotation.Nonnull)

Aggregations

ISimpleURL (com.helger.commons.url.ISimpleURL)7 HCSpan (com.helger.html.hc.html.textlevel.HCSpan)6 HCStrong (com.helger.html.hc.html.textlevel.HCStrong)6 BootstrapButton (com.helger.photon.bootstrap4.button.BootstrapButton)6 BootstrapNavbar (com.helger.photon.bootstrap4.navbar.BootstrapNavbar)6 BootstrapNavbarToggleable (com.helger.photon.bootstrap4.navbar.BootstrapNavbarToggleable)6 IUser (com.helger.photon.security.user.IUser)6 IRequestWebScopeWithoutResponse (com.helger.web.scope.IRequestWebScopeWithoutResponse)6 Locale (java.util.Locale)6 Nonnull (javax.annotation.Nonnull)6 HCDiv (com.helger.html.hc.html.grouping.HCDiv)3 BootstrapDropdownMenu (com.helger.photon.bootstrap4.dropdown.BootstrapDropdownMenu)3 BootstrapNavbarNav (com.helger.photon.bootstrap4.navbar.BootstrapNavbarNav)3 HCNodeList (com.helger.html.hc.impl.HCNodeList)2 SimpleURL (com.helger.commons.url.SimpleURL)1 HCImg (com.helger.html.hc.html.embedded.HCImg)1 URL (java.net.URL)1