GithubHelp home page GithubHelp logo

byashimov / django-controlcenter Goto Github PK

View Code? Open in Web Editor NEW
984.0 984.0 85.0 204 KB

Set of widgets to build dashboards for Django projects

License: BSD 3-Clause "New" or "Revised" License

JavaScript 2.30% Python 59.90% CSS 16.98% HTML 11.35% Stylus 9.47%
admin-dashboard dashboard django

django-controlcenter's People

Contributors

atraining avatar ayuto avatar byashimov avatar chadgh avatar danielquinn avatar fabiocaccamo avatar greeve avatar k8n avatar mick88 avatar minusf avatar pauloxnet avatar pidelport avatar tonysyu avatar tonyyu-indeed avatar unclenight avatar virtosubogdan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-controlcenter's Issues

Pagination for ItemList

When ItemLists become big it'd be amazing if django-controlcenter could offer pagination.

Invalid URLs documentation for `django >= 3.2`.

Since django 3.2, AdminSite.final_catch_all_view has been introduced:

A boolean value that determines whether to add a final catch-all view to the admin that redirects unauthenticated users to the login page. By default, it is set to True.

โš ๏ธ Setting this to False is not recommended as the view protects against a potential model enumeration privacy issue.

The url of any dashboard results in a 404 error.

Summary line in ItemList

I have a need to add a summary line to an item list widget. Currently I add one more item to the list of data that is a sum of the integer columns. The problem with this is the row is sorted with all the other data rows. What I would like is to have a summary row that allows me to define how a column is summarized and would be always placed at the bottom of the table (i.e. table footer).

How would you accomplish this? I am willing to implement a solution but I want to do it in the way that makes the most sense.

Release a new version

The last commits you merged from my pull request #15 permit controlcenter to works with Django 2.0.

Please bump a new version of controlcenter with this commits and release it on pypi.

Thank you

module 'django.db.models' has no attribute 'FieldDoesNotExist'

title: message
Django Version: 3.2.7
Exception Type: AttributeError
Exception Value: module 'django.db.models' has no attribute 'FieldDoesNotExist'
Exception Location: /usr/local/lib/python3.8/site-packages/controlcenter/templatetags/controlcenter_tags.py, line 185, in attrlabel
Python Version: 3.8.12

need fix =)
change django.db.models.FieldDoesNotExist to django.core.exceptions.FieldDoesNotExist

try:
    from django.db.models import FieldDoesNotExist
except ImportError:
    from django.core.exceptions import FieldDoesNotExist

Support for python 3.10

Using with python 3.10 the following error occurs

File "/Users/elenag/.virtualenvs/consialinkenv/lib/python3.10/site-packages/controlcenter/widgets/core.py", line 88, in
class Group(collections.Sequence):
AttributeError: module 'collections' has no attribute 'Sequence'

This class has been move to collections.abc

legend ignores reverseData

https://github.com/gionkunz/chartist-js/issues/508

reverseData: true reverses not only the list elements, but also the lists themselves insides series. This might be logical for some, it is not logical for me.

In any case this messes up the order of widget.legend.

I am not including any patches because the whole reverseData feature needs mental gymnastics that is not worth the effort for me with possible side effects like this.

I am not sure this should be turned on by default.

.DS_Store files in pypi package

can you please remove them?

$ find . -name .DS_Store
./.DS_Store
./static/.DS_Store
./static/controlcenter/.DS_Store
./static/controlcenter/css/.DS_Store

How to customize chartist beyond options?

Is there a way to inject in the current js something like labelInterpolationFnc for chartist?

https://gionkunz.github.io/chartist-js/api-documentation.html:

// In addition to the regular options we specify responsive option overrides
// that will override the default configutation based on the matching media queries.
var responsiveOptions = [
  ['screen and (min-width: 641px) and (max-width: 1024px)', {
    showPoint: false,
    axisX: {
      labelInterpolationFnc: function(value) {
        // Will return Mon, Tue, Wed etc. on medium screens
        return value.slice(0, 3);
      }
    }
  }],
  ['screen and (max-width: 640px)', {
    showLine: false,
    axisX: {
      labelInterpolationFnc: function(value) {
        // Will return M, T, W etc. on small screens
        return value[0];
      }
    }
  }]
];

object is not iterable?

I just leave the queryset as default. And itemlist just give me the info. Python 2.7, Django 1.11

[feature request] Add admin link

I am wondering is it'll be a good idea to add link to django-controlcenter app from admin page without guessing which url I need to paste.
What do you think?

Dashboards urls

I have in settings:

CONTROLCENTER_DASHBOARDS = (
    ('Leads', 'dashboards.Base'),
    ('Backlinks', 'apps.backlinks.dashboards.Backlinks'),
    ('Spiders', 'apps.spiders.dashboards.Spiders'),
)

But I get html without links:

<nav class="controlcenter__nav">
    <a class="controlcenter__nav__item" href="">Leads</a>
    <a class="controlcenter__nav__item" href="">Backlinks</a>
    <a class="controlcenter__nav__item" href="">Spiders</a>
</nav>

What I am doing wrong?
Python 3.6
Django 1.11
django-controlcenter==0.2.5

Can't make a PieChart to work but not getting any error

Hello,

I am trying to create a Chart for a model that have a field with limited choices, represented like this :

class CertificateRequest(models.Model):
    """
    Certificate request object in the database
    """
    NEW = 0
    REQUESTED = 1
    ACCEPTED = 2
    DENIED = 3
    ERRORED = 4
    STATUS = (
        (NEW, _('New')),
        (REQUESTED, _('Requested')),
        (ACCEPTED, _('Accepted')),
        (DENIED, _('Denied')),
        (ERRORED, _('Errored')),
    )
    ***
    status = models.IntegerField(
        verbose_name=_('Status'),
        choices=STATUS,
        default=0
    )
    ****

I want to get the amount of Certificate Requests for each status, to I did like this :

class CertificateRequestsStatusWidget(widgets.SinglePieChart):
    title = "Certificate Requests Status"
    queryset = CertificateRequest.objects.values_list("status").annotate(status_count=Count("status")).order_by("status")

    class Chartist:
        options = {
            "onlyInteger": True
        }

    def values(self):
        return self.queryset

    def labels(self):
        return self.series

    def legend(self):
        return sum([[status[1].__str__() for status in CertificateRequest.STATUS if status[0] == status_id["status"]] for status_id in CertificateRequest.objects.values("status").annotate(status_count=Count("status")).order_by("status")], [])

The legend is more complex as I want to get the names of the statuses depending of if they are in present in the database.

The queries works fine in ipython :

In [55]: CertificateRequest.objects.values_list("status").annotate(status_count=Count("status")).order_by("status")
    ...:
Out[55]: <QuerySet [(1, 1), (2, 25)]>

In [56]: sum([[status[1].__str__() for status in CertificateRequest.STATUS if status[0] == status_id["status"]] for status_id in CertificateR
    ...: equest.objects.values("status").annotate(status_count=Count("status")).order_by("status")], [])
    ...:
Out[56]: ['Requested', 'Accepted']

But on my graph I don't get anything, just the default background.

What is the issue ?
Would not it be better to have more strict code check so if we put something wrong in our methods it will throw an exception with a detailed message ? I've been trying for hours and I can't get this graph to work correctly.

Thank you.
Best regards,
Mathieu

how to add short_description

I add the short_description
but it doesn't work

def get_time(self, obj):
    return obj.time
get_time.allow_tags = True
get_time.short_description = 'Time'


def get_user_count(self, obj):
    return obj.user_count
get_user_count.allow_tags = True
get_user_count.short_description = 'count'

update dashboard without refreshing

Hi, I'm thankfully using this package for my django project as a dashboard.
I use some widgets in my dashboard page such as itemlist, piechart, linechart.
BTW, I have a question for you.
As I mentioned in title, can i update my dashboard page without clicking f5 button?
I've founded that using Ajax or setTimeout function do it.
Please tell me if there is any way to do it.

Usage outside of django admin

Hey guys,

would it make sense to use this package as user dashboard outside of the django admin? It looks great :)

No module named Project

ModuleNotFoundError at /admin/dashboard/mydash/
No module named 'project'. I get this error when I try running in browser. I get same error even after changing project either name of my project or app name

A couple of inconsistencies/unexpected behaviour

First of all, this project looks very promising! I've been trying it out for a couple of hours now, with this result as code:

from django.db.models import Count
from django.db.models.functions import TruncMonth
from django.utils.translation import ugettext_lazy as _

from controlcenter import Dashboard, widgets
from dateutil.relativedelta import relativedelta

from bijleshuis.accounts.models import User


class NewUsersMixin:
    model = User
    title = _('New signups')
    values_list = ('month', 'count')

    def get_queryset(self):
        base = User.objects.all()
        qs = base.annotate(month=TruncMonth('date_joined')).values('month').annotate(count=Count('id'))
        return qs.order_by('-month')


class NewUsersLineChart(NewUsersMixin, widgets.SingleLineChart):
    class Chartist:
        options = {
            'reverseData': True,
        }

    def series(self):
        series = super().series
        series[0].insert(0, 0)
        return series

    def labels(self):
        labels = super().labels
        next_dt = labels[0] + relativedelta(months=1)
        return [dt.strftime('%b %y') for dt in [next_dt] + labels]


class NewUsersBarChart(NewUsersMixin, widgets.SingleBarChart):
    class Chartist:
        options = {
            'reverseData': True,
        }

    def series(self):
        series = super().series
        series.insert(0, 0)
        return series

    def labels(self):
        labels = super().labels
        next_dt = labels[0] + relativedelta(months=1)
        return [dt.strftime('%b %y') for dt in [next_dt] + labels]


class MainDashboard(Dashboard):
    widgets = (
        NewUsersLineChart,
        NewUsersBarChart
    )

As you can see, both widgets are almost identical, with the difference being that one is a line chart and the other a bar chart. They display the exact same data.

  1. In the SingleBarChart, calling super().series results in a one-dimensional list, while the LineBarChart returns a two-dimensional list. I suspect this is a Chartist.js thing, but it's inconsistent on the Python side of things - it's the same one-dimensional dataset after all

  2. There's a lot of code duplication like this. Initially, I tried something like

    class NewUsersListChart(NewUsersMixin, widgets.SingleLineChart):
        pass

    this was kind of unexpected, and leads to a lot of code duplication when making small variants of widgets.

Python 3.10 support

When building project under Python 3.10, I'm getting the following error:

  File "/usr/local/lib/python3.10/site-packages/controlcenter/widgets/core.py", line 88, in <module>
    class Group(collections.Sequence):
AttributeError: module 'collections' has no attribute 'Sequence'

Automatically redirect the main app url to the first dashboard.

In the admin, going to: /admin/dashboard/ results in a 404 error, instead it would be much more useful/usable to redirect the user to the first dashboard, eg.

https://my-domain.com/admin/dashboard/ -> https://my-domain.com/admin/dashboard/accounts/

This would also simplify the url to remember/link for accessing the dashboard.

Sticky headers

What do you think about making the sortable header in the item list optionally sticky? What I mean by sticky is that the header stays visible while scrolling through the list of items. I know I can do this by overriding the itemlist.html template but do you think this should be a built-in thing in the project?

I am willing to contribute this feature to the project but I wanted to check with you about whether you think its worth it.

Barchart series not assigned color when there are more then 15 bars

I have created a SingleBarChart with 30 series.
Chartist assigns each series a class ct-series-{name}. With name looping from a to z.
The django-controlcenter static file 'chartist-default-colors.css' has colors defined for class a to o. Classes p to z do not have a color defined, and therefore do not display on the chart.

Would it be possible to append 'chartist-default-colors.css' to contain classes ct-series-p to ct-series-z?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.