Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Views engine #383

Closed
wants to merge 33 commits into from
Closed

Conversation

matthieucan
Copy link
Contributor

Hi!
Here's my first shot for the views engine we talked about a few weeks ago.

From commit f4afe35:
"The files contained in status/custom_*.py and status/templates/custom_* permit to have a views engine, i.e. a customised form in where you can choose the data you need from Livestatus datasources/columns, arrange them how you like (sorting, filtering, stats) and feed this data to pre-defined templates or your own ones. The views can be represented with simple dictionaries, and are therefore stored through the userdata module."

To rapidly test this, create your own views (link in the left menu) and play with them, or use these predefined ones by adding this to your /etc/adagios/userdata/USER.json: http://fpaste.org/106649/01745996/ (there are 3 views, which use 3 different templates (table, openstreetmaps, and pie chart), so you'll have a good idea of what is doable with the engine).

This is a work in progress, but what is committed here is fully functional.
What I have on my roadmap (but let's go step-by-step):

  • separate public and personal views, have a tool to better organise the left menu,
  • have a dashboard which can use many views on a customisable grid,
  • improve the UI, by adding the possibility to run commands on selected views, have a search input field, etc.

Let me know your thoughts!

matthieucan and others added 20 commits June 2, 2014 11:23
The files contained in status/custom_*.py and status/templates/custom_*
pemit to have a views engine, i.e. a customised form in where you can choose
the data you need from Livestatus datasources/columns, arrange them how
you like (sorting, filtering, stats) and feed this data to pre-defined
templates or your own ones. The views can be represented with simple
dictionaries, and are therefore stored through the userdata module.

User-defined customised views are now possible within Adagios :)
* datatable: jquery plugin to render html tables into
  pageable/sortable/filterable tables. Simpler and more
  functional than datatables.

* jquery-ui: contains the functions which permit DOM elements
  to me draggable. This is used in custom forms, where the user
  can re-order the colums, filters, etc.
This templates, through the help of jqplot, can display a pie chart
representing data coming from aggregated Livestatus queries (with
the "Stats:" clause).
Through OpenLayers.js, displays a map with red/green markers representing
the state of all defined hosts.
The IP addresses are mapped to GPS coordianates through GeoIP.
The files contained in status/custom_*.py and status/templates/custom_*
pemit to have a views engine, i.e. a customised form in where you can choose
the data you need from Livestatus datasources/columns, arrange them how
you like (sorting, filtering, stats) and feed this data to pre-defined
templates or your own ones. The views can be represented with simple
dictionaries, and are therefore stored through the userdata module.

User-defined customised views are now possible within Adagios :)
* datatable: jquery plugin to render html tables into
  pageable/sortable/filterable tables. Simpler and more
  functional than datatables.

* jquery-ui: contains the functions which permit DOM elements
  to me draggable. This is used in custom forms, where the user
  can re-order the colums, filters, etc.
This templates, through the help of jqplot, can display a pie chart
representing data coming from aggregated Livestatus queries (with
the "Stats:" clause).
Through OpenLayers.js, displays a map with red/green markers representing
the state of all defined hosts.
The IP addresses are mapped to GPS coordianates through GeoIP.
@palli
Copy link
Contributor

palli commented Jun 28, 2014

Got it up and running. This is pretty sweet! Haven't looked through all the code yet, but the feature is awesome.

Is it realistic to load a custom view via querystrings only (without saving it first) ? It would make unit testing easier.

The pen-ultimate dream is to make all views in adagios use this engine 👍

@matthieucan
Copy link
Contributor Author

Hey Pall,
I'm far away from my laptop right now, I'll cherry-pick your commits next week!
About the geoip dependencies, you're right, they aren't packaged anywhere, it will be easier to get rid of the locateip filter (at least for now).
It's definitely realistic to load views via querystrings, I'll add the feature!
And make every view use the engine was our initial goal as well, the only blocker now is the action buttons bar (but I'm on it).

More on wednesday!

@palli
Copy link
Contributor

palli commented Jun 29, 2014

Oh boy, 2860 files... Do we really need them all ?

@matthieucan
Copy link
Contributor Author

Alright, I'll update this on wednesday.
We don't need all these files, most of them come from openLayers.js, which we can remove if you don't want it :-)

Pall Sigurdsson added 2 commits July 2, 2014 09:48
This patch fixes an issue where custom_view cannot be
loaded because an extra linebreak is sent with the
livestatus query.

I am guessing shinken's implementation of livestatus
does not care about this.
If livestatus queries fail, return 500 error

This should make unit testing of the view easier.
@matthieucan
Copy link
Contributor Author

@palli About loading custom views via querystrings, it's not as trivial as I previously thought, because the datastructure used is too hierarchical, and it would add some dirty parsing and the use of special characters to have something working. For unit testing this, we can do it the same way as we do for the other user parameters, POST what we want like this: https://github.com/opinkerfi/adagios/blob/master/adagios/misc/tests.py#L97-L98

@matthieucan
Copy link
Contributor Author

I've addressed most of your issues, and added a few commits I had in another branch.
About the 'New view' link, I think the workflow is simpler with the toggling , this reduces the creation of a view to 1 page instead of 2, and I find it less confusing. If you really prefer the 2-step workflow I can do it, but I think it's less ergonomic. I'll now rebase everything on the current master (there's a conflict in base.html), a big commits list should pop-up, don't be afraid ;-)

@palli
Copy link
Contributor

palli commented Jul 2, 2014

Alright. Thanks.

My only diff tool is github at the moment and it still has a problem because of number of files in the pull request, so i have minor problems with reviewing.

I would want to take care of the javascript deps first, then the diff will be a little cleaner. Two questions at the moment:

  • I noticed there are now duplicate copies of datatables, was that on purpose ?
  • Any thoughts or insights on JQplot (im not familiar with any of the graphing javascript libraries). Are we using it for just one pie graph ? Do you foresee if we have more graphing needs in the future we can commit on jqplot as a platform ?

Thanks :)

@matthieucan
Copy link
Contributor Author

Datatables: that's on purpose, yes. They actually are 2 different libraries (datatable and datatables), and I found datatable to be much more efficient at what I did in the template table.html. I definitely agree it would be better to only use one, but both of them are currently used.

Jqplot is currently only used in pie_chart, but in the future it could be nice to have this kind of pie chart on the home page for instance. Do you like them?

At least, I'll have a look if it's possible to use minified versions of these tools (datatable, jqplot, jquery-ui), in order not to ship everything :-)

@matthieucan
Copy link
Contributor Author

Alright, I've trimmed the javascript libraries, and rebased everything.
As it began to be dirty (because of many rebases), I created a new pull request which will be easier to review: #391

@matthieucan matthieucan closed this Jul 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants