• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

knowledgepixels / nanodash / 23361100507

20 Mar 2026 08:21PM UTC coverage: 16.371% (-0.008%) from 16.379%
23361100507

push

github

tkuhn
feat: add upcoming events table view to home page and make nanopub set items-per-page configurable

Add the upcoming-events-view as a table alongside the most recent nanopubs
(reduced to 5 items) on the home page. Remove unnecessary DataView wrappers
for single-item views and strip col-* classes to avoid extra spacing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

731 of 5533 branches covered (13.21%)

Branch coverage included in aggregate %.

1877 of 10398 relevant lines covered (18.05%)

2.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
src/main/java/com/knowledgepixels/nanodash/component/QueryResultNanopubSet.java
1
package com.knowledgepixels.nanodash.component;
2

3
import com.knowledgepixels.nanodash.NanodashSession;
4
import com.knowledgepixels.nanodash.QueryResult;
5
import com.knowledgepixels.nanodash.ViewDisplay;
6
import com.knowledgepixels.nanodash.component.menu.ViewDisplayMenu;
7
import org.apache.wicket.ajax.AjaxRequestTarget;
8
import org.apache.wicket.ajax.markup.html.AjaxLink;
9
import org.apache.wicket.behavior.AttributeAppender;
10
import org.apache.wicket.markup.html.WebMarkupContainer;
11
import org.apache.wicket.markup.html.basic.Label;
12
import org.nanopub.extra.services.ApiResponse;
13
import org.nanopub.extra.services.QueryRef;
14
import org.slf4j.Logger;
15
import org.slf4j.LoggerFactory;
16

17
/**
18
 * Component for displaying query results in a list format.
19
 */
20
public class QueryResultNanopubSet extends QueryResult {
21

22
    private static final Logger logger = LoggerFactory.getLogger(QueryResultNanopubSet.class);
×
23
    private final WebMarkupContainer viewSelector;
24
    private final long itemsPerPage;
25

26
    /**
27
     * Constructor for QueryResultList.
28
     *
29
     * @param markupId    the markup ID
30
     * @param queryRef    the query reference
31
     * @param response    the API response
32
     * @param viewDisplay the view display
33
     */
34
    QueryResultNanopubSet(String markupId, QueryRef queryRef, ApiResponse response, ViewDisplay viewDisplay, long itemsPerPage) {
35
        super(markupId, queryRef, response, viewDisplay);
×
36
        this.itemsPerPage = itemsPerPage;
×
37

38
        logger.info("Rendering {} with '{}' mode.", this.getClass().getName(), NanodashSession.get().getNanopubResultsViewMode().getValue());
×
39

40
        viewSelector = new WebMarkupContainer("viewSelector");
×
41
        viewSelector.setOutputMarkupId(true);
×
42

43
        viewSelector.add(new AjaxLink<>("listEnabler") {
×
44
            @Override
45
            public void onClick(AjaxRequestTarget target) {
46
                NanodashSession.get().setNanopubResultsViewMode(NanopubResults.ViewMode.LIST);
×
47
                logger.info("ListEnabler -- Switched to '{}' mode", NanodashSession.get().getNanopubResultsViewMode().getValue());
×
48
            }
×
49
        });
50

51
        viewSelector.add(new AjaxLink<>("gridEnabler") {
×
52
            @Override
53
            public void onClick(AjaxRequestTarget target) {
54
                NanodashSession.get().setNanopubResultsViewMode(NanopubResults.ViewMode.GRID);
×
55
                logger.info("GridEnabler -- Switched to '{}' mode", NanodashSession.get().getNanopubResultsViewMode().getValue());
×
56
            }
×
57
        });
58

59
        viewSelector.add(new Label("np"));
×
60
        add(viewSelector);
×
61
        showViewDisplayMenu = false; // handled in populateComponent() inside viewSelector
×
62

63
        String titleLabel = grlcQuery.getLabel();
×
64
        if (viewDisplay.getView().getTitle() != null) {
×
65
            titleLabel = viewDisplay.getView().getTitle();
×
66
        }
67
        add(new Label("title", titleLabel));
×
68
        setOutputMarkupId(true);
×
69
    }
×
70

71
    @Override
72
    protected void populateComponent() {
73
        logger.info("Populating the component with nanopub results.");
×
74
        NanopubResults nanopubResults = NanopubResults.fromApiResponse("nanopubs", response, itemsPerPage);
×
75
        nanopubResults.add(AttributeAppender.append("class", NanodashSession.get().getNanopubResultsViewMode().getValue()));
×
76
        add(nanopubResults);
×
77

78
        if (viewDisplay.getNanopubId() != null) {
×
79
            viewSelector.addOrReplace(new ViewDisplayMenu("np", viewDisplay, queryRef, pageResource));
×
80
        } else {
81
            viewSelector.addOrReplace(new Label("np").setVisible(false));
×
82
        }
83
    }
×
84

85
    /**
86
     * Sets the visibility of the title.
87
     *
88
     * @param hasTitle true to show the title, false to hide it
89
     */
90
    public void setTitleVisible(boolean hasTitle) {
91
        this.get("title").setVisible(hasTitle);
×
92
        if (!hasTitle) {
×
93
            viewSelector.add(AttributeAppender.append("class", " no-title"));
×
94
        }
95
    }
×
96

97
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc