Skip to content

Commit 5606ba9

Browse files
author
Trent Willis
committed
Restructure routes to enable easy navigation between selected node and full graph
1 parent b874070 commit 5606ba9

File tree

13 files changed

+77
-12
lines changed

13 files changed

+77
-12
lines changed

app/controllers/graph.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Ember from 'ember';
2+
3+
const {
4+
Controller,
5+
getOwner,
6+
computed,
7+
inject
8+
} = Ember;
9+
10+
export default Controller.extend({
11+
graph: inject.service(),
12+
13+
route: computed.alias('router.currentPath'),
14+
15+
init() {
16+
this.set('router', getOwner(this).lookup('router:main'));
17+
}
18+
});
File renamed without changes.

app/controllers/graph/node.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Ember from 'ember';
2+
3+
const {
4+
inject
5+
} = Ember;
6+
7+
export default Ember.Controller.extend({
8+
graph: inject.service()
9+
});

app/router.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ const Router = Ember.Router.extend({
77
});
88

99
Router.map(function() {
10-
this.route('selected-node');
10+
this.route('graph', { path: '/' }, function() {
11+
this.route('node');
12+
});
13+
1114
this.route('slow-nodes');
1215
});
1316

app/routes/slow-nodes.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

app/services/graph.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ export default Ember.Service.extend({
5050
sessionStorage.setItem(SELECTED_NODE_STORAGE_KEY, node.id);
5151

5252
this.set('selectedNode', node);
53-
getOwner(this).lookup('router:main').transitionTo('selected-node');
53+
getOwner(this).lookup('router:main').transitionTo('graph.node');
5454
}
5555
});

app/styles/app.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ body {
1515
width: 100%;
1616
}
1717

18+
.selected-node-controls {
19+
position: fixed;
20+
width: 100%;
21+
z-index: 1;
22+
bottom: 0;
23+
}
24+
1825
.node text {
1926
font: 10px sans-serif;
2027
}

app/templates/application.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<section class="global-nav hero is-light">
22
<nav class="nav">
33
<div class="nav-left">
4-
{{link-to 'Graph' 'index' class="nav-item is-tab" activeClass="is-active"}}
4+
{{link-to 'Graph' 'graph' class="nav-item is-tab" activeClass="is-active"}}
55
{{link-to 'Nodes' 'slow-nodes' class="nav-item is-tab" activeClass="is-active"}}
66
</div>
77

app/templates/graph.hbs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{outlet}}
2+
3+
<div class="selected-node-controls hero-footer">
4+
<nav class="tabs is-boxed is-fullwidth">
5+
<div class="container">
6+
<ul>
7+
<li class="{{if (eq route 'graph.index') 'is-active'}}">
8+
{{#link-to 'graph.index'}}Full Graph{{/link-to}}
9+
</li>
10+
<li class="{{if (eq route 'graph.node') 'is-active'}}">
11+
{{#link-to 'graph.node'}}
12+
Selected Node: {{if graph.selectedNode graph.selectedNode.label.name 'None'}}
13+
{{/link-to}}
14+
</li>
15+
</ul>
16+
</div>
17+
</nav>
18+
</div>

app/templates/graph/index.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{basic-tree graphData=graph.graph}}

0 commit comments

Comments
 (0)