Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

Moving between pages #1

Open
stikekua opened this issue Mar 28, 2022 · 1 comment
Open

Moving between pages #1

stikekua opened this issue Mar 28, 2022 · 1 comment

Comments

@stikekua
Copy link

Hi there,
Could you please advise how to correct switch two dashboards every X seconds.

My way:
I made simple datasourcePlugin, whitch is switching pages.

`
(function () {
var pageSwitcher = function (settings, updateCallback) {
var self = this;
var init = false;
var updateTimer = null;
var currentSettings = settings;

	function updateRefresh(refreshTime) {
		if (updateTimer) {
			clearInterval(updateTimer);
		}

		updateTimer = setInterval(function () {
			self.updateNow();
		}, refreshTime);
	}

	updateRefresh(currentSettings.switchTime * 1000);

	this.updateNow = function () {
        if(!init){
            init = true;
            return;
        }
        const pages = freeboard.pagesData();
        const currentPage = freeboard.currentPage();
        const pageKeys =Object.keys(pages);
        let indx = pageKeys.findIndex(p => p === currentPage);
        indx++;
        if(indx == pageKeys.length)indx=0; 
        console.log(`Going to page \"${pageKeys[indx]}\"...`)           
        freeboard.gotoPage(pageKeys[indx]);
        updateCallback(pageKeys[indx]);
	}

	this.onDispose = function () {
		clearInterval(updateTimer);
		updateTimer = null;
	}

	this.onSettingsChanged = function (newSettings) {
		currentSettings = newSettings;
		updateRefresh(currentSettings.refresh * 1000);
		self.updateNow();
	}
};

freeboard.loadDatasourcePlugin({
    "type_name": "pageSwitcher",
    "display_name": "pageSwitcher",
    "settings": [
        {
            "name": "switchTime",
            "display_name": "Switch Every",
            "type": "number",
            "suffix": "seconds",
            "default_value": 10
        }
    ],
    newInstance: function (settings, newInstanceCallback, updateCallback) {
        newInstanceCallback(new pageSwitcher(settings, updateCallback));
    }
});

}());
`

But the problem is that after few hours running freeboard not rendering any widget any more. And I have empty panels.

I realized that after each freeboard.gotoPage() are created new instances of widgets. I dont know what happens with old instances. Maybe soem memory problem occures., test PC has 4GB ram and only chrome opened with this page.

Thanks,
Kuan.

@EternityForest
Copy link
Owner

Not sure why I didn't get an issue notification for this before, but it does seem to be a memory leak. A lot of stuff looks to be allocated in knockout.js, and may have to do with one of these issues: http://www.knockmeout.net/2014/10/knockout-cleaning-up.html

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants