talpor / django-dashing

django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project. Inspired in the dashboard framework Dashing
BSD 3-Clause "New" or "Revised" License
731 stars 108 forks source link

DashboardSet - Dashboard disappears after half a second #70

Closed bash-j closed 7 years ago

bash-j commented 7 years ago

Hi,

I am having trouble setting up a DashboardSet. I am not sure how what to use as the name when adding dashboards to the DashboardSet. When I load the page in my browser, the widgets from the site dashboard will display for half a second and then disappear. If I hit the Ctrl key and click on a dashboard it does not display the dashboard. I am not very familiar with javascript, so apologies if I have made an obvious error.

var site = new Dashboard('{"name":"site"}');
var test = new Dashboard('{"name":"test"}');

var myDashboardSet = new DashboardSet();

site.addWidget('convergence_widget', 'Graph', {
    getData: function () {
        $.extend(this.scope, {
            title: 'Test Graph',
            value: Math.floor(Math.random() * 50) + 40,
            more_info: '',
            data: [
                    { x: 0, y: Math.floor(Math.random() * 50) + 40 },
                    { x: 1, y: Math.floor(Math.random() * 50) + 40 },
                    { x: 2, y: Math.floor(Math.random() * 50) + 40 },
                    { x: 3, y: Math.floor(Math.random() * 50) + 40 },
                    { x: 4, y: Math.floor(Math.random() * 50) + 40 }
                ]
            });
    }
});

test.addWidget('clock_widget', 'Clock');

myDashboardSet.addDashboard('site');
myDashboardSet.addDashboard('test');

myDashboardSet.addAction('Link 1', function() {
    window.location.href = 'http://sitelink1/';
});
myDashboardSet.addAction('Link 2', function() {
    window.location.href = 'http://sitelink2/';
});
wickeym commented 7 years ago

Hi bash-j,

Below is your code (hopefully) corrected.

// Create your dashboards
myDashboardSet.addDashboard("site")
myDashboardSet.addDashboard("test")

// Retrieve those dashboards
var site = myDashboardSet.getDashboard("site")
var test = myDashboardSet.getDashboard("test")

// Add widgets
site.addWidget('convergence_widget', 'Graph', {
    getData: function () {
        $.extend(this.scope, {
            title: 'Test Graph',
            value: Math.floor(Math.random() * 50) + 40,
            more_info: '',
            data: [
                    { x: 0, y: Math.floor(Math.random() * 50) + 40 },
                    { x: 1, y: Math.floor(Math.random() * 50) + 40 },
                    { x: 2, y: Math.floor(Math.random() * 50) + 40 },
                    { x: 3, y: Math.floor(Math.random() * 50) + 40 },
                    { x: 4, y: Math.floor(Math.random() * 50) + 40 }
                ]
            });
    }
});

test.addWidget('clock_widget', 'Clock');

myDashboardSet.addAction('Link 1', function() {
    window.location.href = 'http://sitelink1/';
});
myDashboardSet.addAction('Link 2', function() {
    window.location.href = 'http://sitelink2/';
});

Sincerely, Michael

bash-j commented 7 years ago

Hi Michael,

Thank you so much for the quick response. I have changed my code using your guidance and the DashboardSet is now working!

Thanks again! Jonathon