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

Question Developing New Widget Locally #38

Closed ryantenorio closed 9 years ago

ryantenorio commented 9 years ago

I am a little confused on how to set up my directory when I am trying to develop and test a widget locally. Based on the documentation I have my directory like this in my project:

project/ -----static/ ----------dashing-config.js ----------widgets/ ---------------custom_widget.js ---------------custom_widget.css ---------------custom_widget/ -------------------- custom_widget.html

When I do this and add my custom widget to my INSTALLED_WIDGETS option in my settings.py, I receive a "custom_widget does not exist" error in my web console.

mtdb commented 9 years ago

Hi! the directory structure should look like:

project/ -----static/ ----------dashing-config.js ----------widgets/ ---------------custom_widget/ -------------------- custom_widget.js -------------------- custom_widget.css -------------------- custom_widget.html

Try and let me know if works

asampat3090 commented 9 years ago

Hi @individuo7 that didn't work for me. Is there anything else I need to do other than add 'custom_widget' to the INSTALLED_WIDGETS? I added the files and then added code like this to my dashing-config.js but the block never shows up nor do I get any error in my web console....I have no idea what else to do.

dashboard.addWidget('custom_widget', 'CustomWidget', {
    col: 3,
    getData: function () {
        this.interval = 2000;

        $.extend(this.data, {
            title: "Something",
            more_info: "",
            updated_at: "",
            detail: "",
        });

        var pineapple = this;
        $.getJSON('widgets/custom_widget/', function (data) {
            console.log(data.value);
            pineapple.data.value = data.value;
        });
    }
});
asampat3090 commented 9 years ago

UPDATE: I used the following file structure (mirroring what you have in the django-dashing source code and got it to work.

project/ -----static/ ----------dashing-config.js ----------dashing/ ---------------widgets/ --------------------custom_widget/ -------------------------custom_widget.js -------------------------custom_widget.css -------------------------custom_widget.html