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

[State tree] large app #9

Closed
aitboudad opened this issue Aug 13, 2016 · 12 comments
Closed

[State tree] large app #9

aitboudad opened this issue Aug 13, 2016 · 12 comments

Comments

@aitboudad
Copy link

Possible enhancements:

  • use middle click to expand/collapse tree
  • show only the first level

selection_020

@christopherthielen
Copy link
Member

What? it looks fine to me. ;)

@christopherthielen
Copy link
Member

The middle-click idea seems like pretty low-hanging fruit. I don't have time to enhance this now, but would be happy to help guide anyone interested in implementing this.

@christopherthielen
Copy link
Member

One other thing to note: you can increase the size of the viewport by passing height and width props to the third argument of StateVisualizer.create:

  var vis = window['ui-router-visualizer']
  vis.StateVisualizer.create(ng1UIRouter, undefined, { width: 500, height: 500 });
  vis.TransitionVisualizer.create(ng1UIRouter);

https://plnkr.co/edit/dKT52b?p=preview

@aitboudad
Copy link
Author

thank you for the hint, I'll try to work on it next week!

@wpitallo
Copy link

Awesome tool, very cool!

Was wandering how the labels are rendering? If we wanted to send them through a custom parser to add some addition info etc. What code actually renders the labels?

@christopherthielen
Copy link
Member

christopherthielen commented Oct 13, 2016

Here is where the state name is written out (as SVG text): https://github.com/ui-router/visualizer/blob/master/src/state/stateNode.tsx#L33-L40

Just below it is the "label text" (i.e., "active")

The node itself is the StateVisNode which wraps a ui-router state object.

@wpitallo
Copy link

Thanks so much 👍

Was exactly what i was looking for!

christopherthielen added a commit that referenced this issue Jan 27, 2017
@christopherthielen
Copy link
Member

christopherthielen commented Jan 27, 2017

I added some enhancements which makes the visualizer much more usable with large state trees:

  1. Added other layout strategies: Tree (current), Cluster, Radial. The Radial layout works great for large apps.

screen shot 2017-01-27 at 10 19 05 am

  1. Add a zoom level which scales the state nodes and labels:

screen shot 2017-01-27 at 10 19 19 am

  1. Add an interactive resize handle:

screen shot 2017-01-27 at 10 24 27 am

christopherthielen added a commit that referenced this issue Jan 28, 2017
…les:

1) A state can be collapsed only if it has at least one child
2) A state will automatically uncollapse if the state is entered
3) The count of (hidden) descendents is printed inside the collapsed state's circle

Closes #9
@christopherthielen
Copy link
Member

  1. Added Collapse/uncollapsing.
  • Toggle collapse by double-clicking a state
  • The count of collapsed descendents is shown inside the state
  • The state is automatically un-collapsed if it is entered.
  • States without children cannot be collapsed.

anim

@christopherthielen christopherthielen modified the milestone: 3.0.0 Jan 28, 2017
@christopherthielen
Copy link
Member

@aitboudad version 3.0.0 released, please provide feedback

@aitboudad
Copy link
Author

@christopherthielen just checked on my side and it looks really nice, I have two remarks:

  • allow to configure inactive state with children collapsed as default
  • add horizontal tree (left to right)

Thanks in advance!

@christopherthielen
Copy link
Member

@aitboudad just before registering the plugin you can set the initial collapsed status of each state.

For example:

let states: State[] = router.stateRegistry.get().map(s => s.$$state());
let secondLevel = states.filter(s => s.parent.name === 'app');
secondLevel.forEach(s => s._collapsed = true);

router.plugin(Visualizer);

Or in this plunker, collapse all top and second level states:
http://plnkr.co/edit/zrc8YzoXnlhLbSD3TtWc?p=preview

  // Auto-collapse children in state visualizer
  var registry = $uiRouter.stateRegistry;
  $uiRouter.stateRegistry.get().map(s => s.$$state())
      .filter(s => s.path.length === 2 || s.path.length === 3)
      .forEach(s => s._collapsed = true);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants