Search in sources :

Example 71 with HCNodeList

use of com.helger.html.hc.impl.HCNodeList in project phoss-directory by phax.

the class PageSecureParticipantCount method fillContent.

@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    {
        final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
        aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.MAGNIFIER);
        aNodeList.addChild(aToolbar);
    }
    final int nNotDeletedCount = PDMetaManager.getStorageMgr().getContainedParticipantCount();
    aNodeList.addChild(h3(nNotDeletedCount + " participants (entities) are contained"));
    final int nReIndexCount = PDMetaManager.getIndexerMgr().getReIndexList().getItemCount();
    aNodeList.addChild(h3(nReIndexCount + " re-index items are contained"));
    final int nDeadCount = PDMetaManager.getIndexerMgr().getDeadList().getItemCount();
    aNodeList.addChild(h3(nDeadCount + " dead items are contained"));
    if (false)
        try {
            final Collector aCollector = new AllDocumentsCollector(PDMetaManager.getLucene(), (aDoc, nIdx) -> {
                final BootstrapTable aTable = new BootstrapTable();
                for (final IndexableField f : aDoc.getFields()) aTable.addBodyRow().addCells(f.name(), f.fieldType().toString(), f.stringValue());
                aNodeList.addChild(aTable);
                aNodeList.addChild(new HCHR());
            });
            PDMetaManager.getStorageMgr().searchAtomic(new MatchAllDocsQuery(), aCollector);
        } catch (final IOException ex) {
        }
}
Also used : WebPageExecutionContext(com.helger.photon.uicore.page.WebPageExecutionContext) AbstractAppWebPage(com.helger.pd.publisher.ui.AbstractAppWebPage) EDefaultIcon(com.helger.photon.uicore.icon.EDefaultIcon) IndexableField(org.apache.lucene.index.IndexableField) PDMetaManager(com.helger.pd.indexer.mgr.PDMetaManager) IOException(java.io.IOException) Collector(org.apache.lucene.search.Collector) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) BootstrapTable(com.helger.photon.bootstrap4.table.BootstrapTable) Nonempty(com.helger.commons.annotation.Nonempty) HCHR(com.helger.html.hc.html.grouping.HCHR) AllDocumentsCollector(com.helger.pd.indexer.lucene.AllDocumentsCollector) Nonnull(javax.annotation.Nonnull) HCNodeList(com.helger.html.hc.impl.HCNodeList) IndexableField(org.apache.lucene.index.IndexableField) HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapTable(com.helger.photon.bootstrap4.table.BootstrapTable) HCHR(com.helger.html.hc.html.grouping.HCHR) Collector(org.apache.lucene.search.Collector) AllDocumentsCollector(com.helger.pd.indexer.lucene.AllDocumentsCollector) AllDocumentsCollector(com.helger.pd.indexer.lucene.AllDocumentsCollector) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) IOException(java.io.IOException) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery)

Example 72 with HCNodeList

use of com.helger.html.hc.impl.HCNodeList in project phoss-directory by phax.

the class PageSecureParticipantList method fillContent.

@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final IRequestWebScopeWithoutResponse aRequestScope = aWPEC.getRequestScope();
    if (aWPEC.hasAction(CPageParam.ACTION_DELETE)) {
        final String sParticipantID = aRequestScope.params().getAsString(FIELD_PARTICIPANT_ID);
        final IIdentifierFactory aIdentifierFactory = PDMetaManager.getIdentifierFactory();
        final IParticipantIdentifier aParticipantID = aIdentifierFactory.parseParticipantIdentifier(sParticipantID);
        if (aParticipantID != null) {
            boolean bSuccess = false;
            try {
                bSuccess = PDMetaManager.getStorageMgr().deleteEntry(aParticipantID, null, false) > 0;
            } catch (final IOException ex) {
            // ignore
            }
            if (bSuccess)
                aNodeList.addChild(info("The participant ID '" + aParticipantID.getURIEncoded() + "' was deleted"));
            else
                aNodeList.addChild(error("Error deleting participant ID '" + aParticipantID.getURIEncoded() + "'"));
        }
    }
    final ICommonsSortedMap<IParticipantIdentifier, MutableInt> aAllIDs = PDMetaManager.getStorageMgr().getAllContainedParticipantIDs();
    aNodeList.addChild(h3(aAllIDs.size() + " participants (=Business Cards) are contained"));
    int nMaxEntries;
    if (aWPEC.params().containsKey(PARAM_SHOW_ALL))
        nMaxEntries = Integer.MAX_VALUE;
    else {
        nMaxEntries = aWPEC.params().getAsInt(PARAM_MAX_ENTRIES, -1);
        if (nMaxEntries <= 0) {
            // Avoid negative entry count
            nMaxEntries = 500;
        }
        if (aAllIDs.size() > nMaxEntries) {
            aNodeList.addChild(info("Showing only the first " + nMaxEntries + " participant(s), to avoid too much load on the server. Use the parameter '" + PARAM_SHOW_ALL + "' to show all participants, or '" + PARAM_MAX_ENTRIES + "' to specify a maximum number of entries."));
        }
    }
    final HCTable aTable = new HCTable(new DTCol("ID").setInitialSorting(ESortOrder.ASCENDING), new DTCol("Entities").setDisplayType(EDTColType.INT, aDisplayLocale), new BootstrapDTColAction()).setID(getID());
    for (final Map.Entry<IParticipantIdentifier, MutableInt> aEntry : aAllIDs.entrySet()) {
        final String sParticipantID = aEntry.getKey().getURIEncoded();
        final HCRow aRow = aTable.addBodyRow();
        aRow.addCell(sParticipantID);
        aRow.addCell(Integer.toString(aEntry.getValue().intValue()));
        final IHCCell<?> aActionCell = aRow.addCell();
        final ISimpleURL aShowDetails = aWPEC.getLinkToMenuItem(CApplicationID.APP_ID_PUBLIC, CMenuPublic.MENU_SEARCH_SIMPLE).add(PagePublicSearchSimple.FIELD_QUERY, sParticipantID).add(CPageParam.PARAM_ACTION, CPageParam.ACTION_VIEW).add(PagePublicSearchSimple.FIELD_PARTICIPANT_ID, sParticipantID);
        aActionCell.addChild(new HCA(aShowDetails).addChild("Search"));
        aActionCell.addChild(" ");
        final ISimpleURL aReIndex = aWPEC.getLinkToMenuItem(CMenuSecure.MENU_INDEX_MANUALLY).add(PageSecureIndexManually.FIELD_PARTICIPANT_ID, sParticipantID).add(CPageParam.PARAM_ACTION, CPageParam.ACTION_PERFORM);
        aActionCell.addChild(new HCA(aReIndex).addChild("Reindex"));
        aActionCell.addChild(" ");
        final ISimpleURL aDelete = aWPEC.getSelfHref().add(FIELD_PARTICIPANT_ID, sParticipantID).add(CPageParam.PARAM_ACTION, CPageParam.ACTION_DELETE);
        aActionCell.addChild(new HCA(aDelete).addChild("Delete"));
        if (aTable.getBodyRowCount() >= nMaxEntries) {
            LOGGER.info("Stopping rendering after " + nMaxEntries + " entries");
            break;
        }
    }
    aNodeList.addChild(aTable).addChild(BootstrapDataTables.createDefaultDataTables(aWPEC, aTable));
}
Also used : Locale(java.util.Locale) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCA(com.helger.html.hc.html.textlevel.HCA) HCRow(com.helger.html.hc.html.tabular.HCRow) IOException(java.io.IOException) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) HCTable(com.helger.html.hc.html.tabular.HCTable) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) MutableInt(com.helger.commons.mutable.MutableInt) ISimpleURL(com.helger.commons.url.ISimpleURL) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) Map(java.util.Map) ICommonsSortedMap(com.helger.commons.collection.impl.ICommonsSortedMap) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Example 73 with HCNodeList

use of com.helger.html.hc.impl.HCNodeList in project phoss-directory by phax.

the class SecureHTMLProvider method getContent.

@Nonnull
public static IHCNode getContent(@Nonnull final LayoutExecutionContext aLEC) {
    final HCNodeList ret = new HCNodeList();
    // Header
    ret.addChild(_getNavbar(aLEC));
    final BootstrapContainer aOuterContainer = ret.addAndReturnChild(new BootstrapContainer().setFluid(true));
    // Breadcrumbs
    {
        final BootstrapBreadcrumb aBreadcrumbs = BootstrapBreadcrumbProvider.createBreadcrumb(aLEC);
        aBreadcrumbs.addClasses(CBootstrapCSS.D_NONE, CBootstrapCSS.D_SM_BLOCK);
        aOuterContainer.addChild(aBreadcrumbs);
    }
    // Content
    {
        final HCDiv aRow = aOuterContainer.addAndReturnChild(new HCDiv().addClass(CBootstrapCSS.D_MD_FLEX));
        final HCDiv aCol1 = aRow.addAndReturnChild(new HCDiv().addClass(CBootstrapCSS.D_MD_FLEX).addClass(CBootstrapCSS.MR_2));
        final HCDiv aCol2 = aRow.addAndReturnChild(new HCDiv().addClass(CBootstrapCSS.FLEX_FILL));
        // left
        // We need a wrapper span for easy AJAX content replacement
        aCol1.addClass(CBootstrapCSS.D_PRINT_NONE).addChild(new HCSpan().setID(CLayout.LAYOUT_AREAID_MENU).addChild(getMenuContent(aLEC)).addChild(new HCDiv().addChild(new HCSmall().addChild(CDirectoryVersion.BUILD_VERSION))).addChild(new HCDiv().addChild(new HCSmall().addChild(CDirectoryVersion.BUILD_TIMESTAMP))));
        aCol1.addChild(new HCDiv().setID(CLayout.LAYOUT_AREAID_SPECIAL));
        // content - determine is exactly same as for view
        aCol2.addChild(BootstrapPageRenderer.getPageContent(aLEC));
    }
    return ret;
}
Also used : HCDiv(com.helger.html.hc.html.grouping.HCDiv) HCSpan(com.helger.html.hc.html.textlevel.HCSpan) HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapContainer(com.helger.photon.bootstrap4.layout.BootstrapContainer) HCSmall(com.helger.html.hc.html.textlevel.HCSmall) BootstrapBreadcrumb(com.helger.photon.bootstrap4.breadcrumb.BootstrapBreadcrumb) Nonnull(javax.annotation.Nonnull)

Example 74 with HCNodeList

use of com.helger.html.hc.impl.HCNodeList in project phoss-directory by phax.

the class PagePublicSearchExtended method fillContent.

@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    aNodeList.addChild(info("This is a placeholder page - has no effect yet!"));
    final BootstrapViewForm aViewForm = new BootstrapViewForm();
    // Add all search fields
    for (final EPDSearchField eField : EPDSearchField.values()) {
        final HCSearchOperatorSelect aSelect = new HCSearchOperatorSelect(new RequestField(PREFIX_OPERATOR + eField.getFieldName(), ESearchOperator.EQ.getID()), eField.getDataType(), aDisplayLocale);
        final HCNodeList aCtrl = _createCtrl(eField, aDisplayLocale);
        final BootstrapRow aRow = new BootstrapRow();
        aRow.createColumn(2).addChild(aSelect);
        aRow.createColumn(10).addChild(aCtrl);
        aViewForm.addFormGroup(new BootstrapFormGroup().setLabel(eField.getDisplayText(aDisplayLocale)).setCtrl(aRow));
    }
    aNodeList.addChild(aViewForm);
}
Also used : Locale(java.util.Locale) EPDSearchField(com.helger.pd.publisher.search.EPDSearchField) HCSearchOperatorSelect(com.helger.pd.publisher.ui.HCSearchOperatorSelect) BootstrapRow(com.helger.photon.bootstrap4.grid.BootstrapRow) HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapViewForm(com.helger.photon.bootstrap4.form.BootstrapViewForm) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) RequestField(com.helger.photon.core.form.RequestField)

Example 75 with HCNodeList

use of com.helger.html.hc.impl.HCNodeList in project phoss-directory by phax.

the class PagePublicSearchExtended method _createCtrl.

@Nonnull
private static HCNodeList _createCtrl(@Nonnull final EPDSearchField eField, @Nonnull final Locale aDisplayLocale) {
    final String sFieldName = eField.getFieldName();
    final HCNodeList ret = new HCNodeList();
    switch(eField) {
        case COUNTRY:
            ret.addChild(new HCCountrySelect(new RequestField(PREFIX_SPECIAL + sFieldName), aDisplayLocale));
            break;
        case REGISTRATION_DATE:
            ret.addChild(BootstrapDateTimePicker.create(PREFIX_SPECIAL + sFieldName, aDisplayLocale, EBootstrap4DateTimePickerMode.DATE));
            break;
    }
    // Default to String
    ret.addChild(new HCEdit(new RequestField(sFieldName)));
    return ret;
}
Also used : HCCountrySelect(com.helger.photon.uicore.html.select.HCCountrySelect) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCEdit(com.helger.html.hc.html.forms.HCEdit) RequestField(com.helger.photon.core.form.RequestField) Nonnull(javax.annotation.Nonnull)

Aggregations

HCNodeList (com.helger.html.hc.impl.HCNodeList)123 Locale (java.util.Locale)74 BootstrapFormGroup (com.helger.photon.bootstrap4.form.BootstrapFormGroup)42 Nonnull (javax.annotation.Nonnull)41 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)40 HCA (com.helger.html.hc.html.textlevel.HCA)35 PDTToString (com.helger.commons.datetime.PDTToString)28 ISimpleURL (com.helger.commons.url.ISimpleURL)27 HCRow (com.helger.html.hc.html.tabular.HCRow)26 BootstrapButton (com.helger.photon.bootstrap4.button.BootstrapButton)24 RequestField (com.helger.photon.core.form.RequestField)24 DTCol (com.helger.photon.uictrls.datatables.column.DTCol)24 HCTable (com.helger.html.hc.html.tabular.HCTable)23 BootstrapViewForm (com.helger.photon.bootstrap4.form.BootstrapViewForm)23 BootstrapForm (com.helger.photon.bootstrap4.form.BootstrapForm)21 BootstrapDTColAction (com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction)21 FormErrorList (com.helger.photon.core.form.FormErrorList)21 BootstrapDataTables (com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables)20 HCTextNode (com.helger.html.hc.impl.HCTextNode)19 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)19