Monday, November 28, 2016¶
About dashboard widgets and user preferences¶
Now finally I can write a bit more about #1284.
It was triggered by a simple request from Aurélie: they wanted to make
it configurable per user whether
lino.modlib.notify.models.MyMessages
is to be visible in the
main admin screen or not.
My first idea was to add an option “Display messages in main screen”. But in a discussion with Hamza I understood:
I am reluctant to add this option because it makes the user preferences more complex. Simple users wiil be irritated because they don’t know what to put there…
Actually my feeling is deeper: I doubt whether this option makes sense at all. This option is not only irritating for simple users.
I also think that even those people who did not want to see “Mes messages” (because they rely on their emails), even these people sometimes want to see their messages in the main screen. The real solution is to make all those admin main items configurable.
The admin main items are like the “widgets” used sometimes by CMS frameworks.
Actually we should not have an option “Display messages in main screen”, but a panel where every user can customize which widgets they want to see, and in which order. And maybe whether they should be initially collapsed… or whether there should be several columns…
The idea caused a little series of changes:
Lino now has the notion of “user preferences” (
lino.core.userprefs
). Required a little APi extensionlino.core.plugin.Plugin.setup_user_prefs()
.I started to rename the “admin main page” to “dashboard”, wrote a
lino.core.dashboard
module for encapsulating the concept and a new pluginlino.modlib.dashboard
for letting users define “widgets” for (optinally) configuring their dashboard.
As a side effect of this, the
lino_xl.lib.blogs.models.LatestEntries
table now also has a
slave summary panel. Also note that this table is actually not a slave
table (it has no master). I extended the slave summary panel so that
it works also on master tables.
En passant I discovered and fixed a subtle bug: The
use_websockets
option
must be a class attribute of lino.core.site.Site
(and not of
lino.modlib.notify.Plugin
). The problem caused channels to
be installed even when use_websockets was set to False. It is
analog to use_java
.
Also en passant some more optimizations for #923: The
lino.modlib.notify.models.MyMessages
table now has a custom
summary so that the messages are being displayed as list items. And
when you open it in its own window (where you have an ExtJS grid),
then you now have an action to mark all messages as seen. It is
currently not possible to render that action as a html link in the
slave summary. And it is now labelled “My notification messages”
(instead of just “My messages”).
TODO:
(The Lino Welfare “Châtelet” variant or The Lino Welfare “Eupen” variant) Explorateur –> Système –> All dashboard widgets : ‘NoneType’ object has no attribute ‘get_request_queryset’
rename
get_slave_summary()
to get_summar_html.