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

knowledgepixels / nanodash / 17638150642

11 Sep 2025 08:05AM UTC coverage: 13.776% (-0.06%) from 13.839%
17638150642

push

github

tkuhn
style(QueryResultTable): borrow style from ItemListPanel

432 of 3954 branches covered (10.93%)

Branch coverage included in aggregate %.

1104 of 7196 relevant lines covered (15.34%)

0.68 hits per line

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

46.51
src/main/java/com/knowledgepixels/nanodash/page/NanodashPage.java
1
package com.knowledgepixels.nanodash.page;
2

3
import com.knowledgepixels.nanodash.Project;
4
import com.knowledgepixels.nanodash.User;
5
import com.knowledgepixels.nanodash.Utils;
6
import com.knowledgepixels.nanodash.WicketApplication;
7
import com.knowledgepixels.nanodash.template.TemplateData;
8
import org.apache.wicket.markup.head.IHeaderResponse;
9
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
10
import org.apache.wicket.markup.head.JavaScriptReferenceHeaderItem;
11
import org.apache.wicket.markup.html.WebPage;
12
import org.apache.wicket.request.flow.RedirectToUrlException;
13
import org.apache.wicket.request.mapper.parameter.PageParameters;
14
import org.apache.wicket.request.resource.JavaScriptResourceReference;
15
import org.slf4j.Logger;
16
import org.slf4j.LoggerFactory;
17

18
/**
19
 * Abstract base class for Nanodash pages.
20
 * Provides functionality for auto-refreshing data and rendering JavaScript resources.
21
 */
22
public abstract class NanodashPage extends WebPage {
23

24
    private static final long serialVersionUID = 1L;
25
    private static final Logger logger = LoggerFactory.getLogger(NanodashPage.class);
3✔
26

27
    private static long lastRefresh = 0L;
2✔
28
    private static final long REFRESH_INTERVAL = 60 * 1000; // 1 minute
29
    private static boolean refreshRunning = false;
2✔
30

31
    private long state = 0L;
3✔
32

33
    private static JavaScriptResourceReference nanodashJs = new JavaScriptResourceReference(WicketApplication.class, "script/nanodash.js");
7✔
34

35
    /**
36
     * Returns the mount path for this page.
37
     *
38
     * @return the mount path as a String
39
     */
40
    public abstract String getMountPath();
41

42
    /**
43
     * Constructor for NanodashPage.
44
     *
45
     * @param parameters the page parameters
46
     */
47
    protected NanodashPage(PageParameters parameters) {
48
        super(parameters);
3✔
49
        ensureRefreshed();
2✔
50
    }
1✔
51

52
    private void ensureRefreshed() {
53
        synchronized (getClass()) {
5✔
54
            state = lastRefresh;
3✔
55
            if (!refreshRunning && System.currentTimeMillis() - lastRefresh > REFRESH_INTERVAL) {
8!
56
                lastRefresh = System.currentTimeMillis();
2✔
57
                refreshRunning = true;
2✔
58
                new Thread(() -> {
4✔
59
//                                                try {
60
//                                                        Thread.sleep(2000);
61
//                                                } catch (InterruptedException ex) {
62
//                                                        logger.error();
63
//                                                }
64
                    try {
65
                        logger.info("Refreshing ...");
3✔
66
                        User.refreshUsers();
×
67
                        TemplateData.refreshTemplates();
×
68
                        Project.refresh();
×
69
                        logger.info("Refreshing done.");
×
70
                        lastRefresh = System.currentTimeMillis();
×
71
                    } catch (Exception ex) {
×
72
                        logger.error("Error during refresh", ex);
×
73
                    } finally {
74
                        refreshRunning = false;
×
75
                    }
76
                }).start();
1✔
77
            }
78
        }
3✔
79
    }
1✔
80

81
    /**
82
     * Checks if auto-refresh is enabled for this page.
83
     * Override this method in subclasses to enable auto-refresh.
84
     *
85
     * @return true if auto-refresh is enabled, false otherwise
86
     */
87
    protected boolean hasAutoRefreshEnabled() {
88
        return false;
×
89
    }
90

91
    /**
92
     * {@inheritDoc}
93
     */
94
    @Override
95
    protected void onRender() {
96
        if (hasAutoRefreshEnabled() && state < lastRefresh) {
×
97
            throw new RedirectToUrlException(getMountPath() + "?" + Utils.getPageParametersAsString(getPageParameters()));
×
98
        }
99
        super.onRender();
×
100
    }
×
101

102
    /**
103
     * {@inheritDoc}
104
     * <p>
105
     * Renders the head section of the page, including JavaScript references.
106
     */
107
    @Override
108
    public void renderHead(IHeaderResponse response) {
109
        super.renderHead(response);
×
110
        response.render(JavaScriptHeaderItem.forReference(getApplication().getJavaScriptLibrarySettings().getJQueryReference()));
×
111
        response.render(JavaScriptReferenceHeaderItem.forReference(nanodashJs));
×
112
    }
×
113

114
}
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