tessera-metrics / tessera

A dashboard front-end for graphite.
http://tessera-metrics.github.io/tessera/
Apache License 2.0
1.19k stars 81 forks source link

Transforms & Client-Side Routing #76

Open aalpern opened 10 years ago

aalpern commented 10 years ago

Basic layout transforms are in place on the client side - having them as part of the JavaScript model works best. Right now a layout class is super-simple; it takes a dashboard item (such as the definition) and returns another dashboard item with the contents re-arranged. Number of column switching is handled this way.

Notes

Rename layouts to transforms - the one convention can cover basic re-layout (i.e. column switching) and drill-downs, where we take one graph and get more detail on it.

Transformed items and Queries

Dashboard items currently have a query_name to reference a query stored in the dashboard_definition.

In order to display a proper breadcrumb navigation trail for drilldowns, we're going to need to move the breadcrumb template client-side as well.

(at this point, it looks like almost all the UI will client-side eventually, leaving the server side code to handle API, persistence, and serving static assets).

aalpern commented 10 years ago

Client Side Routing

Client side routing uses the HTML5 browser history API to integrate in-page state changes with the browser history (i.e. "the back button"). Given the in-page nature of transforms, it's necessary to allow linking to a transform (and for generate sanity -- after digging in to a transform, the back button should not take the user back to the dashboard list, but to the pre-transform state)

Routes

Here are some random noodlings on what client-side routed URLs should look like:

Base dashboard URL:

/dashboards/3/detailed-overview
/dashboards/:id/:slug

Time-shifting first graph:

/dashboards/3/detailed-overview/d3/transform/time_shift

General transform routing:

/dashboards/:id/:slug/:item-id/transform/:transform-name?from=:from-time

Router Components

aalpern commented 10 years ago

Limitations

Tasks

We can continue to control visibility using data attributes; can effectively have multi-valent visibility attribute using CSS substring matching operators:

[data-ds-visible-in-mode*="transform"] for strict substring matching, or use the ~= operator for whitespace-separated matching.

aalpern commented 10 years ago

The behavior described here is now functionally pretty much complete, but the implementation is pretty ad-hoc and a bit messy. Going to leave this open for a while, or punt it to R2 or R3 for later cleanup. I think nearly all the UI needs to come client-side so it's all routed.