Dashboard Modules

Build-In Dashboard Modules

AppList

_images/dashboard_module_app_list.png
class jet.dashboard.modules.AppList(title=None, model=None, context=None, **kwargs)

Shows applications and containing models links. For each model “created” and “change” links are displayed.

Usage example:

from django.utils.translation import gettext_lazy as _
from jet.dashboard import modules
from jet.dashboard.dashboard import Dashboard, AppIndexDashboard


class CustomIndexDashboard(Dashboard):
    columns = 3

    def init_with_context(self, context):
        self.children.append(modules.AppList(
            _('Applications'),
            exclude=('auth.*',),
            column=0,
            order=0
        ))
exclude = None

Specify models which should NOT be displayed. exclude is an array of string formatted as app_label.model. Also its possible to specify all application models with * sign (e.g. auth.*).

init_with_context(context)

Allows you to load data and initialize module’s state.

load_settings(settings)

Should be implemented to restore saved in database settings. Required if you have custom settings.

models = None

Specify models which should be displayed. models is an array of string formatted as app_label.model. Also its possible to specify all application models with * sign (e.g. auth.*).

settings_dict()

Should be implemented to save settings to database. This method should return dict which will be serialized using json. Required if you have custom settings.

template = 'jet.dashboard/modules/app_list.html'

Path to widget’s template. There is no need to extend such templates from any base templates.

title = 'Applications'

Default widget title that will be displayed for widget in the dashboard. User can change it later for every widget.

ModelList

_images/dashboard_module_model_list.png
class jet.dashboard.modules.ModelList(title=None, model=None, context=None, **kwargs)

Shows models links. For each model “created” and “change” links are displayed.

Usage example:

from django.utils.translation import gettext_lazy as _
from jet.dashboard import modules
from jet.dashboard.dashboard import Dashboard, AppIndexDashboard


class CustomIndexDashboard(Dashboard):
    columns = 3

    def init_with_context(self, context):
        self.children.append(modules.ModelList(
            _('Models'),
            exclude=('auth.*',),
            column=0,
            order=0
        ))
exclude = None

Specify models which should NOT be displayed. exclude is an array of string formatted as app_label.model. Also its possible to specify all application models with * sign (e.g. auth.*).

init_with_context(context)

Allows you to load data and initialize module’s state.

load_settings(settings)

Should be implemented to restore saved in database settings. Required if you have custom settings.

models = None

Specify models which should be displayed. models is an array of string formatted as app_label.model. Also its possible to specify all application models with * sign (e.g. auth.*).

settings_dict()

Should be implemented to save settings to database. This method should return dict which will be serialized using json. Required if you have custom settings.

template = 'jet.dashboard/modules/model_list.html'

Path to widget’s template. There is no need to extend such templates from any base templates.

title = 'Models'

Default widget title that will be displayed for widget in the dashboard. User can change it later for every widget.

RecentActions

_images/dashboard_module_recent_actions.png
class jet.dashboard.modules.RecentActions(title=None, limit=10, **kwargs)

Display list of most recent admin actions with following information: entity name, type of action, author, date

Usage example:

from django.utils.translation import gettext_lazy as _
from jet.dashboard import modules
from jet.dashboard.dashboard import Dashboard, AppIndexDashboard


class CustomIndexDashboard(Dashboard):
    columns = 3

    def init_with_context(self, context):
        self.children.append(modules.RecentActions(
            _('Recent Actions'),
            10,
            column=0,
            order=0
        ))
exclude_list = None

Specify actions of which models should NOT be displayed. exclude_list is an array of string formatted as app_label.model. Also its possible to specify all application models with * sign (e.g. auth.*).

include_list = None

Specify actions of which models should be displayed. include_list is an array of string formatted as app_label.model. Also its possible to specify all application models with * sign (e.g. auth.*).

init_with_context(context)

Allows you to load data and initialize module’s state.

limit = 10

Number if entries to be shown (may be changed by each user personally).

load_settings(settings)

Should be implemented to restore saved in database settings. Required if you have custom settings.

settings_dict()

Should be implemented to save settings to database. This method should return dict which will be serialized using json. Required if you have custom settings.

settings_form

alias of RecentActionsSettingsForm

template = 'jet.dashboard/modules/recent_actions.html'

Path to widget’s template. There is no need to extend such templates from any base templates.

title = 'Recent Actions'

Default widget title that will be displayed for widget in the dashboard. User can change it later for every widget.

Feed

_images/dashboard_module_feed.png
class jet.dashboard.modules.Feed(title=None, feed_url=None, limit=None, **kwargs)

Display RSS Feed entries with following information: entry title, date and link to the full version

Usage example:

from django.utils.translation import gettext_lazy as _
from jet.dashboard import modules
from jet.dashboard.dashboard import Dashboard, AppIndexDashboard


class CustomIndexDashboard(Dashboard):
    columns = 3

    def init_with_context(self, context):
        self.children.append(modules.Feed(
            _('Latest Django News'),
            feed_url='http://www.djangoproject.com/rss/weblog/',
            limit=5,
            column=0,
            order=0
        ))
ajax_load = True

A boolean field which specify if widget should be rendered on dashboard page load or fetched later via AJAX.

feed_url = None

URL of the RSS feed (may be changed by each user personally).

init_with_context(context)

Allows you to load data and initialize module’s state.

limit = None

Number if entries to be shown (may be changed by each user personally).

load_settings(settings)

Should be implemented to restore saved in database settings. Required if you have custom settings.

settings_dict()

Should be implemented to save settings to database. This method should return dict which will be serialized using json. Required if you have custom settings.

settings_form

alias of FeedSettingsForm

template = 'jet.dashboard/modules/feed.html'

Path to widget’s template. There is no need to extend such templates from any base templates.

title = 'RSS Feed'

Default widget title that will be displayed for widget in the dashboard. User can change it later for every widget.

Google Analytics Widgets

Attention

Google Analytics widgets required extra setup

_images/dashboard_module_google_analytics.png

Extra Installation

  • Install python package:

pip install google-api-python-client==1.4.1
  • Specify path to your Google Analytics client_secrets.json (obtained at Google website):

JET_MODULE_GOOGLE_ANALYTICS_CLIENT_SECRETS_FILE = os.path.join(PROJECT_DIR, 'client_secrets.json')
  • Add import to the top of your urls.py:

from jet.dashboard.dashboard_modules import google_analytics_views

Usage Example

from django.utils.translation import gettext_lazy as _
from jet.dashboard.dashboard import Dashboard, AppIndexDashboard
from jet.dashboard.dashboard_modules import google_analytics


class CustomIndexDashboard(Dashboard):
    columns = 3

    def init_with_context(self, context):
       self.available_children.append(google_analytics.GoogleAnalyticsVisitorsTotals)
       self.available_children.append(google_analytics.GoogleAnalyticsVisitorsChart)
       self.available_children.append(google_analytics.GoogleAnalyticsPeriodVisitors)

Yandex Metrika Widgets

Attention

Yandex Metrika widgets required extra setup

_images/dashboard_module_yandex_metrika.png

Extra Installation

  • Set your Yandex Metrika CLIENT_ID and CLIENT_SECRET (obtained at Yandex Metrika API website):

JET_MODULE_YANDEX_METRIKA_CLIENT_ID = 'YANDEX_METRIKA_CLIENT_ID'
JET_MODULE_YANDEX_METRIKA_CLIENT_SECRET = 'YANDEX_METRIKA_CLIENT_SECRET'
  • Add import to the top of your urls.py:

from jet.dashboard.dashboard_modules import yandex_metrika_views

Usage Example

from django.utils.translation import gettext_lazy as _
from jet.dashboard.dashboard import Dashboard, AppIndexDashboard
from jet.dashboard.dashboard_modules import yandex_metrika


class CustomIndexDashboard(Dashboard):
    columns = 3

    def init_with_context(self, context):
       self.available_children.append(yandex_metrika.YandexMetrikaVisitorsTotals)
       self.available_children.append(yandex_metrika.YandexMetrikaVisitorsChart)
       self.available_children.append(yandex_metrika.YandexMetrikaPeriodVisitors)
class jet.dashboard.dashboard_modules.yandex_metrika.YandexMetrikaVisitorsTotals(title=None, period=None, **kwargs)

Yandex Metrika widget that shows total number of visitors, visits and viewers for a particular period of time. Period may be following: Today, Last week, Last month, Last quarter, Last year

init_with_context(context)

Allows you to load data and initialize module’s state.

period = None

Which period should be displayed. Allowed values - integer of days

template = 'jet.dashboard/modules/yandex_metrika_visitors_totals.html'

Path to widget’s template. There is no need to extend such templates from any base templates.

title = 'Yandex Metrika visitors totals'

Default widget title that will be displayed for widget in the dashboard. User can change it later for every widget.

class jet.dashboard.dashboard_modules.yandex_metrika.YandexMetrikaVisitorsChart(title=None, period=None, show=None, group=None, **kwargs)

Yandex Metrika widget that shows visitors/visits/viewer chart for a particular period of time. Data is grouped by day, week or month Period may be following: Today, Last week, Last month, Last quarter, Last year

group = None

Sets grouping of data. Possible values: day, week, month

init_with_context(context)

Allows you to load data and initialize module’s state.

load_settings(settings)

Should be implemented to restore saved in database settings. Required if you have custom settings.

period = None

Which period should be displayed. Allowed values - integer of days

settings_dict()

Should be implemented to save settings to database. This method should return dict which will be serialized using json. Required if you have custom settings.

settings_form

alias of YandexMetrikaChartSettingsForm

show = None

What data should be shown. Possible values: visitors, visits, page_views

style = 'overflow-x: auto;'

Optional style attributes which will be applied to widget content container.

template = 'jet.dashboard/modules/yandex_metrika_visitors_chart.html'

Path to widget’s template. There is no need to extend such templates from any base templates.

title = 'Yandex Metrika visitors chart'

Default widget title that will be displayed for widget in the dashboard. User can change it later for every widget.

class jet.dashboard.dashboard_modules.yandex_metrika.YandexMetrikaPeriodVisitors(title=None, period=None, group=None, **kwargs)

Yandex Metrika widget that shows visitors, visits and viewers for a particular period of time. Data is grouped by day, week or month Period may be following: Today, Last week, Last month, Last quarter, Last year

contrast = False

A boolean field which makes widget ui color contrast.

group = None

Sets grouping of data. Possible values: day, week, month

init_with_context(context)

Allows you to load data and initialize module’s state.

load_settings(settings)

Should be implemented to restore saved in database settings. Required if you have custom settings.

period = None

Which period should be displayed. Allowed values - integer of days

settings_dict()

Should be implemented to save settings to database. This method should return dict which will be serialized using json. Required if you have custom settings.

settings_form

alias of YandexMetrikaPeriodVisitorsSettingsForm

template = 'jet.dashboard/modules/yandex_metrika_period_visitors.html'

Path to widget’s template. There is no need to extend such templates from any base templates.

title = 'Yandex Metrika period visitors'

Default widget title that will be displayed for widget in the dashboard. User can change it later for every widget.