• RE: Unable to load template

    Also works fine in Safari.

    posted in Plugin Development
  • RE: Unable to load template

    @pitaj Private browsing doesn't solve it. And the two scripts you mentioned are where they should be.

    Chrome (inkognito) still works. Firefox (private browsing) still doesn't work.

    posted in Plugin Development
  • RE: Unable to load template

    @pitaj This is the template:

    <div class="row">
        <div class="col-xs-12 col-md-2 no-print">
            <div class="row">
                <div class="col-xs-12 col-sm-6 col-md-12 form-group">
                    <label for="start">[[admin/advanced/events:filter-start]]</label>
                    <input type="date" component="analytics/input-start" name="start" value="{query.start}"
                        class="form-control" />
                </div>
                <div class="col-xs-12 col-sm-6 col-md-12 form-group">
                    <label for="end">[[admin/advanced/events:filter-end]]</label>
                    <input type="date" id="end" component="analytics/input-end" value="{query.end}"
                        class="form-control" />
                </div>
                <div class="form-group col-xs-12">
                    <button class="btn btn-primary" component="analytics/apply-btn">Apply</button>
                </div>
                <div class="form-group col-xs-12">
                    <button class="btn btn-primary" component="analytics/view-activity-report">Activity report</button>
                </div>
            </div>
        </div>
        <div class="col-xs-12 col-md-10" id="events-chart">
            <canvas></canvas>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12" id="companies-chart">
            <canvas></canvas>
        </div>
    </div>
    

    The two canvases are used to draw diagrams with chart.js included from NodeBB core.

    The template is located in static/templates/community/analytics.tpl

    To me though, the error suggests that it tries to load a js file that it assumes exists (and it does) but then fails and halts everything. It's also seems a bit odd that it works fine on Chrome, but not Firefox.

    posted in Plugin Development
  • RE: Unable to load template

    @baris The plugin is not open source as of yet. It hopefully will be in the future but right now it's not ready.

    This is the plugin.json:

    {
    	"id": "nodebb-plugin-community-analytics",
    	"library": "./library.js",
    	"hooks": [
    		{
    			"hook": "static:app.load", "method": "init"
    		},
    		{
    			"hook": "static:api.routes", "method": "addRoutes"
    		},
    		{
    			"hook": "filter:admin.header.build", "method": "addAdminNavigation"
    		},
    		{
    			"hook": "action:events.log", "method": "writeEventLog"
    		}
    	],
    	"staticDirs": {
    		"static": "./static"
    	},
    	"less": [
    		"static/style.less"
    	],
    	"modules": {
    		"chroma.js": "static/external/chroma.min.js"
    	},
    	"scripts": [
    		"static/lib/communityAnalytics.js",
    		"static/lib/globalAnalytics.js",
    		"static/lib/activityReport.js",
    		"static/lib/chartHelpers.js"
    	],
    	"acpScripts": [
    		"static/lib/admin.js"
    	],
    	"templates": "static/templates",
    	"languages": "languages"
    }
    

    This is in the controllers.js-file.

    Controllers.renderCommunityAnalyticsPage = async (req, res) => {
    	const cid = parseInt(req.params.category_id, 10);
    
    	if (Number.isNaN(cid)) return Helpers.notAllowed(req, res);
    
    	const category = await Categories.getCategoryData(cid);
    
    	const { from, to } = getTimestamps(req.query.from, req.query.to);
    
    	return res.render('community/analytics', {
    		category,
    		filters: {
    			from,
    			to,
    		}
    	});
    };
    

    This is the script (not all obviously) that's not being found and the cause of an error being thrown:

    'use strict';
    
    define('forum/community/analytics', ['api', 'components'], (api, components) => {
        const Analytics = {
            category: ajaxify.data.category,
        };
    
        Analytics.init = () => {
    
        };
    
        return Analytics;
    });
    
    

    There are some functions in there that are not relevant, since the script doesn't even load. I just wanted to show how I defined it.

    posted in Plugin Development
  • RE: Unable to load template

    @pitaj I also have this issue in another plugin, but then it was only in the admin panel so I didn't put any effort into fixing it. This is on the forum itself, which is why I would like to sort it out.

    posted in Plugin Development
  • RE: Unable to load template

    @pitaj Yep.

    Unable to load template: community/analytics nodebb.min.js:25493:12
    

    and

    Uncaught Error: Script error for "/assets/templates/community/analytics.js"
    https://requirejs.org/docs/errors.html#scripterror
    

    These actually come up twice in one navigation.

    I have tried rebuild/restart and clear cache.

    posted in Plugin Development
  • Unable to load template

    I have a number of custom templates in my plugin and for some reason browsing to them can sometimes cause issues. In Chrome it looks like it works fine, but Firefox seems to have issues.

    It seems to originate from ajaxify.loadTemplate.

    The template has a script attached to it via plugin.json as such: "static/lib/communityAnalytics.js",.

    The script itself is defined as follows define('forum/community/analytics',...

    Clicking on a link that takes you to that template/page works fine in Chrome, but fails in Firefox. Browsing directly to that page works in both browsers.

    Any ideas?

    posted in Plugin Development
  • RE: Groups - Category IDs to display posts from

    Ahh, ok! Will check that out!

    posted in Bug Reports
  • Groups - Category IDs to display posts from

    This feature does not seam to work in 1.18.0.

    The Group posts does not change if i set a category id.

    edit: This does not work in groups in community.nodebb.org. Dont know what version in run here!

    posted in Bug Reports
  • RE: createTags broken in 1.18.x

    Yes indeed, it works with addTags. I figured it out on my own but thanks for the reply @baris 😉

    posted in Bug Reports