Search in sources :

Example 1 with BootstrapSuccessBox

use of com.helger.photon.bootstrap4.alert.BootstrapSuccessBox in project phoss-smp by phax.

the class SMPRendererSecure method getMenuContent.

@Nonnull
public static IHCNode getMenuContent(@Nonnull final ILayoutExecutionContext aLEC) {
    final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
    final HCNodeList ret = new HCNodeList();
    final ISMPSettings aSettings = SMPMetaManager.getSettings();
    ret.addChild(BootstrapMenuItemRenderer.createSideBarMenu(aLEC));
    final BootstrapSuccessBox aBox = new BootstrapSuccessBox().addClass(CBootstrapCSS.MT_2);
    if (SMPMetaManager.getInstance().getBackendConnectionState().isFalse()) {
        aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" No database connection: ").addChild(new HCA(CAjax.FUNCTION_BACKEND_CONNECTION_RESET.getInvocationURL(aRequestScope)).addChild("Retry")));
        aBox.setType(EBootstrapAlertType.DANGER);
    }
    // Information on SML usage
    if (aSettings.isSMLEnabled()) {
        aBox.addChild(new HCDiv().addChild(EDefaultIcon.YES.getAsNode()).addChild(" SML connection is configured."));
        if (aSettings.getSMLInfo() == null) {
            aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" No SML is selected. ").addChild(new HCA(aLEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).addChild("Fix me")));
            aBox.setType(EBootstrapAlertType.DANGER);
        }
    } else {
        // Warn only if SML is needed
        if (aSettings.isSMLRequired()) {
            aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" SML connection is NOT configured. ").addChild(new HCA(aLEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).addChild("Fix me")));
            aBox.setTypeIfWorse(EBootstrapAlertType.WARNING);
        }
    }
    if (aSettings.isDirectoryIntegrationRequired()) {
        if (aSettings.isDirectoryIntegrationEnabled()) {
            aBox.addChild(new HCDiv().addChild(EDefaultIcon.YES.getAsNode()).addChild(" Directory support is configured."));
            if (StringHelper.hasNoText(aSettings.getDirectoryHostName())) {
                aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" No Directory host is provided. ").addChild(new HCA(aLEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).addChild("Fix me")));
                aBox.setType(EBootstrapAlertType.DANGER);
            }
        } else {
            // Warn only if Directory is needed
            aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" Directory support is NOT configured. ").addChild(new HCA(aLEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).addChild("Fix me")));
            aBox.setTypeIfWorse(EBootstrapAlertType.WARNING);
        }
    }
    // Information on certificate
    if (!SMPKeyManager.isKeyStoreValid()) {
        aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" Certificate configuration is invalid."));
        aBox.setType(EBootstrapAlertType.DANGER);
    }
    ret.addChild(aBox);
    return ret;
}
Also used : HCDiv(com.helger.html.hc.html.grouping.HCDiv) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) HCNodeList(com.helger.html.hc.impl.HCNodeList) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) HCA(com.helger.html.hc.html.textlevel.HCA) BootstrapSuccessBox(com.helger.photon.bootstrap4.alert.BootstrapSuccessBox) Nonnull(javax.annotation.Nonnull)

Aggregations

HCDiv (com.helger.html.hc.html.grouping.HCDiv)1 HCA (com.helger.html.hc.html.textlevel.HCA)1 HCNodeList (com.helger.html.hc.impl.HCNodeList)1 ISMPSettings (com.helger.phoss.smp.settings.ISMPSettings)1 BootstrapSuccessBox (com.helger.photon.bootstrap4.alert.BootstrapSuccessBox)1 IRequestWebScopeWithoutResponse (com.helger.web.scope.IRequestWebScopeWithoutResponse)1 Nonnull (javax.annotation.Nonnull)1