Search in sources :

Example 11 with HCRow

use of com.helger.html.hc.html.tabular.HCRow in project peppol-practical by phax.

the class PageSecureCommentAdmin method fillContent.

@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final CommentThreadManager aCommentThreadMgr = CommentThreadManager.getInstance();
    boolean bShowList = true;
    final String sSelectedObjectType = aWPEC.params().getAsString(PARAM_TYPE);
    final String sSelectedOwningObjectID = aWPEC.params().getAsString(CPageParam.PARAM_OBJECT);
    if (aWPEC.hasAction(CPageParam.ACTION_VIEW) && StringHelper.hasText(sSelectedObjectType) && StringHelper.hasText(sSelectedOwningObjectID)) {
        final TypedObject<String> aTO = TypedObject.create(new ObjectType(sSelectedObjectType), sSelectedOwningObjectID);
        final List<ICommentThread> aCommentThreads = aCommentThreadMgr.getAllCommentThreadsOfObject(aTO);
        if (!aCommentThreads.isEmpty()) {
            // Don't allow comment creation
            aNodeList.addChild(CommentUI.getCommentList(aWPEC, aTO, CommentAction.createGeneric(ECommentAction.NONE), null, null, false));
            // Toolbar
            final IButtonToolbar<?> aToolbar = new BootstrapButtonToolbar(aWPEC);
            aToolbar.addButton(EPhotonCoreText.BACK_TO_OVERVIEW.getDisplayText(aDisplayLocale), aWPEC.getSelfHref(), EDefaultIcon.BACK_TO_LIST);
            aNodeList.addChild(aToolbar);
            bShowList = false;
        }
    }
    if (bShowList) {
        // Refresh button
        final IButtonToolbar<?> aToolbar = new BootstrapButtonToolbar(aWPEC);
        aToolbar.addButton(EPhotonCoreText.BUTTON_REFRESH.getDisplayText(aDisplayLocale), aWPEC.getSelfHref(), EDefaultIcon.REFRESH);
        aNodeList.addChild(aToolbar);
        final ITabBox<?> aTabBox = new BootstrapTabBox();
        for (final ObjectType aOT : CollectionHelper.getSorted(aCommentThreadMgr.getAllRegisteredObjectTypes())) {
            final HCNodeList aTab = new HCNodeList();
            final HCTable aTable = new HCTable(new DTCol(EText.HEADER_OBJECT_ID.getDisplayText(aDisplayLocale)), new DTCol(EText.HEADER_THREADS.getDisplayText(aDisplayLocale)).addClass(CSS_CLASS_RIGHT).setDisplayType(EDTColType.INT, aDisplayLocale), new DTCol(EText.HEADER_COMMENTS.getDisplayText(aDisplayLocale)).addClass(CSS_CLASS_RIGHT).setDisplayType(EDTColType.INT, aDisplayLocale), new DTCol(EText.HEADER_ACTIVE_COMMENTS.getDisplayText(aDisplayLocale)).addClass(CSS_CLASS_RIGHT).setDisplayType(EDTColType.INT, aDisplayLocale), new DTCol(EText.HEADER_LAST_CHANGE.getDisplayText(aDisplayLocale)).addClass(CSS_CLASS_RIGHT).setDisplayType(EDTColType.DATETIME, aDisplayLocale).setInitialSorting(ESortOrder.DESCENDING)).setID(getID() + aOT.getName());
            final CommentThreadObjectTypeManager aCTOTMgr = aCommentThreadMgr.getManagerOfObjectType(aOT);
            for (final Map.Entry<String, ICommonsList<ICommentThread>> aEntry : aCTOTMgr.getAllCommentThreads().entrySet()) {
                final String sOwningObjectID = aEntry.getKey();
                final ISimpleURL aViewURL = AbstractWebPageForm.createViewURL(aWPEC, sOwningObjectID).add(PARAM_TYPE, aOT.getName());
                final HCRow aRow = aTable.addBodyRow();
                aRow.addCell(new HCA(aViewURL).addChild(sOwningObjectID));
                aRow.addCell(Integer.toString(aEntry.getValue().size()));
                int nActiveComments = 0;
                final ICommonsList<IComment> aAllComments = new CommonsArrayList<>();
                for (final ICommentThread aCommentThread : aEntry.getValue()) {
                    aAllComments.addAll(aCommentThread.getAllComments());
                    nActiveComments += aCommentThread.getTotalActiveCommentCount();
                }
                Collections.sort(aAllComments, Comparator.comparing(IComment::getLastChangeDateTime).reversed());
                aRow.addCell(Integer.toString(aAllComments.size()));
                aRow.addCell(Integer.toString(nActiveComments));
                if (aAllComments.isEmpty())
                    aRow.addCell();
                else
                    aRow.addCell(PDTToString.getAsString(aAllComments.get(0).getLastChangeDateTime(), aDisplayLocale));
            }
            aTab.addChild(aTable);
            final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
            aTab.addChild(aDataTables);
            aTabBox.addTab(aOT.getName(), aOT.getName(), aTab, aOT.getName().equals(sSelectedObjectType));
        }
        aNodeList.addChild(aTabBox);
    }
}
Also used : Locale(java.util.Locale) ICommonsList(com.helger.commons.collection.impl.ICommonsList) IComment(com.helger.peppol.comment.domain.IComment) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCRow(com.helger.html.hc.html.tabular.HCRow) PDTToString(com.helger.commons.datetime.PDTToString) BootstrapTabBox(com.helger.photon.bootstrap4.nav.BootstrapTabBox) ICommentThread(com.helger.peppol.comment.domain.ICommentThread) ObjectType(com.helger.commons.type.ObjectType) CommentThreadObjectTypeManager(com.helger.peppol.comment.domain.CommentThreadObjectTypeManager) ISimpleURL(com.helger.commons.url.ISimpleURL) CommentThreadManager(com.helger.peppol.comment.domain.CommentThreadManager) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) DataTables(com.helger.photon.uictrls.datatables.DataTables) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables) HCA(com.helger.html.hc.html.textlevel.HCA) HCTable(com.helger.html.hc.html.tabular.HCTable) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) Map(java.util.Map) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList)

Example 12 with HCRow

use of com.helger.html.hc.html.tabular.HCRow in project phoss-directory by phax.

the class PageSecureListIndex method fillContent.

@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    // Add toolbar
    {
        final BootstrapButtonToolbar aToolbar = aNodeList.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
        aToolbar.addChild(new BootstrapButton().addChild("Refresh").setIcon(EDefaultIcon.REFRESH).setOnClick(aWPEC.getSelfHref()));
        aToolbar.addChild(span("Current server time: " + PDTToString.getAsString(PDTFactory.getCurrentLocalTime(), aDisplayLocale)).addClass(PDCommonUI.CSS_CLASS_VERTICAL_PADDED_TEXT));
    }
    final LinkedBlockingQueue<Object> aQueue = PDMetaManager.getIndexerMgr().getIndexerWorkQueue().getQueue();
    final int nLength = aQueue.size();
    if (nLength == 0) {
        aNodeList.addChild(success("The Index Queue is currently empty"));
    } else {
        aNodeList.addChild(info("The Index Queue contains " + nLength + " entries"));
        final BootstrapTable aTable = new BootstrapTable(new DTCol("Queue date time").setDisplayType(EDTColType.DATETIME, aDisplayLocale).setInitialSorting(ESortOrder.DESCENDING), new DTCol("Participant ID"), new DTCol("Action"), new DTCol("Owner"), new DTCol("Requestor")).setID("indexqueue");
        for (final Object o : aQueue) if (o instanceof IIndexerWorkItem) {
            final IIndexerWorkItem aObj = (IIndexerWorkItem) o;
            final HCRow aRow = aTable.addBodyRow();
            aRow.addCell(PDTToString.getAsString(aObj.getCreationDateTime(), aDisplayLocale));
            aRow.addCell(aObj.getParticipantID().getURIEncoded());
            aRow.addCell(aObj.getType().getDisplayName());
            aRow.addCell(aObj.getOwnerID());
            aRow.addCell(aObj.getRequestingHost());
        }
        aNodeList.addChild(aTable).addChild(BootstrapDataTables.createDefaultDataTables(aWPEC, aTable));
    }
}
Also used : Locale(java.util.Locale) IIndexerWorkItem(com.helger.pd.indexer.index.IIndexerWorkItem) HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapTable(com.helger.photon.bootstrap4.table.BootstrapTable) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) HCRow(com.helger.html.hc.html.tabular.HCRow) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)

Example 13 with HCRow

use of com.helger.html.hc.html.tabular.HCRow in project phoss-directory by phax.

the class PageSecureAdminSMLConfiguration method showListOfExistingObjects.

@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final ISMLInfoManager aSMLInfoMgr = PDPMetaManager.getSMLInfoMgr();
    aNodeList.addChild(info("This page lets you create custom SML configurations that can be used for registration."));
    final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
    aToolbar.addButton("Create new SML configuration", createCreateURL(aWPEC), EDefaultIcon.NEW);
    aNodeList.addChild(aToolbar);
    final HCTable aTable = new HCTable(new DTCol("Name").setInitialSorting(ESortOrder.ASCENDING), new DTCol("DNS Zone"), new DTCol("Management Service URL"), new DTCol("Client Cert?"), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
    for (final ISMLInfo aCurObject : aSMLInfoMgr.getAll()) {
        final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject);
        final HCRow aRow = aTable.addBodyRow();
        aRow.addCell(new HCA(aViewLink).addChild(aCurObject.getDisplayName()));
        aRow.addCell(aCurObject.getDNSZone());
        aRow.addCell(aCurObject.getManagementServiceURL());
        aRow.addCell(EPhotonCoreText.getYesOrNo(aCurObject.isClientCertificateRequired(), 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.getDisplayName()) : createEmptyAction());
    }
    final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
    aNodeList.addChild(aTable).addChild(aDataTables);
}
Also used : Locale(java.util.Locale) HCNodeList(com.helger.html.hc.impl.HCNodeList) ISMLInfo(com.helger.peppol.sml.ISMLInfo) HCA(com.helger.html.hc.html.textlevel.HCA) HCRow(com.helger.html.hc.html.tabular.HCRow) HCTable(com.helger.html.hc.html.tabular.HCTable) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) ISimpleURL(com.helger.commons.url.ISimpleURL) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) ISMLInfoManager(com.helger.pd.publisher.app.ISMLInfoManager) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) HCTextNode(com.helger.html.hc.impl.HCTextNode) DataTables(com.helger.photon.uictrls.datatables.DataTables) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables)

Example 14 with HCRow

use of com.helger.html.hc.html.tabular.HCRow in project phoss-directory by phax.

the class AbstractPageSecureReIndex method showListOfExistingObjects.

@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    // Add toolbar
    {
        final BootstrapButtonToolbar aToolbar = aNodeList.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
        aToolbar.addChild(new BootstrapButton().addChild("Refresh").setIcon(EDefaultIcon.REFRESH).setOnClick(aWPEC.getSelfHref()));
        aToolbar.addChild(new BootstrapButton().addChild("Delete all entries").setIcon(EDefaultIcon.DELETE).setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_DELETE_ALL)));
        aToolbar.addChild(span("Current server time: " + PDTToString.getAsString(PDTFactory.getCurrentLocalTime(), aDisplayLocale)).addClass(PDCommonUI.CSS_CLASS_VERTICAL_PADDED_TEXT));
    }
    final HCTable aTable = new HCTable(new DTCol("Reg date").setDisplayType(EDTColType.DATETIME, aDisplayLocale).setInitialSorting(ESortOrder.DESCENDING), new DTCol("Participant"), new DTCol("Action"), new DTCol("Retries").setDisplayType(EDTColType.INT, aDisplayLocale), m_bDeadIndex ? null : new DTCol("Next retry").setDisplayType(EDTColType.DATETIME, aDisplayLocale), new DTCol("Last retry").setDisplayType(EDTColType.DATETIME, aDisplayLocale), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
    for (final IReIndexWorkItem aItem : getReIndexWorkItemList().getAllItems()) {
        final ISimpleURL aViewLink = createViewURL(aWPEC, aItem);
        final IIndexerWorkItem aWorkItem = aItem.getWorkItem();
        final HCRow aRow = aTable.addBodyRow();
        aRow.addCell(new HCA(aViewLink).addChild(PDTToString.getAsString(aWorkItem.getCreationDateTime(), aDisplayLocale)));
        aRow.addCell(aWorkItem.getParticipantID().getURIEncoded());
        aRow.addCell(aWorkItem.getType().getDisplayName());
        aRow.addCell(Integer.toString(aItem.getRetryCount()));
        if (!m_bDeadIndex)
            aRow.addCell(PDTToString.getAsString(aItem.getNextRetryDT(), aDisplayLocale));
        aRow.addCell(PDTToString.getAsString(aItem.getMaxRetryDT(), aDisplayLocale));
        final IHCCell<?> aActionCell = aRow.addCell();
        if (m_bDeadIndex) {
            aActionCell.addChild(new HCA(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_REINDEX_NOW).add(CPageParam.PARAM_OBJECT, aItem.getID())).setTitle("Re-index the entry now").addChild(EDefaultIcon.NEXT.getAsNode()));
            aActionCell.addChild(" ");
        }
        aActionCell.addChild(createDeleteLink(aWPEC, aItem));
    }
    aNodeList.addChild(aTable);
    aNodeList.addChild(BootstrapDataTables.createDefaultDataTables(aWPEC, aTable));
}
Also used : Locale(java.util.Locale) HCNodeList(com.helger.html.hc.impl.HCNodeList) IReIndexWorkItem(com.helger.pd.indexer.reindex.IReIndexWorkItem) HCA(com.helger.html.hc.html.textlevel.HCA) HCRow(com.helger.html.hc.html.tabular.HCRow) HCTable(com.helger.html.hc.html.tabular.HCTable) IIndexerWorkItem(com.helger.pd.indexer.index.IIndexerWorkItem) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) ISimpleURL(com.helger.commons.url.ISimpleURL) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)

Example 15 with HCRow

use of com.helger.html.hc.html.tabular.HCRow 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)

Aggregations

HCRow (com.helger.html.hc.html.tabular.HCRow)25 Locale (java.util.Locale)24 HCNodeList (com.helger.html.hc.impl.HCNodeList)23 DTCol (com.helger.photon.uictrls.datatables.column.DTCol)21 HCTable (com.helger.html.hc.html.tabular.HCTable)20 ISimpleURL (com.helger.commons.url.ISimpleURL)19 HCA (com.helger.html.hc.html.textlevel.HCA)19 BootstrapDTColAction (com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction)18 BootstrapDataTables (com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables)17 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)16 DataTables (com.helger.photon.uictrls.datatables.DataTables)16 HCTextNode (com.helger.html.hc.impl.HCTextNode)11 PDTToString (com.helger.commons.datetime.PDTToString)8 Nonnull (javax.annotation.Nonnull)8 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)6 ICommonsList (com.helger.commons.collection.impl.ICommonsList)5 BootstrapButton (com.helger.photon.bootstrap4.button.BootstrapButton)5 PDTFromString (com.helger.commons.datetime.PDTFromString)4 ISMPServiceInformation (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation)4 ISMPServiceInformationManager (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager)4