1
1
Django Metrics Dashboard
2
2
========================
3
3
4
- DO NOT USE THIS! THIS IS AN EARLY ALPHA AND DOES NOT WORK!
5
-
6
4
A reusable Django app that allows you to display a dashboard with any number
7
- of widgets to show any data you care about. The widets are updated via
5
+ of widgets to show any data you care about. The widgets are updated via
8
6
socket.io, so you never need to refresh your dashboard.
9
7
8
+ You need to setup a socket.io-server that accepts incoming subscriptions and
9
+ sends out broadcasts when widgets need an update. For this we have created
10
+ https://github.com/bitmazk/django-socketio-messenger
11
+
12
+ TODO: Write a blog post about how to set this up on Webfaction.
13
+
10
14
Prerequisites
11
15
-------------
12
16
13
17
You need at least the following packages in your virtualenv:
14
18
15
19
* Django 1.4.3
16
20
* South
21
+ * django-libs
22
+ * django-load
23
+ * requests
24
+ * django-socketio
25
+ * lockfile
17
26
18
27
Installation
19
28
------------
@@ -65,7 +74,9 @@ DASHBOARD_MESSENGER_URL
65
74
Set this to the API endpoint of your ``django-socketio-messenger ``
66
75
installation. A valid value should look like this::
67
76
68
- http://<IP>:<PORT>/broadcast_channel/
77
+ http://<HOST>[:<PORT>]/broadcast_channel/
78
+
79
+ Depending on your setup you might or might not need to specify a port.
69
80
70
81
We need this because all messages going through socketio must be sent from
71
82
the same process. However, this app needs to broadcast messages from an
@@ -87,18 +98,21 @@ For now: Install it and go visit the URL :) More features coming soon.
87
98
Creating widgets
88
99
----------------
89
100
101
+ * See https://github.com/bitmazk/md-pypispy-users as an example.
90
102
* Create a new Django app. Per convention, you should call your app something
91
- like ``dashboardwidget_yourwidgetname ``. This way we can easily search
92
- PyPi for ``dashboardwidget `` and will find all widgets that have been
103
+ like ``md_yourwidgetname ``. This way we can easily search
104
+ PyPi for ``md_ `` and will find all widgets that have been
93
105
published.
94
106
* Give it a file ``dashboard_widget.py ``
95
107
* Implement your widget. It should inherit ``DashboardWidgetBase ``
96
108
* Your widget needs the following implementations:
97
109
* a ``template_name `` attribute, just like any Django view
110
+ * ``sizex `` & ``sizey `` attributes that define the widget size
111
+ * an ``update_interval `` attribute in seconds.
98
112
* a ``get_context_data `` method. It should return a dictionary
99
113
of template context variables
100
114
* a ``update_widget_data `` method. It should get data from a 3rd party API
101
- and save it to the widget's model. THen it should send a message to the
115
+ and save it to the widget's model. Then it should send a message to the
102
116
widget's socket.io channel so that the subscribed browsers know that the
103
117
widget has new data and needs an update.
104
118
* Register your widget with the ``dashboard_widget_pool ``.
@@ -111,6 +125,9 @@ Example ``dashboard_widgets.py``::
111
125
class DummyWidget(DashboardWidgetBase):
112
126
"""This widget is used by the tests."""
113
127
template_name = 'dashboardwidget_dummy/dummy_widget.html'
128
+ sizex = 2
129
+ sizey = 1
130
+ update_interval = 60
114
131
115
132
def get_context_data(self):
116
133
return {
@@ -157,18 +174,6 @@ do the following::
157
174
$ ./manage.py schemamigration metrics_dashboard --auto
158
175
159
176
160
- Compiling the CSS files
161
- -----------------------
162
-
163
- If you want to make changes to the CSS files, please edit the files
164
- ``metrics-dashboard-variables.less ``, ``styles.less `` and
165
- ``responsive-styles.less ``. Then run ``fab lessc `` from the root of the
166
- project.
167
-
168
- If you want to setup a file system watcher and compile the ``.css `` files
169
- automagically, just execute ``./watchmedo-less.sh ``.
170
-
171
-
172
177
Discuss
173
178
-------
174
179
0 commit comments